From 363b284b7c7d2d4565b028bbbc69c99661ad3b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=BA=86=E4=B8=AA=E7=99=BD?= <543593352@qq.com> Date: Thu, 12 Dec 2024 16:34:47 +0800 Subject: [PATCH] 1 --- .../src/views/Editor/CanvasTool/index.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue index 18ac469..896f6cf 100644 --- a/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue +++ b/src/renderer/src/AixPPTist/src/views/Editor/CanvasTool/index.vue @@ -208,6 +208,18 @@ const insertImageElement = (files: FileList) => { // }) } +//获取当前的时间 +const getTime=()=>{ + const now = new Date(); + const year = now.getFullYear(); + const month = ('0' + (now.getMonth() + 1)).slice(-2); + const day = ('0' + now.getDate()).slice(-2); + const hours = ('0' + now.getHours()).slice(-2); + const minutes = ('0' + now.getMinutes()).slice(-2); + const seconds = ('0' + now.getSeconds()).slice(-2); + return `${year}-${month}-${day}_${hours}:${minutes}:${seconds}`; +}; + /** * base64转图片File * @param {String} base64 图片base64 @@ -234,9 +246,10 @@ const base64ToFile = (base64: string, fileName = '试题图片') => { // charCodeAt():获取给定索引处字符对应的 UTF-16 代码单元 u8arr[n] = bstr.charCodeAt(n) } + const filename = fileName+getTime() // 利用构造函数创建File文件对象 // new File(bits, name, options) - const file = new File([u8arr], `${fileName}.${suffix}`, { + const file = new File([u8arr], `${filename}.${suffix}`, { type: type }) // 返回file