🗑️ 增加几个 callback 处理

This commit is contained in:
BTMuli
2023-12-11 15:49:41 +08:00
parent 17744cc01d
commit 07e944859c
3 changed files with 53 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
* @since Beta v0.3.6
*/
import { genAuthkey } from "./genAuthkey";
import { genAuthkey, genAuthkey2 } from "./genAuthkey";
import { getAbyss } from "./getAbyss";
import { getActionTicketBySToken } from "./getActionTicket";
import { getAnnoContent, getAnnoList } from "./getAnno";
@@ -33,6 +33,7 @@ const TGRequest = {
},
User: {
getAuthkey: genAuthkey,
getAuthkey2: genAuthkey2,
getGachaLog,
getRecord: getGameRecord,
byLoginTicket: {

View File

@@ -1,7 +1,7 @@
/**
* @file web/request/genAuthkey.ts
* @description 生成 authkey
* @since Beta v0.3.0
* @since Beta v0.3.7
*/
import { http } from "@tauri-apps/api";
@@ -39,3 +39,25 @@ export async function genAuthkey(
return res.data;
});
}
/**
* @description 生成 authkey
* @since Beta v0.3.0
* @param {Record<string, string>} cookie cookie // stoken_v2 & mid
* @param {object} payload payload
* @returns {Promise<string|TGApp.BBS.Response.Base>} authkey
*/
export async function genAuthkey2(
cookie: Record<string, string>,
payload: Record<string, string>,
): Promise<TGApp.BBS.Response.Base> {
const url = "https://api-takumi.mihoyo.com/binding/api/genAuthKey";
const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(payload), "lk2", true);
return await http
.fetch<TGApp.BBS.Response.Base>(url, {
method: "POST",
headers: header,
body: http.Body.json(payload),
})
.then((res) => res.data);
}