mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/request/getStoken.ts
|
||||
* @description 获取 stoken
|
||||
* @since Beta v0.4.3
|
||||
* @since Beta v0.4.4
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
@@ -11,17 +11,22 @@ import { getRequestHeader } from "../utils/getRequestHeader";
|
||||
|
||||
/**
|
||||
* @description 获取 stoken
|
||||
* @since Beta v0.3.0
|
||||
* @since Beta v0.4.4
|
||||
* @param {string} accountId 账户 ID
|
||||
* @param {string} gameToken 游戏 Token
|
||||
* @param {string} token 游戏 Token
|
||||
* @param {string} isGameToken 是否为游戏 Token
|
||||
* @returns {Promise<TGApp.BBS.Response.getStokenByGameTokenData | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getStokenByGameToken(
|
||||
accountId: string,
|
||||
gameToken: string,
|
||||
token: string,
|
||||
isGameToken: boolean,
|
||||
): Promise<TGApp.BBS.Response.getStokenByGameTokenData | TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi.mihoyo.com/account/ma-cn-session/app/getSTokenByGameToken";
|
||||
const data = { account_id: Number(accountId), game_token: gameToken };
|
||||
let url = "https://api-takumi.mihoyo.com/account/ma-cn-session/app/getSTokenByGameToken";
|
||||
if (isGameToken) {
|
||||
url = "https://api-takumi.mihoyo.com/account/ma-cn-session/app/getTokenByGameToken";
|
||||
}
|
||||
const data = { account_id: Number(accountId), game_token: token };
|
||||
const header = {
|
||||
"x-rpc-app_id": TGConstant.BBS.APP_ID,
|
||||
};
|
||||
@@ -32,8 +37,7 @@ export async function getStokenByGameToken(
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
@@ -64,7 +68,7 @@ export async function getTokenBySToken(
|
||||
headers: header,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user