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.0
|
||||
* @since Beta v0.6.1
|
||||
*/
|
||||
|
||||
import { genAuthkey, genAuthkey2 } from "./genAuthkey.js";
|
||||
@@ -9,7 +9,7 @@ import { getAbyss } from "./getAbyss.js";
|
||||
import { getActionTicketBySToken } from "./getActionTicket.js";
|
||||
import { getAnnoContent, getAnnoList } from "./getAnno.js";
|
||||
import getAuthTicket from "./getAuthTicket.js";
|
||||
import { getAvatarList, getAvatarDetail } from "./getAvatarDetail.js";
|
||||
import { getAvatarList, getAvatarDetail, getAvatarIndex } from "./getAvatarDetail.js";
|
||||
import getCode from "./getCode.js";
|
||||
import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken.js";
|
||||
import { getDeviceFp } from "./getDeviceFp.js";
|
||||
@@ -44,6 +44,7 @@ const TGRequest = {
|
||||
getAbyss,
|
||||
getAccounts: getGameAccountsByCookie,
|
||||
getUserInfo: getUserInfoByCookie,
|
||||
getAvatarIndex,
|
||||
getAvatarList,
|
||||
getAvatarDetail,
|
||||
},
|
||||
|
||||
@@ -1,27 +1,50 @@
|
||||
/**
|
||||
* @file web/request/getAvatarDetail.ts
|
||||
* @description 获取角色详情相关请求函数
|
||||
* @since Beta v0.5.3
|
||||
* @since Beta v0.6.1
|
||||
*/
|
||||
|
||||
import TGHttp from "../../utils/TGHttp.js";
|
||||
import TGApi from "../api/TGApi.js";
|
||||
import TGUtils from "../utils/TGUtils.js";
|
||||
|
||||
/**
|
||||
* @description 手动刷新角色数据
|
||||
* @since Beta v0.6.1
|
||||
* @param {TGApp.App.Account.Cookie} cookie Cookie
|
||||
* @param {TGApp.Sqlite.Account.Game} user 用户
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function getAvatarIndex(
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
user: TGApp.Sqlite.Account.Game,
|
||||
): Promise<TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.getUserBase;
|
||||
const params = { avatar_list_type: 1, role_id: user.gameUid, server: user.region };
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const header = TGUtils.User.getHeader(ck, "GET", params, "common");
|
||||
return await TGHttp<TGApp.BBS.Response.Base>(url, {
|
||||
method: "GET",
|
||||
headers: header,
|
||||
query: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取角色列表
|
||||
* @since Beta v0.5.3
|
||||
* @param {Record<string, string>} cookie Cookie
|
||||
* @param {string} roleId 用户 uid
|
||||
* @since Beta v0.6.1
|
||||
* @param {TGApp.App.Account.Cookie} cookie Cookie
|
||||
* @param {TGApp.Sqlite.Account.Game} user 用户
|
||||
* @return {Promise<TGApp.Game.Avatar.Avatar[]|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getAvatarList(
|
||||
cookie: Record<string, string>,
|
||||
roleId: string,
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
user: TGApp.Sqlite.Account.Game,
|
||||
): Promise<TGApp.Game.Avatar.Avatar[] | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.byCookie.getAvatarList;
|
||||
const data = { role_id: roleId, server: TGUtils.Tools.getServerByUid(roleId) };
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
|
||||
const data = { role_id: user.gameUid, server: user.region };
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const header = TGUtils.User.getHeader(ck, "POST", data, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Avatar.ListResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
@@ -33,24 +56,21 @@ export async function getAvatarList(
|
||||
|
||||
/**
|
||||
* @description 获取角色详情
|
||||
* @since Beta v0.5.3
|
||||
* @param {Record<string, string>} cookie Cookie
|
||||
* @param {string} roleId 用户 uid
|
||||
* @since Beta v0.6.1
|
||||
* @param {TGApp.App.Account.Cookie} cookie Cookie
|
||||
* @param {TGApp.Sqlite.Account.Game} user 用户
|
||||
* @param {string[]} avatarIds 角色 id 列表
|
||||
* @return {Promise<TGApp.Game.Avatar.AvatarDetail|TGApp.BBS.Response.Base>}
|
||||
*/
|
||||
export async function getAvatarDetail(
|
||||
cookie: Record<string, string>,
|
||||
roleId: string,
|
||||
cookie: TGApp.App.Account.Cookie,
|
||||
user: TGApp.Sqlite.Account.Game,
|
||||
avatarIds: string[],
|
||||
): Promise<TGApp.Game.Avatar.AvatarDetail | TGApp.BBS.Response.Base> {
|
||||
const url = TGApi.GameData.byCookie.getAvatarDetail;
|
||||
const data = {
|
||||
role_id: roleId,
|
||||
server: TGUtils.Tools.getServerByUid(roleId),
|
||||
character_ids: avatarIds,
|
||||
};
|
||||
const header = TGUtils.User.getHeader(cookie, "POST", data, "common");
|
||||
const data = { role_id: user.gameUid, server: user.region, character_ids: avatarIds };
|
||||
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
|
||||
const header = TGUtils.User.getHeader(ck, "POST", data, "common");
|
||||
const resp = await TGHttp<TGApp.Game.Avatar.DetailResponse | TGApp.BBS.Response.Base>(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
|
||||
Reference in New Issue
Block a user