mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🌱 幻想真境剧诗数据获取
This commit is contained in:
319
src/types/Game/Combat.d.ts
vendored
Normal file
319
src/types/Game/Combat.d.ts
vendored
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
/**
|
||||||
|
* @file types/Game/Combat.d.ts
|
||||||
|
* @description 幻想真境剧诗类型定义
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 幻想真境剧诗相关类型
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @namespace TGApp.Game.Combat
|
||||||
|
* @memberOf TGApp.Game
|
||||||
|
*/
|
||||||
|
declare namespace TGApp.Game.Combat {
|
||||||
|
/**
|
||||||
|
* @description 幻想真境剧诗数据返回类型
|
||||||
|
* @interface Response
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @extends TGApp.BBS.Response.BaseWithData
|
||||||
|
* @property {FullData} data
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
interface Response extends TGApp.BBS.Response.BaseWithData {
|
||||||
|
data: FullData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 返回完整数据类型
|
||||||
|
* @interface FullData
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {boolean} is_unlock 是否解锁
|
||||||
|
* @property {Record<string,string>} links 相关链接
|
||||||
|
* @property {Array<Combat>} data 挑战数据
|
||||||
|
* @return FullData
|
||||||
|
*/
|
||||||
|
interface FullData {
|
||||||
|
is_unlock: boolean;
|
||||||
|
links: Record<string, string>;
|
||||||
|
data: Array<Combat>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 角色数据
|
||||||
|
* @interface Avatar
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {number} avatar_id 角色id
|
||||||
|
* @property {number} avatar_type 角色武器类型 // todo
|
||||||
|
* @property {string} name 角色名称
|
||||||
|
* @property {string} element 角色元素 // todo Dendro
|
||||||
|
* @property {string} image 角色图像
|
||||||
|
* @property {number} level 角色等级
|
||||||
|
* @property {number} rarity 角色稀有度
|
||||||
|
* @return Avatar
|
||||||
|
*/
|
||||||
|
interface Avatar {
|
||||||
|
avatar_id: number;
|
||||||
|
avatar_type: number;
|
||||||
|
name: string;
|
||||||
|
element: string;
|
||||||
|
image: string;
|
||||||
|
level: number;
|
||||||
|
rarity: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 简要角色
|
||||||
|
* @interface AvatarMini
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {number} avatar_id 角色id
|
||||||
|
* @property {number} avatar_icon 角色图标
|
||||||
|
* @property {string} value 值
|
||||||
|
* @property {number} rarity 角色稀有度
|
||||||
|
* @return AvatarMini
|
||||||
|
*/
|
||||||
|
interface AvatarMini {
|
||||||
|
avatar_id: number;
|
||||||
|
avatar_icon: string;
|
||||||
|
value: string;
|
||||||
|
rarity: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Buff
|
||||||
|
* @interface Buff
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {string} name 名称
|
||||||
|
* @property {string} icon 图标
|
||||||
|
* @property {number} level 等级
|
||||||
|
* @property {Array<BuffEffect>} level_effect 不同等级下的助益
|
||||||
|
* @return Buff
|
||||||
|
*/
|
||||||
|
interface Buff {
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
level: number;
|
||||||
|
level_effect: Array<BuffEffect>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Buff助益
|
||||||
|
* @interface BuffEffect
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {string} icon 图标
|
||||||
|
* @property {string} name 名称
|
||||||
|
* @property {string} desc 描述
|
||||||
|
* @return BuffEffect
|
||||||
|
*/
|
||||||
|
interface BuffEffect {
|
||||||
|
icon: string;
|
||||||
|
name: string;
|
||||||
|
desc: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 卡片
|
||||||
|
* @interface Card
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {string} icon 图标
|
||||||
|
* @property {string} name 名称
|
||||||
|
* @property {string} desc 描述 // todo 带 <color>
|
||||||
|
* @property {boolean} is_enhanced 是否加强
|
||||||
|
* @property {number} id ID
|
||||||
|
* @return Card
|
||||||
|
*/
|
||||||
|
interface Card {
|
||||||
|
icon: string;
|
||||||
|
name: string;
|
||||||
|
desc: string;
|
||||||
|
is_enhanced: boolean;
|
||||||
|
id: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 时间
|
||||||
|
* @interface DateTime
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {number} year 年份
|
||||||
|
* @property {number} month 月份
|
||||||
|
* @property {number} day 日期
|
||||||
|
* @property {number} hour 小时
|
||||||
|
* @property {number} minute 分钟
|
||||||
|
* @property {number} second 秒
|
||||||
|
* @return DateTime
|
||||||
|
*/
|
||||||
|
interface DateTime {
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
day: number;
|
||||||
|
hour: number;
|
||||||
|
minute: number;
|
||||||
|
second: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 状态
|
||||||
|
* @interface Stat
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {number} difficulty_id 难度等级
|
||||||
|
* @property {number} max_round_id 最多层数
|
||||||
|
* @property {number} heraldry 纹章数
|
||||||
|
* @property {Array<0|1>} get_medal_round_list 星章获取状况
|
||||||
|
* @property {number} medal_num 星章获取数
|
||||||
|
* @property {number} coin_num 硬币数
|
||||||
|
* @property {number} avatar_bonus_num 角色声援数
|
||||||
|
* @property {number} rent_cnt 出借次数
|
||||||
|
* @return Stat
|
||||||
|
*/
|
||||||
|
interface Stat {
|
||||||
|
difficulty_id: number;
|
||||||
|
max_round_id: number;
|
||||||
|
heraldry: number;
|
||||||
|
get_medal_round_list: Array<0 | 1>;
|
||||||
|
medal_num: number;
|
||||||
|
coin_num: number;
|
||||||
|
avatar_bonus_num: number;
|
||||||
|
rent_cnt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 敌人
|
||||||
|
* @interface Enemy
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {string} name 名称
|
||||||
|
* @property {string} icon 图标
|
||||||
|
* @property {number} level 等级
|
||||||
|
* @return Enemy
|
||||||
|
*/
|
||||||
|
interface Enemy {
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
level: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 单期挑战数据
|
||||||
|
* @interface Combat
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {Detail} detail 挑战详情
|
||||||
|
* @property {Stat} stat 挑战状态
|
||||||
|
* @property {Schedule} schedule 挑战期数
|
||||||
|
* @property {boolean} has_data 是否有数据
|
||||||
|
* @property {boolean} has_detail_data 是否有详细数据
|
||||||
|
* @return Combat
|
||||||
|
*/
|
||||||
|
interface Combat {
|
||||||
|
detail: Detail;
|
||||||
|
stat: Stat;
|
||||||
|
schedule: Schedule;
|
||||||
|
has_data: boolean;
|
||||||
|
has_detail_data: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 挑战详情
|
||||||
|
* @interface Detail
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {Array<RoundData>} rounds_data 轮次数据
|
||||||
|
* @property {Stat} detail_stat 详细状态
|
||||||
|
* @property {string} lineup_link 未知链接
|
||||||
|
* @property {Array<Avatar>} backup_avatars 后备角色
|
||||||
|
* @property {FightStatisic} fight_statisic buff加成
|
||||||
|
* @return Detail
|
||||||
|
*/
|
||||||
|
interface Detail {
|
||||||
|
rounds_data: Array<RoundData>;
|
||||||
|
detail_stat: Stat;
|
||||||
|
lineup_link: string;
|
||||||
|
backup_avatars: Array<Avatar>;
|
||||||
|
fight_statisic: FightStatisic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 轮次数据
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @interface RoundData
|
||||||
|
* @property {Array<Avatar>} avatars 角色
|
||||||
|
* @property {Array<Card>} choice_cards 选中卡片
|
||||||
|
* @property {Array<Buff>} buffs 获得 助益
|
||||||
|
* @property {boolean} is_get_medal 是否获得星章
|
||||||
|
* @property {number} round_id 轮次ID
|
||||||
|
* @property {string} finish_time 完成时间(秒级时间戳)
|
||||||
|
* @property {DateTime} finish_date_time 完成时间
|
||||||
|
* @property {Array<Enemy>} enemies 敌人
|
||||||
|
* @property {SplendourBuff} splendour_buff 总体Buff
|
||||||
|
* @return RoundData
|
||||||
|
*/
|
||||||
|
interface RoundData {
|
||||||
|
avatars: Array<Avatar>;
|
||||||
|
choice_cards: Array<Card>;
|
||||||
|
buffs: Array<Buff>;
|
||||||
|
is_get_medal: boolean;
|
||||||
|
round_id: number;
|
||||||
|
finish_time: string;
|
||||||
|
finish_date_time: DateTime;
|
||||||
|
enemies: Array<Enemy>;
|
||||||
|
splendour_buff: SplendourBuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 总体buff
|
||||||
|
* @interface SplendourBuff
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {object} summary 概况
|
||||||
|
* @property {number} summary.total_level 总等级
|
||||||
|
* @property {string} summary.desc 描述
|
||||||
|
* @property {Array<Buff>} buffs 助益
|
||||||
|
* @return SplendourBuff
|
||||||
|
*/
|
||||||
|
interface SplendourBuff {
|
||||||
|
summary: {
|
||||||
|
total_level: number;
|
||||||
|
desc: string;
|
||||||
|
};
|
||||||
|
buffs: Array<Buff>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 战斗数据
|
||||||
|
* @interface FightStatisic
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {AvatarMini} max_defeat_avatar 击败最多敌人
|
||||||
|
* @property {AvatarMini} max_damage_avatar 最高伤害输出
|
||||||
|
* @property {AvatarMini} max_take_damage_avatar 最高承受伤害
|
||||||
|
* @property {AvatarMini} total_coin_consumed 消耗幻剧之花
|
||||||
|
* @property {Array<AvatarMini>} shortest_avatar_list 最快完成演出队伍
|
||||||
|
* @property {number} total_use_time 总时间
|
||||||
|
* @property {boolean} is_show_battle_stats 是否展示
|
||||||
|
* @return FightStatisic
|
||||||
|
*/
|
||||||
|
interface FightStatisic {
|
||||||
|
max_defeat_avatar: AvatarMini;
|
||||||
|
max_damage_avatar: AvatarMini;
|
||||||
|
max_take_damage_avatar: AvatarMini;
|
||||||
|
total_coin_consumed: AvatarMini;
|
||||||
|
shortest_avatar_list: Array<AvatarMini>;
|
||||||
|
total_use_time: number;
|
||||||
|
is_show_battle_stats: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 期数
|
||||||
|
* @interface Schedule
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
* @property {string} start_time 开始时间(秒级时间戳)
|
||||||
|
* @property {string} end_time 结束时间(秒级时间戳)
|
||||||
|
* @property {number} schedule_type 类型 // 1-本期。2-上期
|
||||||
|
* @property {number} schedule_id ID
|
||||||
|
* @property {DateTime} start_date_time 开始时间
|
||||||
|
* @property {DateTime} end_date_time 结束时间
|
||||||
|
* @return Schedule
|
||||||
|
*/
|
||||||
|
interface Schedule {
|
||||||
|
start_time: string;
|
||||||
|
end_time: string;
|
||||||
|
schedule_type: number;
|
||||||
|
schedule_id: number;
|
||||||
|
start_date_time: DateTime;
|
||||||
|
end_date_time: DateTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
PostID:{{ postId }} | Render by TeyvatGuide v{{ appVersion }}
|
PostID:{{ postId }} | Render by TeyvatGuide v{{ appVersion }}
|
||||||
</div>
|
</div>
|
||||||
<div class="tp-post-meta">
|
<div class="tp-post-meta">
|
||||||
|
<!-- todo 点击跳转 -->
|
||||||
<div class="mpm-forum" v-if="postData.forum">
|
<div class="mpm-forum" v-if="postData.forum">
|
||||||
<img :src="getGameIcon(postData.forum.game_id)" alt="gameIcon" />
|
<img :src="getGameIcon(postData.forum.game_id)" alt="gameIcon" />
|
||||||
<img :src="postData.forum.icon" alt="forumIcon" />
|
<img :src="postData.forum.icon" alt="forumIcon" />
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
<span>{{ postData.collection.collection_title }}</span>
|
<span>{{ postData.collection.collection_title }}</span>
|
||||||
<span>{{ postData.collection.cur }}/{{ postData.collection.total }}</span>
|
<span>{{ postData.collection.cur }}/{{ postData.collection.total }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- todo 点击跳转 -->
|
||||||
<div v-for="topic in postData.topics" :key="topic.id" class="tp-post-topic">
|
<div v-for="topic in postData.topics" :key="topic.id" class="tp-post-topic">
|
||||||
<v-icon size="12">mdi-tag</v-icon>
|
<v-icon size="12">mdi-tag</v-icon>
|
||||||
<span>{{ topic.name }}</span>
|
<span>{{ topic.name }}</span>
|
||||||
@@ -242,24 +244,14 @@ function parseContent(content: string): string {
|
|||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "describe":
|
case "describe":
|
||||||
result.push({
|
result.push({ insert: data.describe });
|
||||||
insert: data.describe,
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case "imgs":
|
case "imgs":
|
||||||
data.imgs.forEach((item) => {
|
data.imgs.forEach((item) => result.push({ insert: { image: item } }));
|
||||||
result.push({
|
|
||||||
insert: {
|
|
||||||
image: item,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TGLogger.Warn(`[t-post][${postId}][parseContent] Unknown key: ${key}`);
|
TGLogger.Warn(`[t-post][${postId}][parseContent] Unknown key: ${key}`);
|
||||||
result.push({
|
result.push({ insert: data[key] });
|
||||||
insert: data[key],
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file web/api/TGApi.ts
|
* @file web/api/TGApi.ts
|
||||||
* @description 应用用到的 API
|
* @description 应用用到的 API
|
||||||
* @since Beta v0.5.3
|
* @since Beta v0.6.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { BBSUserInfoApi } from "./BBS.js";
|
import { BBSUserInfoApi } from "./BBS.js";
|
||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
TakumiCalculateSyncAvatarDetailApi,
|
TakumiCalculateSyncAvatarDetailApi,
|
||||||
TakumiRecordCharacterListApi,
|
TakumiRecordCharacterListApi,
|
||||||
TakumiRecordCharacterDetailApi,
|
TakumiRecordCharacterDetailApi,
|
||||||
|
TakumiRecordCombatApi,
|
||||||
} from "./Takumi.js";
|
} from "./Takumi.js";
|
||||||
|
|
||||||
// 应用 API
|
// 应用 API
|
||||||
@@ -50,6 +51,7 @@ const TGApi = {
|
|||||||
getUserBase: TakumiRecordIndexApi, // 获取用户基本信息
|
getUserBase: TakumiRecordIndexApi, // 获取用户基本信息
|
||||||
getDailyNotes: TakumiRecordDailyNotesApi, // 获取实时便笺
|
getDailyNotes: TakumiRecordDailyNotesApi, // 获取实时便笺
|
||||||
getAbyss: TakumiRecordAbyssApi, // 获取深境螺旋信息
|
getAbyss: TakumiRecordAbyssApi, // 获取深境螺旋信息
|
||||||
|
getRoleCombat: TakumiRecordCombatApi, // 获取幻想真境剧诗
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file web/api/Takumi.ts
|
* @file web/api/Takumi.ts
|
||||||
* @description 定义 Takumi API
|
* @description 定义 Takumi API
|
||||||
* @since Beta v0.5.3
|
* @since Beta v0.6.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const TakumiApi = "https://api-takumi.mihoyo.com/"; // 基础 API
|
const TakumiApi = "https://api-takumi.mihoyo.com/"; // 基础 API
|
||||||
@@ -12,13 +12,14 @@ const TakumiRecordApi = "https://api-takumi-record.mihoyo.com/"; // 游戏记录
|
|||||||
const TakumiRecordGenshinApi = `${TakumiRecordApi}game_record/app/genshin/api/`; // 原神游戏记录 API
|
const TakumiRecordGenshinApi = `${TakumiRecordApi}game_record/app/genshin/api/`; // 原神游戏记录 API
|
||||||
|
|
||||||
export const TakumiTokensApi = `${TakumiAuthApi}getMultiTokenByLoginTicket`; // 登录票据 API
|
export const TakumiTokensApi = `${TakumiAuthApi}getMultiTokenByLoginTicket`; // 登录票据 API
|
||||||
export const TakumiRecordDailyNotesApi = `${TakumiRecordApi}game_record/app/genshin/api/dailyNote`; // 游戏记录便笺 API
|
export const TakumiRecordDailyNotesApi = `${TakumiRecordGenshinApi}dailyNote`; // 游戏记录便笺 API
|
||||||
export const TakumiRecordCardApi = `${TakumiRecordApi}game_record/app/card/wapi/getGameRecordCard`; // 游戏记录卡片 API
|
export const TakumiRecordCardApi = `${TakumiRecordApi}game_record/app/card/wapi/getGameRecordCard`; // 游戏记录卡片 API
|
||||||
export const TakumiRecordIndexApi = `${TakumiRecordGenshinApi}index`; // 原神游戏记录索引 API
|
export const TakumiRecordIndexApi = `${TakumiRecordGenshinApi}index`; // 原神游戏记录索引 API
|
||||||
export const TakumiRecordCharactersApi = `${TakumiRecordGenshinApi}character`; // 原神游戏记录角色 API
|
export const TakumiRecordCharactersApi = `${TakumiRecordGenshinApi}character`; // 原神游戏记录角色 API
|
||||||
export const TakumiRecordCharacterListApi = `${TakumiRecordCharactersApi}/list`; // 原神游戏记录角色列表 API
|
export const TakumiRecordCharacterListApi = `${TakumiRecordCharactersApi}/list`; // 原神游戏记录角色列表 API
|
||||||
export const TakumiRecordCharacterDetailApi = `${TakumiRecordCharactersApi}/detail`; // 原神游戏记录角色详情 API
|
export const TakumiRecordCharacterDetailApi = `${TakumiRecordCharactersApi}/detail`; // 原神游戏记录角色详情 API
|
||||||
export const TakumiRecordAbyssApi = `${TakumiRecordGenshinApi}spiralAbyss`; // 原神游戏记录深境螺旋 API
|
export const TakumiRecordAbyssApi = `${TakumiRecordGenshinApi}spiralAbyss`; // 原神游戏记录深境螺旋 API
|
||||||
|
export const TakumiRecordCombatApi = `${TakumiRecordGenshinApi}role_combat`;
|
||||||
export const TakumiSTokenBindingRolesApi = `${TakumiBindingApi}getUserGameRolesBySToken`; // 获取绑定角色 API-根据 stoken
|
export const TakumiSTokenBindingRolesApi = `${TakumiBindingApi}getUserGameRolesBySToken`; // 获取绑定角色 API-根据 stoken
|
||||||
export const TakumiCookieBindingRolesApi = `${TakumiBindingApi}getUserGameRolesByCookie`; // 获取绑定角色 API-根据 Cookie
|
export const TakumiCookieBindingRolesApi = `${TakumiBindingApi}getUserGameRolesByCookie`; // 获取绑定角色 API-根据 Cookie
|
||||||
|
|
||||||
|
|||||||
39
src/web/request/getRoleCombat.ts
Normal file
39
src/web/request/getRoleCombat.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* @file web/request/getRoleCombat.ts
|
||||||
|
* @description 真境剧诗
|
||||||
|
* @since Beta v0.6.2
|
||||||
|
*/
|
||||||
|
|
||||||
|
import TGHttp from "../../utils/TGHttp.js";
|
||||||
|
import TGApi from "../api/TGApi.js";
|
||||||
|
import TGUtils from "../utils/TGUtils.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取剧诗信息
|
||||||
|
* @since Beta v.0.6.2
|
||||||
|
* @param {TGApp.App.Account.Cookie} cookie
|
||||||
|
* @param {TGApp.Sqlite.Account.Game} account
|
||||||
|
* @returns {Promise<TGApp.Game.Combat.Combat[]|TGApp.BBS.Response.Base|false>}
|
||||||
|
*/
|
||||||
|
export async function getRoleCombat(
|
||||||
|
cookie: TGApp.App.Account.Cookie,
|
||||||
|
account: TGApp.Sqlite.Account.Game,
|
||||||
|
): Promise<TGApp.Game.Combat.Combat[] | TGApp.BBS.Response.Base | false> {
|
||||||
|
const url = TGApi.GameData.getRoleCombat;
|
||||||
|
const params = { role_id: account.gameUid, server: account.region, active: 1, need_detail: true };
|
||||||
|
const ck = {
|
||||||
|
account_id: cookie.account_id,
|
||||||
|
cookie_token: cookie.cookie_token,
|
||||||
|
ltoken: cookie.ltoken,
|
||||||
|
ltuid: cookie.ltuid,
|
||||||
|
};
|
||||||
|
const header = TGUtils.User.getHeader(ck, "GET", params, "common");
|
||||||
|
const resp = await TGHttp<TGApp.Game.Combat.Response | TGApp.BBS.Response.Base>(url, {
|
||||||
|
method: "GET",
|
||||||
|
headers: header,
|
||||||
|
query: params,
|
||||||
|
});
|
||||||
|
if (resp.retcode != 0) return <TGApp.BBS.Response.Base>resp;
|
||||||
|
if (!resp.data.is_unlock) return false;
|
||||||
|
return resp.data.data;
|
||||||
|
}
|
||||||
@@ -67,10 +67,10 @@ function getDS(method: string, data: string, saltType: string, isSign: boolean):
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取请求头
|
* @description 获取请求头
|
||||||
* @since Beta v0.5.3
|
* @since Beta v0.6.2
|
||||||
* @param {Record<string, string>} cookie cookie
|
* @param {Record<string, string>} cookie cookie
|
||||||
* @param {string} method 请求方法
|
* @param {string} method 请求方法
|
||||||
* @param {Record<string, string|number>|string} data 请求数据
|
* @param {Record<string, string|number|string[]|boolean>|string} data 请求数据
|
||||||
* @param {string} saltType salt 类型
|
* @param {string} saltType salt 类型
|
||||||
* @param {boolean} isSign 是否为签名
|
* @param {boolean} isSign 是否为签名
|
||||||
* @returns {Record<string, string>} 请求头
|
* @returns {Record<string, string>} 请求头
|
||||||
@@ -78,7 +78,7 @@ function getDS(method: string, data: string, saltType: string, isSign: boolean):
|
|||||||
export function getRequestHeader(
|
export function getRequestHeader(
|
||||||
cookie: Record<string, string>,
|
cookie: Record<string, string>,
|
||||||
method: string,
|
method: string,
|
||||||
data: Record<string, string | number | string[]> | string,
|
data: Record<string, string | number | string[] | boolean> | string,
|
||||||
saltType: string,
|
saltType: string,
|
||||||
isSign: boolean = false,
|
isSign: boolean = false,
|
||||||
): Record<string, string> {
|
): Record<string, string> {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file web/utils/tools.ts
|
* @file web/utils/tools.ts
|
||||||
* @description 应用用到的工具函数
|
* @description 应用用到的工具函数
|
||||||
* @since Beta v0.5.3
|
* @since Beta v0.6.2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import TGConstant from "../constant/TGConstant.js";
|
import TGConstant from "../constant/TGConstant.js";
|
||||||
@@ -42,11 +42,11 @@ export function transCookie(cookie: Record<string, string>): string {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description ds 算法需要数据转换后的字符串是按照字典序排序的
|
* @description ds 算法需要数据转换后的字符串是按照字典序排序的
|
||||||
* @since Beta v0.5.3
|
* @since Beta v0.6.2
|
||||||
* @param {Record<string, string|number>} obj object
|
* @param {Record<string, string|number>} obj object
|
||||||
* @returns {string} query string
|
* @returns {string} query string
|
||||||
*/
|
*/
|
||||||
export function transParams(obj: Record<string, string | number | string[]>): string {
|
export function transParams(obj: Record<string, string | number | string[] | boolean>): string {
|
||||||
let res = "";
|
let res = "";
|
||||||
const keys = Object.keys(obj).sort();
|
const keys = Object.keys(obj).sort();
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
@@ -58,6 +58,8 @@ export function transParams(obj: Record<string, string | number | string[]>): st
|
|||||||
/**
|
/**
|
||||||
* @description 根据 uid 获取 server
|
* @description 根据 uid 获取 server
|
||||||
* @since Beta v0.4.3
|
* @since Beta v0.4.3
|
||||||
|
* @todo instead of account.region
|
||||||
|
* @deprecated
|
||||||
* @param {string} uid uid
|
* @param {string} uid uid
|
||||||
* @returns {string} server
|
* @returns {string} server
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user