From fb0138dc4a7074f9fcbc3a850024537ae81a7100 Mon Sep 17 00:00:00 2001 From: godo Date: Fri, 20 Dec 2024 09:25:23 +0800 Subject: [PATCH] change lockdesktop --- .../src/components/desktop/LockDesktop.vue | 2 +- frontend/src/system/config.ts | 78 +++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/desktop/LockDesktop.vue b/frontend/src/components/desktop/LockDesktop.vue index cfe68c7..d9c10f0 100644 --- a/frontend/src/components/desktop/LockDesktop.vue +++ b/frontend/src/components/desktop/LockDesktop.vue @@ -217,7 +217,7 @@ }); const onLogin = async () => { - localStorage.removeItem("godoosClientId"); + //localStorage.removeItem("godoosClientId"); if (loginCallback) { const platform = store.ThirdPartyPlatform; const code = router.currentRoute.value.query.code as string; diff --git a/frontend/src/system/config.ts b/frontend/src/system/config.ts index d152e46..1a176de 100644 --- a/frontend/src/system/config.ts +++ b/frontend/src/system/config.ts @@ -329,43 +329,43 @@ export const clearSystemConfig = () => { } //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("") -// } -// 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; -// } +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) { - const timestamp = new Date().getTime(); - const random = Math.floor(Math.random() * 1000000); - uuid = `${timestamp}${random}`; - localStorage.setItem("godoosClientId", uuid); - } - return uuid; -} \ No newline at end of file + let uuid: any = localStorage.getItem("ClientID"); + 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("ClientID", uuid); + } + return uuid; +} +// export const getClientId = () => { +// let uuid: any = localStorage.getItem("godoosClientId"); +// if (!uuid) { +// const timestamp = new Date().getTime(); +// const random = Math.floor(Math.random() * 1000000); +// uuid = `${timestamp}${random}`; +// localStorage.setItem("godoosClientId", uuid); +// } +// return uuid; +// } \ No newline at end of file