Browse Source

change client Id

master
godo 5 months ago
parent
commit
175d5409b5
  1. 52
      frontend/src/system/config.ts
  2. 7
      frontend/src/system/index.ts
  3. 2
      frontend/src/util/clientid.ts

52
frontend/src/system/config.ts

@ -1,7 +1,7 @@
import { generateRandomString } from "../util/common.ts";
export const configStoreType = localStorage.getItem('GodoOS-storeType') || 'local';
import { parseAiConfig } from "./aiconfig.ts";
import { getClientId } from "../util/clientid.ts";
import { GetClientId } from "../util/clientid.ts";
/**
*
*
@ -224,9 +224,9 @@ export function getUrl(url: string, islast = true) {
return config.apiUrl + url
} else {
if (islast) {
return config.userInfo.url + url + '&uuid=' + getClientId() + '&token=' + config.userInfo.token
return config.userInfo.url + url + '&uuid=' + GetClientId() + '&token=' + config.userInfo.token
} else {
return config.userInfo.url + url + '?uuid=' + getClientId() + '&token=' + config.userInfo.token
return config.userInfo.url + url + '?uuid=' + GetClientId() + '&token=' + config.userInfo.token
}
}
@ -234,7 +234,7 @@ export function getUrl(url: string, islast = true) {
export function getWorkflowUrl() {
const config = getSystemConfig();
if (config.userType == 'member') {
return config.userInfo.url + '/views/desktop/index.html' + '?uuid=' + getClientId() + '&token=' + config.userInfo.token
return config.userInfo.url + '/views/desktop/index.html' + '?uuid=' + GetClientId() + '&token=' + config.userInfo.token
}
}
export function fetchGet(url: string, headerConfig?: { [key: string]: string }) {
@ -252,7 +252,7 @@ export function fetchGet(url: string, headerConfig?: { [key: string]: string })
credentials: 'include',
headers: {
//'Content-Type': 'application/json',
'ClientID': getClientId(),
'ClientID': GetClientId(),
'Authorization': config.userInfo.token,
...headerConfig
}
@ -273,7 +273,7 @@ export function fetchPost(url: string, data: any, headerConfig?: { [key: string]
credentials: 'include',
body: data,
headers: {
'ClientID': getClientId(),
'ClientID': GetClientId(),
'Authorization': config.userInfo.token,
...headerConfig
}
@ -330,43 +330,3 @@ 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("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;
// }

7
frontend/src/system/index.ts

@ -21,7 +21,8 @@ import { RestartApp } from '@/util/goutil';
import { notifyError } from '@/util/msg';
//import { isShareFile } from '@/util/sharePath';
import { pick } from '../util/modash';
import { clearSystemConfig, fetchGet, getClientId, getFileUrl, getSystemConfig, getSystemKey, setSystemConfig, setSystemKey } from './config';
import { GetClientId } from "../util/clientid.ts";
import { clearSystemConfig, fetchGet, getFileUrl, getSystemConfig, getSystemKey, setSystemConfig, setSystemKey } from './config';
import { OsFileInterface } from './core/FIleInterface';
import { extname } from './core/Path';
import { initBuiltinApp, initBuiltinFileOpener } from './initBuiltin';
@ -119,7 +120,7 @@ export class System {
//console.log(config.userType)
if (config.userType == 'person') {
upgradeStore.systemMessage();
}else{
} else {
upgradeStore.onlineMessage()
}
}, 3000);
@ -192,7 +193,7 @@ export class System {
password: password,
github_code: loginCode?.github_code,
gitee_code: loginCode?.gitee_code,
clientId: getClientId(),
clientId: GetClientId(),
}),
});
if (!res.ok) {

2
frontend/src/util/clientid.ts

@ -85,7 +85,7 @@ function getOSInfo() {
}
return hash.toString(36); // Convert to base 36 for shorter string
}
export const getClientId = () => {
export function GetClientId(){
let uuid = localStorage.getItem("ClientID");
if (!uuid) {
const fingerprint = getBrowserFingerprint();

Loading…
Cancel
Save