feat(web): Q3 前端体验优化 — ErrorBoundary + 5 hooks + 共享类型 + i18n 基础

- ErrorBoundary 组件:全局错误捕获与优雅降级
- 提取 5 个自定义 hooks:useCountUp, useDarkMode, useDebouncedValue, usePaginatedData, useApiRequest
- 从 11 个 API 文件提取 PaginatedResponse 共享类型到 api/types.ts
- 统一 API 错误处理(api/errors.ts)
- client.ts 迁移到 axios adapter 模式(替代废弃的 CancelToken)
- 添加 react-i18next 国际化基础设施 + zh-CN 语言包
This commit is contained in:
iven
2026-04-17 19:40:58 +08:00
parent 6a44cbecf3
commit 9d18b7e079
25 changed files with 324 additions and 52 deletions

View File

@@ -0,0 +1,12 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import zhCN from './locales/zh-CN.json';
i18n.use(initReactI18next).init({
resources: { 'zh-CN': { translation: zhCN } },
lng: 'zh-CN',
fallbackLng: 'zh-CN',
interpolation: { escapeValue: false },
});
export default i18n;

View File

@@ -0,0 +1,34 @@
{
"common": {
"save": "保存",
"cancel": "取消",
"delete": "删除",
"edit": "编辑",
"create": "新建",
"search": "搜索",
"confirm": "确认",
"loading": "加载中...",
"success": "操作成功",
"error": "操作失败"
},
"auth": {
"login": {
"title": "登录",
"username": "用户名",
"password": "密码",
"submit": "登录",
"success": "登录成功",
"failed": "用户名或密码错误"
}
},
"nav": {
"home": "首页",
"users": "用户管理",
"roles": "角色管理",
"organizations": "组织管理",
"workflow": "工作流",
"messages": "消息中心",
"settings": "系统设置",
"plugins": "插件管理"
}
}