🎨 代码格式化

This commit is contained in:
BTMuli
2023-06-25 16:15:15 +08:00
parent 7982649bbc
commit 7567bba147
174 changed files with 29970 additions and 29840 deletions

View File

@@ -10,4 +10,4 @@ const Hk4eAnnoApi = `${Hk4eApi}/common/hk4e_cn/announcement/api`; // 公告 API
export const Hk4eAnnoListApi = `${Hk4eAnnoApi}/getAnnList?`; // 公告列表 API
export const Hk4eAnnoContentApi = `${Hk4eAnnoApi}/getAnnContent?`; // 公告内容 API
export const Hk4eAnnoQuery =
"game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc&region=cn_gf01&level=60&uid=500299765"; // 公告 Query
"game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc&region=cn_gf01&level=60&uid=500299765"; // 公告 Query

View File

@@ -10,9 +10,12 @@ import { ENKA_API } from "./ENKA";
import { Hk4eAnnoListApi, Hk4eAnnoContentApi, Hk4eAnnoQuery } from "./Hk4e";
import { PassportTokenApi, PassportCookieTokenApi, PassportVerifyApi } from "./Passport";
import {
TakumiTokensApi, TakumiRecordCardApi,
TakumiRecordCharactersApi, TakumiRecordIndexApi,
TakumiRecordAbyssApi, TakumiSTokenBindingRolesApi,
TakumiTokensApi,
TakumiRecordCardApi,
TakumiRecordCharactersApi,
TakumiRecordIndexApi,
TakumiRecordAbyssApi,
TakumiSTokenBindingRolesApi,
TakumiCookieBindingRolesApi,
} from "./Takumi";

View File

@@ -20,17 +20,23 @@ import { getRequestHeader } from "../utils/getRequestHeader";
* @param {TGApp.Sqlite.Account.Game} account 游戏账号
* @returns {Promise<TGApp.Game.Abyss.FullData|TGApp.App.Base.Response>}
*/
export async function getAbyss (cookie: Record<string, string>, schedule_type: string, account: TGApp.Sqlite.Account.Game): Promise<TGApp.Game.Abyss.FullData | TGApp.BBS.Response.Base> {
export async function getAbyss(
cookie: Record<string, string>,
schedule_type: string,
account: TGApp.Sqlite.Account.Game,
): Promise<TGApp.Game.Abyss.FullData | TGApp.BBS.Response.Base> {
const url = TGApi.GameData.getAbyss;
const role_id = account.gameUid;
const params = { role_id, schedule_type, server: account.region };
const header = getRequestHeader(cookie, "GET", params, "common");
return await http.fetch<TGApp.Game.Abyss.Response>(url, {
method: "GET",
headers: header,
query: params,
}).then(res => {
if (res.data.retcode !== 0) return res.data;
return res.data.data;
});
return await http
.fetch<TGApp.Game.Abyss.Response>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data;
});
}

View File

