Files
epic-ui/src/api/index.ts
hxt 21a3348e0e feat(character): 更新角色详情页面配装数据展示
- 添加平均属性和主流套装占比展示
-优化面板属性展示,增加最近更新时间
- 调整套装组合和神器数据展示方式
- 优化数据处理逻辑,提高页面加载速度
2025-05-25 19:38:21 +08:00

159 lines
3.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {Api} from "../utils/axios/config";
// 查询参数接口
export interface GvgTeamQueryParams {
defenseHeroes?: string[];
attackHeroes?: string[];
equipmentInfo?: string;
artifacts?: string[];
battleStrategy?: string;
pageNum?: number;
pageSize?: number;
}
// 英雄信息接口
export interface HeroInfo {
heroCode: string;
headImgUrl: string;
heroName: string;
}
// 阵容数据接口
export interface GvgTeam {
id: number;
defenseHeroes: string[];
defenseHeroInfos: HeroInfo[];
attackHeroes: string[];
attackHeroInfos: HeroInfo[];
equipmentInfo: string;
artifacts: string;
battleStrategy: string;
prerequisites: string;
importantNotes: string;
}
// 分页响应接口
export interface PageResult<T> {
total: number;
list: T[];
}
export interface Response<T> {
code: number;
data: T;
msg: string;
}
// 英雄列表接口
export interface Hero {
id: number;
heroCode: string;
heroName: string;
nickName: string;
headImgUrl: string;
}
// 角色详情接口类型
export interface HeroDetailResp {
heroRespSimpleVO: {
id: string;
heroCode: string;
heroName: string;
nickName: string | null;
headImgUrl: string;
stars: number;
role: string;
attribute: string;
};
hero60AttributeVO: {
cp: number;
atk: number;
hp: number;
spd: number;
def: number;
chc: number;
chd: number;
dac: number;
eff: number;
efr: number;
};
heroSetAvgVO: {
atk: number;
hp: number;
spd: number;
def: number;
chc: number;
chd: number;
dac: number;
eff: number;
efr: number;
};
heroSetPercentVOS: {
setName: string;
percent: number;
}[];
heroSetShows: {
cp: number;
atk: number;
hp: number;
spd: number;
def: number;
chc: number;
chd: number;
dac: number;
eff: number;
efr: number;
hds: string;
ctr: string;
}[];
}
// 查询角色详情
export const getHeroDetail = async (heroCode: string): Promise<HeroDetailResp> => {
return await Api.get<HeroDetailResp>(`/epic/hero/hero-detail?heroCode=${heroCode}`)
};
// 查询 GVG 阵容列表
export const getGvgTeamList = async (heroCodes?: string[]) => {
const params = new URLSearchParams();
if (heroCodes && heroCodes.length > 0) {
params.append('heroCodes', heroCodes.join(','));
}
const response = await Api.get<GvgTeam[]>(`/epic/hero/team-list?${params.toString()}`);
return response;
};
// 获取 GVG 阵容详情
export const getGvgTeamDetail = async (id: number) => {
const response = await Api.get<Response<GvgTeam>>(`/api/gvg/team/${id}`);
if (response.code === 0) {
return response.data;
}
throw new Error(response.msg || "获取阵容详情失败");
};
// 查询所有英雄列表
export const getHeroList = async () => {
const response = await Api.get<Hero[]>("/epic/hero/list-all");
return response;
};
export interface ImageRecognitionResult {
heroNames: string[]; // 6个有序的角色名称前3个为一组后3个为一组
}
// 图片识别接口
export const recognizeHeroesFromImage = async (file: File): Promise<ImageRecognitionResult> => {
try {
const response = await Api.upload<string[]>('/epic/hero/recognize', file);
console.log(response)
if (response && Array.isArray(response)) {
return {heroNames: response};
}
throw new Error("图片识别失败");
} catch (error) {
console.error('Failed to recognize heroes from image:', error);
throw error;
}
};