From 13aba70154e6146dc7ac4882a73d2575d89b3030 Mon Sep 17 00:00:00 2001 From: godo Date: Sat, 2 Nov 2024 13:03:57 +0800 Subject: [PATCH 1/2] change uuid --- frontend/src/system/config.ts | 56 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/frontend/src/system/config.ts b/frontend/src/system/config.ts index b55b575..3d1628c 100644 --- a/frontend/src/system/config.ts +++ b/frontend/src/system/config.ts @@ -299,32 +299,42 @@ export const clearSystemConfig = () => { localStorage.setItem('GodoOS-storeType', storetype) //localStorage.removeItem('GodoOS-config'); }; -function bin2hex(s: string) { - s = encodeURI(s);//只会有0-127的ascii不转化 - let m: any = s.match(/%[\dA-F]{2}/g), a: any = s.split(/%[\dA-F]{2}/), i, j, n, t; - m.push("") - for (i in a) { - if (a[i] === "") { a[i] = m[i]; continue } - n = "" - for (j in a[i]) { - t = a[i][j].charCodeAt().toString(16).toUpperCase() - if (t.length === 1) t = "0" + t - n += "%" + t - } - a[i] = n + m[i] - } - return a.join("").split("%").join("") -} +// function bin2hex(s: string) { +// s = encodeURI(s);//只会有0-127的ascii不转化 +// let m: any = s.match(/%[\dA-F]{2}/g), a: any = s.split(/%[\dA-F]{2}/), i, j, n, t; +// m.push("") +// for (i in a) { +// if (a[i] === "") { a[i] = m[i]; continue } +// n = "" +// for (j in a[i]) { +// t = a[i][j].charCodeAt().toString(16).toUpperCase() +// if (t.length === 1) t = "0" + t +// n += "%" + t +// } +// a[i] = n + m[i] +// } +// return a.join("").split("%").join("") +// } +// export const getClientId = () => { +// let uuid: any = localStorage.getItem("godoosClientId"); +// if (!uuid) { +// let canvas = document.createElement('canvas'); +// let ctx: any = canvas.getContext('2d'); +// ctx.fillStyle = '#FF0000'; +// ctx.fillRect(0, 0, 8, 10); +// let b64 = canvas.toDataURL().replace("data:image/png;base64,", ""); +// let bin = window.atob(b64); +// uuid = bin2hex(bin.slice(-16, -12)); +// localStorage.setItem("godoosClientId", uuid); +// } +// return uuid; +// } export const getClientId = () => { let uuid: any = localStorage.getItem("godoosClientId"); if (!uuid) { - let canvas = document.createElement('canvas'); - let ctx: any = canvas.getContext('2d'); - ctx.fillStyle = '#FF0000'; - ctx.fillRect(0, 0, 8, 10); - let b64 = canvas.toDataURL().replace("data:image/png;base64,", ""); - let bin = window.atob(b64); - uuid = bin2hex(bin.slice(-16, -12)); + const timestamp = new Date().getTime(); + const random = Math.floor(Math.random() * 1000000); + uuid = `${timestamp}${random}`; localStorage.setItem("godoosClientId", uuid); } return uuid; From 327b6b435a77db199e510f2c34216632b2d4e601 Mon Sep 17 00:00:00 2001 From: wei_yunxiao <277130180@qq.com> Date: Sat, 2 Nov 2024 15:58:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:uuid=E5=8F=8Ats=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/desktop/LockDesktop.vue | 1 + frontend/src/hook/useComputer.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/desktop/LockDesktop.vue b/frontend/src/components/desktop/LockDesktop.vue index aad74cf..28c3043 100644 --- a/frontend/src/components/desktop/LockDesktop.vue +++ b/frontend/src/components/desktop/LockDesktop.vue @@ -121,6 +121,7 @@ onMounted(() => { }); async function onLogin() { + localStorage.removeItem("godoosClientId"); if (loginCallback) { const res = await loginCallback(userName.value, userPassword.value); if (res) { diff --git a/frontend/src/hook/useComputer.ts b/frontend/src/hook/useComputer.ts index fdc3886..cc73b4a 100644 --- a/frontend/src/hook/useComputer.ts +++ b/frontend/src/hook/useComputer.ts @@ -21,7 +21,7 @@ export const useComputer = (adpater: { if (path === '') path = '/'; else if (path === '/') path = '/'; else if (path.endsWith('/')) path = path.substr(0, path.length - 1); - + if(path.substring(0,2) !== '/F') { const isExist = await adpater.exists(path); if (!isExist) { @@ -75,7 +75,7 @@ export const useComputer = (adpater: { // const path = file?.isShare ? file.titleName : file.path const path = file.path adpater.setRouter(path); - refersh(file); + refersh(); } else { adpater.openFile(file.path); }