From f603a2c20541b2f0b8e04aa2842a610a87965394 Mon Sep 17 00:00:00 2001 From: shenhan Date: Mon, 17 Mar 2025 10:53:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9uuid=E5=92=8Cpro=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.pro | 2 +- app/components/fileUpload/index.vue | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/.env.pro b/.env.pro index be17dc1..0b5eda0 100644 --- a/.env.pro +++ b/.env.pro @@ -1,2 +1,2 @@ NODE_ENV = 'production' -VITE_NUXT_ENV = 'http://1.13.246.108:8080/' \ No newline at end of file +VITE_NUXT_ENV = 'http://113.45.190.154:8080/' \ No newline at end of file diff --git a/app/components/fileUpload/index.vue b/app/components/fileUpload/index.vue index 598ccde..2e67f40 100644 --- a/app/components/fileUpload/index.vue +++ b/app/components/fileUpload/index.vue @@ -145,13 +145,13 @@ const calculateFileHash = (file: File): Promise => { // }); // }; // 生成唯一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;