mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
✨ 添加 gt 获取 st,ckt 相关请求
This commit is contained in:
43
src/types/BBS/Account.d.ts
vendored
43
src/types/BBS/Account.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
* @file types BBS Account.d.ts
|
||||
* @description BBS 账户相关类型定义文件
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Account {
|
||||
@@ -41,4 +41,45 @@ declare namespace TGApp.BBS.Account {
|
||||
rebind_mobile_time: string;
|
||||
links: unknown[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 通过 gameToken 获取 stoken 返回的用户信息
|
||||
* @interface getStokenByGameTokenInfo
|
||||
* @since Beta v0.3.0
|
||||
* @property {string} aid 账号 id
|
||||
* @property {string} mid mid
|
||||
* @property {string} account_name 账号名称
|
||||
* @property {string} email 邮箱
|
||||
* @property {number} is_email_verify 是否验证邮箱 // 0 未验证 1 已验证
|
||||
* @property {string} area_code 手机区号 // '+86'
|
||||
* @property {string} mobile 手机号 // 部分明文,中间隐藏
|
||||
* @property {string} safe_area_code 安全手机区号
|
||||
* @property {string} safe_mobile 安全手机号
|
||||
* @property {string} realname 真实姓名 // 最后一位明文,其他隐藏
|
||||
* @property {string} identity_code 身份证号 // 头尾三位明文,其他隐藏
|
||||
* @property {string} rebind_area_code 重新绑定手机区号
|
||||
* @property {string} rebind_mobile 重新绑定手机号
|
||||
* @property {string} rebind_mobile_time 重新绑定手机时间
|
||||
* @property {unknown[]} links 账号绑定信息
|
||||
* @property {string} country 国家
|
||||
* @return getStokenByGameTokenInfo
|
||||
*/
|
||||
export interface getStokenByGameTokenInfo {
|
||||
aid: string;
|
||||
mid: string;
|
||||
account_name: string;
|
||||
email: string;
|
||||
is_email_verify: number;
|
||||
area_code: string;
|
||||
mobile: string;
|
||||
safe_area_code: string;
|
||||
safe_mobile: string;
|
||||
realname: string;
|
||||
identity_code: string;
|
||||
rebind_area_code: string;
|
||||
rebind_mobile: string;
|
||||
rebind_mobile_time: string;
|
||||
links: unknown[];
|
||||
country: string;
|
||||
}
|
||||
}
|
||||
|
||||
51
src/types/BBS/Response.d.ts
vendored
51
src/types/BBS/Response.d.ts
vendored
@@ -3,7 +3,7 @@
|
||||
* @description BBS 返回数据类型定义文件
|
||||
* @todo 视情况看看要不要拆分
|
||||
* @author BTMuli< bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
declare namespace TGApp.BBS.Response {
|
||||
@@ -100,4 +100,53 @@ declare namespace TGApp.BBS.Response {
|
||||
need_realperson: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 通过 gameToken 获取 stoken 的返回类型
|
||||
* @interface getStokenByGameToken
|
||||
* @since Beta v0.3.0
|
||||
* @extends Base
|
||||
* @property {getStokenByGameTokenData} data - 返回数据
|
||||
* @return getStokenByGameToken
|
||||
*/
|
||||
export interface getStokenByGameToken extends Base {
|
||||
data: getStokenByGameTokenData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 通过 gameToken 获取 stoken 的返回类型数据
|
||||
* @interface getStokenByGameTokenData
|
||||
* @since Beta v0.3.0
|
||||
* @property {number} token.token_type - token 类型
|
||||
* @property {string} token.token - token 值
|
||||
* @property {TGApp.BBS.Account.getStokenByGameTokenInfo} user_info - 用户信息
|
||||
* @property {unknown} realname_info - 实名信息 // todo: 未知类型
|
||||
* @property {boolean} need_realperson - 是否需要实名认证
|
||||
* @return getStokenByGameToken
|
||||
*/
|
||||
export interface getStokenByGameTokenData {
|
||||
token: {
|
||||
token_type: number;
|
||||
token: string;
|
||||
};
|
||||
user_info: TGApp.BBS.Account.getStokenByGameTokenInfo;
|
||||
realname_info: unknown;
|
||||
need_realperson: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 通过 gameToken 获取 cookie_token 的返回类型
|
||||
* @interface getCookieTokenByGameToken
|
||||
* @since Beta v0.3.0
|
||||
* @extends Base
|
||||
* @property {string} data.uid - 用户 uid
|
||||
* @property {string} data.cookie_token - cookie_token 值
|
||||
* @return getCookieTokenByGameToken
|
||||
*/
|
||||
export interface getCookieTokenByGameToken extends Base {
|
||||
data: {
|
||||
uid: string;
|
||||
cookie_token: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
* @file web constant TGConstant.ts
|
||||
* @description 常量
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
import { BBS_VERSION, BBS_HEADER_AGENT } from "./bbs";
|
||||
import { BBS_VERSION, BBS_HEADER_AGENT, BBS_APP_ID } from "./bbs";
|
||||
import SALT from "./salt";
|
||||
import SERVER from "./server";
|
||||
import { GAME_BIZ } from "./utils";
|
||||
@@ -14,6 +14,7 @@ const TGConstant = {
|
||||
BBS: {
|
||||
VERSION: BBS_VERSION,
|
||||
USER_AGENT: BBS_HEADER_AGENT,
|
||||
APP_ID: BBS_APP_ID,
|
||||
},
|
||||
Salt: SALT,
|
||||
Server: SERVER,
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
* @file web constant bbs.ts
|
||||
* @description 常量-应用数据
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.0
|
||||
* @since Beta v0.3.0
|
||||
*/
|
||||
|
||||
export const BBS_VERSION = "2.50.1";
|
||||
export const BBS_HEADER_AGENT = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
|
||||
export const BBS_APP_ID = "bll8iq97cem8";
|
||||
|
||||
@@ -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