mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
🎨 优化方法
This commit is contained in:
@@ -41,44 +41,48 @@ export async function getVerification(
|
||||
* @description 将验证完的参数提交给米游社
|
||||
* @since Beta v0.3.3
|
||||
* @todo 待测试
|
||||
* @param {string} urlOri 原始 url
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {TGApp.BBS.Geetest.GeetestValidate} validate 验证码参数
|
||||
* @return {Promise<TGApp.BBS.Response.Base|unknown>} 提交结果
|
||||
* @return {Promise<boolean>} 提交结果
|
||||
*/
|
||||
export async function submitVerification(
|
||||
urlOri: string,
|
||||
cookie: Record<string, string>,
|
||||
validate: TGApp.BBS.Geetest.GeetestValidate,
|
||||
): Promise<TGApp.BBS.Response.Base | unknown> {
|
||||
): Promise<boolean> {
|
||||
const url = "https://api-takumi-record.mihoyo.com/game_record/app/card/wapi/verifyVerification";
|
||||
const data = {
|
||||
const dataRaw = {
|
||||
geetest_challenge: validate.geetest_challenge,
|
||||
geetest_validate: validate.geetest_validate,
|
||||
geetest_seccode: validate.geetest_seccode,
|
||||
};
|
||||
console.log(data);
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "lk2", true);
|
||||
const data = JSON.stringify(dataRaw);
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "common", false);
|
||||
const reqHeader = {
|
||||
...header,
|
||||
"x-rpc-challenge_game": "2",
|
||||
"x-rpc-challenge_trace": validate.geetest_challenge,
|
||||
"x-rpc-challenge": validate.geetest_challenge,
|
||||
"x-rpc-validate": validate.geetest_validate,
|
||||
"x-rpc-seccode": validate.geetest_seccode,
|
||||
"x-rpc-challenge_path": urlOri,
|
||||
};
|
||||
console.log(reqHeader);
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: reqHeader,
|
||||
body: http.Body.json(data),
|
||||
body: http.Body.json(dataRaw),
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.rawHeaders);
|
||||
if (res.data.retcode !== 0) {
|
||||
showSnackbar({
|
||||
text: `[${res.data.retcode}] ${res.data.message}`,
|
||||
color: "error",
|
||||
});
|
||||
console.error(res.data);
|
||||
return false;
|
||||
}
|
||||
return res.data;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/**
|
||||
* @file web utils getRequestHeader.ts
|
||||
* @description 获取请求头
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Beta v0.3.0
|
||||
* @since Beta v0.3.3
|
||||
*/
|
||||
|
||||
// Node
|
||||
import md5 from "js-md5";
|
||||
// Tauri.Genshin
|
||||
import Md5 from "js-md5";
|
||||
import TGConstant from "../constant/TGConstant";
|
||||
import { transCookie, transParams } from "./tools";
|
||||
|
||||
@@ -59,7 +56,7 @@ export function getRandomString(length: number): string {
|
||||
|
||||
/**
|
||||
* @description 获取 ds
|
||||
* @since Beta v0.3.0
|
||||
* @since Beta v0.3.3
|
||||
* @version 2.50.1
|
||||
* @param {string} method 请求方法
|
||||
* @param {string} data 请求数据
|
||||
@@ -76,7 +73,7 @@ function getDS(method: string, data: string, saltType: string, isSign: boolean):
|
||||
const query = method === "GET" ? data : "";
|
||||
let hashStr = `salt=${salt}&t=${time}&r=${random}&b=${body}&q=${query}`;
|
||||
if (isSign) hashStr = `salt=${salt}&t=${time}&r=${random}`;
|
||||
const md5Str = md5.update(hashStr).hex();
|
||||
const md5Str = Md5.md5.update(hashStr).hex();
|
||||
return `${time},${random},${md5Str}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user