From 6f8ecc32de1d179c8205ac6441cd1de10ce7ba6b Mon Sep 17 00:00:00 2001 From: ttommybot Date: Wed, 12 Aug 2026 14:58:58 +0800 Subject: [PATCH] fix: restore FAQ batch actions --- frontend/src/i18n/locales/en-US.ts | 8 +- frontend/src/i18n/locales/ko-KR.ts | 6 + frontend/src/i18n/locales/ru-RU.ts | 6 + frontend/src/i18n/locales/zh-CN.ts | 6 + .../components/FAQBatchActions.test.ts | 53 ++++++ .../knowledge/components/FAQBatchBar.vue | 145 +++++++++++++++ .../knowledge/components/FAQEntryManager.vue | 173 +++++++++--------- 7 files changed, 310 insertions(+), 87 deletions(-) create mode 100644 frontend/src/views/knowledge/components/FAQBatchActions.test.ts create mode 100644 frontend/src/views/knowledge/components/FAQBatchBar.vue diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 277faacf..9520b58b 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -2623,6 +2623,7 @@ export default { similarityThresholdLabel: 'Similarity Threshold', statusEnabled: 'Enabled', statusDisabled: 'Disabled', + statusEnableSuccess: 'FAQ entry enabled', statusDisableSuccess: 'FAQ entry disabled', statusUpdateFailed: 'Failed to update status', recommended: 'Recommend', @@ -2631,7 +2632,12 @@ export default { recommendedDisableSuccess: 'FAQ entry recommendation disabled', recommendedUpdateFailed: 'Failed to update recommendation status', batchUpdateTag: 'Batch Set Tags', - batchUpdateTagTip: 'Set tags for {count} selected entries' + batchUpdateTagTip: 'Set tags for {count} selected entries', + batchEnable: 'Enable selected', + batchDisable: 'Disable selected', + batchDelete: 'Delete selected', + confirmBatchDelete: 'Delete the selected {count} FAQ entries? This action cannot be undone.', + batchDeleteSuccess: 'Deleted {count} FAQ entries' }, faqImport: { title: 'Batch Import FAQ', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 4534f548..ba01cff6 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -3558,6 +3558,7 @@ export default { similarityThresholdLabel: '유사도 임계값', statusEnabled: '활성화됨', statusDisabled: '비활성화됨', + statusEnableSuccess: 'FAQ 항목이 활성화되었습니다', statusDisableSuccess: 'FAQ 항목이 비활성화되었습니다', statusUpdateFailed: '상태 업데이트 실패', recommended: '추천', @@ -3567,6 +3568,11 @@ export default { recommendedUpdateFailed: '추천 상태 업데이트 실패', batchUpdateTag: '일괄 태그 설정', batchUpdateTagTip: '{count}개 선택된 항목에 태그가 설정됩니다', + batchEnable: '일괄 활성화', + batchDisable: '일괄 비활성화', + batchDelete: '일괄 삭제', + confirmBatchDelete: '선택한 FAQ 항목 {count}개를 삭제하시겠습니까? 삭제 후에는 복구할 수 없습니다.', + batchDeleteSuccess: 'FAQ 항목 {count}개를 삭제했습니다', modes: { questionOnly: '표준 질문/유사 질문만', questionAnswer: '표준 질문 + 답변', diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index de45910e..ff8e4450 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -3558,6 +3558,7 @@ export default { similarityThresholdLabel: 'Порог сходства', statusEnabled: 'Включено', statusDisabled: 'Выключено', + statusEnableSuccess: 'Запись FAQ включена', statusDisableSuccess: 'Запись FAQ отключена', statusUpdateFailed: 'Не удалось обновить статус', recommended: 'Рекомендовать', @@ -3567,6 +3568,11 @@ export default { recommendedUpdateFailed: 'Не удалось обновить статус рекомендации', batchUpdateTag: 'Пакетная установка тегов', batchUpdateTagTip: 'Установить теги для {count} выбранных записей', + batchEnable: 'Включить выбранные', + batchDisable: 'Отключить выбранные', + batchDelete: 'Удалить выбранные', + confirmBatchDelete: 'Удалить выбранные записи FAQ ({count})? Это действие нельзя отменить.', + batchDeleteSuccess: 'Удалено записей FAQ: {count}', modes: { questionOnly: 'Только вопросы', questionAnswer: 'Вопрос + ответ', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index bcfae62f..9f5c200b 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -3558,6 +3558,7 @@ export default { similarityThresholdLabel: '相似度阈值', statusEnabled: '已启用', statusDisabled: '已禁用', + statusEnableSuccess: 'FAQ 条目已启用', statusDisableSuccess: 'FAQ 条目已禁用', statusUpdateFailed: '更新状态失败', recommended: '推荐', @@ -3567,6 +3568,11 @@ export default { recommendedUpdateFailed: '更新推荐状态失败', batchUpdateTag: '批量设置标签', batchUpdateTagTip: '将为 {count} 个选中的条目设置标签', + batchEnable: '批量启用', + batchDisable: '批量禁用', + batchDelete: '批量删除', + confirmBatchDelete: '确认删除选中的 {count} 个 FAQ 条目?删除后将无法恢复。', + batchDeleteSuccess: '已删除 {count} 个 FAQ 条目', modes: { questionOnly: '仅标准问/相似问', questionAnswer: '标准问 + 答案', diff --git a/frontend/src/views/knowledge/components/FAQBatchActions.test.ts b/frontend/src/views/knowledge/components/FAQBatchActions.test.ts new file mode 100644 index 00000000..727202d8 --- /dev/null +++ b/frontend/src/views/knowledge/components/FAQBatchActions.test.ts @@ -0,0 +1,53 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { readFileSync } from 'node:fs' + +const manager = readFileSync(new URL('./FAQEntryManager.vue', import.meta.url), 'utf8') +const batchBar = readFileSync(new URL('./FAQBatchBar.vue', import.meta.url), 'utf8') +const locales = [ + readFileSync(new URL('../../../i18n/locales/zh-CN.ts', import.meta.url), 'utf8'), + readFileSync(new URL('../../../i18n/locales/en-US.ts', import.meta.url), 'utf8'), + readFileSync(new URL('../../../i18n/locales/ko-KR.ts', import.meta.url), 'utf8'), + readFileSync(new URL('../../../i18n/locales/ru-RU.ts', import.meta.url), 'utf8'), +] + +test('FAQ 批量操作通过组件事件直接连接,不再依赖全局事件', () => { + assert.match(manager, /import FAQBatchBar from '\.\/FAQBatchBar\.vue'/) + assert.match(manager, / { + assert.match(batchBar, /v-if="count > 0 && \(canEdit \|\| canManage\)"/) + assert.match(batchBar, /v-if="canEdit && disabledCount > 0"/) + assert.match(batchBar, /v-if="canEdit && enabledCount > 0"/) + assert.match(batchBar, / canEdit\.value \|\| canManage\.value\)/) + assert.match(manager, /if \(!canSelectEntries\.value \|\| batchActionLoading\.value\) return/) +}) + +test('危险操作需要确认,所有批量请求都防止重复提交', () => { + assert.match(batchBar, /confirmBatchDelete/) + assert.match(batchBar, /@confirm="emit\('delete'\)"/) + assert.match(batchBar, /const actionLoading = computed/) + assert.match(manager, /const batchDeleteLoading = ref\(false\)/) + assert.match(manager, /const batchTagLoading = ref\(false\)/) + assert.match(manager, /const batchStatusAction = ref<'enable' \| 'disable' \| null>\(null\)/) + assert.match(manager, /finally \{\s*batchDeleteLoading\.value = false\s*\}/) + assert.match(manager, /finally \{\s*batchTagLoading\.value = false\s*\}/) + assert.match(manager, /finally \{\s*batchStatusAction\.value = null\s*\}/) +}) + +test('所有支持的语言都包含 FAQ 批量操作文案', () => { + for (const locale of locales) { + assert.match(locale, /batchEnable:/) + assert.match(locale, /batchDisable:/) + assert.match(locale, /batchDelete:/) + assert.match(locale, /confirmBatchDelete:/) + assert.match(locale, /batchDeleteSuccess:/) + } +}) diff --git a/frontend/src/views/knowledge/components/FAQBatchBar.vue b/frontend/src/views/knowledge/components/FAQBatchBar.vue new file mode 100644 index 00000000..496c43a9 --- /dev/null +++ b/frontend/src/views/knowledge/components/FAQBatchBar.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/frontend/src/views/knowledge/components/FAQEntryManager.vue b/frontend/src/views/knowledge/components/FAQEntryManager.vue index 8ef88177..1d29c9f7 100644 --- a/frontend/src/views/knowledge/components/FAQEntryManager.vue +++ b/frontend/src/views/knowledge/components/FAQEntryManager.vue @@ -231,7 +231,8 @@ -
+
@@ -252,7 +253,7 @@