mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🔥 移除无用代码
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/request/TGRequest.ts
|
||||
* @description 应用用到的请求函数
|
||||
* @since Beta v0.6.1
|
||||
* @since Beta v0.6.2
|
||||
*/
|
||||
|
||||
import { genAuthkey, genAuthkey2 } from "./genAuthkey.js";
|
||||
@@ -17,10 +17,7 @@ import { getGachaLog } from "./getGachaLog.js";
|
||||
import { getGameAccountsByCookie, getGameAccountsBySToken } from "./getGameAccounts.js";
|
||||
import { getGameRecord } from "./getGameRecord.js";
|
||||
import { getLTokenBySToken } from "./getLToken.js";
|
||||
import { getGameRoleListByLToken } from "./getRoleList.js";
|
||||
import { getStokenByGameToken, getTokenBySToken } from "./getStoken.js";
|
||||
import getSyncAvatarDetail from "./getSyncAvatarDetail.js";
|
||||
import getSyncAvatarListAll from "./getSyncAvatarListAll.js";
|
||||
import { getUserCollect } from "./getUserCollect.js";
|
||||
import { getUserInfoByCookie } from "./getUserInfo.js";
|
||||
import { verifyLToken } from "./verifyLToken.js";
|
||||
@@ -40,6 +37,7 @@ const TGRequest = {
|
||||
getCollect: getUserCollect,
|
||||
getGachaLog,
|
||||
getRecord: getGameRecord,
|
||||
verifyLToken,
|
||||
byCookie: {
|
||||
getAbyss,
|
||||
getAccounts: getGameAccountsByCookie,
|
||||
@@ -48,10 +46,6 @@ const TGRequest = {
|
||||
getAvatarList,
|
||||
getAvatarDetail,
|
||||
},
|
||||
byLToken: {
|
||||
verify: verifyLToken,
|
||||
getRoleList: getGameRoleListByLToken,
|
||||
},
|
||||
bySToken: {
|
||||
update: getTokenBySToken,
|
||||
getAccounts: getGameAccountsBySToken,
|
||||
@@ -63,10 +57,6 @@ const TGRequest = {
|
||||
getCookieToken: getCookieTokenByGameToken,
|
||||
getStoken: getStokenByGameToken,
|
||||
},
|
||||
calculate: {
|
||||
getSyncAvatarListAll,
|
||||
getSyncAvatarDetail,
|
||||
},
|
||||
},
|
||||
Nav: {
|
||||
getCode,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/request/genAuthkey.ts
|
||||
* @description 生成 authkey
|
||||
* @since Beta v0.5.0
|
||||
* @since Beta v0.6.2
|
||||
*/
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
@@ -10,23 +10,24 @@ import TGUtils from "../utils/TGUtils.js";
|
||||
|
||||
/**
|
||||
* @description 生成 authkey
|
||||
* @since Beta v0.5.0
|
||||
* @param {Record<string, string>} cookie cookie // stoken_v2 & mid
|
||||
* @param {string} gameUid 游戏 uid
|
||||
* @since Beta v0.6.2
|
||||
* @param {TGApp.App.Account.Cookie} cookie cookie
|
||||
* @param {TGApp.Sqlite.Account.Game} account 账户
|
||||
* @returns {Promise<string|TGApp.BBS.Response.Base>} authkey
|
||||
*/
|
||||
export async function genAuthkey(
|
||||
cookie: Record<string, string>,
|
||||
gameUid: string,
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
): Promise<string | TGApp.BBS.Response.Base> {
|
||||
const url = "https://api-takumi.mihoyo.com/binding/api/genAuthKey";
|
||||
const ck = { stoken: cookie.stoken, mid: cookie.mid };
|
||||
const data = {
|
||||
auth_appid: "webview_gacha",
|
||||
game_biz: TGConstant.Utils.GAME_BIZ,
|
||||
game_uid: Number(gameUid),
|
||||
region: TGUtils.Tools.getServerByUid(gameUid),
|
||||
game_uid: account.gameUid,
|
||||
region: account.region,
|
||||
};
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(data), "lk2", true);
|
||||
const header = TGUtils.User.getHeader(ck, "POST", JSON.stringify(data), "lk2", true);
|
||||
const resp = await TGHttp<TGApp.Game.Gacha.AuthkeyResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* @file web/request/getRoleList.ts
|
||||
* @description 获取游戏角色列表的请求方法
|
||||
* @since Beta v0.5.0
|
||||
*/
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
|
||||
/**
|
||||
* @description 通过 Cookie 获取用户角色列表
|
||||
* @since Beta v0.5.0
|
||||
* @param {Record<string, string>} cookie Cookie
|
||||
* @param {TGApp.Sqlite.Account.Game} account 游戏账号
|
||||
* @returns {Promise<TGApp.Game.Character.ListItem[]|TGApp.BBS.Response.Base>} 用户角色列表
|
||||
*/
|
||||
export async function getGameRoleListByLToken(
|
||||
cookie: Record<string, string>,
|
||||
account: TGApp.Sqlite.Account.Game,
|
||||
): Promise<TGApp.Game.Character.ListItem[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.byCookie.getCharacter;
|
||||
const uid = account.gameUid;
|
||||
const data = { role_id: uid, server: TGUtils.Tools.getServerByUid(uid) };
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", JSON.stringify(data), "common");
|
||||
const resp = await TGHttp<TGApp.Game.Character.ListResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
headers: header,
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.avatars;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* @file web/request/getSyncAvatarDetail.ts
|
||||
* @description 获取同步角色详情相关请求函数
|
||||
* @since Beta v0.5.0
|
||||
*/
|
||||
|
||||
import { app } from "@tauri-apps/api";
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
|
||||
/**
|
||||
* @description 获取同步角色详情
|
||||
* @since Beta v0.5.0
|
||||
* @param {string} accountId 账号 id
|
||||
* @param {string} cookieToken cookie token
|
||||
* @param {string} uid 用户 uid
|
||||
* @param {number} avatarId 角色 id
|
||||
* @returns {Promise<TGApp.Game.Calculate.AvatarDetail|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getSyncAvatarDetail(
|
||||
accountId: string,
|
||||
cookieToken: string,
|
||||
uid: string,
|
||||
avatarId: number,
|
||||
): Promise<TGApp.Game.Calculate.AvatarDetail | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.calculate.getSyncAvatarDetail;
|
||||
const params = {
|
||||
uid,
|
||||
region: TGUtils.Tools.getServerByUid(uid),
|
||||
avatar_id: avatarId.toString(),
|
||||
};
|
||||
const version = await app.getVersion();
|
||||
const header = {
|
||||
"User-Agent": `TeyvatGuide/${version}`,
|
||||
Referer: "https://webstatic.mihoyo.com/",
|
||||
Cookie: TGUtils.Tools.transCookie({ account_id: accountId, cookie_token: cookieToken }),
|
||||
};
|
||||
const resp = await TGHttp<
|
||||
TGApp.Game.Calculate.SyncAvatarDetailResponse | TGApp.BBS.Response.Base
|
||||
>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: params,
|
||||
});
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
export default getSyncAvatarDetail;
|
||||
@@ -1,65 +0,0 @@
|
||||
/**
|
||||
* @file web/request/getSyncAvatarListAll.ts
|
||||
* @description 获取同步角色列表请求
|
||||
* @since Beta v0.5.0
|
||||
*/
|
||||
|
||||
import { app } from "@tauri-apps/api";
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
|
||||
/**
|
||||
* @description 获取同步角色列表请求
|
||||
* @since Beta v0.5.0
|
||||
* @param {Record<string,string>} cookie cookie
|
||||
* @param {string} uid 用户 uid
|
||||
* @param {number} page 页码
|
||||
* @return {Promise<TGApp.Game.Calculate.AvatarListItem[]|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getSyncAvatarList(
|
||||
cookie: Record<string, string>,
|
||||
uid: string,
|
||||
page: number,
|
||||
): Promise<TGApp.Game.Calculate.AvatarListItem[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.calculate.getSyncAvatarList; // 获取同步角色列表请求地址
|
||||
const data = { uid, region: TGUtils.Tools.getServerByUid(uid), page };
|
||||
const version = await app.getVersion();
|
||||
const header = {
|
||||
"User-Agent": `TeyvatGuide/${version}`,
|
||||
Referer: "https://webstatic.mihoyo.com/",
|
||||
Cookie: TGUtils.Tools.transCookie(cookie),
|
||||
};
|
||||
const resp = await TGHttp<TGApp.Game.Calculate.SyncAvatarListResponse | TGApp.BBS.Response.Base>(
|
||||
url,
|
||||
{ method: "POST", body: JSON.stringify(data), headers: header },
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取同步角色列表-汇总
|
||||
* @since Alpha v0.2.1
|
||||
* @param {Record<string,string>} cookie cookie
|
||||
* @param {string} uid 用户 uid
|
||||
* @return {Promise<TGApp.Game.Calculate.AvatarListItem[]|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getSyncAvatarListAll(
|
||||
cookie: Record<string, string>,
|
||||
uid: string,
|
||||
): Promise<TGApp.Game.Calculate.AvatarListItem[] | TGApp.BBS.Response.Base> {
|
||||
let page = 1;
|
||||
let res = await getSyncAvatarList(cookie, uid, page);
|
||||
if (!Array.isArray(res)) return res;
|
||||
let list: TGApp.Game.Calculate.AvatarListItem[] = [];
|
||||
while (Array.isArray(res) && res.length > 0) {
|
||||
list = list.concat(res);
|
||||
page++;
|
||||
res = await getSyncAvatarList(cookie, uid, page);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
export default getSyncAvatarListAll;
|
||||
Reference in New Issue
Block a user