【功能修复】文件上传:修复生成文件名重名的问题

pull/743/head
shaomh 2025-03-20 17:00:41 +08:00
parent 20a2ced413
commit 56eb9e01a8
1 changed files with 3 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import * as FileApi from '@/api/infra/file'
import CryptoJS from 'crypto-js'
import { UploadRawFile, UploadRequestOptions } from 'element-plus/es/components/upload/src/upload'
import axios from 'axios'
import dayjs from 'dayjs'
/**
* URL
@ -92,7 +93,8 @@ async function generateFileName(file: UploadRawFile) {
const sha256 = CryptoJS.SHA256(wordArray).toString()
// 拼接后缀
const ext = file.name.substring(file.name.lastIndexOf('.'))
return `${sha256}${ext}`
const time = dayjs(new Date()).format('YYYYMMDDHHmmssSSS')
return `${time}_${sha256}${ext}`
}
/**