mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-16 09:58:13 +08:00
✨ 添加 gt 获取 st,ckt 相关请求
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @file web request getCookieToken.ts
|
||||
* @description 获取 Cookie Token 的请求函数
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
// tauri
|
||||
@@ -41,3 +41,27 @@ export async function getCookieTokenBySToken(
|
||||
return res.data.data.cookie_token;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据 gameToken 获取 cookie_token
|
||||
* @since Beta v0.3.0
|
||||
* @param {string} accountId 账号 id
|
||||
* @param {string} gameToken gameToken
|
||||
* @returns {Promise<string|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getCookieTokenByGameToken(
|
||||
accountId: string,
|
||||
gameToken: string,
|
||||
): Promise<string | TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi.mihoyo.com/auth/api/getCookieAccountInfoByGameToken";
|
||||
const data = { account_id: accountId, game_token: gameToken };
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Response.getCookieTokenByGameToken>(url, {
|
||||
method: "GET",
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data.cookie_token;
|
||||
});
|
||||
}
|
||||
|
||||
39
src/web/request/getStoken.ts
Normal file
39
src/web/request/getStoken.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file web request getStoken.ts
|
||||
* @description 获取 stoken
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
// tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
// constant
|
||||
import TGConstant from "../constant/TGConstant";
|
||||
|
||||
/**
|
||||
* @description 获取 stoken
|
||||
* @since Beta v0.3.0
|
||||
* @param {string} accountId 账户 ID
|
||||
* @param {string} gameToken 游戏 Token
|
||||
* @returns {Promise<string | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getStokenByGameToken(
|
||||
accountId: string,
|
||||
gameToken: string,
|
||||
): Promise<TGApp.BBS.Response.getStokenByGameTokenData | TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi.mihoyo.com/account/ma-cn-session/app/getTokenByGameToken";
|
||||
const data = { account_id: accountId, game_token: gameToken };
|
||||
const header = {
|
||||
"x-rpc-app_id": TGConstant.BBS.APP_ID,
|
||||
};
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Response.getStokenByGameToken>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user