Files
rustfs-console/types/api.ts
T
overtrue 0598f8065f refactor: 修复 API 客户端 composables 滥用和硬编码路径问题
- 修复 lib/api-client.ts 中在类方法中直接调用 composables 的问题
- 添加 ApiErrorHandler 错误处理器,通过依赖注入方式处理 401 错误
- 创建路由工具函数 utils/routes.ts,统一管理路由路径
- 修复 composables/useAuth.ts 中的硬编码路径,使用工具函数
- 修复 components/copy-input.vue 的生命周期问题,在 onMounted 中创建 ClipboardJS 实例
- 修复 plugins/03.s3.ts 中的错误处理,使用 navigateTo 替代直接操作 window.location
- 修复 pages/config.vue 中的硬编码路径
- 添加 composables/useFormValidation.ts、useAsyncOperation.ts、useErrorHandler.ts 工具函数(供后续使用)
- 添加 types/api.ts 类型定义
2025-10-31 22:50:59 +08:00

58 lines
944 B
TypeScript

/**
* API 相关类型定义
*/
/**
* API 错误处理器回调函数类型
*/
export type ApiErrorHandlerCallback = () => void | Promise<void>;
/**
* API 客户端错误处理器接口
*/
export interface IApiErrorHandler {
handle401(): Promise<void>;
handle403(): Promise<void>;
handleServerError(): Promise<void>;
handleByStatus(status: number): Promise<void>;
}
/**
* API 请求基础配置
*/
export interface ApiRequestConfig {
baseURL?: string;
headers?: Record<string, string>;
timeout?: number;
}
/**
* API 响应基础结构
*/
export interface ApiResponse<T = any> {
data?: T;
message?: string;
code?: number;
}
/**
* 分页请求参数
*/
export interface PaginationParams {
page?: number;
pageSize?: number;
offset?: number;
limit?: number;
}
/**
* 分页响应数据
*/
export interface PaginatedResponse<T> {
items: T[];
total: number;
page?: number;
pageSize?: number;
}