@@ -15,8 +15,10 @@ import TGApi from "../api/TGApi";
* @since Alpha v0.1.2
* @returns {Promise<TGApp.BBS.Announcement.ListData>}
*/
export async function getAnnoList (): Promise<TGApp.BBS.Announcement.ListData> {
return await http.fetch<TGApp.BBS.Announcement.ListResponse>(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`).then((res) => res.data.data);
export async function getAnnoList(): Promise<TGApp.BBS.Announcement.ListData> {
return await http
.fetch<TGApp.BBS.Announcement.ListResponse>(`${TGApi.GameAnnoList}${TGApi.GameAnnoQuery}`)
.then((res) => res.data.data);
}
/**
@@ -25,12 +27,12 @@ export async function getAnnoList (): Promise<TGApp.BBS.Announcement.ListData> {
* @param {number} annId 公告 ID
* @returns {Promise<TGApp.BBS.Announcement.ContentItem>}
*/
export async function getAnnoContent (annId: number): Promise<TGApp.BBS.Announcement.ContentItem> {
export async function getAnnoContent(annId: number): Promise<TGApp.BBS.Announcement.ContentItem> {
const annoContents: TGApp.BBS.Announcement.ContentItem[] = await http
.fetch<TGApp.BBS.Announcement.ContentResponse>(`${TGApi.GameAnnoContent}${TGApi.GameAnnoQuery}`)
.then((res) => res.data.data.list);
const annoContent = annoContents.find((item) => item.ann_id === annId);
if (annoContent) {
if (annoContent != null) {
return annoContent;
} else {
throw new Error("公告内容不存在");

View File

@@ -19,7 +19,10 @@ import TGUtils from "../utils/TGUtils";
* @param {string} stoken stoken
* @returns {Promise<string|TGApp.BBS.Response.Base>}
*/
export async function getCookieTokenBySToken (stuid: string, stoken: string): Promise<string | TGApp.BBS.Response.Base> {
export async function getCookieTokenBySToken(
stuid: string,
stoken: string,
): Promise<string | TGApp.BBS.Response.Base> {
const url = TGApi.GameTokens.getCookieToken;
const cookie = {
stuid,
@@ -27,12 +30,14 @@ export async function getCookieTokenBySToken (stuid: string, stoken: string): Pr
};
const params = { stoken };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http.fetch<TGApp.BBS.Response.getCookieTokenBySToken>(url, {
method: "GET",
headers: header,
query: params,
}).then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.cookie_token;
});
return await http
.fetch<TGApp.BBS.Response.getCookieTokenBySToken>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.cookie_token;
});
}

View File

@@ -20,7 +20,10 @@ import TGConstant from "../constant/TGConstant";
* @param {string} stuid 登录用户 uid
* @returns {Promise<TGApp.User.Game.Account[]|TGApp.BBS.Response.Base>}
*/
export async function getGameAccountsBySToken (stoken: string, stuid: string): Promise<TGApp.User.Account.Game[] | TGApp.BBS.Response.Base> {
export async function getGameAccountsBySToken(
stoken: string,
stuid: string,
): Promise<TGApp.User.Account.Game[] | TGApp.BBS.Response.Base> {
const url = TGApi.GameData.bySToken.getAccounts;
const cookie = {
stuid,
@@ -37,7 +40,10 @@ export async function getGameAccountsBySToken (stoken: string, stuid: string): P
* @param {string} account_id 游戏账号 id
* @returns {Promise<TGApp.User.Account.Game[]|TGApp.BBS.Response.Base>}
*/
export async function getGameAccountsByCookie (cookie_token: string, account_id: string): Promise<TGApp.User.Account.Game[] | TGApp.BBS.Response.Base> {
export async function getGameAccountsByCookie(
cookie_token: string,
account_id: string,
): Promise<TGApp.User.Account.Game[] | TGApp.BBS.Response.Base> {
const url = TGApi.GameData.byCookie.getAccounts;
const cookie = {
account_id,
@@ -55,14 +61,20 @@ export async function getGameAccountsByCookie (cookie_token: string, account_id:
* @param {Record<string, string>} params 请求参数
* @returns {Promise<TGApp.User.Account.Game[]|TGApp.BBS.Response.Base>}
*/
async function getGameAccounts (url: string, cookie: Record<string, string>, params: Record<string, string>): Promise<TGApp.BBS.Response.Base | TGApp.User.Account.Game[]> {
async function getGameAccounts(
url: string,
cookie: Record<string, string>,
params: Record<string, string>,
): Promise<TGApp.BBS.Response.Base | TGApp.User.Account.Game[]> {
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http.fetch<TGApp.User.Account.GameResponse>(url, {
method: "GET",
headers: header,
query: params,
}).then(res => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.list;
});
return await http
.fetch<TGApp.User.Account.GameResponse>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.list;
});
}

View File

@@ -20,18 +20,23 @@ import TGUtils from "../utils/TGUtils";
* @param {TGApp.Sqlite.Account.Game} user 用户的基本信息
* @returns {Promise<TGApp.Game.Record.FullData|TGApp.BBS.Response.Base>} 用户基本信息
*/
export async function getGameRecord (cookie: Record<string, string>, user: TGApp.Sqlite.Account.Game): Promise<TGApp.Game.Record.FullData | TGApp.BBS.Response.Base> {
export async function getGameRecord(
cookie: Record<string, string>,
user: TGApp.Sqlite.Account.Game,
): Promise<TGApp.Game.Record.FullData | TGApp.BBS.Response.Base> {
const url = TGApi.GameData.getUserBase;
const params = { role_id: user.gameUid, server: user.region };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http.fetch<TGApp.Game.Record.Response>(url, {
method: "GET",
headers: header,
query: params,
}).then((res) => {
if (res.data.retcode !== 0) {
return res.data;
}
return res.data.data;
});
return await http
.fetch<TGApp.Game.Record.Response>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) {
return res.data;
}
return res.data.data;
});
}

View File

@@ -19,7 +19,10 @@ import TGUtils from "../utils/TGUtils";
* @param {string} stoken stoken
* @returns {Promise<string|TGApp.BBS.Response.Base>}
*/
export async function getLTokenBySToken (stuid: string, stoken: string): Promise<string | TGApp.BBS.Response.Base> {
export async function getLTokenBySToken(
stuid: string,
stoken: string,
): Promise<string | TGApp.BBS.Response.Base> {
const url = TGApi.GameTokens.getLToken;
const cookie = {
stuid,
@@ -27,12 +30,14 @@ export async function getLTokenBySToken (stuid: string, stoken: string): Promise
};
const params = { stoken };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http.fetch<TGApp.BBS.Response.getLTokenBySToken>(url, {
method: "GET",
headers: header,
query: params,
}).then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.ltoken;
});
return await http
.fetch<TGApp.BBS.Response.getLTokenBySToken>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.ltoken;
});
}

View File

@@ -18,18 +18,28 @@ import TGUtils from "../utils/TGUtils";
* @param {TGApp.Sqlite.Account.Game} account 游戏账号
* @returns {Promise<TGApp.Game.Character.ListItem[]|TGApp.BBS.Response.Base>} 用户角色列表
*/
export async function getGameRoleListByLToken (cookie: TGApp.BBS.Constant.CookieGroup4, account: TGApp.Sqlite.Account.Game): Promise<TGApp.Game.Character.ListItem[] | TGApp.BBS.Response.Base> {
export async function getGameRoleListByLToken(
cookie: TGApp.BBS.Constant.CookieGroup4,
account: TGApp.Sqlite.Account.Game,
): Promise<TGApp.Game.Character.ListItem[] | TGApp.BBS.Response.Base> {
const url = TGApi.GameData.byCookie.getCharacter;
const uid = account.gameUid;
// eslint-disable-next-line camelcase
const data = { role_id: uid, server: TGUtils.Tools.getServerByUid(uid) };
const header = TGUtils.User.getHeader(cookie as unknown as Record<string, string>, "POST", JSON.stringify(data), "common");
return await http.fetch<TGApp.Game.Character.ListResponse>(url, {
method: "POST",
headers: header,
body: http.Body.json(data),
}).then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.avatars;
});
const header = TGUtils.User.getHeader(
cookie as unknown as Record<string, string>,
"POST",
JSON.stringify(data),
"common",
);
return await http
.fetch<TGApp.Game.Character.ListResponse>(url, {
method: "POST",
headers: header,
body: http.Body.json(data),
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.avatars;
});
}

View File

@@ -19,7 +19,10 @@ import TGUtils from "../utils/TGUtils";
* @param {string} uid 登录用户 uid
* @returns {Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base>}
*/
export async function getTokensByLoginTicket (ticket: string, uid: string): Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base> {
export async function getTokensByLoginTicket(
ticket: string,
uid: string,
): Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base> {
const cookie = {
login_ticket: ticket,
login_uid: uid,
@@ -28,13 +31,15 @@ export async function getTokensByLoginTicket (ticket: string, uid: string): Prom
// eslint-disable-next-line camelcase
const params = { login_ticket: ticket, token_types: 3, uid };
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
return await http.fetch<TGApp.BBS.Response.getTokens>(url, {
method: "GET",
headers: header,
query: params,
}).then((res) => {
console.log(res);
if (res.data.retcode !== 0) return res.data;
return res.data.data.list;
});
return await http
.fetch<TGApp.BBS.Response.getTokens>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
console.log(res);
if (res.data.retcode !== 0) return res.data;
return res.data.data.list;
});
}

View File

@@ -21,7 +21,10 @@ import { type UserResponse } from "../../plugins/Mys/interface/user";
* @param {string} account_id 用户 account_id
* @returns {Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base>}
*/
export async function getUserInfoByCookie (cookie_token: string, account_id: string): Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base> {
export async function getUserInfoByCookie(
cookie_token: string,
account_id: string,
): Promise<TGApp.App.Account.BriefInfo | TGApp.BBS.Response.Base> {
const cookie = {
cookie_token,
account_id,
@@ -29,18 +32,20 @@ export async function getUserInfoByCookie (cookie_token: string, account_id: str
const url = TGApi.GameData.byCookie.getUserInfo;
const params = { gids: "2" };
const header = TGUtils.User.getSignHeader(cookie, "GET", {}, "common");
return await http.fetch<UserResponse>(url, {
method: "GET",
headers: header,
query: params,
}).then((res) => {
if (res.data.retcode !== 0) return res.data;
const info = res.data.data.user_info;
return {
nickname: info.nickname,
uid: info.uid,
avatar: info.avatar_url,
desc: info.introduce,
};
});
return await http
.fetch<UserResponse>(url, {
method: "GET",
headers: header,
query: params,
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
const info = res.data.data.user_info;
return {
nickname: info.nickname,
uid: info.uid,
avatar: info.avatar_url,
desc: info.introduce,
};
});
}

View File

@@ -19,7 +19,7 @@ import { verifyLToken } from "./verifyLToken";
* @param {string} uid login_uid
* @returns {Promise<void>}
*/
async function initCookie (ticket: string, uid: string): Promise<void> {
async function initCookie(ticket: string, uid: string): Promise<void> {
const tokenRes = await getTokensByLoginTicket(ticket, uid);
const cookie: TGApp.BBS.Constant.Cookie = {
account_id: uid,
@@ -35,8 +35,8 @@ async function initCookie (ticket: string, uid: string): Promise<void> {
if (Array.isArray(tokenRes)) {
const lToken = tokenRes.find((item) => item.name === "ltoken");
const sToken = tokenRes.find((item) => item.name === "stoken");
if (lToken) cookie.ltoken = lToken.token;
if (sToken) cookie.stoken = sToken.token;
if (lToken != null) cookie.ltoken = lToken.token;
if (sToken != null) cookie.stoken = sToken.token;
const cookieToken = await getCookieTokenBySToken(uid, cookie.stoken);
if (typeof cookieToken === "string") cookie.cookie_token = cookieToken;
const mid = await verifyLToken(cookie.ltoken, cookie.ltuid);

View File

@@ -19,7 +19,10 @@ import TGUtils from "../utils/TGUtils";
* @param {string} ltuid 登录用户 uid
* @returns {Promise<string | TGApp.BBS.Response.Base>}
*/
export async function verifyLToken (ltoken: string, ltuid: string): Promise<string | TGApp.BBS.Response.Base> {
export async function verifyLToken(
ltoken: string,
ltuid: string,
): Promise<string | TGApp.BBS.Response.Base> {
const url = TGApi.GameTokens.verifyLToken;
const cookie = {
ltoken,
@@ -27,12 +30,14 @@ export async function verifyLToken (ltoken: string, ltuid: string): Promise<stri
};
const data = { ltoken };
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
return await http.fetch<TGApp.BBS.Response.verifyUserInfoBySToken>(url, {
method: "POST",
headers: header,
body: http.Body.json(data),
}).then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.user_info.mid;
});
return await http
.fetch<TGApp.BBS.Response.verifyUserInfoBySToken>(url, {
method: "POST",
headers: header,
body: http.Body.json(data),
})
.then((res) => {
if (res.data.retcode !== 0) return res.data;
return res.data.data.user_info.mid;
});
}

View File

@@ -14,7 +14,7 @@ import { fs, path } from "@tauri-apps/api";
* @param {Record<string, string>} cookie cookie
* @returns {Promise<void>}
*/
export async function backupCookieData (cookie: Record<string, string>): Promise<void> {
export async function backupCookieData(cookie: Record<string, string>): Promise<void> {
const savePath = `${await path.appLocalDataDir()}\\userData\\cookie.json`;
await fs.writeTextFile(savePath, JSON.stringify(cookie, null, 2));
}
@@ -25,7 +25,7 @@ export async function backupCookieData (cookie: Record<string, string>): Promise
* @param {TGApp.Sqlite.Abyss.SingleTable[]} abyssData 深渊数据
* @returns {Promise<void>}
*/
export async function backupAbyssData (abyssData: TGApp.Sqlite.Abyss.SingleTable[]): Promise<void> {
export async function backupAbyssData(abyssData: TGApp.Sqlite.Abyss.SingleTable[]): Promise<void> {
const savePath = `${await path.appLocalDataDir()}\\userData\\abyss.json`;
await fs.writeTextFile(savePath, JSON.stringify(abyssData, null, 2));
}

View File

@@ -14,7 +14,9 @@ const defaultCover = "/source/UI/defaultCover.webp";
* @param {TGApp.BBS.Announcement.ListData[]} data 公告数据
* @returns {TGApp.App.Announcement.ListCard[]} 渲染用的卡片
*/
export function getAnnoCard (data: TGApp.BBS.Announcement.ListData): TGApp.App.Announcement.ListCard[] {
export function getAnnoCard(
data: TGApp.BBS.Announcement.ListData,
): TGApp.App.Announcement.ListCard[] {
const cards: TGApp.App.Announcement.ListCard[] = [];
data.list.map((annoList: TGApp.BBS.Announcement.ListItem) => {
return annoList.list.map((anno: TGApp.BBS.Announcement.AnnoSingle) => {

View File

@@ -18,7 +18,7 @@ import { transCookie, transParams } from "./tools";
* @param {string} saltType salt 类型
* @returns {string} salt
*/
function getSalt (saltType: string) {
function getSalt(saltType: string) {
switch (saltType) {
case "common":
return TGConstant.Salt.Other.X4;
@@ -36,7 +36,7 @@ function getSalt (saltType: string) {
* @param {number} max 最大值
* @returns {number} 随机数
*/
function getRandomNumber (min: number, max: number): number {
function getRandomNumber(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1) + min);
}
@@ -46,7 +46,7 @@ function getRandomNumber (min: number, max: number): number {
* @param {number} length 字符串长度
* @returns {string} 随机字符串
*/
export function getRandomString (length: number): string {
export function getRandomString(length: number): string {
const str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let res = "";
for (let i = 0; i < length; i++) {
@@ -65,7 +65,7 @@ export function getRandomString (length: number): string {
* @param {boolean} isSign 是否为签名
* @returns {string} ds
*/
function getDS (method: string, data: string, saltType: string, isSign: boolean = false): string {
function getDS(method: string, data: string, saltType: string, isSign: boolean = false): string {
const salt = getSalt(saltType);
const time = Math.floor(Date.now() / 1000).toString();
let random = getRandomNumber(100000, 200000).toString();
@@ -86,7 +86,12 @@ function getDS (method: string, data: string, saltType: string, isSign: boolean
* @param {string} saltType salt 类型
* @returns {Record<string, string>} 请求头
*/
export function getRequestHeader (cookie: Record<string, string>, method: string, data: Record<string, string | number> | string, saltType: string): Record<string, string> {
export function getRequestHeader(
cookie: Record<string, string>,
method: string,
data: Record<string, string | number> | string,
saltType: string,
): Record<string, string> {
let ds;
if (typeof data === "string") {
ds = getDS(method, data, saltType);
@@ -113,7 +118,12 @@ export function getRequestHeader (cookie: Record<string, string>, method: string
* @param {string} saltType salt 类型
* @returns {Record<string, string>} 请求头
*/
export function getRequestSignHeader (cookie: Record<string, string>, method: string, data: Record<string, string | number>, saltType: string): Record<string, string> {
export function getRequestSignHeader(
cookie: Record<string, string>,
method: string,
data: Record<string, string | number>,
saltType: string,
): Record<string, string> {
return {
"User-Agent": TGConstant.BBS.USER_AGENT,
"x-rpc-app_version": TGConstant.BBS.VERSION,

View File

@@ -14,7 +14,7 @@ import { saveImgLocal } from "../../utils/TGShare";
* @param {string} data 游戏内公告数据
* @returns {Promise<string>} 解析后的数据
*/
export async function parseAnnoContent (data: string): Promise<string> {
export async function parseAnnoContent(data: string): Promise<string> {
const htmlBase = new DOMParser().parseFromString(data, "text/html");
htmlBase.querySelectorAll("span").forEach((span) => {
if (span.style.fontSize) {

View File

@@ -15,9 +15,9 @@ import TGSqlite from "../../plugins/Sqlite";
* @since Alpha v0.2.0
* @returns {Promise<boolean>}
*/
export async function restoreCookieData (): Promise<boolean> {
export async function restoreCookieData(): Promise<boolean> {
const cookiePath = `${await path.appLocalDataDir()}\\userData\\cookie.json`;
if (!await fs.exists(cookiePath)) return false;
if (!(await fs.exists(cookiePath))) return false;
const cookieData = await fs.readTextFile(cookiePath);
await TGSqlite.saveAppData("cookie", JSON.stringify(JSON.parse(cookieData)));
return true;
@@ -28,9 +28,9 @@ export async function restoreCookieData (): Promise<boolean> {
* @since Alpha v0.2.0
* @returns {Promise<boolean>}
*/
export async function restoreAbyssData (): Promise<boolean> {
export async function restoreAbyssData(): Promise<boolean> {
const abyssPath = `${await path.appLocalDataDir()}\\userData\\abyss.json`;
if (!await fs.exists(abyssPath)) return false;
if (!(await fs.exists(abyssPath))) return false;
const abyssData = await fs.readTextFile(abyssPath);
await TGSqlite.restoreAbyss(JSON.parse(abyssData));
return true;

View File

@@ -14,14 +14,14 @@ import TGConstant from "../constant/TGConstant";
* @param {string} data 内容
* @returns {string} 转义后的内容
*/
export function decodeRegExp (data: string): string {
export function decodeRegExp(data: string): string {
let res = data;
if (res.length === 0) return res;
res = res.replace(/&lt;/g, "<");
res = res.replace(/&gt;/g, ">");
res = res.replace(/&nbsp;/g, " ");
res = res.replace(/&#39;/g, "'");
res = res.replace(/&quot;/g, "\"");
res = res.replace(/&quot;/g, '"');
res = res.replace(/&apos;/g, "'");
res = res.replace(/&amp;/g, "&");
return res;
@@ -33,7 +33,7 @@ export function decodeRegExp (data: string): string {
* @param {Record<string, string>} cookie cookie
* @returns {string} 转换后的 cookie
*/
export function transCookie (cookie: Record<string, string>) {
export function transCookie(cookie: Record<string, string>) {
let res = "";
for (const key of Object.keys(cookie).sort()) {
res += `${key}=${cookie[key]};`;
@@ -47,7 +47,7 @@ export function transCookie (cookie: Record<string, string>) {
* @param {Record<string, string|number>} obj object
* @returns {string} query string
*/
export function transParams (obj: Record<string, string | number>): string {
export function transParams(obj: Record<string, string | number>): string {
let res = "";
const keys = Object.keys(obj).sort();
for (const key of keys) {
@@ -62,7 +62,7 @@ export function transParams (obj: Record<string, string | number>): string {
* @param {string} uid uid
* @returns {string} server
*/
export function getServerByUid (uid: string): string {
export function getServerByUid(uid: string): string {
// 获取第一个字符
const first = uid[0];
// 1-4 为国服-天空岛