159 lines
3.8 KiB
TypeScript
159 lines
3.8 KiB
TypeScript
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;
|
||
}
|
||
};
|