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