feat: Oauth update
This commit is contained in:
@@ -3,13 +3,11 @@
|
||||
import Request from "./request";
|
||||
import { handleLocalforage } from "@/utils/localforage";
|
||||
|
||||
const token = String(handleLocalforage.getItem("token"));
|
||||
const token = handleLocalforage.getItem("token").then();
|
||||
const web: Request = new Request({
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API,
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json;charset=utf-8',
|
||||
// Accept: 'application/json',
|
||||
Authorization: token,
|
||||
token: import.meta.env.VITE_APP_TOKEN_KEY + " " + token,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -4,26 +4,28 @@ import CryptoJS from "crypto-js";
|
||||
const key = CryptoJS.enc.Hex.parse("d86d7bab3d6ac01ad9dc6a897652f2d2");
|
||||
// const iv = CryptoJS.enc.Latin1.parse("d86d7bab3d6ac01ad9dc6a897652f2d2");
|
||||
|
||||
// 加密
|
||||
/**
|
||||
* 加密
|
||||
* @param data
|
||||
*/
|
||||
function EncryptData(data: any) {
|
||||
const srcs = CryptoJS.enc.Utf8.parse(data);
|
||||
const encrypted = CryptoJS.AES.encrypt(srcs, key, {
|
||||
const src = CryptoJS.enc.Utf8.parse(data);
|
||||
const encrypted = CryptoJS.AES.encrypt(src, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
});
|
||||
return encrypted.toString();
|
||||
}
|
||||
|
||||
// 解密
|
||||
/**
|
||||
* 解密
|
||||
* @param data
|
||||
*/
|
||||
function DecryptData(data: any) {
|
||||
// const stime = new Date().getTime();
|
||||
const decrypt = CryptoJS.AES.decrypt(data, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
});
|
||||
const result = JSON.parse(CryptoJS.enc.Utf8.stringify(decrypt).toString());
|
||||
// const etime = new Date().getTime();
|
||||
// console.log("DecryptData Time:" + (etime - stime));
|
||||
return result;
|
||||
return JSON.parse(CryptoJS.enc.Utf8.stringify(decrypt).toString());
|
||||
}
|
||||
export { EncryptData, DecryptData };
|
||||
|
||||
Reference in New Issue
Block a user