️ 调整扫码登录逻辑

close #99
This commit is contained in:
目棃
2024-03-12 22:02:04 +08:00
parent cb8d12cc84
commit 16e550ee40
6 changed files with 127 additions and 74 deletions

View File

@@ -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;
});
}