mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-04-03 06:55:06 +08:00
🌱 完成深渊数据获取
This commit is contained in:
@@ -97,7 +97,8 @@ export function getRequestHeader (cookie: Record<string, string>, method: string
|
||||
"User-Agent": TGConstant.BBS.USER_AGENT,
|
||||
"x-rpc-app_version": TGConstant.BBS.VERSION,
|
||||
"x-rpc-client_type": "5",
|
||||
Referer: TGConstant.BBS.REFERER,
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
Referer: "https://webstatic.mihoyo.com",
|
||||
DS: ds,
|
||||
Cookie: transCookie(cookie),
|
||||
};
|
||||
@@ -117,7 +118,8 @@ export function getRequestSignHeader (cookie: Record<string, string>, method: st
|
||||
"User-Agent": TGConstant.BBS.USER_AGENT,
|
||||
"x-rpc-app_version": TGConstant.BBS.VERSION,
|
||||
"x-rpc-client_type": "5",
|
||||
Referer: TGConstant.BBS.REFERER,
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
Referer: "https://webstatic.mihoyo.com",
|
||||
DS: getDS(method, transParams(data), saltType, true),
|
||||
Cookie: transCookie(cookie),
|
||||
};
|
||||
|
||||
@@ -29,21 +29,21 @@ export function decodeRegExp (data: string): string {
|
||||
|
||||
/**
|
||||
* @description 将 cookie 对象转换为字符串
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @returns {string} 转换后的 cookie
|
||||
*/
|
||||
export function transCookie (cookie: Record<string, string>) {
|
||||
let res = "";
|
||||
for (const [key, value] of Object.entries(cookie)) {
|
||||
res += `${key}=${value};`;
|
||||
for (const key of Object.keys(cookie).sort()) {
|
||||
res += `${key}=${cookie[key]};`;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description ds 算法需要数据转换后的字符串是按照字典序排序的
|
||||
* @since Alpha v0.2.0
|
||||
* @since Alpha v0.1.5
|
||||
* @param {Record<string, string|number>} obj object
|
||||
* @returns {string} query string
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ export function transParams (obj: Record<string, string | number>): string {
|
||||
let res = "";
|
||||
const keys = Object.keys(obj).sort();
|
||||
for (const key of keys) {
|
||||
res += `${key}=${obj[key]}&`;
|
||||
res += `${key}=${obj[key].toString()}&`;
|
||||
}
|
||||
return res.slice(0, -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user