mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-18 10:18:14 +08:00
🌱 初步完成角色天赋获取
This commit is contained in:
51
src/web/request/getSyncAvatarDetail.ts
Normal file
51
src/web/request/getSyncAvatarDetail.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file web request getSyncAvatarDetail.ts
|
||||
* @description 获取同步角色详情相关请求函数
|
||||
* @author BTMuli <bt-muli@outlook.com>
|
||||
* @since Alpha v0.2.1
|
||||
*/
|
||||
|
||||
// tauri
|
||||
import { http } from "@tauri-apps/api";
|
||||
// api
|
||||
import TGApi from "../api/TGApi";
|
||||
// utils
|
||||
import TGUtils from "../utils/TGUtils";
|
||||
|
||||
/**
|
||||
* @description 获取同步角色详情
|
||||
* @since Alpha v0.2.1
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {string} uid 用户 uid
|
||||
* @param {string} avatarId 角色 id
|
||||
* @returns {Promise<TGApp.Game.Calculate.AvatarDetail|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
async function getSyncAvatarDetail(
|
||||
cookie: Record<string, string>,
|
||||
uid: string,
|
||||
avatarId: string,
|
||||
): 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,
|
||||
};
|
||||
const header = {
|
||||
"User-Agent": "Tauri.Genshin/0.2.1",
|
||||
Referer: "https://webstatic.mihoyo.com/",
|
||||
Cookie: TGUtils.Tools.transCookie(cookie),
|
||||
};
|
||||
return await http
|
||||
.fetch<TGApp.Game.Calculate.SyncAvatarDetailResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: params,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.retcode !== 0) return res.data as TGApp.BBS.Response.Base;
|
||||
return res.data.data as TGApp.Game.Calculate.AvatarDetail;
|
||||
});
|
||||
}
|
||||
|
||||
export default getSyncAvatarDetail;
|
||||
Reference in New Issue
Block a user