mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/request/TGRequest.ts
|
||||
* @description 应用用到的请求函数
|
||||
* @since Beta v0.3.6
|
||||
* @since Beta v0.4.3
|
||||
*/
|
||||
|
||||
import { genAuthkey, genAuthkey2 } from "./genAuthkey";
|
||||
@@ -16,7 +16,7 @@ import { getGameAccountsByCookie, getGameAccountsBySToken } from "./getGameAccou
|
||||
import { getGameRecord } from "./getGameRecord";
|
||||
import { getLTokenBySToken } from "./getLToken";
|
||||
import { getGameRoleListByLToken } from "./getRoleList";
|
||||
import { getStokenByGameToken } from "./getStoken";
|
||||
import { getStokenByGameToken, getTokenBySToken } from "./getStoken";
|
||||
import getSyncAvatarDetail from "./getSyncAvatarDetail";
|
||||
import getSyncAvatarListAll from "./getSyncAvatarListAll";
|
||||
import { getTokensByLoginTicket } from "./getTokens";
|
||||
@@ -49,6 +49,7 @@ const TGRequest = {
|
||||
getRoleList: getGameRoleListByLToken,
|
||||
},
|
||||
bySToken: {
|
||||
update: getTokenBySToken,
|
||||
getAccounts: getGameAccountsBySToken,
|
||||
getCookieToken: getCookieTokenBySToken,
|
||||
getLToken: getLTokenBySToken,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/request/getGameAccounts.ts
|
||||
* @description 获取游戏账号信息相关请求函数
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.4.3
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
@@ -26,7 +26,7 @@ export async function getGameAccountsBySToken(
|
||||
stuid,
|
||||
stoken,
|
||||
};
|
||||
const params = { stoke: stoken, game_biz: TGConstant.Utils.GAME_BIZ };
|
||||
const params = { stoken, stuid, game_biz: TGConstant.Utils.GAME_BIZ };
|
||||
return await getGameAccounts(url, cookie, params);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ async function getGameAccounts(
|
||||
query: params,
|
||||
})
|
||||
.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.list;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* @file web/request/getStoken.ts
|
||||
* @description 获取 stoken
|
||||
* @since Beta v0.3.0
|
||||
* @since Beta v0.4.3
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
|
||||
import TGConstant from "../constant/TGConstant";
|
||||
import { getRequestHeader } from "../utils/getRequestHeader";
|
||||
|
||||
/**
|
||||
* @description 获取 stoken
|
||||
@@ -19,7 +20,7 @@ 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 url = "https://api-takumi.mihoyo.com/account/ma-cn-session/app/getSTokenByGameToken";
|
||||
const data = { account_id: Number(accountId), game_token: gameToken };
|
||||
const header = {
|
||||
"x-rpc-app_id": TGConstant.BBS.APP_ID,
|
||||
@@ -30,6 +31,38 @@ export async function getStokenByGameToken(
|
||||
headers: header,
|
||||
body: http.Body.json(data),
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description stoken v1 到 v2
|
||||
* @since Beta v0.4.3
|
||||
* @param {string} stoken 账户 ID
|
||||
* @param {string} stuid 游戏 Token
|
||||
* @returns {Promise<TGApp.BBS.Response.getStokenByGameTokenData | TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getTokenBySToken(
|
||||
stoken: string,
|
||||
stuid: string,
|
||||
): Promise<TGApp.BBS.Response.getTokenBySTokenData | TGApp.BBS.Response.Base> {
|
||||
const url = "https://passport-api.mihoyo.com/account/ma-cn-session/app/getTokenBySToken";
|
||||
const cookie = {
|
||||
stoken,
|
||||
stuid,
|
||||
};
|
||||
const header = {
|
||||
"x-rpc-app_id": TGConstant.BBS.APP_ID,
|
||||
...getRequestHeader(cookie, "POST", "", "prod"),
|
||||
};
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Response.getTokenBySToken | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
return res.data.data;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/request/getTokens.ts
|
||||
* @description 获取游戏 Token
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.4.3
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
@@ -11,7 +11,7 @@ import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 根据 login_ticket 获取游戏 Token,包括 stoken 和 ltoken
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.4.3
|
||||
* @param {string} ticket 登录票证
|
||||
* @param {string} uid 登录用户 uid
|
||||
* @returns {Promise<TGApp.BBS.Response.getTokensRes[] | TGApp.BBS.Response.Base>}
|
||||
@@ -26,7 +26,7 @@ export async function getTokensByLoginTicket(
|
||||
};
|
||||
const url = TGApi.GameTokens.getTokens;
|
||||
// eslint-disable-next-line camelcase
|
||||
const params = { login_ticket: ticket, token_types: 3, uid };
|
||||
const params = { login_ticket: ticket, token_types: "3", uid };
|
||||
const header = TGUtils.User.getHeader(cookie, "GET", params, "common");
|
||||
return await http
|
||||
.fetch<TGApp.BBS.Response.getTokens | TGApp.BBS.Response.Base>(url, {
|
||||
|
||||
Reference in New Issue
Block a user