修改uuid和pro地址
parent
9d87e7db9d
commit
f603a2c205
2
.env.pro
2
.env.pro
|
@ -1,2 +1,2 @@
|
|||
NODE_ENV = 'production'
|
||||
VITE_NUXT_ENV = 'http://1.13.246.108:8080/'
|
||||
VITE_NUXT_ENV = 'http://113.45.190.154:8080/'
|
|
@ -145,13 +145,13 @@ const calculateFileHash = (file: File): Promise<string> => {
|
|||
// });
|
||||
// };
|
||||
// 生成唯一ID
|
||||
const guid = () => {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
||||
const r = (Math.random() * 16) | 0;
|
||||
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
// const guid = () => {
|
||||
// return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
|
||||
// const r = (Math.random() * 16) | 0;
|
||||
// const v = c === "x" ? r : (r & 0x3) | 0x8;
|
||||
// return v.toString(16);
|
||||
// });
|
||||
// };
|
||||
|
||||
// 初始化参数
|
||||
const initParam = () => {
|
||||
|
@ -164,13 +164,14 @@ const initParam = () => {
|
|||
requiredValid.value = false;
|
||||
};
|
||||
|
||||
function getOssDefaultPath(name, uuid) {
|
||||
function getOssDefaultPath(name:any) {
|
||||
const timestamp = Date.now();
|
||||
const now = new Date();
|
||||
const year = now.getFullYear(); // 获取当前年份
|
||||
const month = String(now.getMonth() + 1).padStart(2, "0"); // 获取当前月份,确保两位
|
||||
const day = String(now.getDate()).padStart(2, "0"); // 获取当前日期,确保两位
|
||||
|
||||
return `${year}/${month}/${day}/${uuid}/${name}`; // 拼接路径
|
||||
return `${year}/${month}/${day}/${timestamp}/${name}`; // 拼接路径
|
||||
}
|
||||
// 选择文件处理
|
||||
const selectFile = async (event: Event) => {
|
||||
|
@ -259,7 +260,7 @@ const selectFile = async (event: Event) => {
|
|||
}
|
||||
|
||||
totalChunks.value = Math.ceil(file.value.size / chunkSize.value);
|
||||
objectKey.value = `${getOssDefaultPath(fileName.value, guid())}`;
|
||||
objectKey.value = `${getOssDefaultPath(fileName.value)}`;
|
||||
// 获取上传ID
|
||||
const res = await request.get(`/file/getUploadId?objectKey=${objectKey.value}`);
|
||||
uploadId.value = res.data;
|
||||
|
|
Loading…
Reference in New Issue