From ec97ea8787834f9d5b80e3d36b98cd3ceaad1ade Mon Sep 17 00:00:00 2001 From: sophie <16087569+sophie_liang@user.noreply.gitee.com> Date: Sun, 14 Jun 2026 21:41:07 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=87=8D=E6=9E=84=20V3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend_architecture_refactor.md | 118 +- frontend/index.html | 2 +- frontend/scripts/merge-kb-runtime-i18n.mjs | 406 ++++++ frontend/scripts/merge-kb-workspace-i18n.mjs | 629 +++++++++ frontend/scripts/merge-schedule-form-i18n.mjs | 259 ++++ frontend/src/App.vue | 5 +- .../admin/modules/schedules/SchedulesPage.vue | 1236 +---------------- .../components/ScheduleCreateEditModal.vue | 534 +++++++ .../components/ScheduleOverviewPanel.vue | 149 ++ .../components/SchedulePageHeader.vue | 46 + .../components/ScheduleTestRunDialog.vue | 183 +++ .../components/ScheduleWorkbenchPanel.vue | 334 +++++ .../components/SchedulesPageOverlays.vue | 24 + .../schedule-admin/schedule-admin.state.ts | 158 +++ .../schedule-admin/useScheduleAdminForm.ts | 359 +++++ .../schedule-admin/useScheduleAdminList.ts | 136 ++ .../schedule-admin/useScheduleAdminLookups.ts | 46 + .../schedule-admin/useScheduleAdminRuns.ts | 215 +++ .../schedule-admin/useScheduleAdminTestRun.ts | 101 ++ .../composables/schedules.context.ts | 30 + .../composables/useSchedulesAdmin.ts | 1119 +-------------- .../schedules/types/schedule-admin.types.ts | 134 ++ .../schedules/utils/schedule-cron.utils.ts | 154 ++ .../utils/schedule-form-payload.utils.ts | 46 + .../schedules/utils/schedule-format.utils.ts | 29 + .../features/chat/api/toolRunProgress.api.ts | 12 + .../features/chat/components/ChatInputBar.vue | 2 +- .../chat/components/ToolRunProgressCard.vue | 2 +- .../chat/composables/useToolRunProgress.ts | 2 +- frontend/src/features/chat/index.ts | 2 + .../chat/types/tool-run-progress.types.ts} | 9 +- .../kb/components/KbWorkspaceOverlays.vue | 635 +++++++++ .../kb-workspace/kb-workspace.state.ts | 2 +- .../kb-workspace/useKbWorkspaceComputed.ts | 73 +- .../kb-workspace/useKbWorkspaceData.ts | 10 +- .../kb-workspace/useKbWorkspaceDocuments.ts | 87 +- .../kb-workspace/useKbWorkspaceModals.ts | 16 +- .../kb-workspace/useKbWorkspacePathUpload.ts | 55 +- .../features/kb/composables/useKbWorkspace.ts | 51 +- .../src/features/kb/utils/kb-display.utils.ts | 48 +- .../src/features/kb/utils/kb-i18n.types.ts | 2 + .../features/kb/utils/kb-path-upload.utils.ts | 17 +- .../features/kb/utils/kb-workflow.utils.ts | 77 +- .../src/features/kb/views/KbWorkspaceView.vue | 716 +--------- .../workspace/pages/ShippingNoticePage.vue | 2 +- .../workspace}/views/ShippingNoticeView.vue | 6 +- frontend/src/i18n.ts | 506 +------ frontend/src/locales/en/admin.json | 53 +- frontend/src/locales/en/common.json | 21 + frontend/src/locales/en/feedback.json | 29 + frontend/src/locales/en/filePreview.json | 11 + frontend/src/locales/en/kb.json | 259 ++++ frontend/src/locales/en/profile.json | 32 + frontend/src/locales/en/scheduleRuns.json | 21 + frontend/src/locales/en/theme.json | 8 + frontend/src/locales/index.ts | 100 +- frontend/src/locales/th/admin.json | 53 +- frontend/src/locales/th/common.json | 21 + frontend/src/locales/th/feedback.json | 29 + frontend/src/locales/th/filePreview.json | 11 + frontend/src/locales/th/kb.json | 259 ++++ frontend/src/locales/th/profile.json | 32 + frontend/src/locales/th/scheduleRuns.json | 21 + frontend/src/locales/th/theme.json | 8 + frontend/src/locales/zh-CN/admin.json | 53 +- frontend/src/locales/zh-CN/common.json | 21 + frontend/src/locales/zh-CN/feedback.json | 29 + frontend/src/locales/zh-CN/filePreview.json | 11 + frontend/src/locales/zh-CN/kb.json | 259 ++++ frontend/src/locales/zh-CN/profile.json | 32 + frontend/src/locales/zh-CN/scheduleRuns.json | 21 + frontend/src/locales/zh-CN/theme.json | 8 + frontend/src/locales/zh-TW/admin.json | 53 +- frontend/src/locales/zh-TW/common.json | 21 + frontend/src/locales/zh-TW/feedback.json | 29 + frontend/src/locales/zh-TW/filePreview.json | 11 + frontend/src/locales/zh-TW/kb.json | 259 ++++ frontend/src/locales/zh-TW/profile.json | 32 + frontend/src/locales/zh-TW/scheduleRuns.json | 21 + frontend/src/locales/zh-TW/theme.json | 8 + 80 files changed, 6887 insertions(+), 3733 deletions(-) create mode 100644 frontend/scripts/merge-kb-runtime-i18n.mjs create mode 100644 frontend/scripts/merge-kb-workspace-i18n.mjs create mode 100644 frontend/scripts/merge-schedule-form-i18n.mjs create mode 100644 frontend/src/features/admin/modules/schedules/components/ScheduleCreateEditModal.vue create mode 100644 frontend/src/features/admin/modules/schedules/components/ScheduleOverviewPanel.vue create mode 100644 frontend/src/features/admin/modules/schedules/components/SchedulePageHeader.vue create mode 100644 frontend/src/features/admin/modules/schedules/components/ScheduleTestRunDialog.vue create mode 100644 frontend/src/features/admin/modules/schedules/components/ScheduleWorkbenchPanel.vue create mode 100644 frontend/src/features/admin/modules/schedules/components/SchedulesPageOverlays.vue create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedule-admin/schedule-admin.state.ts create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminForm.ts create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminList.ts create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminLookups.ts create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminRuns.ts create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminTestRun.ts create mode 100644 frontend/src/features/admin/modules/schedules/composables/schedules.context.ts create mode 100644 frontend/src/features/admin/modules/schedules/types/schedule-admin.types.ts create mode 100644 frontend/src/features/admin/modules/schedules/utils/schedule-cron.utils.ts create mode 100644 frontend/src/features/admin/modules/schedules/utils/schedule-form-payload.utils.ts create mode 100644 frontend/src/features/admin/modules/schedules/utils/schedule-format.utils.ts create mode 100644 frontend/src/features/chat/api/toolRunProgress.api.ts rename frontend/src/{api/toolRunProgress.ts => features/chat/types/tool-run-progress.types.ts} (82%) create mode 100644 frontend/src/features/kb/components/KbWorkspaceOverlays.vue create mode 100644 frontend/src/features/kb/utils/kb-i18n.types.ts rename frontend/src/{ => features/workspace}/views/ShippingNoticeView.vue (98%) create mode 100644 frontend/src/locales/en/common.json create mode 100644 frontend/src/locales/en/feedback.json create mode 100644 frontend/src/locales/en/filePreview.json create mode 100644 frontend/src/locales/en/profile.json create mode 100644 frontend/src/locales/en/scheduleRuns.json create mode 100644 frontend/src/locales/en/theme.json create mode 100644 frontend/src/locales/th/common.json create mode 100644 frontend/src/locales/th/feedback.json create mode 100644 frontend/src/locales/th/filePreview.json create mode 100644 frontend/src/locales/th/profile.json create mode 100644 frontend/src/locales/th/scheduleRuns.json create mode 100644 frontend/src/locales/th/theme.json create mode 100644 frontend/src/locales/zh-CN/common.json create mode 100644 frontend/src/locales/zh-CN/feedback.json create mode 100644 frontend/src/locales/zh-CN/filePreview.json create mode 100644 frontend/src/locales/zh-CN/profile.json create mode 100644 frontend/src/locales/zh-CN/scheduleRuns.json create mode 100644 frontend/src/locales/zh-CN/theme.json create mode 100644 frontend/src/locales/zh-TW/common.json create mode 100644 frontend/src/locales/zh-TW/feedback.json create mode 100644 frontend/src/locales/zh-TW/filePreview.json create mode 100644 frontend/src/locales/zh-TW/profile.json create mode 100644 frontend/src/locales/zh-TW/scheduleRuns.json create mode 100644 frontend/src/locales/zh-TW/theme.json diff --git a/docs/refactor/frontend_architecture_refactor.md b/docs/refactor/frontend_architecture_refactor.md index fa43c5c3..0ffa783b 100644 --- a/docs/refactor/frontend_architecture_refactor.md +++ b/docs/refactor/frontend_architecture_refactor.md @@ -129,7 +129,7 @@ frontend/src/ │ │ │ ├── announcements/ │ │ │ ├── questions/ │ │ │ ├── wecom/ -│ │ │ ├── schedules/ +│ │ │ ├── schedules/ # types/utils + context + panel/overlays(见 §10.5) │ │ │ └── knowledge-base/ │ │ └── components/ │ │ └── AdminNav.vue @@ -144,7 +144,8 @@ frontend/src/ │ │ ├── useKbWorkspace.ts # 编排入口 │ │ └── kb-workspace/ # state / computed / data / pathUpload / documents / modals │ ├── views/ -│ │ └── KbWorkspaceView.vue # 作业面壳(模板 + 弹窗) +│ │ ├── KbWorkspaceView.vue # 作业面主内容壳 +│ │ └── components/KbWorkspaceOverlays.vue # 弹窗层 │ └── components/ # 治理面:KbAdminPanel、Dify*Dialog │ ├── locales/ # i18n 按语言 + 业务域拆分 @@ -330,7 +331,7 @@ flowchart TB | 项 | 说明 | |----|------| -| API | `features/kb/api/kb.api.ts`(`src/api/kb.ts` deprecated 转发) | +| API | `features/kb/api/kb.api.ts`(`src/api/kb.ts` 已删除) | | 作业面编排 | `useKbWorkspace` + `kb-workspace/*` 子 composable | | 权限 | `hasKnowledgeBaseAccess` / 作业面批量操作:`role === 'admin'` | | i18n | `locales/{en,zh-CN,zh-TW,th}/kb.json` | @@ -509,6 +510,8 @@ features/admin/modules/ └── composables/use*Admin.ts + components/ ``` +**schedules/**(2026-06 瘦身,详见 §10.5):`SchedulesPage.vue` 薄壳 + `useSchedulesAdmin` + `schedule-admin/*` + `schedules.context` + 6 个子组件(Header / Overview / Workbench / Overlays / TestRun / CreateEdit)。 + ### 9.3 构建验证 `npm run build` 通过;`AdminView.vue` 已删除。 @@ -565,9 +568,27 @@ Phase 2 Chat 目标:将原 `views/ChatView.vue`(~5500 行)拆为 feature - ~~KB 域收口~~ → 见 §16 - ~~`locales/` 按域拆分~~ → 见 §15.2 +### 10.5 Admin Schedules 模块瘦身(2026-06,已实现) + +参照 KB 作业面模式,将原 `SchedulesPage.vue`(~1200 行)与 `useSchedulesAdmin.ts`(~1100 行)拆为薄壳 + provide/inject 子组件。 + +| 项 | 路径 / 约行数 | +|----|---------------| +| 页面壳层 | `SchedulesPage.vue`(~26 行:`reactive(useSchedulesAdmin())` + `provide` + 4 子组件) | +| 编排入口 | `composables/useSchedulesAdmin.ts`(~28 行,组合子模块) | +| 子 composable | `composables/schedule-admin/`:`state`(~145)、`useScheduleAdminLookups`(~40)、`useScheduleAdminList`(~124)、`useScheduleAdminRuns`(~196)、`useScheduleAdminForm`(~329)、`useScheduleAdminTestRun`(~95) | +| provide/inject | `composables/schedules.context.ts`(~26 行) | +| 类型与默认工厂 | `types/schedule-admin.types.ts`(~127 行) | +| 纯函数 | `utils/schedule-cron.utils.ts`、`utils/schedule-format.utils.ts`、`utils/schedule-form-payload.utils.ts` | +| 子组件 | `SchedulePageHeader`(~44)、`ScheduleOverviewPanel`(~146)、`ScheduleWorkbenchPanel`(~329)、`SchedulesPageOverlays`(~24)、`ScheduleTestRunDialog`(~175)、`ScheduleCreateEditModal`(~525) | + +子 panel / overlays 通过 `useSchedulesAdminContext()` inject,无 props 透传。`npm run build` 通过。 + +**i18n(2026-06)**:`ScheduleCreateEditModal`、`ScheduleTestRunDialog`、`ScheduleWorkbenchPanel`(Dify 快照区)硬编码中文已外置至 `locales/*/admin.json`(`schedule.form.*`、`schedule.difySnapshot.*`、`schedule.testRun.*`);合并脚本 `frontend/scripts/merge-schedule-form-i18n.mjs`。顺带修复创建按钮误用 `admin.schedule.form.admin.createSchedule` 键。 + --- -## 11. Phase 3 Workspace 模块(部分实现) +## 11. Phase 3 Workspace 模块(已实现) Phase 3 目标:将原 `WorkspaceView.vue` 拆为独立 feature,路由 `/workspace/*`。 @@ -587,7 +608,7 @@ Phase 3 目标:将原 `WorkspaceView.vue` 拆为独立 feature,路由 `/work | 页面 | 现状 | |------|------| | `KnowledgeBasePage.vue` | ✅ 嵌入 `features/kb/views/KbWorkspaceView.vue`(`embedded`) | -| `ShippingNoticePage.vue` | 嵌入 `src/views/ShippingNoticeView.vue`(待迁入 workspace) | +| `ShippingNoticePage.vue` | ✅ 嵌入 `features/workspace/views/ShippingNoticeView.vue`(`embedded`) | ### 11.3 路由 @@ -595,7 +616,7 @@ Phase 3 目标:将原 `WorkspaceView.vue` 拆为独立 feature,路由 `/work /workspace/applications → HomePage /workspace/profile → ProfilePage /workspace/schedule-runs → ScheduleRunsPage -/workspace/shipping-notice → ShippingNoticePage(legacy 嵌入) +/workspace/shipping-notice → ShippingNoticePage(嵌入 ShippingNoticeView) /workspace/knowledge-base → KnowledgeBasePage(legacy 嵌入) /workspace/history → chat/history/HistoryPage ``` @@ -619,7 +640,9 @@ Phase 4 目标:领域 HTTP 请求迁入对应 `features/*/api/`,`shared/api/ | 排程共用类型 | `shared/types/schedule.types.ts` | ✅ | | `src/api/shippingNotice.ts` | `features/chat/api/shipping.api.ts` | ✅ | | 货代类型 | `features/chat/types/shipping.api.types.ts` | ✅ | -| `src/api/kb.ts` | `features/kb/api/kb.api.ts` | ✅ deprecated 转发保留 | +| `src/api/toolRunProgress.ts` | `features/chat/api/toolRunProgress.api.ts` | ✅ | +| 工具进度类型 | `features/chat/types/tool-run-progress.types.ts` | ✅ | +| `src/api/kb.ts` | `features/kb/api/kb.api.ts` | ✅(deprecated 转发已删除) | ### 12.2 新代码 import 规范 @@ -647,9 +670,8 @@ import { getWorkspaceShippingTask } from '@/features/chat'; ### 12.3 兼容策略 -- ~~`src/api/{client,admin,schedule,shippingNotice,chat,user}.ts` deprecated 转发~~ → **已删除**(2026-06-11) -- **新代码必须使用 feature / shared 路径** -- `src/api/kb.ts` 保留 deprecated 转发,新代码使用 `@/features/kb/api/kb.api` +- ~~`src/api/{client,admin,schedule,shippingNotice,chat,user,toolRunProgress,kb}.ts` deprecated 转发~~ → **已全部删除**(2026-06-11) +- **`src/api/` 目录已清空**;新代码必须使用 `@/features/*/api/*` 或 `@/shared/api/client` ### 12.4 构建验证 @@ -658,7 +680,7 @@ import { getWorkspaceShippingTask } from '@/features/chat'; ### 12.5 下一步 - ~~KB API 迁入 `features/kb/api/kb.api.ts`~~ → 已完成(见 §16) -- ~~清理 deprecated `src/api/*` 转发~~ → 已完成(仅保留 `kb.ts`) +- ~~清理 deprecated `src/api/*` 转发~~ → 已完成(`src/api/` 已清空) - `locales/` 按域拆分 → 见 §15 --- @@ -736,26 +758,25 @@ import { useTheme, requestJson } from '@/shared'; | 删除 `src/composables/` | 7 个 deprecated 转发已移除 | | 删除 `src/utils/` | 6 个 deprecated 转发已移除 | | 删除 `src/styles/` | 3 个 CSS 转发已移除 | -| 删除 `src/api/*`(除 kb) | client/admin/chat/user/schedule/shippingNotice 转发已移除 | -| 删除 `src/router/index.ts` | 全仓已改用 `@/app/router` | -| 修复 `api/kb.ts` | 改为引用 `@/shared/api/client` | +| 删除 `src/api/*` | 全部转发已移除,`src/api/` 目录已清空 | | 移除 `axios` 依赖 | 代码未使用,已从 `package.json` 删除 | | `main.ts` / `App.vue` | 保留在 `src/` 根(见 §7.2 约定) | ### 15.2 i18n 按域拆分(已完成) -**现状**:`src/i18n.ts` 仅保留 `createI18n` 注册与 locale 默认值;各业务域 messages 均已外置 JSON。 +**现状**:`src/i18n.ts` 仅保留 `createI18n` 注册与空 locale 骨架;**全部** messages 均已外置 JSON。 **已完成 ✅** | 域 | 路径 | |----|------| | `errors` | `locales/{en,zh-CN,zh-TW,th}/errors.json` | -| `auth` | `locales/{en,zh-CN,zh-TW,th}/auth.json` | +| `auth` | `locales/{en,zh-CN,zh-TW,th}/auth.json`(展平合并:`login.*` 等) | | `workspace` | `locales/{en,zh-CN,zh-TW,th}/workspace.json` | | `chat` | `locales/{en,zh-CN,zh-TW,th}/chat.json` | | `admin` | `locales/{en,zh-CN,zh-TW,th}/admin.json` | -| `kb` | `locales/{en,zh-CN,zh-TW,th}/kb.json` | +| `kb` | `locales/{en,zh-CN,zh-TW,th}/kb.json`(展平合并:`kbDifySettings.*` 等) | +| `common` / `scheduleRuns` / `filePreview` / `profile` / `feedback` / `theme` | 同上四语言 JSON | | 合并入口 | `locales/index.ts` → `mergeExternalLocales()` | `i18n.ts` 在 `createI18n` 前调用 `mergeExternalLocales(messages)`,四语言外置域与拆分前行为一致。 @@ -771,7 +792,13 @@ src/locales/ │ ├── workspace.json │ ├── chat.json │ ├── admin.json -│ └── kb.json +│ ├── kb.json +│ ├── common.json +│ ├── scheduleRuns.json +│ ├── filePreview.json +│ ├── profile.json +│ ├── feedback.json +│ └── theme.json ``` **迁移步骤**(均已完成): @@ -782,41 +809,55 @@ src/locales/ 4. ~~拆 `chat.*` → `chat.json`~~ ✅ 5. ~~拆 `admin.*` → `admin.json`~~ ✅ 6. ~~拆 `kb.*` → `kb.json`(四语言)~~ ✅ -7. 每步 `npm run build` + 四语言 spot check -8. `i18n.ts` 仅保留 `createI18n` 注册与 locale 默认值 +7. ~~拆共享域 `common` / `scheduleRuns` / `filePreview` / `profile` / `feedback` / `theme`~~ ✅ +8. 每步 `npm run build` + 四语言 spot check +9. `i18n.ts` 仅保留 `createI18n` 注册与 locale 骨架 **注意**:AGENTS.md 要求四语言同步;拆分时用脚本或 CI 校验 key 对齐。 -### 15.3 待办:清理 `src/views/`(优先级:低) +### 15.3 清理 `src/views/`(已完成 ✅) -| 文件 | 引用方 | 处理方式 | -|------|--------|----------| -| ~~`KbWorkspaceView.vue`~~ | — | ✅ 已迁入 `features/kb/views/`(见 §16) | -| `ShippingNoticeView.vue` (~250 行) | `workspace/shipping-notice` | 迁入 `features/workspace/pages/` 或独立 feature | +| 文件 | 状态 | +|------|------| +| ~~`KbWorkspaceView.vue`~~ | ✅ 已迁入 `features/kb/views/`(见 §16) | +| ~~`ShippingNoticeView.vue`~~ | ✅ 已迁入 `features/workspace/views/` | -### 15.4 KB 域收口(已实现,见 §16) +`src/views/`、`src/api/` 空目录已删除。 + +### 15.4 deprecated 遗留清理(已完成 ✅) + +| 项 | 状态 | +|----|------| +| `shared/components/kb/*` | 已删除(canonical:`features/kb/components/*`) | +| `shared/composables/useChat.ts` | 已删除(canonical:`features/chat/composables/useChat`) | +| `features/workspace/pages/HistoryPage.vue` | 已删除(canonical:`chat/history/HistoryPage`) | +| `features/workspace/composables/useWorkspaceHistory.ts` | 已删除 | +| `src/api/toolRunProgress.ts` | 已迁入 `features/chat/api/toolRunProgress.api.ts` | +| `src/api/kb.ts` | 已删除 | + +### 15.5 KB 域收口(已实现,见 §16) - ~~`src/api/kb.ts` → `features/kb/api/kb.api.ts`~~ ✅ - ~~`shared/components/kb/*` → `features/kb/components/*`~~ ✅ - ~~路由收敛:`/kb/workspace` redirect → `/workspace/knowledge-base`~~ ✅ - ~~作业面 monolith 拆分:`useKbWorkspace` + `kb-workspace/*`~~ ✅ -### 15.5 可选优化(非必须) +### 15.6 可选优化(非必须) | 项 | 说明 | |----|------| -| `index.html` `lang="zh-CN"` | 主语言为中文,利于 SEO/无障碍 | -| `App.vue` 文件头注释 | 与项目注释规范一致 | +| ~~`index.html` `lang="zh-CN"`~~ | ✅ | +| ~~`App.vue` 文件头注释~~ | ✅ | | `frontend/.env.development` | 若需纯前端多环境 API 地址,再用 `VITE_*` | | Vite 8 beta → stable | 关注正式版发布后升级 | -### 15.6 推荐执行顺序 +### 15.7 推荐执行顺序 ```text ✅ Phase A:删 deprecated 转发 + 去 axios ✅ Phase B:i18n 拆 locales/(errors → auth → workspace → chat → admin → kb) -→ Phase C:ShippingNoticeView 迁入 workspace -✅ Phase D:KB 域收口(治理/作业面拆分 + composable 拆分)→ 见 §16 +✅ Phase C:ShippingNoticeView 迁入 workspace +✅ Phase E:API 遗留清理 + deprecated 文件删除 + i18n 共享域外置 ``` --- @@ -857,7 +898,8 @@ features/kb/ │ ├── useKbWorkspacePathUpload.ts │ ├── useKbWorkspaceDocuments.ts │ └── useKbWorkspaceModals.ts -├── views/KbWorkspaceView.vue # 模板壳(~1160 行,逻辑在 composable) +├── views/KbWorkspaceView.vue # 主内容壳(~550 行) +├── components/KbWorkspaceOverlays.vue # 弹窗层(~635 行) └── components/ ├── KbAdminPanel.vue ├── DifySettingsDialog.vue @@ -868,7 +910,7 @@ features/kb/ | 项 | 说明 | |----|------| -| API 迁入 | `features/kb/api/kb.api.ts`;`src/api/kb.ts` deprecated 转发 | +| API 迁入 | `features/kb/api/kb.api.ts`(`src/api/kb.ts` 已删除) | | 组件迁入 | `KbAdminPanel`、`DifySettingsDialog`、`DifyHealthDialog` | | 作业面拆分 | 类型/纯函数 utils + `useKbWorkspace` 子 composable | | 视图薄壳 | `KbWorkspaceView.vue` script 仅 `useKbWorkspace({ embedded })` | @@ -884,13 +926,13 @@ features/kb/ | 项 | 说明 | |----|------| -| 作业面 View 继续瘦身 | 弹窗块可抽为 `features/kb/components/*Modal.vue`,目标 View < 300 行 | -| 作业面 i18n 全覆盖 | 模板内仍有部分硬编码中文(批量操作按钮等),需迁入 `kb.json` | -| 删除 `src/api/kb.ts` | 确认全仓无 `@/api/kb` import 后移除 deprecated 转发 | +| 作业面 View 继续瘦身 | ✅ 弹窗已抽至 `KbWorkspaceOverlays.vue`(View ~550 行 → 主内容壳;Overlays ~620 行);文档列表区可继续拆 panel | +| 作业面 i18n 全覆盖 | ✅ 模板 + utils/composable 运行时文案已迁入 `kb.json`(`kbWorkspace.*` 四语言);`kb.api.ts` 错误 fallback 仍为中文(低优先级) | +| 删除 `src/api/kb.ts` | ✅ 全仓已无 `@/api/kb` import,deprecated 转发已移除 | ### 16.6 下一步(全项目) -- `ShippingNoticeView` 迁入 workspace → §15.3 Phase C +- ~~`ShippingNoticeView` 迁入 workspace~~ → §15.3 ✅ - Chat / admin 域内低优先级待办 → §10.3 --- diff --git a/frontend/index.html b/frontend/index.html index 7bc203dd..14c766e8 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,5 +1,5 @@ - + diff --git a/frontend/scripts/merge-kb-runtime-i18n.mjs b/frontend/scripts/merge-kb-runtime-i18n.mjs new file mode 100644 index 00000000..c52d9f65 --- /dev/null +++ b/frontend/scripts/merge-kb-runtime-i18n.mjs @@ -0,0 +1,406 @@ +/** + * scripts/merge-kb-runtime-i18n.mjs + * 合并 kbWorkspace 运行时文案(status / workflow / errors / msg)至各语言 kb.json + */ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const localesRoot = path.resolve(__dirname, '../src/locales'); + +const patches = { + en: { + status: { + draft: 'Pending upload', + uploaded: 'Uploaded', + processing: 'Cleaning', + cleaned: 'Cleaned', + ready: 'Ready', + synced: 'Synced', + syncing: 'Syncing', + failed: 'Failed', + queued: 'Queued', + running: 'Running', + success: 'Success', + cancelled: 'Cancelled', + idle: 'Not started', + done: 'Completed', + pendingClean: 'Pending clean', + pendingSync: 'Pending sync', + cleaning: 'Cleaning', + uploading: 'Uploading', + unknown: 'Unknown status', + unnamedDocument: 'Untitled document', + }, + workflow: { upload: 'Upload', clean: 'Clean', sync: 'Sync' }, + failureModal: { + uploadData: 'Upload failures', + cleanData: 'Clean failures', + syncData: 'Sync failures', + generic: 'Failure data', + stageUploadFailed: 'Upload failed', + stageCleanFailed: 'Clean failed', + stageSyncFailed: 'Sync failed', + }, + errors: { + unreadableClean: 'Historical failure reason is unreadable. Click "Clean data" to retry.', + unreadableSync: 'Historical sync failure is unreadable. Please retry sync.', + unreadableUpload: 'Historical upload failure is unreadable. Please re-upload.', + legacyCleanRecovered: 'Legacy clean task was recovered manually. Click "Clean data" to retry.', + sourceFileNotFound: 'Source file not found. Re-upload before cleaning.', + cleanTimeout: 'Clean timed out. Retry later or check if the source file is corrupted.', + duplicateFile: 'Upload failed: file already exists.', + apiRequestFailed: 'Knowledge base API request failed.', + localFolder: 'Local folder', + fileFallback: 'File {index}', + uploadFailed: 'Upload failed', + }, + msg: { + operationFailed: 'Operation failed', + loadGroupsFailed: 'Failed to load groups', + loadDocumentsFailed: 'Failed to load documents', + loadJobsFailed: 'Failed to load jobs', + readSourceFailed: 'Failed to read source file', + noVersion: 'No version', + readMarkdownFailed: 'Failed to read cleaned Markdown', + saveMarkdownFailed: 'Failed to save Markdown', + markdownSaved: 'Cleaned Markdown saved', + deleteDocumentFailed: 'Failed to delete document', + documentDeleted: 'Document deleted', + selectDocumentsToSync: 'Please select documents to sync', + batchSyncResult: 'Batch sync submitted: {success} succeeded, {fail} failed. {detail}', + batchSyncSuccess: 'Batch sync submitted: {success} succeeded', + selectDocumentsToClean: 'Please select documents to clean', + noDocumentsToClean: 'No selected documents can be cleaned', + batchCleanResult: 'Batch clean submitted: {success} succeeded, {fail} failed. {detail}', + batchCleanSuccess: 'Batch clean submitted: {success} succeeded', + selectDocumentsToDelete: 'Please select documents to delete', + batchDeleteResult: 'Batch delete completed: {success} succeeded, {fail} failed. {detail}', + batchDeleteSuccess: 'Batch delete completed: {success} succeeded', + reselectFile: 'Please re-select a file for "{name}"', + recleanFailed: 'Re-clean failed', + recleanSubmitted: 'Re-clean submitted: {name}', + resyncFailed: 'Re-sync failed: {detail}', + resyncSubmitted: 'Re-sync submitted: {name}', + processingFile: 'Processing file...', + uploadFailed: 'File upload failed', + versionUploaded: 'Version "{file}" uploaded, clean queued', + uploadingProgress: 'Uploading {current}/{total}: {file}', + createDocumentFailed: 'Failed to create document', + uploadVersionFailed: 'Failed to upload version', + uploadCleanupFailed: 'Upload failed and empty document could not be removed ({detail})', + uploadSummary: 'Upload done: {success} succeeded, {fail} failed. {detail}', + uploadAllSuccess: 'Uploaded {count} file(s), clean tasks queued', + syncDifyFailed: 'Sync to Dify failed: {detail}', + syncDifyFailedGeneric: 'Sync to Dify failed', + syncSubmitted: 'Sync task submitted', + pathUploadBusy: 'Upload in progress, please wait', + selectGroupFirst: 'Please select a group first', + selectPathFiles: 'Please select at least one local folder or file', + createPathJobFailed: 'Failed to create path upload job', + pathStageFailed: 'Path file staging failed', + pathUploadDone: 'Path files uploaded and clean submitted', + deletePathFileConfirm: 'Delete path file "{path}"?', + deletePathFileFailed: 'Failed to delete path file', + pathRecordDeletedWithDoc: 'Path record deleted with document', + pathRecordDeleted: 'Path record deleted', + selectPathFilesToDelete: 'Please select files to delete', + batchDeletePathConfirm: 'Delete {count} selected path file(s)?', + batchDeletePathResult: 'Batch delete: {success} succeeded, {fail} failed. {detail}', + batchDeletePathSuccess: 'Batch delete: {success} succeeded', + retryPathFailed: 'Failed to retry files', + retryPathOne: 'Failed file resubmitted', + retryPathAll: 'Failed files resubmitted', + pathUploadProgress: 'Path upload: total {total}, pending {pending}, uploaded {uploaded}, failed {failed}', + deleteDocumentConfirm: 'Delete document "{name}"?', + batchDeleteDocumentsConfirm: 'Delete {count} selected document(s)? Dify documents will also be removed.', + markdownFailedWithReason: 'Clean failed, no Markdown yet. Reason: {reason}', + markdownFailedRetry: 'Clean failed, no Markdown yet. Please re-clean.', + markdownProcessing: 'Document is being cleaned, no Markdown yet.', + markdownPendingClean: 'Document pending clean, no Markdown yet.', + markdownNotGenerated: 'No Markdown generated for this document yet.', + }, + }, + 'zh-CN': { + status: { + draft: '待上传', uploaded: '已上传', processing: '清洗中', cleaned: '已清洗', ready: '已就绪', + synced: '已同步', syncing: '同步中', failed: '失败', queued: '排队中', running: '进行中', + success: '成功', cancelled: '已取消', idle: '未开始', done: '已完成', pendingClean: '待清洗', + pendingSync: '待同步', cleaning: '清洗中', uploading: '上传中', unknown: '未知状态', unnamedDocument: '未命名文档', + }, + workflow: { upload: '上传', clean: '清洗', sync: '同步' }, + failureModal: { + uploadData: '上传失败数据', cleanData: '清洗失败数据', syncData: '同步失败数据', generic: '失败数据', + stageUploadFailed: '上传失败', stageCleanFailed: '清洗失败', stageSyncFailed: '同步失败', + }, + errors: { + unreadableClean: '历史失败任务原因不可读,请重新点击“清洗数据”发起清洗', + unreadableSync: '历史同步失败原因不可读,请重新发起同步', + unreadableUpload: '历史上传失败原因不可读,请重新上传文件', + legacyCleanRecovered: '历史遗留清洗任务已人工回收,请重新点击“清洗数据”发起清洗', + sourceFileNotFound: '原始文件不存在,请重新上传后再清洗', + cleanTimeout: '文件清洗超时,请稍后重试;若多次失败,请检查源文件是否损坏', + duplicateFile: '上传失败,文件已存在', + apiRequestFailed: '知识库接口请求失败', + localFolder: '本地目录', + fileFallback: '文件{index}', + uploadFailed: '上传失败', + }, + msg: { + operationFailed: '操作失败', + loadGroupsFailed: '加载知识库分组失败', + loadDocumentsFailed: '加载文档列表失败', + loadJobsFailed: '加载任务列表失败', + readSourceFailed: '读取原始文件失败', + noVersion: '暂无版本', + readMarkdownFailed: '读取清洗后的 Markdown 失败', + saveMarkdownFailed: '保存 Markdown 失败', + markdownSaved: '清洗后的 Markdown 已保存', + deleteDocumentFailed: '删除文档失败', + documentDeleted: '文档已删除', + selectDocumentsToSync: '请先选择要批量同步的文档', + batchSyncResult: '批量同步任务已提交:成功 {success} 条,失败 {fail} 条。{detail}', + batchSyncSuccess: '批量同步任务已提交:共成功 {success} 条', + selectDocumentsToClean: '请先选择要清洗的文档', + noDocumentsToClean: '当前所选文档没有可重新清洗的项', + batchCleanResult: '批量清洗任务已提交:成功 {success} 条,失败 {fail} 条。{detail}', + batchCleanSuccess: '批量清洗任务已提交:共成功 {success} 条', + selectDocumentsToDelete: '请先选择要批量删除的文档', + batchDeleteResult: '批量删除完成:成功 {success} 条,失败 {fail} 条。{detail}', + batchDeleteSuccess: '批量删除完成:共成功 {success} 条', + reselectFile: '请重新为「{name}」选择文件后提交', + recleanFailed: '重新清洗失败', + recleanSubmitted: '已重新提交清洗:{name}', + resyncFailed: '重新同步失败:{detail}', + resyncSubmitted: '已重新提交同步:{name}', + processingFile: '开始处理文件...', + uploadFailed: '文件上传失败', + versionUploaded: '版本文件「{file}」上传成功,清洗已排队', + uploadingProgress: '正在上传 {current}/{total}: {file}', + createDocumentFailed: '创建文档失败', + uploadVersionFailed: '上传文档版本失败', + uploadCleanupFailed: '上传失败后未能自动清理空文档({detail})', + uploadSummary: '上传完成:成功 {success} 个,失败 {fail} 个。{detail}', + uploadAllSuccess: '成功上传 {count} 个文件,清洗任务已排队', + syncDifyFailed: '同步到 Dify 失败:{detail}', + syncDifyFailedGeneric: '同步到 Dify 失败', + syncSubmitted: '同步任务已提交,等待后台处理', + pathUploadBusy: '有文件正在上传请稍等再试~', + selectGroupFirst: '请先选择知识库分组', + selectPathFiles: '请先选择至少一个本地目录或文件', + createPathJobFailed: '创建上传路径任务失败', + pathStageFailed: '路径文件暂存失败', + pathUploadDone: '路径文件已逐个上传并提交清洗', + deletePathFileConfirm: '确认删除路径文件「{path}」吗?', + deletePathFileFailed: '删除路径上传文件失败', + pathRecordDeletedWithDoc: '已删除路径记录,并同步删除对应文档', + pathRecordDeleted: '已删除路径记录', + selectPathFilesToDelete: '请先选择要删除的文件', + batchDeletePathConfirm: '确认批量删除已选中的 {count} 条路径文件吗?', + batchDeletePathResult: '批量删除完成:成功 {success} 条,失败 {fail} 条。{detail}', + batchDeletePathSuccess: '批量删除完成:共成功 {success} 条', + retryPathFailed: '重试失败文件失败', + retryPathOne: '已重新提交该失败文件', + retryPathAll: '已重新提交失败文件', + pathUploadProgress: '路径上传进度:总计 {total} 条,待上传 {pending} 条,已上传 {uploaded} 条,失败 {failed} 条', + deleteDocumentConfirm: '确认删除文档「{name}」吗?', + batchDeleteDocumentsConfirm: '确认批量删除已选中的 {count} 条文档吗?会同步删除 Dify 对应文档。', + markdownFailedWithReason: '当前文档清洗失败,尚未生成 Markdown。失败原因:{reason}', + markdownFailedRetry: '当前文档清洗失败,尚未生成 Markdown,请重新清洗后重试', + markdownProcessing: '当前文档正在清洗中,暂未生成 Markdown,请稍后再试', + markdownPendingClean: '当前文档待清洗,暂未生成 Markdown,请先发起清洗', + markdownNotGenerated: '当前文档尚未生成 Markdown', + }, + }, + 'zh-TW': { + status: { + draft: '待上傳', uploaded: '已上傳', processing: '清洗中', cleaned: '已清洗', ready: '已就緒', + synced: '已同步', syncing: '同步中', failed: '失敗', queued: '排隊中', running: '進行中', + success: '成功', cancelled: '已取消', idle: '未開始', done: '已完成', pendingClean: '待清洗', + pendingSync: '待同步', cleaning: '清洗中', uploading: '上傳中', unknown: '未知狀態', unnamedDocument: '未命名文檔', + }, + workflow: { upload: '上傳', clean: '清洗', sync: '同步' }, + failureModal: { + uploadData: '上傳失敗數據', cleanData: '清洗失敗數據', syncData: '同步失敗數據', generic: '失敗數據', + stageUploadFailed: '上傳失敗', stageCleanFailed: '清洗失敗', stageSyncFailed: '同步失敗', + }, + errors: { + unreadableClean: '歷史失敗任務原因不可讀,請重新點擊「清洗數據」發起清洗', + unreadableSync: '歷史同步失敗原因不可讀,請重新發起同步', + unreadableUpload: '歷史上傳失敗原因不可讀,請重新上傳文件', + legacyCleanRecovered: '歷史遺留清洗任務已人工回收,請重新點擊「清洗數據」發起清洗', + sourceFileNotFound: '原始文件不存在,請重新上傳後再清洗', + cleanTimeout: '文件清洗超時,請稍後重試;若多次失敗,請檢查源文件是否損壞', + duplicateFile: '上傳失敗,文件已存在', + apiRequestFailed: '知識庫接口請求失敗', + localFolder: '本地目錄', + fileFallback: '文件{index}', + uploadFailed: '上傳失敗', + }, + msg: { + operationFailed: '操作失敗', + loadGroupsFailed: '載入知識庫分組失敗', + loadDocumentsFailed: '載入文檔列表失敗', + loadJobsFailed: '載入任務列表失敗', + readSourceFailed: '讀取原始文件失敗', + noVersion: '暫無版本', + readMarkdownFailed: '讀取清洗後的 Markdown 失敗', + saveMarkdownFailed: '保存 Markdown 失敗', + markdownSaved: '清洗後的 Markdown 已保存', + deleteDocumentFailed: '刪除文檔失敗', + documentDeleted: '文檔已刪除', + selectDocumentsToSync: '請先選擇要批量同步的文檔', + batchSyncResult: '批量同步任務已提交:成功 {success} 條,失敗 {fail} 條。{detail}', + batchSyncSuccess: '批量同步任務已提交:共成功 {success} 條', + selectDocumentsToClean: '請先選擇要清洗的文檔', + noDocumentsToClean: '當前所選文檔沒有可重新清洗的項', + batchCleanResult: '批量清洗任務已提交:成功 {success} 條,失敗 {fail} 條。{detail}', + batchCleanSuccess: '批量清洗任務已提交:共成功 {success} 條', + selectDocumentsToDelete: '請先選擇要批量刪除的文檔', + batchDeleteResult: '批量刪除完成:成功 {success} 條,失敗 {fail} 條。{detail}', + batchDeleteSuccess: '批量刪除完成:共成功 {success} 條', + reselectFile: '請重新為「{name}」選擇文件後提交', + recleanFailed: '重新清洗失敗', + recleanSubmitted: '已重新提交清洗:{name}', + resyncFailed: '重新同步失敗:{detail}', + resyncSubmitted: '已重新提交同步:{name}', + processingFile: '開始處理文件...', + uploadFailed: '文件上傳失敗', + versionUploaded: '版本文件「{file}」上傳成功,清洗已排隊', + uploadingProgress: '正在上傳 {current}/{total}: {file}', + createDocumentFailed: '創建文檔失敗', + uploadVersionFailed: '上傳文檔版本失敗', + uploadCleanupFailed: '上傳失敗後未能自動清理空文檔({detail})', + uploadSummary: '上傳完成:成功 {success} 個,失敗 {fail} 個。{detail}', + uploadAllSuccess: '成功上傳 {count} 個文件,清洗任務已排隊', + syncDifyFailed: '同步到 Dify 失敗:{detail}', + syncDifyFailedGeneric: '同步到 Dify 失敗', + syncSubmitted: '同步任務已提交,等待後台處理', + pathUploadBusy: '有文件正在上傳請稍等再試~', + selectGroupFirst: '請先選擇知識庫分組', + selectPathFiles: '請先選擇至少一個本地目錄或文件', + createPathJobFailed: '創建上傳路徑任務失敗', + pathStageFailed: '路徑文件暫存失敗', + pathUploadDone: '路徑文件已逐個上傳並提交清洗', + deletePathFileConfirm: '確認刪除路徑文件「{path}」嗎?', + deletePathFileFailed: '刪除路徑上傳文件失敗', + pathRecordDeletedWithDoc: '已刪除路徑記錄,並同步刪除對應文檔', + pathRecordDeleted: '已刪除路徑記錄', + selectPathFilesToDelete: '請先選擇要刪除的文件', + batchDeletePathConfirm: '確認批量刪除已選中的 {count} 條路徑文件嗎?', + batchDeletePathResult: '批量刪除完成:成功 {success} 條,失敗 {fail} 條。{detail}', + batchDeletePathSuccess: '批量刪除完成:共成功 {success} 條', + retryPathFailed: '重試失敗文件失敗', + retryPathOne: '已重新提交該失敗文件', + retryPathAll: '已重新提交失敗文件', + pathUploadProgress: '路徑上傳進度:總計 {total} 條,待上傳 {pending} 條,已上傳 {uploaded} 條,失敗 {failed} 條', + deleteDocumentConfirm: '確認刪除文檔「{name}」嗎?', + batchDeleteDocumentsConfirm: '確認批量刪除已選中的 {count} 條文檔嗎?會同步刪除 Dify 對應文檔。', + markdownFailedWithReason: '當前文檔清洗失敗,尚未生成 Markdown。失敗原因:{reason}', + markdownFailedRetry: '當前文檔清洗失敗,尚未生成 Markdown,請重新清洗後重試', + markdownProcessing: '當前文檔正在清洗中,暫未生成 Markdown,請稍後再試', + markdownPendingClean: '當前文檔待清洗,暫未生成 Markdown,請先發起清洗', + markdownNotGenerated: '當前文檔尚未生成 Markdown', + }, + }, + th: { + status: { + draft: 'รออัปโหลด', uploaded: 'อัปโหลดแล้ว', processing: 'กำลังทำความสะอาด', cleaned: 'ทำความสะอาดแล้ว', ready: 'พร้อม', + synced: 'ซิงค์แล้ว', syncing: 'กำลังซิงค์', failed: 'ล้มเหลว', queued: 'อยู่ในคิว', running: 'กำลังดำเนินการ', + success: 'สำเร็จ', cancelled: 'ยกเลิกแล้ว', idle: 'ยังไม่เริ่ม', done: 'เสร็จสิ้น', pendingClean: 'รอทำความสะอาด', + pendingSync: 'รอซิงค์', cleaning: 'กำลังทำความสะอาด', uploading: 'กำลังอัปโหลด', unknown: 'สถานะไม่ทราบ', unnamedDocument: 'เอกสารไม่มีชื่อ', + }, + workflow: { upload: 'อัปโหลด', clean: 'ทำความสะอาด', sync: 'ซิงค์' }, + failureModal: { + uploadData: 'ข้อมูลอัปโหลดล้มเหลว', cleanData: 'ข้อมูลทำความสะอาดล้มเหลว', syncData: 'ข้อมูลซิงค์ล้มเหลว', generic: 'ข้อมูลล้มเหลว', + stageUploadFailed: 'อัปโหลดล้มเหลว', stageCleanFailed: 'ทำความสะอาดล้มเหลว', stageSyncFailed: 'ซิงค์ล้มเหลว', + }, + errors: { + unreadableClean: 'ไม่สามารถอ่านสาเหตุความล้มเหลวในอดีตได้ กด "ทำความสะอาดข้อมูล" เพื่อลองใหม่', + unreadableSync: 'ไม่สามารถอ่านสาเหตุซิงค์ล้มเหลวในอดีตได้ โปรดซิงค์ใหม่', + unreadableUpload: 'ไม่สามารถอ่านสาเหตุอัปโหลดล้มเหลวในอดีตได้ โปรดอัปโหลดใหม่', + legacyCleanRecovered: 'งานทำความสะอาดเก่าถูกกู้คืนด้วยตนเอง กด "ทำความสะอาดข้อมูล" เพื่อลองใหม่', + sourceFileNotFound: 'ไม่พบไฟล์ต้นฉบับ โปรดอัปโหลดใหม่ก่อนทำความสะอาด', + cleanTimeout: 'ทำความสะอาดหมดเวลา ลองใหม่ภายหลังหรือตรวจสอบไฟล์ต้นฉบับ', + duplicateFile: 'อัปโหลดล้มเหลว: มีไฟล์นี้อยู่แล้ว', + apiRequestFailed: 'คำขอ API คลังความรู้ล้มเหลว', + localFolder: 'โฟลเดอร์ในเครื่อง', + fileFallback: 'ไฟล์ {index}', + uploadFailed: 'อัปโหลดล้มเหลว', + }, + msg: { + operationFailed: 'ดำเนินการล้มเหลว', + loadGroupsFailed: 'โหลดกลุ่มล้มเหลว', + loadDocumentsFailed: 'โหลดเอกสารล้มเหลว', + loadJobsFailed: 'โหลดงานล้มเหลว', + readSourceFailed: 'อ่านไฟล์ต้นฉบับล้มเหลว', + noVersion: 'ไม่มีเวอร์ชัน', + readMarkdownFailed: 'อ่าน Markdown ที่ทำความสะอาดแล้วล้มเหลว', + saveMarkdownFailed: 'บันทึก Markdown ล้มเหลว', + markdownSaved: 'บันทึก Markdown ที่ทำความสะอาดแล้ว', + deleteDocumentFailed: 'ลบเอกสารล้มเหลว', + documentDeleted: 'ลบเอกสารแล้ว', + selectDocumentsToSync: 'โปรดเลือกเอกสารที่จะซิงค์เป็นชุด', + batchSyncResult: 'ส่งซิงค์เป็นชุด: สำเร็จ {success}, ล้มเหลว {fail}. {detail}', + batchSyncSuccess: 'ส่งซิงค์เป็นชุด: สำเร็จ {success}', + selectDocumentsToClean: 'โปรดเลือกเอกสารที่จะทำความสะอาด', + noDocumentsToClean: 'เอกสารที่เลือกไม่มีรายการที่ทำความสะอาดได้', + batchCleanResult: 'ส่งทำความสะอาดเป็นชุด: สำเร็จ {success}, ล้มเหลว {fail}. {detail}', + batchCleanSuccess: 'ส่งทำความสะอาดเป็นชุด: สำเร็จ {success}', + selectDocumentsToDelete: 'โปรดเลือกเอกสารที่จะลบเป็นชุด', + batchDeleteResult: 'ลบเป็นชุดเสร็จ: สำเร็จ {success}, ล้มเหลว {fail}. {detail}', + batchDeleteSuccess: 'ลบเป็นชุดเสร็จ: สำเร็จ {success}', + reselectFile: 'โปรดเลือกไฟล์ใหม่สำหรับ "{name}"', + recleanFailed: 'ทำความสะอาดใหม่ล้มเหลว', + recleanSubmitted: 'ส่งทำความสะอาดใหม่: {name}', + resyncFailed: 'ซิงค์ใหม่ล้มเหลว: {detail}', + resyncSubmitted: 'ส่งซิงค์ใหม่: {name}', + processingFile: 'เริ่มประมวลผลไฟล์...', + uploadFailed: 'อัปโหลดไฟล์ล้มเหลว', + versionUploaded: 'อัปโหลดเวอร์ชัน "{file}" แล้ว งานทำความสะอาดอยู่ในคิว', + uploadingProgress: 'กำลังอัปโหลด {current}/{total}: {file}', + createDocumentFailed: 'สร้างเอกสารล้มเหลว', + uploadVersionFailed: 'อัปโหลดเวอร์ชันเอกสารล้มเหลว', + uploadCleanupFailed: 'อัปโหลดล้มเหลวและลบเอกสารว่างไม่ได้ ({detail})', + uploadSummary: 'อัปโหลดเสร็จ: สำเร็จ {success}, ล้มเหลว {fail}. {detail}', + uploadAllSuccess: 'อัปโหลด {count} ไฟล์สำเร็จ งานทำความสะอาดอยู่ในคิว', + syncDifyFailed: 'ซิงค์ไป Dify ล้มเหลว: {detail}', + syncDifyFailedGeneric: 'ซิงค์ไป Dify ล้มเหลว', + syncSubmitted: 'ส่งงานซิงค์แล้ว', + pathUploadBusy: 'กำลังอัปโหลด โปรดรอสักครู่', + selectGroupFirst: 'โปรดเลือกกลุ่มก่อน', + selectPathFiles: 'โปรดเลือกโฟลเดอร์หรือไฟล์ในเครื่องอย่างน้อยหนึ่งรายการ', + createPathJobFailed: 'สร้างงานอัปโหลด path ล้มเหลว', + pathStageFailed: 'จัดเก็บไฟล์ path ชั่วคราวล้มเหลว', + pathUploadDone: 'อัปโหลดไฟล์ path และส่งทำความสะอาดแล้ว', + deletePathFileConfirm: 'ลบไฟล์ path "{path}"?', + deletePathFileFailed: 'ลบไฟล์ path ล้มเหลว', + pathRecordDeletedWithDoc: 'ลบบันทึก path และเอกสารที่เกี่ยวข้องแล้ว', + pathRecordDeleted: 'ลบบันทึก path แล้ว', + selectPathFilesToDelete: 'โปรดเลือกไฟล์ที่จะลบ', + batchDeletePathConfirm: 'ลบไฟล์ path ที่เลือก {count} รายการ?', + batchDeletePathResult: 'ลบเป็นชุด: สำเร็จ {success}, ล้มเหลว {fail}. {detail}', + batchDeletePathSuccess: 'ลบเป็นชุด: สำเร็จ {success}', + retryPathFailed: 'ลองใหม่ไฟล์ล้มเหลวไม่สำเร็จ', + retryPathOne: 'ส่งไฟล์ที่ล้มเหลวใหม่แล้ว', + retryPathAll: 'ส่งไฟล์ล้มเหลวทั้งหมดใหม่แล้ว', + pathUploadProgress: 'อัปโหลด path: ทั้งหมด {total}, รอ {pending}, อัปโหลด {uploaded}, ล้มเหลว {failed}', + deleteDocumentConfirm: 'ลบเอกสาร "{name}"?', + batchDeleteDocumentsConfirm: 'ลบเอกสารที่เลือก {count} รายการ? จะลบใน Dify ด้วย', + markdownFailedWithReason: 'ทำความสะอาดล้มเหลว ยังไม่มี Markdown. สาเหตุ: {reason}', + markdownFailedRetry: 'ทำความสะอาดล้มเหลว ยังไม่มี Markdown โปรดทำความสะอาดใหม่', + markdownProcessing: 'กำลังทำความสะอาด ยังไม่มี Markdown', + markdownPendingClean: 'รอทำความสะอาด ยังไม่มี Markdown', + markdownNotGenerated: 'ยังไม่มี Markdown สำหรับเอกสารนี้', + }, + }, +}; + +for (const [locale, patch] of Object.entries(patches)) { + const filePath = path.join(localesRoot, locale, 'kb.json'); + const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); + data.kbWorkspace = { ...data.kbWorkspace, ...patch }; + fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8'); + console.log(`Merged runtime i18n into ${locale}/kb.json`); +} diff --git a/frontend/scripts/merge-kb-workspace-i18n.mjs b/frontend/scripts/merge-kb-workspace-i18n.mjs new file mode 100644 index 00000000..0e9feefa --- /dev/null +++ b/frontend/scripts/merge-kb-workspace-i18n.mjs @@ -0,0 +1,629 @@ +/** + * scripts/merge-kb-workspace-i18n.mjs + * 合并 kbWorkspace 作业面 i18n 键至各语言 locales 下 kb.json + */ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const localesRoot = path.resolve(__dirname, '../src/locales'); + +const patches = { + en: { + sidebar: { + groupsTitle: 'Groups', + loadingGroups: 'Loading groups...', + emptyGroups: 'No knowledge base groups yet.', + noDescription: 'No description', + }, + summary: { + currentGroup: 'Current group', + documentCount: 'Documents', + pendingSync: 'Pending sync', + uploadFailed: 'Upload failures', + cleanFailed: 'Clean failures', + syncFailed: 'Sync failures', + }, + filters: { all: 'All', upload: 'Upload', clean: 'Clean', sync: 'Sync' }, + common: { + processing: 'Processing...', + delete: 'Delete', + close: 'Close', + cancel: 'Cancel', + retry: 'Retry', + remove: 'Remove', + none: 'None', + countUnit: 'items', + failureReason: 'Reason: {reason}', + perPage: 'Per page', + prevPage: 'Previous', + nextPage: 'Next', + }, + documents: { + title: 'Documents', + infoTip: 'Basic document entries in this group. Uploading files creates documents and starts cleaning automatically.', + uploadPath: 'Upload path', + uploadFile: 'Upload file', + batchClean: 'Clean data', + batchCleanCount: 'Clean data ({count})', + batchSync: 'Batch sync', + batchSyncCount: 'Batch sync ({count})', + batchDelete: 'Batch delete', + batchDeleteCount: 'Batch delete ({count})', + historyBatches: 'History batches', + searchPlaceholder: 'Search by file name', + clearSearch: 'Clear search', + selectGroup: 'Please select a knowledge base group.', + loadingDocuments: 'Loading documents...', + emptyNoDocs: 'No documents in this group. Upload a file above to create the first record.', + emptyNoSearchMatch: 'No documents match the current search and filters.', + emptyNoFilterMatch: 'No documents match the current filters.', + versionCount: 'Versions: {count}', + currentVersion: 'Current: v{version}', + viewRecord: 'View history', + uploadVersion: 'Upload version', + syncDify: 'Sync to Dify', + syncingDify: 'Syncing...', + updatedAt: 'Updated: {time}', + selectedCount: 'Selected {selected} · Total {total}', + showingRange: 'Showing {start}-{end}', + pageInfo: 'Page {page} / {totalPages} · {total} items', + documentFallback: 'Document #{id}', + }, + pathUpload: { + progressTitle: 'Path upload progress', + uploading: 'Uploading', + completed: 'Completed', + batchHint: 'Recommended {batchSize} files per batch, auto-continue every {seconds}s.', + total: 'Total {count}', + pending: 'Pending {count}', + uploaded: 'Uploaded {count}', + failed: 'Failed {count}', + success: 'Success {count}', + pendingProcess: 'Pending {count}', + currentFile: 'Current file: {name}', + details: 'Upload details', + viewHistory: 'View history', + retryFailedFiles: 'Retry failed files', + retryAllFailed: 'Retry all failed files', + selectAllFiltered: 'Select all filtered', + deselectAllFiltered: 'Deselect all', + selectAll: 'Select all', + deselectAll: 'Deselect all', + batchLabel: 'Batch #{id}', + createdAt: 'Created: {time}', + finishedAt: ' · Finished: {time}', + noBatchMessage: 'No batch description', + batchDelete: 'Batch delete', + batchDeleteCount: 'Batch delete ({count})', + deleting: 'Deleting...', + emptyHistory: 'No path upload history yet.', + }, + recordModal: { + title: 'Document history', + viewing: 'Viewing: {name}', + loading: 'Loading document history...', + versionsTitle: 'Versions', + versionsCount: '{count} items', + versionsEmpty: 'No versions yet. Upload a version to see it here.', + syncTitle: 'Dify sync records', + syncEmpty: 'No Dify sync records. Click "Sync to Dify" to create one.', + versionLabel: 'Version: {id}', + sizeBytes: 'Size: {size} bytes', + }, + markdownModal: { + readingVersion: 'Loading current version...', + previewText: 'Preview text', + cleanMarkdown: 'Cleaned Markdown', + loading: 'Loading cleaned Markdown...', + placeholder: 'No Markdown yet. Paste or edit content here.', + saving: 'Saving...', + save: 'Save Markdown', + editorTitle: 'Markdown editor', + }, + sourceInfoModal: { + title: 'Source file info', + viewing: 'Viewing: {name}', + loading: 'Loading source file info...', + empty: 'No source file info. Upload a version to see it here.', + currentVersion: 'Current version', + opening: 'Opening...', + fileName: 'File: {name}', + fileSize: 'Size: {size}', + fileType: 'Type: {ext}', + }, + failureModal: { + summary: '{count} failure records in this group, {pageSize} per page.', + empty: 'No failure data.', + currentVersion: 'Current version:', + noVersion: 'No version', + resubmit: 'Resubmit', + reclean: 'Re-clean', + resync: 'Re-sync', + pageInfo: 'Page {page} / {totalPages}', + }, + pathUploadModal: { + title: 'Upload path', + subtitle: 'Select a local folder. Files are imported in batches and enter the cleaning workflow automatically.', + localPickerTitle: 'Local folder picker', + localPickerHint: 'You can add folders multiple times. Browsers cannot read arbitrary pasted paths.', + pickFolder: 'Select local folder', + pathListLabel: 'Path list', + pathListPlaceholder: 'Paths fill in after folder selection; paste notes for multiple paths if needed.', + pendingFiles: 'Pending files', + selectedRoots: 'Selected roots: {paths}', + noRoots: 'None', + pickFolderFirst: 'Select a local folder before confirming upload.', + confirmUpload: 'Confirm upload', + }, + pathUploadHistoryModal: { + title: 'Path upload history', + subtitle: 'View batch results, failed files, and retry options.', + }, + }, + 'zh-CN': { + sidebar: { + groupsTitle: '分组列表', + loadingGroups: '正在加载分组...', + emptyGroups: '暂无知识库分组。', + noDescription: '暂无描述', + }, + summary: { + currentGroup: '当前知识库分组', + documentCount: '文档数量', + pendingSync: '待同步数量', + uploadFailed: '上传失败数量', + cleanFailed: '清洗失败数量', + syncFailed: '同步失败数量', + }, + filters: { all: '全部', upload: '上传', clean: '清洗', sync: '同步' }, + common: { + processing: '处理中...', + delete: '删除', + close: '关闭', + cancel: '取消', + retry: '重试', + remove: '移除', + none: '暂无', + countUnit: '条', + failureReason: '失败原因:{reason}', + perPage: '每页', + prevPage: '上一页', + nextPage: '下一页', + }, + documents: { + title: '文档列表', + infoTip: '当前分组下的基础文档条目,上传文件后将自动创建文档并开始清洗流程。', + uploadPath: '上传路径', + uploadFile: '上传文件', + batchClean: '清洗数据', + batchCleanCount: '清洗数据({count})', + batchSync: '批量同步', + batchSyncCount: '批量同步({count})', + batchDelete: '批量删除', + batchDeleteCount: '批量删除({count})', + historyBatches: '历史批次', + searchPlaceholder: '按文件名称模糊搜索', + clearSearch: '清空搜索', + selectGroup: '请选择一个知识库分组。', + loadingDocuments: '正在加载文档...', + emptyNoDocs: '当前分组暂无文档,可直接在上方创建第一条文档记录。', + emptyNoSearchMatch: '当前搜索和筛选条件下暂无匹配文档。', + emptyNoFilterMatch: '当前筛选条件下暂无匹配文档。', + versionCount: '版本数:{count}', + currentVersion: ' · 当前版本:v{version} · ', + viewRecord: '查看记录', + uploadVersion: '上传版本', + syncDify: '同步 Dify', + syncingDify: '同步中...', + updatedAt: '更新时间:{time}', + selectedCount: '已选 {selected} 条 · 共 {total} 条', + showingRange: '当前显示 {start}-{end} 条', + pageInfo: '第 {page} / {totalPages} 页 · 共 {total} 条', + documentFallback: '文档 #{id}', + }, + pathUpload: { + progressTitle: '路径上传进度', + uploading: '上传中', + completed: '已完成', + batchHint: '建议每批 {batchSize} 条,间隔 {seconds} 秒自动继续。', + total: '总计 {count}', + pending: '待上传 {count}', + uploaded: '已上传 {count}', + failed: '失败 {count}', + success: '成功 {count}', + pendingProcess: '待处理 {count}', + currentFile: '当前文件:{name}', + details: '上传详情', + viewHistory: '查看历史', + retryFailedFiles: '重试失败文件', + retryAllFailed: '重试全部失败文件', + selectAllFiltered: '全选当前筛选', + deselectAllFiltered: '取消全选', + selectAll: '全选', + deselectAll: '取消全选', + batchLabel: '批次 #{id}', + createdAt: '创建时间:{time}', + finishedAt: ' · 完成时间:{time}', + noBatchMessage: '暂无批次说明', + batchDelete: '批量删除', + batchDeleteCount: '批量删除 ({count})', + deleting: '删除中...', + emptyHistory: '当前暂无上传路径历史批次。', + }, + recordModal: { + title: '文档记录', + viewing: '当前查看:{name}', + loading: '正在加载文档记录...', + versionsTitle: '版本记录', + versionsCount: '{count} 条', + versionsEmpty: '暂无版本记录,上传版本后会显示在这里。', + syncTitle: 'Dify 同步记录', + syncEmpty: '暂无 Dify 同步记录,手动点击“同步 Dify”后会显示在这里。', + versionLabel: '版本:{id}', + sizeBytes: '大小:{size} bytes', + }, + markdownModal: { + readingVersion: '正在读取当前版本...', + previewText: '预览文本', + cleanMarkdown: '清洗 Markdown', + loading: '正在加载清洗后的 Markdown...', + placeholder: '当前文档尚未生成 Markdown,可在此粘贴或编辑内容。', + saving: '保存中...', + save: '保存 Markdown', + editorTitle: 'Markdown 编辑器', + }, + sourceInfoModal: { + title: '源文件信息', + viewing: '当前查看:{name}', + loading: '正在加载源文件信息...', + empty: '暂无源文件信息,上传版本后会显示在这里。', + currentVersion: '当前版本', + opening: '正在打开...', + fileName: '文件名:{name}', + fileSize: '大小:{size}', + fileType: '类型:{ext}', + }, + failureModal: { + summary: '当前分组共 {count} 条失败记录,每页 {pageSize} 条。', + empty: '当前没有失败数据。', + currentVersion: '当前版本:', + noVersion: '暂无版本', + resubmit: '重新提交', + reclean: '重新清洗', + resync: '重新同步', + pageInfo: '第 {page} / {totalPages} 页', + }, + pathUploadModal: { + title: '上传路径', + subtitle: '选择本地目录后,系统会按批次将该路径下文件导入当前分组并自动进入清洗流程。', + localPickerTitle: '本地路径选择', + localPickerHint: '支持多次选择目录追加文件;当前浏览器安全限制下,手动粘贴任意本机路径不能直接读取文件内容。', + pickFolder: '选择本地目录', + pathListLabel: '路径清单', + pathListPlaceholder: '目录选择后会自动填充路径清单;如需记录多路径,可在此粘贴备注。', + pendingFiles: '待上传文件', + selectedRoots: '已选根路径:{paths}', + noRoots: '暂无', + pickFolderFirst: '请选择本地目录后再确认上传。', + confirmUpload: '确认上传', + }, + pathUploadHistoryModal: { + title: '上传路径历史批次', + subtitle: '查看每次路径上传的批次结果、失败文件与重试入口。', + }, + }, + 'zh-TW': { + sidebar: { + groupsTitle: '分組列表', + loadingGroups: '正在載入分組...', + emptyGroups: '暫無知識庫分組。', + noDescription: '暫無描述', + }, + summary: { + currentGroup: '當前知識庫分組', + documentCount: '文檔數量', + pendingSync: '待同步數量', + uploadFailed: '上傳失敗數量', + cleanFailed: '清洗失敗數量', + syncFailed: '同步失敗數量', + }, + filters: { all: '全部', upload: '上傳', clean: '清洗', sync: '同步' }, + common: { + processing: '處理中...', + delete: '刪除', + close: '關閉', + cancel: '取消', + retry: '重試', + remove: '移除', + none: '暫無', + countUnit: '條', + failureReason: '失敗原因:{reason}', + perPage: '每頁', + prevPage: '上一頁', + nextPage: '下一頁', + }, + documents: { + title: '文檔列表', + infoTip: '當前分組下的基礎文檔條目,上傳文件後將自動創建文檔並開始清洗流程。', + uploadPath: '上傳路徑', + uploadFile: '上傳文件', + batchClean: '清洗數據', + batchCleanCount: '清洗數據({count})', + batchSync: '批量同步', + batchSyncCount: '批量同步({count})', + batchDelete: '批量刪除', + batchDeleteCount: '批量刪除({count})', + historyBatches: '歷史批次', + searchPlaceholder: '按文件名稱模糊搜索', + clearSearch: '清空搜索', + selectGroup: '請選擇一個知識庫分組。', + loadingDocuments: '正在載入文檔...', + emptyNoDocs: '當前分組暫無文檔,可直接在上方創建第一條文檔記錄。', + emptyNoSearchMatch: '當前搜索和篩選條件下暫無匹配文檔。', + emptyNoFilterMatch: '當前篩選條件下暫無匹配文檔。', + versionCount: '版本數:{count}', + currentVersion: ' · 當前版本:v{version} · ', + viewRecord: '查看記錄', + uploadVersion: '上傳版本', + syncDify: '同步 Dify', + syncingDify: '同步中...', + updatedAt: '更新時間:{time}', + selectedCount: '已選 {selected} 條 · 共 {total} 條', + showingRange: '當前顯示 {start}-{end} 條', + pageInfo: '第 {page} / {totalPages} 頁 · 共 {total} 條', + documentFallback: '文檔 #{id}', + }, + pathUpload: { + progressTitle: '路徑上傳進度', + uploading: '上傳中', + completed: '已完成', + batchHint: '建議每批 {batchSize} 條,間隔 {seconds} 秒自動繼續。', + total: '總計 {count}', + pending: '待上傳 {count}', + uploaded: '已上傳 {count}', + failed: '失敗 {count}', + success: '成功 {count}', + pendingProcess: '待處理 {count}', + currentFile: '當前文件:{name}', + details: '上傳詳情', + viewHistory: '查看歷史', + retryFailedFiles: '重試失敗文件', + retryAllFailed: '重試全部失敗文件', + selectAllFiltered: '全選當前篩選', + deselectAllFiltered: '取消全選', + selectAll: '全選', + deselectAll: '取消全選', + batchLabel: '批次 #{id}', + createdAt: '創建時間:{time}', + finishedAt: ' · 完成時間:{time}', + noBatchMessage: '暫無批次說明', + batchDelete: '批量刪除', + batchDeleteCount: '批量刪除 ({count})', + deleting: '刪除中...', + emptyHistory: '當前暫無上傳路徑歷史批次。', + }, + recordModal: { + title: '文檔記錄', + viewing: '當前查看:{name}', + loading: '正在載入文檔記錄...', + versionsTitle: '版本記錄', + versionsCount: '{count} 條', + versionsEmpty: '暫無版本記錄,上傳版本後會顯示在這裡。', + syncTitle: 'Dify 同步記錄', + syncEmpty: '暫無 Dify 同步記錄,手動點擊「同步 Dify」後會顯示在這裡。', + versionLabel: '版本:{id}', + sizeBytes: '大小:{size} bytes', + }, + markdownModal: { + readingVersion: '正在讀取當前版本...', + previewText: '預覽文本', + cleanMarkdown: '清洗 Markdown', + loading: '正在載入清洗後的 Markdown...', + placeholder: '當前文檔尚未生成 Markdown,可在此粘貼或編輯內容。', + saving: '保存中...', + save: '保存 Markdown', + editorTitle: 'Markdown 編輯器', + }, + sourceInfoModal: { + title: '源文件信息', + viewing: '當前查看:{name}', + loading: '正在載入源文件信息...', + empty: '暫無源文件信息,上傳版本後會顯示在這裡。', + currentVersion: '當前版本', + opening: '正在打開...', + fileName: '文件名:{name}', + fileSize: '大小:{size}', + fileType: '類型:{ext}', + }, + failureModal: { + summary: '當前分組共 {count} 條失敗記錄,每頁 {pageSize} 條。', + empty: '當前沒有失敗數據。', + currentVersion: '當前版本:', + noVersion: '暫無版本', + resubmit: '重新提交', + reclean: '重新清洗', + resync: '重新同步', + pageInfo: '第 {page} / {totalPages} 頁', + }, + pathUploadModal: { + title: '上傳路徑', + subtitle: '選擇本地目錄後,系統會按批次將該路徑下文件導入當前分組並自動進入清洗流程。', + localPickerTitle: '本地路徑選擇', + localPickerHint: '支持多次選擇目錄追加文件;當前瀏覽器安全限制下,手動粘貼任意本機路徑不能直接讀取文件內容。', + pickFolder: '選擇本地目錄', + pathListLabel: '路徑清單', + pathListPlaceholder: '目錄選擇後會自動填充路徑清單;如需記錄多路徑,可在此粘貼備註。', + pendingFiles: '待上傳文件', + selectedRoots: '已選根路徑:{paths}', + noRoots: '暫無', + pickFolderFirst: '請選擇本地目錄後再確認上傳。', + confirmUpload: '確認上傳', + }, + pathUploadHistoryModal: { + title: '上傳路徑歷史批次', + subtitle: '查看每次路徑上傳的批次結果、失敗文件與重試入口。', + }, + }, + th: { + sidebar: { + groupsTitle: 'รายการกลุ่ม', + loadingGroups: 'กำลังโหลดกลุ่ม...', + emptyGroups: 'ยังไม่มีกลุ่มคลังความรู้', + noDescription: 'ไม่มีคำอธิบาย', + }, + summary: { + currentGroup: 'กลุ่มปัจจุบัน', + documentCount: 'จำนวนเอกสาร', + pendingSync: 'รอซิงค์', + uploadFailed: 'อัปโหลดล้มเหลว', + cleanFailed: 'ทำความสะอาดล้มเหลว', + syncFailed: 'ซิงค์ล้มเหลว', + }, + filters: { all: 'ทั้งหมด', upload: 'อัปโหลด', clean: 'ทำความสะอาด', sync: 'ซิงค์' }, + common: { + processing: 'กำลังดำเนินการ...', + delete: 'ลบ', + close: 'ปิด', + cancel: 'ยกเลิก', + retry: 'ลองใหม่', + remove: 'นำออก', + none: 'ไม่มี', + countUnit: 'รายการ', + failureReason: 'สาเหตุ: {reason}', + perPage: 'ต่อหน้า', + prevPage: 'ก่อนหน้า', + nextPage: 'ถัดไป', + }, + documents: { + title: 'รายการเอกสาร', + infoTip: 'รายการเอกสารพื้นฐานในกลุ่มนี้ การอัปโหลดไฟล์จะสร้างเอกสารและเริ่มทำความสะอาดอัตโนมัติ', + uploadPath: 'อัปโหลดจาก path', + uploadFile: 'อัปโหลดไฟล์', + batchClean: 'ทำความสะอาดข้อมูล', + batchCleanCount: 'ทำความสะอาดข้อมูล ({count})', + batchSync: 'ซิงค์เป็นชุด', + batchSyncCount: 'ซิงค์เป็นชุด ({count})', + batchDelete: 'ลบเป็นชุด', + batchDeleteCount: 'ลบเป็นชุด ({count})', + historyBatches: 'ประวัติ batch', + searchPlaceholder: 'ค้นหาตามชื่อไฟล์', + clearSearch: 'ล้างการค้นหา', + selectGroup: 'โปรดเลือกกลุ่มคลังความรู้', + loadingDocuments: 'กำลังโหลดเอกสาร...', + emptyNoDocs: 'ยังไม่มีเอกสารในกลุ่มนี้ อัปโหลดไฟล์ด้านบนเพื่อสร้างรายการแรก', + emptyNoSearchMatch: 'ไม่พบเอกสารที่ตรงกับการค้นหาและตัวกรอง', + emptyNoFilterMatch: 'ไม่พบเอกสารที่ตรงกับตัวกรอง', + versionCount: 'เวอร์ชัน: {count}', + currentVersion: ' · เวอร์ชันปัจจุบัน: v{version} · ', + viewRecord: 'ดูประวัติ', + uploadVersion: 'อัปโหลดเวอร์ชัน', + syncDify: 'ซิงค์ไป Dify', + syncingDify: 'กำลังซิงค์...', + updatedAt: 'อัปเดต: {time}', + selectedCount: 'เลือก {selected} · ทั้งหมด {total}', + showingRange: 'แสดง {start}-{end}', + pageInfo: 'หน้า {page} / {totalPages} · {total} รายการ', + documentFallback: 'เอกสาร #{id}', + }, + pathUpload: { + progressTitle: 'ความคืบหน้าการอัปโหลด path', + uploading: 'กำลังอัปโหลด', + completed: 'เสร็จสิ้น', + batchHint: 'แนะนำ {batchSize} ไฟล์ต่อ batch ทำต่ออัตโนมัติทุก {seconds} วินาที', + total: 'ทั้งหมด {count}', + pending: 'รออัปโหลด {count}', + uploaded: 'อัปโหลดแล้ว {count}', + failed: 'ล้มเหลว {count}', + success: 'สำเร็จ {count}', + pendingProcess: 'รอดำเนินการ {count}', + currentFile: 'ไฟล์ปัจจุบัน: {name}', + details: 'รายละเอียดการอัปโหลด', + viewHistory: 'ดูประวัติ', + retryFailedFiles: 'ลองใหม่ไฟล์ที่ล้มเหลว', + retryAllFailed: 'ลองใหม่ไฟล์ล้มเหลวทั้งหมด', + selectAllFiltered: 'เลือกทั้งหมดที่กรอง', + deselectAllFiltered: 'ยกเลิกการเลือก', + selectAll: 'เลือกทั้งหมด', + deselectAll: 'ยกเลิกการเลือก', + batchLabel: 'Batch #{id}', + createdAt: 'สร้างเมื่อ: {time}', + finishedAt: ' · เสร็จเมื่อ: {time}', + noBatchMessage: 'ไม่มีคำอธิบาย batch', + batchDelete: 'ลบเป็นชุด', + batchDeleteCount: 'ลบเป็นชุด ({count})', + deleting: 'กำลังลบ...', + emptyHistory: 'ยังไม่มีประวัติการอัปโหลด path', + }, + recordModal: { + title: 'ประวัติเอกสาร', + viewing: 'กำลังดู: {name}', + loading: 'กำลังโหลดประวัติเอกสาร...', + versionsTitle: 'เวอร์ชัน', + versionsCount: '{count} รายการ', + versionsEmpty: 'ยังไม่มีเวอร์ชัน อัปโหลดเวอร์ชันเพื่อดูที่นี่', + syncTitle: 'บันทึกซิงค์ Dify', + syncEmpty: 'ยังไม่มีบันทึกซิงค์ Dify คลิก "ซิงค์ไป Dify" เพื่อสร้าง', + versionLabel: 'เวอร์ชัน: {id}', + sizeBytes: 'ขนาด: {size} bytes', + }, + markdownModal: { + readingVersion: 'กำลังโหลดเวอร์ชันปัจจุบัน...', + previewText: 'ข้อความตัวอย่าง', + cleanMarkdown: 'Markdown ที่ทำความสะอาดแล้ว', + loading: 'กำลังโหลด Markdown...', + placeholder: 'ยังไม่มี Markdown วางหรือแก้ไขเนื้อหาได้ที่นี่', + saving: 'กำลังบันทึก...', + save: 'บันทึก Markdown', + editorTitle: 'ตัวแก้ไข Markdown', + }, + sourceInfoModal: { + title: 'ข้อมูลไฟล์ต้นฉบับ', + viewing: 'กำลังดู: {name}', + loading: 'กำลังโหลดข้อมูลไฟล์ต้นฉบับ...', + empty: 'ยังไม่มีข้อมูลไฟล์ต้นฉบับ อัปโหลดเวอร์ชันเพื่อดูที่นี่', + currentVersion: 'เวอร์ชันปัจจุบัน', + opening: 'กำลังเปิด...', + fileName: 'ไฟล์: {name}', + fileSize: 'ขนาด: {size}', + fileType: 'ประเภท: {ext}', + }, + failureModal: { + summary: 'กลุ่มนี้มี {count} รายการล้มเหลว {pageSize} รายการต่อหน้า', + empty: 'ไม่มีข้อมูลล้มเหลว', + currentVersion: 'เวอร์ชันปัจจุบัน:', + noVersion: 'ไม่มีเวอร์ชัน', + resubmit: 'ส่งใหม่', + reclean: 'ทำความสะอาดใหม่', + resync: 'ซิงค์ใหม่', + pageInfo: 'หน้า {page} / {totalPages}', + }, + pathUploadModal: { + title: 'อัปโหลด path', + subtitle: 'เลือกโฟลเดอร์ในเครื่อง ระบบจะนำเข้าไฟล์เป็น batch และเข้าสู่ workflow ทำความสะอาดอัตโนมัติ', + localPickerTitle: 'เลือกโฟลเดอร์ในเครื่อง', + localPickerHint: 'เลือกโฟลเดอร์ได้หลายครั้ง เบราว์เซอร์ไม่สามารถอ่าน path ที่วางเองได้', + pickFolder: 'เลือกโฟลเดอร์ในเครื่อง', + pathListLabel: 'รายการ path', + pathListPlaceholder: 'path จะเติมหลังเลือกโฟลเดอร์ วางหมายเหตุหลาย path ได้ที่นี่', + pendingFiles: 'ไฟล์รออัปโหลด', + selectedRoots: 'root ที่เลือก: {paths}', + noRoots: 'ไม่มี', + pickFolderFirst: 'โปรดเลือกโฟลเดอร์ในเครื่องก่อนยืนยันอัปโหลด', + confirmUpload: 'ยืนยันอัปโหลด', + }, + pathUploadHistoryModal: { + title: 'ประวัติ batch อัปโหลด path', + subtitle: 'ดูผลลัพธ์ batch ไฟล์ล้มเหลว และตัวเลือกลองใหม่', + }, + }, +}; + +for (const [locale, patch] of Object.entries(patches)) { + const filePath = path.join(localesRoot, locale, 'kb.json'); + const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); + data.kbWorkspace = { ...data.kbWorkspace, ...patch }; + fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8'); + console.log(`Merged kbWorkspace i18n into ${locale}/kb.json`); +} diff --git a/frontend/scripts/merge-schedule-form-i18n.mjs b/frontend/scripts/merge-schedule-form-i18n.mjs new file mode 100644 index 00000000..7f187dde --- /dev/null +++ b/frontend/scripts/merge-schedule-form-i18n.mjs @@ -0,0 +1,259 @@ +/** + * scripts/merge-schedule-form-i18n.mjs + * 合并排程创建/编辑弹窗与 Dify 快照相关文案至各语言 admin.json + */ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const localesRoot = path.resolve(__dirname, '../src/locales'); + +const patches = { + en: { + form: { + dsDbType: 'Database type', + dsHost: 'Host', + dsHostPlaceholder: 'e.g. 192.168.1.100 or ${SRM_SQLSERVER_HOST}', + dsPort: 'Port', + dsDatabase: 'Database', + dsDatabasePlaceholder: 'Database name', + dsUsername: 'Username', + dsPassword: 'Password', + dsPasswordPlaceholder: 'or ${ENV_VAR}', + dsDriver: 'ODBC driver', + dsEncrypt: 'Encrypt', + dsTrustCert: 'TrustServerCertificate', + defaultNo: 'Default (no)', + defaultYes: 'Default (yes)', + envVarHint: 'Values support {token} format and are resolved from environment variables at runtime (recommended for passwords).', + envVarToken: '${ENV_VAR_NAME}', + baseFetchSql: 'Base fetch SQL (base_fetch_sql) — SELECT + FROM + JOIN only, no WHERE', + fetchWhereConditions: 'WHERE clause (fetch_where_conditions) — edit to test different filters', + fetchOrderBy: 'Order by (fetch_order_by)', + detailSql: 'Detail SQL (detail_sql)', + writebackSql: 'Writeback SQL (writeback_sql)', + rowIdKey: 'Row ID key (row_id_key)', + logPrefix: 'Log prefix (log_prefix)', + aliasOrder: 'Field order (alias_order) — comma-separated', + detailAliasOrder: 'Detail field order (detail_alias_order) — comma-separated', + headerLabels: 'Header labels (header_labels) — JSON', + apiUrl: 'API URL', + apiMethod: 'HTTP method', + apiTimeoutSeconds: 'Timeout (seconds)', + apiHeaders: 'Request headers (Headers) — JSON', + apiBodyTemplate: 'Request body template (Body)', + agentLabel: 'Agent', + agentOptionId: ' (ID: {id})', + difySystemPrompt: 'Dify System Prompt', + difySystemPromptHint: 'Available when a Dify Agent is enabled. Saved as system_prompt in the Workflow; LLM nodes must reference this variable.', + difySystemPromptPlaceholder: + 'e.g. You are a material compliance assistant. Based on record test data, return JSON with dify_result (pass/fail/manual review) and dify_message.', + }, + difySnapshot: { + title: 'Dify execution snapshot (audit)', + agent: 'Agent', + agentId: ' (ID: {id})', + difyAppId: 'Dify App ID', + systemPrompt: 'System Prompt', + notConfigured: '(Not configured)', + notConfiguredUseDefault: '(Not configured; using Dify workflow default prompt)', + notEnabledTest: 'Dify was not enabled for this test', + notEnabledRun: 'Dify Agent was not enabled for this run', + }, + testRun: { + baseFetchSqlReadonly: 'Base fetch SQL (base_fetch_sql) — read-only', + limitRows: 'Row limit (limit)', + }, + }, + 'zh-CN': { + form: { + dsDbType: '数据库类型', + dsHost: '主机地址', + dsHostPlaceholder: '如 192.168.1.100 或 ${SRM_SQLSERVER_HOST}', + dsPort: '端口', + dsDatabase: '数据库', + dsDatabasePlaceholder: '数据库名', + dsUsername: '用户名', + dsPassword: '密码', + dsPasswordPlaceholder: '或 ${ENV_VAR}', + dsDriver: 'ODBC 驱动', + dsEncrypt: 'Encrypt', + dsTrustCert: 'TrustServerCertificate', + defaultNo: '默认 (no)', + defaultYes: '默认 (yes)', + envVarHint: '值支持 {token} 格式,运行时自动从环境变量解析(推荐密码使用此方式)', + envVarToken: '${环境变量名}', + baseFetchSql: '基础查询 SQL (base_fetch_sql) — SELECT + FROM + JOIN 部分,不含 WHERE', + fetchWhereConditions: 'WHERE 条件 (fetch_where_conditions) — 可修改以测试不同筛选条件', + fetchOrderBy: '排序 (fetch_order_by)', + detailSql: '明细 SQL (detail_sql)', + writebackSql: '回写 SQL (writeback_sql)', + rowIdKey: '主键字段 (row_id_key)', + logPrefix: '日志前缀 (log_prefix)', + aliasOrder: '字段顺序 (alias_order) — 逗号分隔', + detailAliasOrder: '明细字段顺序 (detail_alias_order) — 逗号分隔', + headerLabels: '表头标签 (header_labels) — JSON 格式', + apiUrl: 'API 地址', + apiMethod: '请求方法', + apiTimeoutSeconds: '超时(秒)', + apiHeaders: '请求头 (Headers) — JSON 格式', + apiBodyTemplate: '请求体模板 (Body)', + agentLabel: 'Agent', + agentOptionId: '(ID: {id})', + difySystemPrompt: 'Dify System Prompt', + difySystemPromptHint: + '仅在启用 Dify Agent 时可配置。保存后将作为 system_prompt 传入 Workflow;编排中 LLM 节点需引用该变量。', + difySystemPromptPlaceholder: + '例如:你是物料合规判定助手。根据 record 中的检测数据判定是否合格,仅返回 JSON:dify_result(合格/不合格/人工判定)与 dify_message。', + }, + difySnapshot: { + title: 'Dify 执行快照(审计)', + agent: 'Agent', + agentId: '(ID: {id})', + difyAppId: 'Dify App ID', + systemPrompt: 'System Prompt', + notConfigured: '(未配置)', + notConfiguredUseDefault: '(未配置,使用 Dify 编排内默认提示词)', + notEnabledTest: '本次测试未启用 Dify', + notEnabledRun: '本次执行未启用 Dify Agent', + }, + testRun: { + baseFetchSqlReadonly: '基础查询 SQL (base_fetch_sql) — 只读', + limitRows: '限制行数 (limit)', + }, + }, + 'zh-TW': { + form: { + dsDbType: '資料庫類型', + dsHost: '主機位址', + dsHostPlaceholder: '如 192.168.1.100 或 ${SRM_SQLSERVER_HOST}', + dsPort: '連接埠', + dsDatabase: '資料庫', + dsDatabasePlaceholder: '資料庫名稱', + dsUsername: '使用者名稱', + dsPassword: '密碼', + dsPasswordPlaceholder: '或 ${ENV_VAR}', + dsDriver: 'ODBC 驅動', + dsEncrypt: 'Encrypt', + dsTrustCert: 'TrustServerCertificate', + defaultNo: '預設 (no)', + defaultYes: '預設 (yes)', + envVarHint: '值支援 {token} 格式,執行時自動從環境變數解析(建議密碼使用此方式)', + envVarToken: '${環境變數名}', + baseFetchSql: '基礎查詢 SQL (base_fetch_sql) — SELECT + FROM + JOIN 部分,不含 WHERE', + fetchWhereConditions: 'WHERE 條件 (fetch_where_conditions) — 可修改以測試不同篩選條件', + fetchOrderBy: '排序 (fetch_order_by)', + detailSql: '明細 SQL (detail_sql)', + writebackSql: '回寫 SQL (writeback_sql)', + rowIdKey: '主鍵欄位 (row_id_key)', + logPrefix: '日誌前綴 (log_prefix)', + aliasOrder: '欄位順序 (alias_order) — 逗號分隔', + detailAliasOrder: '明細欄位順序 (detail_alias_order) — 逗號分隔', + headerLabels: '表頭標籤 (header_labels) — JSON 格式', + apiUrl: 'API 位址', + apiMethod: '請求方法', + apiTimeoutSeconds: '逾時(秒)', + apiHeaders: '請求標頭 (Headers) — JSON 格式', + apiBodyTemplate: '請求體模板 (Body)', + agentLabel: 'Agent', + agentOptionId: '(ID: {id})', + difySystemPrompt: 'Dify System Prompt', + difySystemPromptHint: + '僅在啟用 Dify Agent 時可配置。保存後將作為 system_prompt 傳入 Workflow;編排中 LLM 節點需引用該變數。', + difySystemPromptPlaceholder: + '例如:你是物料合規判定助手。根據 record 中的檢測資料判定是否合格,僅返回 JSON:dify_result(合格/不合格/人工判定)與 dify_message。', + }, + difySnapshot: { + title: 'Dify 執行快照(審計)', + agent: 'Agent', + agentId: '(ID: {id})', + difyAppId: 'Dify App ID', + systemPrompt: 'System Prompt', + notConfigured: '(未配置)', + notConfiguredUseDefault: '(未配置,使用 Dify 編排內預設提示詞)', + notEnabledTest: '本次測試未啟用 Dify', + notEnabledRun: '本次執行未啟用 Dify Agent', + }, + testRun: { + baseFetchSqlReadonly: '基礎查詢 SQL (base_fetch_sql) — 唯讀', + limitRows: '限制行數 (limit)', + }, + }, + th: { + form: { + dsDbType: 'ประเภทฐานข้อมูล', + dsHost: 'โฮสต์', + dsHostPlaceholder: 'เช่น 192.168.1.100 หรือ ${SRM_SQLSERVER_HOST}', + dsPort: 'พอร์ต', + dsDatabase: 'ฐานข้อมูล', + dsDatabasePlaceholder: 'ชื่อฐานข้อมูล', + dsUsername: 'ชื่อผู้ใช้', + dsPassword: 'รหัสผ่าน', + dsPasswordPlaceholder: 'หรือ ${ENV_VAR}', + dsDriver: 'ไดรเวอร์ ODBC', + dsEncrypt: 'Encrypt', + dsTrustCert: 'TrustServerCertificate', + defaultNo: 'ค่าเริ่มต้น (no)', + defaultYes: 'ค่าเริ่มต้น (yes)', + envVarHint: 'รองรับรูปแบบ {token} และจะถูกแก้จากตัวแปรสภาพแวดล้อมขณะรัน (แนะนำสำหรับรหัสผ่าน)', + envVarToken: '${ชื่อตัวแปรสภาพแวดล้อม}', + baseFetchSql: 'SQL ดึงข้อมูลพื้นฐาน (base_fetch_sql) — เฉพาะ SELECT + FROM + JOIN ไม่รวม WHERE', + fetchWhereConditions: 'เงื่อนไข WHERE (fetch_where_conditions) — แก้ไขเพื่อทดสอบตัวกรอง', + fetchOrderBy: 'เรียงลำดับ (fetch_order_by)', + detailSql: 'SQL รายละเอียด (detail_sql)', + writebackSql: 'SQL เขียนกลับ (writeback_sql)', + rowIdKey: 'คีย์แถว (row_id_key)', + logPrefix: 'คำนำหน้าบันทึก (log_prefix)', + aliasOrder: 'ลำดับฟิลด์ (alias_order) — คั่นด้วยจุลภาค', + detailAliasOrder: 'ลำดับฟิลด์รายละเอียด (detail_alias_order) — คั่นด้วยจุลภาค', + headerLabels: 'ป้ายหัวตาราง (header_labels) — JSON', + apiUrl: 'URL ของ API', + apiMethod: 'วิธี HTTP', + apiTimeoutSeconds: 'หมดเวลา (วินาที)', + apiHeaders: 'ส่วนหัวคำขอ (Headers) — JSON', + apiBodyTemplate: 'เทมเพลต body คำขอ (Body)', + agentLabel: 'Agent', + agentOptionId: ' (ID: {id})', + difySystemPrompt: 'Dify System Prompt', + difySystemPromptHint: + 'ใช้ได้เมื่อเปิดใช้ Dify Agent จะบันทึกเป็น system_prompt ใน Workflow; โหนด LLM ต้องอ้างอิงตัวแปรนี้', + difySystemPromptPlaceholder: + 'เช่น คุณเป็นผู้ช่วยตรวจสอบความสอดคล้องของวัสดุ จากข้อมูล record ให้คืน JSON: dify_result (ผ่าน/ไม่ผ่าน/ตรวจด้วยมือ) และ dify_message', + }, + difySnapshot: { + title: 'สแนปช็อตการทำงาน Dify (ตรวจสอบ)', + agent: 'Agent', + agentId: ' (ID: {id})', + difyAppId: 'Dify App ID', + systemPrompt: 'System Prompt', + notConfigured: '(ยังไม่ได้ตั้งค่า)', + notConfiguredUseDefault: '(ยังไม่ได้ตั้งค่า ใช้ prompt เริ่มต้นใน Dify workflow)', + notEnabledTest: 'การทดสอบนี้ไม่ได้เปิดใช้ Dify', + notEnabledRun: 'การรันนี้ไม่ได้เปิดใช้ Dify Agent', + }, + testRun: { + baseFetchSqlReadonly: 'SQL ดึงข้อมูลพื้นฐาน (base_fetch_sql) — อ่านอย่างเดียว', + limitRows: 'จำกัดจำนวนแถว (limit)', + }, + }, +}; + +function deepMerge(target, source) { + for (const [key, value] of Object.entries(source)) { + if (value && typeof value === 'object' && !Array.isArray(value)) { + target[key] = deepMerge(target[key] ?? {}, value); + } else { + target[key] = value; + } + } + return target; +} + +for (const [locale, patch] of Object.entries(patches)) { + const filePath = path.join(localesRoot, locale, 'admin.json'); + const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); + data.schedule = deepMerge(data.schedule ?? {}, patch); + fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8'); + console.log(`Updated ${filePath}`); +} diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 31cd9c13..79ec771a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,5 +1,8 @@ - diff --git a/frontend/src/features/admin/modules/schedules/components/ScheduleCreateEditModal.vue b/frontend/src/features/admin/modules/schedules/components/ScheduleCreateEditModal.vue new file mode 100644 index 00000000..377c6254 --- /dev/null +++ b/frontend/src/features/admin/modules/schedules/components/ScheduleCreateEditModal.vue @@ -0,0 +1,534 @@ + + + diff --git a/frontend/src/features/admin/modules/schedules/components/ScheduleOverviewPanel.vue b/frontend/src/features/admin/modules/schedules/components/ScheduleOverviewPanel.vue new file mode 100644 index 00000000..f9273c50 --- /dev/null +++ b/frontend/src/features/admin/modules/schedules/components/ScheduleOverviewPanel.vue @@ -0,0 +1,149 @@ +/** + * features/admin/modules/schedules/components/ScheduleOverviewPanel.vue + * 定时任务概览模式:统计卡片与任务卡片网格。 + * 依赖:schedules.context、lucide-vue-next。 + * 逻辑:inject admin;展示 schedules 列表与快捷操作。 + */ + + + diff --git a/frontend/src/features/admin/modules/schedules/components/SchedulePageHeader.vue b/frontend/src/features/admin/modules/schedules/components/SchedulePageHeader.vue new file mode 100644 index 00000000..3ea3da8b --- /dev/null +++ b/frontend/src/features/admin/modules/schedules/components/SchedulePageHeader.vue @@ -0,0 +1,46 @@ +/** + * features/admin/modules/schedules/components/SchedulePageHeader.vue + * 定时任务页顶栏:返回、标题、刷新。 + * 依赖:schedules.context、lucide-vue-next。 + * 逻辑:inject admin 上下文;概览/工作台模式切换标题与返回按钮。 + */ + + + diff --git a/frontend/src/features/admin/modules/schedules/components/ScheduleTestRunDialog.vue b/frontend/src/features/admin/modules/schedules/components/ScheduleTestRunDialog.vue new file mode 100644 index 00000000..a46c09c3 --- /dev/null +++ b/frontend/src/features/admin/modules/schedules/components/ScheduleTestRunDialog.vue @@ -0,0 +1,183 @@ + + +