- 新增 tsconfig.json 配置 - 新增 types/ 目录(7个类型定义文件,与后端 DTO 对齐) - 迁移 vite.config.js → vite.config.ts - 迁移 main.js → main.ts - 迁移 utils/api.js → utils/api.ts(泛型化请求封装) - 迁移 utils/currency.js → utils/currency.ts - 迁移 6 个 Vue 页面组件(添加 lang="ts" 和类型注解) - 新增 TYPESCRIPT_MIGRATION.md 迁移计划文档 - 更新 todo.md 进度 收益:完整类型提示、编译时错误检查、重构安全性提升
46 lines
786 B
TypeScript
46 lines
786 B
TypeScript
/**
|
|
* API 响应类型定义(与后端 DTO 对齐)
|
|
*/
|
|
|
|
// 通用 API 响应结构
|
|
export interface ApiResponse<T = any> {
|
|
code: number;
|
|
message: string;
|
|
data: T;
|
|
}
|
|
|
|
// 请求配置
|
|
export interface RequestConfig {
|
|
url: string;
|
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
data?: Record<string, any>;
|
|
headers?: Record<string, string>;
|
|
timeout?: number;
|
|
}
|
|
|
|
// API 错误
|
|
export interface ApiError {
|
|
code: number;
|
|
message: string;
|
|
details?: Record<string, any>;
|
|
}
|
|
|
|
// 股票搜索结果
|
|
export interface TickerSearchResult {
|
|
symbol: string;
|
|
name: string;
|
|
exchange?: string;
|
|
type?: string;
|
|
}
|
|
|
|
// ===== 认证相关 =====
|
|
|
|
export interface WechatLoginRequest {
|
|
code: string;
|
|
}
|
|
|
|
export interface WechatLoginResponse {
|
|
token: string;
|
|
userId: string;
|
|
}
|