qiutianhong 7 months ago
parent
commit
a9889fbac0
  1. 1
      frontend/src/components/desktop/LockDesktop.vue
  2. 4
      frontend/src/hook/useComputer.ts
  3. 56
      frontend/src/system/config.ts
  4. 6
      godo/files/os.go

1
frontend/src/components/desktop/LockDesktop.vue

@ -121,6 +121,7 @@ onMounted(() => {
}); });
async function onLogin() { async function onLogin() {
localStorage.removeItem("godoosClientId");
if (loginCallback) { if (loginCallback) {
const res = await loginCallback(userName.value, userPassword.value); const res = await loginCallback(userName.value, userPassword.value);
if (res) { if (res) {

4
frontend/src/hook/useComputer.ts

@ -21,7 +21,7 @@ export const useComputer = (adpater: {
if (path === '') path = '/'; if (path === '') path = '/';
else if (path === '/') path = '/'; else if (path === '/') path = '/';
else if (path.endsWith('/')) path = path.substr(0, path.length - 1); else if (path.endsWith('/')) path = path.substr(0, path.length - 1);
if(path.substring(0,2) !== '/F') { if(path.substring(0,2) !== '/F') {
const isExist = await adpater.exists(path); const isExist = await adpater.exists(path);
if (!isExist) { if (!isExist) {
@ -75,7 +75,7 @@ export const useComputer = (adpater: {
// const path = file?.isShare ? file.titleName : file.path // const path = file?.isShare ? file.titleName : file.path
const path = file.path const path = file.path
adpater.setRouter(path); adpater.setRouter(path);
refersh(file); refersh();
} else { } else {
adpater.openFile(file.path); adpater.openFile(file.path);
} }

56
frontend/src/system/config.ts

@ -299,32 +299,42 @@ export const clearSystemConfig = () => {
localStorage.setItem('GodoOS-storeType', storetype) localStorage.setItem('GodoOS-storeType', storetype)
//localStorage.removeItem('GodoOS-config'); //localStorage.removeItem('GodoOS-config');
}; };
function bin2hex(s: string) { // function bin2hex(s: string) {
s = encodeURI(s);//只会有0-127的ascii不转化 // 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; // let m: any = s.match(/%[\dA-F]{2}/g), a: any = s.split(/%[\dA-F]{2}/), i, j, n, t;
m.push("") // m.push("")
for (i in a) { // for (i in a) {
if (a[i] === "") { a[i] = m[i]; continue } // if (a[i] === "") { a[i] = m[i]; continue }
n = "" // n = ""
for (j in a[i]) { // for (j in a[i]) {
t = a[i][j].charCodeAt().toString(16).toUpperCase() // t = a[i][j].charCodeAt().toString(16).toUpperCase()
if (t.length === 1) t = "0" + t // if (t.length === 1) t = "0" + t
n += "%" + t // n += "%" + t
} // }
a[i] = n + m[i] // a[i] = n + m[i]
} // }
return a.join("").split("%").join("") // 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 = () => { export const getClientId = () => {
let uuid: any = localStorage.getItem("godoosClientId"); let uuid: any = localStorage.getItem("godoosClientId");
if (!uuid) { if (!uuid) {
let canvas = document.createElement('canvas'); const timestamp = new Date().getTime();
let ctx: any = canvas.getContext('2d'); const random = Math.floor(Math.random() * 1000000);
ctx.fillStyle = '#FF0000'; uuid = `${timestamp}${random}`;
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); localStorage.setItem("godoosClientId", uuid);
} }
return uuid; return uuid;

6
godo/files/os.go

@ -364,7 +364,11 @@ func IsHavePwd(pwd string) bool {
func GetSalt(r *http.Request) (string, error) { func GetSalt(r *http.Request) (string, error) {
data, ishas := libs.GetConfig("salt") data, ishas := libs.GetConfig("salt")
if ishas { if ishas {
return data.(string), nil // 断言成功则返回
if salt, ok := data.(string); ok {
return salt, nil
}
return "", fmt.Errorf("类型断言失败,期望类型为 string")
} }
salt := r.Header.Get("salt") salt := r.Header.Get("salt")
if salt != "" { if salt != "" {

Loading…
Cancel
Save