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:
12
apps/web/src/i18n/index.ts
Normal file
12
apps/web/src/i18n/index.ts
Normal 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;
|
||||
34
apps/web/src/i18n/locales/zh-CN.json
Normal file
34
apps/web/src/i18n/locales/zh-CN.json
Normal 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": "插件管理"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user