Compare commits

..

3 Commits

Author SHA1 Message Date
baigl f75ab621d2 Merge pull request 'baigl' (#124) from baigl into main
Reviewed-on: #124
2024-12-12 16:35:47 +08:00
白了个白 a711eb2745 Merge branch 'main' of http://27.128.240.72:3000/zhuhao/AIx_Smarttalk_WS into baigl 2024-12-12 16:35:04 +08:00
白了个白 363b284b7c 1 2024-12-12 16:34:47 +08:00
1 changed files with 14 additions and 1 deletions

View File

@ -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 * base64转图片File
* @param {String} base64 图片base64 * @param {String} base64 图片base64
@ -234,9 +246,10 @@ const base64ToFile = (base64: string, fileName = '试题图片') => {
// charCodeAt() UTF-16 // charCodeAt() UTF-16
u8arr[n] = bstr.charCodeAt(n) u8arr[n] = bstr.charCodeAt(n)
} }
const filename = fileName+getTime()
// File // File
// new File(bits, name, options) // new File(bits, name, options)
const file = new File([u8arr], `${fileName}.${suffix}`, { const file = new File([u8arr], `${filename}.${suffix}`, {
type: type type: type
}) })
// file // file