🔥 移除无用代码

This commit is contained in:
目棃
2024-11-08 17:48:28 +08:00
parent eea9287cfa
commit 044059beb0
11 changed files with 14 additions and 720 deletions

View File

@@ -254,7 +254,7 @@ async function refreshUser(uid: string) {
loading.value = true;
emits("loadOuter", { show: true, title: "正在刷新用户信息" });
emits("loadOuter", { show: true, title: "正在验证 LToken" });
const verifyLTokenRes = await TGRequest.User.byLToken.verify(ck.ltoken, ck.ltuid);
const verifyLTokenRes = await TGRequest.User.verifyLToken(ck.ltoken, ck.ltuid);
if (typeof verifyLTokenRes === "string") {
emits("loadOuter", { show: true, title: "正在验证 LToken", text: "验证 LToken 成功!" });
await TGLogger.Info("[tc-userBadge][refreshUser] 验证 LToken 成功");

View File

@@ -160,12 +160,7 @@ async function confirmRefresh(force: boolean): Promise<void> {
await TGLogger.Warn("[UserGacha][${account.gameUid}][confirmRefresh] 未检测到 cookie");
return;
}
const cookie = {
stoken: userStore.cookie.value.stoken,
mid: userStore.cookie.value.mid,
};
const gameUid = account.value.gameUid;
const authkeyRes = await TGRequest.User.getAuthkey(cookie, gameUid);
const authkeyRes = await TGRequest.User.getAuthkey(userStore.cookie.value, account.value);
if (typeof authkeyRes === "string") {
authkey.value = authkeyRes;
await TGLogger.Info(`[UserGacha][${account.value.gameUid}][confirmRefresh] 成功获取 authkey`);

View File

@@ -1,148 +0,0 @@
/**
* @file types/Game/Calculate.d.ts
* @description 养成计算器相关类型定义文件
* @since Alpha v0.2.1
*/
/**
* @description 养成计算器相关类型定义命名空间
* @since Alpha v0.2.1
* @namespace TGApp.Game.Calculate
* @memberof TGApp.Game
*/
declare namespace TGApp.Game.Calculate {
/**
* @description 获取同步角色列表返回
* @since Alpha v0.2.1
* @see TGRequest.User.calculate.getSyncAvatarListAll
* @interface SyncAvatarListResponse
* @extends TGApp.BBS.Response.BaseWithData
* @property {Array<AvatarListItem>} data.list - 角色列表
* @return SyncAvatarListResponse
*/
interface SyncAvatarListResponse extends TGApp.BBS.Response.BaseWithData {
data: {
list: AvatarListItem[];
};
}
/**
* @description 获取同步角色列表返回的角色数据
* @since Alpha v0.2.1
* @interface AvatarListItem
* @property {number} id - 角色 ID
* @property {string} name - 角色名称
* @property {string} icon - 角色头像
* @property {number} weapon_cat_id - 角色武器类型
* @property {number} avatar_level - 角色等级
* @property {number} element_attr_id - 角色元素类型
* @property {number} max_level - 角色最大等级
* @property {number} level_current - 角色当前等级
* @return AvatarListItem
*/
interface AvatarListItem {
id: number;
name: string;
icon: string;
weapon_cat_id: number;
avatar_level: number;
element_attr_id: number;
max_level: number;
level_current: number;
}
/**
* @description 获取同步角色详情返回
* @since Alpha v0.2.1
* @see TGRequest.User.calculate.getSyncAvatarDetail
* @interface SyncAvatarDetailResponse
* @extends TGApp.BBS.Response.BaseWithData
* @property {AvatarDetail} data - 角色详情
* @return SyncAvatarDetailResponse
*/
interface SyncAvatarDetailResponse extends TGApp.BBS.Response.BaseWithData {
data: TGApp.Game.Calculate.AvatarDetail;
}
/**
* @description 获取同步角色详情返回的角色详情数据
* @since Alpha v0.2.1
* @interface AvatarDetail
* @property {AvatarDetailSkill[]} skill_list - 角色技能列表
* @property {AvatarDetailWeapon} weapon - 角色武器
* @property {AvatarDetailRelic[]} reliquary_list - 角色圣遗物列表
* @return AvatarDetail
*/
interface AvatarDetail {
skill_list: AvatarDetailSkill[];
weapon: AvatarDetailWeapon;
reliquary_list: AvatarDetailRelic[];
}
/**
* @description 获取同步角色详情返回的角色技能数据
* @since Alpha v0.2.1
* @interface AvatarDetailSkill
* @property {number} id - 技能 ID
* @property {number} group_id - 技能组 ID
* @property {string} name - 技能名称
* @property {string} icon - 技能图标
* @property {number} max_level - 技能最大等级
* @property {number} level_current - 技能当前等级
* @return AvatarDetailSkill
*/
interface AvatarDetailSkill {
id: number;
group_id: number;
name: string;
icon: string;
max_level: number;
level_current: number;
}
/**
* @description 获取同步角色详情返回的角色武器数据
* @since Alpha v0.2.1
* @interface AvatarDetailWeapon
* @property {number} id - 武器 ID
* @property {string} name - 武器名称
* @property {string} icon - 武器图标
* @property {number} weapon_cat_id - 武器类型
* @property {number} weapon_level - 武器等级
* @property {number} max_level - 武器最大等级
* @property {number} level_current - 武器当前等级
* @return AvatarDetailWeapon
*/
interface AvatarDetailWeapon {
id: number;
name: string;
icon: string;
weapon_cat_id: number;
weapon_level: number;
max_level: number;
level_current: number;
}
/**
* @description 获取同步角色详情返回的角色圣遗物数据
* @since Alpha v0.2.1
* @interface AvatarDetailRelic
* @property {number} id - 圣遗物 ID
* @property {string} name - 圣遗物名称
* @property {string} icon - 圣遗物图标
* @property {number} reliquary_cat_id - 圣遗物类型
* @property {number} reliquary_level - 圣遗物等级
* @property {number} level_current - 圣遗物当前等级
* @property {number} max_level - 圣遗物最大等级
* @return AvatarDetailRelic
*/
interface AvatarDetailRelic {
id: number;
name: string;
icon: string;
reliquary_cat_id: number;
reliquary_level: number;
level_current: number;
max_level: number;
}
}

View File

@@ -1,194 +0,0 @@
/**
* @file types/Game/Character.d.ts
* @description 游戏角色相关类型定义文件
* @since Alpha v0.2.0
*/
/**
* @description 游戏角色相关类型定义命名空间
* @since Alpha v0.2.0
* @namespace TGApp.Game.Character
* @memberof TGApp.Game
*/
declare namespace TGApp.Game.Character {
/**
* @description 角色列表数据返回类型
* @interface ListResponse
* @since Alpha v0.2.0
* @extends TGApp.BBS.Response.BaseWithData
* @property {ListItem[]} data.avatars - 角色列表
* @property {ListRole} data.role - 角色信息
* @return ListResponse
*/
interface ListResponse extends TGApp.BBS.Response.BaseWithData {
data: {
avatars: ListItem[];
role: ListRole;
};
}
/**
* @description 角色列表数据类型
* @interface ListItem
* @since Alpha v0.2.0
* @property {number} id - 角色 ID
* @property {string} image - 角色全身像
* @property {string} icon - 角色头像
* @property {string} name - 角色名称
* @property {TGApp.Game.Constant.EnumElementEn} element - 角色元素
* @property {number} fetter - 角色好感等级
* @property {number} level - 角色等级
* @property {number} rarity - 角色稀有度
* @property {LIWeapon} weapon - 角色武器
* @property {LIRelic[]} reliquaries - 角色圣遗物
* @property {LIConstellation[]} constellations - 角色命座
* @property {number} actived_constellation_num - 角色已激活命座数量
* @property {LICostume[]} costumes - 角色时装
* @property {number} constellation_level - 角色命座等级
* @property {unknown} external
* @return ListItem
*/
interface ListItem {
id: number;
image: string;
icon: string;
name: string;
element: TGApp.Game.Constant.EnumElementEn;
fetter: number;
level: number;
rarity: number;
weapon: LIWeapon;
reliquaries: LIRelic[];
constellations: LIConstellation[];
actived_constellation_num: number;
costumes: LICostume[];
constellation_level: number;
external: unknown;
}
/**
* @description 角色信息
* @interface ListRole
* @since Alpha v0.2.0
* @property {string} AvatarUrl - 角色头像 // 大部分情况下是空的
* @property {string} nickname - 角色昵称
* @property {string} region - 角色所在地区
* @property {number} level - 角色等级
* @return ListRole
*/
interface ListRole {
AvatarUrl: string;
nickname: string;
region: string;
level: number;
}
/**
* @description 角色武器数据类型
* @interface LIWeapon
* @since Alpha v0.2.0
* @property {number} id - 武器 ID
* @property {string} name - 武器名称
* @property {string} icon - 武器图标
* @property {number} type - 武器类型
* @property {number} rarity - 武器稀有度
* @property {number} level - 武器等级
* @property {number} promote_level - 武器等级对应的突破等级
* @property {string} type_name - 武器类型名称
* @property {string} desc - 武器描述
* @property {number} affix_level - 武器精炼等级
* @return LIWeapon
*/
interface LIWeapon {
id: number;
name: string;
icon: string;
type: number;
rarity: number;
level: number;
promote_level: number;
type_name: string;
desc: string;
affix_level: number;
}
/**
* @description 角色圣遗物数据类型
* @interface LIRelic
* @since Alpha v0.2.0
* @property {number} id - 圣遗物 ID
* @property {string} name - 圣遗物名称
* @property {string} icon - 圣遗物图标
* @property {number} pos - 圣遗物位置
* @property {number} rarity - 圣遗物稀有度
* @property {number} level - 圣遗物等级
* @property {RelicSet} set - 圣遗物套装
* @property {TGApp.Game.Constant.EnumRelic} pos_name - 圣遗物位置名称
* @return LIRelic
*/
interface LIRelic {
id: number;
name: string;
icon: string;
pos: number;
rarity: number;
level: number;
set: RelicSet;
pos_name: TGApp.Game.Constant.EnumRelic;
}
/**
* @description 圣遗物套装数据类型
* @interface RelicSet
* @since Alpha v0.2.0
* @property {number} id - 圣遗物套装 ID
* @property {string} name - 圣遗物套装名称
* @property {number} affixes[].activation_number - 圣遗物套装激活数量
* @property {string} affixes[].effect - 圣遗物套装效果
* @return RelicSet
*/
interface RelicSet {
id: number;
name: string;
affixes: Array<{
activation_number: number;
effect: string;
}>;
}
/**
* @description 角色命座数据类型
* @interface LIConstellation
* @since Alpha v0.2.0
* @property {number} id - 命座 ID
* @property {string} name - 命座名称
* @property {string} icon - 命座图标
* @property {string} effect - 命座效果
* @property {boolean} is_actived - 命座是否激活
* @property {number} pos - 命座位置
* @return LIConstellation
*/
interface LIConstellation {
id: number;
name: string;
icon: string;
effect: string;
is_actived: boolean;
pos: number;
}
/**
* @description 角色时装数据类型
* @interface LICostume
* @since Alpha v0.2.0
* @property {number} id - 时装 ID
* @property {string} name - 时装名称
* @property {string} icon - 时装图标
* @return LICostume
*/
interface LICostume {
id: number;
name: string;
icon: string;
}
}

View File

@@ -86,85 +86,3 @@ declare namespace TGApp.Game.Constant {
circlet = "理之冠",
}
}
// /**
// * @description 突破信息,适用于角色和武器等级
// * @since Alpha v0.1.3
// * @interface levelUp
// * @property {number} level - 突破等级指达到突破要求的等级0 表示未突破
// * @property {Material[]} materials - 突破所需材料
// * @property {Record<string, number>[]} upAttri - 突破后的属性加成
// * @property {Record<string, number>[]} averAttri - 突破后的平均每级属性加成
// * @property {string} addInfo - 突破后的附加信息,如天赋解锁
// * @return levelUp
// */
// export interface levelUp {
// level: number
// materials: Material[]
// upAttri: Array<Record<string, number>>
// averAttri: Array<Record<string, number>>
// addInfo?: string
// }
//
// /**
// * @description 材料信息
// * @since Alpha v0.1.3
// * @interface Material
// * @property {number} id - 材料 ID
// * @property {string} name - 材料名称
// * @property {number} star - 材料星级
// * @property {string} type - 材料类型
// * @property {number} count - 材料数量
// * @property {string[]} source - 材料获取途径
// * @property {string} description - 材料描述
// * @return Material
// */
// export interface Material {
// id: number
// name: string
// star: number
// type: string
// count?: number
// source: string[]
// description: string
// }
//
// /**
// * @description 本应用的食物类型
// * @since Alpha v0.1.3
// * @interface Food
// * @property {number} id - 食物 ID
// * @property {string} name - 食物名称
// * @property {number} star - 食物星级
// * @property {string} type - 食物类型
// * @property {number} count - 食物数量
// * @property {string} description - 食物描述
// * @property {string[]} source - 食谱来源
// * @property {string} effect - 食物效果
// * @return Food
// */
// export interface Food {
// id: number
// name: string
// star: number
// type: string
// count?: number
// description: string
// source: string[]
// effect: string
// }
//
// /**
// * @description 本应用的基础属性类型
// * @since Alpha v0.1.3
// * @interface BaseAttri
// * @property {string} icon - 属性图标
// * @property {string} name - 属性名称
// * @property {string} value - 属性值
// * @return BaseAttri
// */
// export interface BaseAttri {
// icon: string
// name: string
// value: string
// }

View File

@@ -1,119 +0,0 @@
/**
* @file types/Game/DailyNotes.d.ts
* @description 获取实时便笺数据类型定义文件
* @since Alpha v0.2.2
*/
/**
* @description 获取实时便笺数据
* @since Alpha v0.2.2
* @namespace TGApp.Game.DailyNotes
* @memberof TGApp.Game
*/
declare namespace TGApp.Game.DailyNotes {
/**
* @description 便笺数据返回
* @since Alpha v0.2.2
* @interface Response
* @extends TGApp.BBS.Response.BaseWithData
* @property {FullInfo} data - 便笺数据
* @return Response
*/
interface Response extends TGApp.BBS.Response.BaseWithData {
data: FullInfo;
}
/**
* @description 便笺数据
* @since Alpha v0.2.2
* @interface FullInfo
* @property {number} current_resin - 当前体力
* @property {number} max_resin - 最大体力
* @property {string} resin_recovery_time - 体力恢复时间(秒)
* @property {number} finished_task_num - 已完成日常任务数
* @property {number} total_task_num - 日常任务总数
* @property {boolean} is_extra_reward_received - 是否已领取额外奖励
* @property {number} remain_resin_discount_num - 剩余周本减半次数
* @property {number} resin_discount_num_limit - 周本减半次数上限
* @property {number} current_expedition_num - 当前委托数
* @property {number} max_expedition_num - 最大委托数
* @property {Expedition[]} expeditions - 委托数据
* @property {number} current_home_coin - 洞天宝钱数
* @property {number} max_home_coin - 洞天宝钱上限
* @property {string} home_coin_recovery_time - 洞天宝钱恢复时间(秒)
* @property {string} calendar_url - 日历地址 // 未使用
* @property {Transform} transformer - 便笺数据转换器
* @return FullInfo
*/
interface FullInfo {
current_resin: number;
max_resin: number;
resin_recovery_time: string;
finished_task_num: number;
total_task_num: number;
is_extra_reward_received: boolean;
remain_resin_discount_num: number;
resin_discount_num_limit: number;
current_expedition_num: number;
max_expedition_num: number;
expeditions: Expedition[];
current_home_coin: number;
max_home_coin: number;
home_coin_recovery_time: string;
calendar_url: string;
transformer: Transform;
}
/**
* @description 委托数据
* @since Alpha v0.2.2
* @interface Expedition
* @property {string} avatar_side_icon - 头像侧边图标
* @property {string} status - 委托状态 // Ongoing: 进行中Finished: 已完成Expired: 已过期
* @property {string} remained_time - 剩余时间(秒)
* @return Expedition
*/
interface Expedition {
avatar_side_icon: string;
status: string;
remained_time: string;
}
/**
* @description 便笺数据转换器
* @since Alpha v0.2.2
* @interface Transform
* @property {boolean} obtained - 是否已获取
* @property {TransformTime} recovery_time - 恢复时间
* @property {string} wiki - 百科地址
* @property {boolean} noticed - 是否已通知
* @property {string} last_job_id - 上次任务 ID
* @return Transform
*/
interface Transform {
obtained: boolean;
recovery_time: TransformTime;
wiki: string;
noticed: boolean;
last_job_id: string;
}
/**
* @description 便笺数据转换器恢复时间
* @since Alpha v0.2.2
* @interface TransformTime
* @property {number} Day - 天
* @property {number} Hour - 小时
* @property {number} Minute - 分钟
* @property {number} Second - 秒
* @property {boolean} reached - 是否已达到恢复时间
* @return TransformTime
*/
interface TransformTime {
Day: number;
Hour: number;
Minute: number;
Second: number;
reached: boolean;
}
}

View File

@@ -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,

View File

@@ -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,

View File

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

View File

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

View File

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