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
+2 -2
View File
@@ -84,8 +84,8 @@ const handleLogin = async () => {
await login(form.username, form.password)
ElMessage.success('登录成功')
router.push('/')
} catch (error: any) {
ElMessage.error(error.message || '登录失败')
} catch {
// 错误已由 request 拦截器统一处理
} finally {
loading.value = false
}