881 B
881 B
types.ts
路径:src/api/types.ts
功能用途
公共 API 类型定义,供 event、order、position、market 等模块复用,避免重复声明。
核心类型
PageResult<T>
分页结果通用结构:
interface PageResult<T> {
list: T[]
page: number
pageSize: number
total: number
}
ApiResponse<T>
通用 API 响应:
interface ApiResponse<T = unknown> {
code: number
data?: T
msg: string
}
使用方式
import type { PageResult, ApiResponse } from '@/api/types'
// 在接口模块中导出供外部使用
export type { PageResult }
export interface MyListResponse {
code: number
data: PageResult<MyItem>
msg: string
}
扩展方式
- 新增通用类型时在此文件添加
- 各 API 模块通过
export type { Xxx }重新导出,保持向后兼容