feat(frontend): 对接后端统一响应格式,增强错误处理

- 新增 types/api.ts,定义 ApiResponse/PaginatedData 泛型类型和业务错误码常量
- 增强 request.ts 拦截器:提取后端错误信息、映射 HTTP 状态码和业务错误码为中文提示
- 为 auth/audit/subsystem API 添加泛型返回类型
- 为各视图添加 try/catch 防止未处理的 Promise 拒绝
This commit is contained in:
2026-07-15 10:52:41 +08:00
parent 4f1df02f53
commit 3de59c4fc2
10 changed files with 137 additions and 32 deletions
+7 -3
View File
@@ -33,9 +33,13 @@ const auditData = ref<LoginAudit[]>([])
const total = ref(0)
const fetchData = async () => {
const { data } = await auditApi.getLoginAudit()
auditData.value = data.items
total.value = data.total
try {
const { data } = await auditApi.getLoginAudit()
auditData.value = data.items
total.value = data.total
} catch {
// 错误已由 request 拦截器统一处理
}
}
const refresh = () => {