diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts index 7e38807b..ca88b21f 100755 --- a/frontend/src/i18n/locales/en-US.ts +++ b/frontend/src/i18n/locales/en-US.ts @@ -678,6 +678,14 @@ export default { confirmBatchDeleteDocument: 'Delete {count} selected documents? This action cannot be undone.', batchDeleteSuccess: 'Deleted {count} documents', batchDeleteFailed: 'Batch delete failed', + batchTag: 'Batch Tag', + batchTagDialogHeading: 'Batch Tag', + batchTagSubtitle: 'Set tags for {count} selected documents (will replace existing tags)', + batchTagSelectedSection: 'Selected', + batchTagAvailableSection: 'Available', + batchTagNoSelected: 'None selected', + batchTagSuccess: 'Tags applied to {count} documents', + batchTagFailed: 'Batch tag failed', confirmBatchReparseDocument: 'Rebuild {count} selected documents? Existing content will be cleared and each document will be re-parsed.', confirmBatchReparse: 'Confirm and reparse', batchReparseSuccess: 'Submitted {count} rebuild tasks', diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts index 53cba3e3..2dea7ed6 100755 --- a/frontend/src/i18n/locales/ko-KR.ts +++ b/frontend/src/i18n/locales/ko-KR.ts @@ -681,6 +681,14 @@ export default { confirmBatchDeleteDocument: "선택한 {count}개 문서를 삭제하시겠습니까? 삭제 후 복구할 수 없습니다.", batchDeleteSuccess: "{count}개 문서가 삭제되었습니다", batchDeleteFailed: "일괄 삭제 실패", + batchTag: "일괄 태그", + batchTagDialogHeading: "일괄 태그 지정", + batchTagSubtitle: "선택한 {count}개 문서에 태그를 일괄 설정합니다 (기존 태그는 대체됩니다)", + batchTagSelectedSection: "선택된 태그", + batchTagAvailableSection: "선택 가능", + batchTagNoSelected: "선택 없음", + batchTagSuccess: "{count}개 문서에 태그가 적용되었습니다", + batchTagFailed: "일괄 태그 실패", confirmBatchReparseDocument: "선택한 {count}개 문서를 재구축하시겠습니까? 기존 내용이 삭제되고 각 문서가 다시 파싱됩니다.", confirmBatchReparse: "확인 후 재파싱", batchReparseSuccess: "재구축 작업 {count}개가 제출되었습니다", diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts index a94fbedf..231de94a 100755 --- a/frontend/src/i18n/locales/ru-RU.ts +++ b/frontend/src/i18n/locales/ru-RU.ts @@ -603,6 +603,14 @@ export default { confirmBatchDeleteDocument: 'Удалить {count} выбранных документов? Это действие нельзя отменить.', batchDeleteSuccess: 'Удалено документов: {count}', batchDeleteFailed: 'Ошибка пакетного удаления', + batchTag: 'Пакетная метка', + batchTagDialogHeading: 'Пакетное назначение меток', + batchTagSubtitle: 'Установить метки для {count} выбранных документов (заменит существующие метки)', + batchTagSelectedSection: 'Выбранные', + batchTagAvailableSection: 'Доступные', + batchTagNoSelected: 'Ничего не выбрано', + batchTagSuccess: 'Метки применены к {count} документам', + batchTagFailed: 'Ошибка пакетного назначения меток', confirmBatchReparseDocument: 'Пересобрать {count} выбранных документов? Существующее содержимое будет удалено, и каждый документ будет обработан заново.', confirmBatchReparse: 'Подтвердить и обработать заново', batchReparseSuccess: 'Отправлено задач пересборки: {count}', diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts index 90bb7b9d..b85d3e3b 100755 --- a/frontend/src/i18n/locales/zh-CN.ts +++ b/frontend/src/i18n/locales/zh-CN.ts @@ -679,6 +679,14 @@ export default { confirmBatchDeleteDocument: "确认删除选中的 {count} 个文档?删除后将无法恢复。", batchDeleteSuccess: "成功删除 {count} 个文档", batchDeleteFailed: "批量删除失败", + batchTag: "批量打标签", + batchTagDialogHeading: "批量打标签", + batchTagSubtitle: "为选中的 {count} 个文档统一设置标签(将替换文档原有标签)", + batchTagSelectedSection: "已选标签", + batchTagAvailableSection: "可选标签", + batchTagNoSelected: "暂未选择", + batchTagSuccess: "已为 {count} 个文档成功设置标签", + batchTagFailed: "批量打标签失败", confirmBatchReparseDocument: "确认重建选中的 {count} 个文档?现有内容将被清除并重新解析。", confirmBatchReparse: "确认并重新解析", batchReparseSuccess: "已提交 {count} 个重建任务", diff --git a/frontend/src/views/knowledge/KnowledgeBase.vue b/frontend/src/views/knowledge/KnowledgeBase.vue index f5ff7ad0..80d294a8 100644 --- a/frontend/src/views/knowledge/KnowledgeBase.vue +++ b/frontend/src/views/knowledge/KnowledgeBase.vue @@ -43,6 +43,7 @@ import DocumentCardView from './components/DocumentCardView.vue'; import DocumentBatchBar from './components/DocumentBatchBar.vue'; import KbUploadSourceDropdown from './components/KbUploadSourceDropdown.vue'; import TagEditDialog from './components/TagEditDialog.vue'; +import BatchTagDialog from './components/BatchTagDialog.vue'; import KbTagManageDrawer from './components/KbTagManageDrawer.vue'; import type { KnowledgeProcessOverrides } from '@/types/knowledgeProcess'; import { useUploadConfirmStore, type UploadConfirmResult } from '@/stores/uploadConfirm'; @@ -420,6 +421,8 @@ const selectedIds = ref>(new Set()); let lastSelectedIndex = -1; const batchDeleting = ref(false); const batchReparsing = ref(false); +const batchTagging = ref(false); +const batchTagDialogVisible = ref(false); // IDs submitted for async batch reparse; hold optimistic pending until the worker updates DB. const pendingReparseAck = ref>(new Set()); @@ -779,6 +782,11 @@ const openTagManageFromEditDialog = () => { tagManageDrawerVisible.value = true; }; +const openTagManageFromBatchDialog = () => { + batchTagDialogVisible.value = false; + tagManageDrawerVisible.value = true; +}; + const onTagManageChanged = (payload?: { deletedTagId?: string }) => { if (!kbId.value) return; void loadTags(kbId.value, true); @@ -1892,6 +1900,32 @@ const confirmBatchDelete = async () => { } }; +const handleBatchTag = () => { + if (batchDeleting.value || batchReparsing.value || batchTagging.value || selectedIds.value.size === 0) return; + batchTagDialogVisible.value = true; +}; + +const onBatchTagConfirm = async (tagIds: string[]) => { + const ids = Array.from(selectedIds.value); + const updateMap: Record = {}; + for (const id of ids) { + updateMap[id] = tagIds; + } + batchTagging.value = true; + try { + await updateKnowledgeTagBatch({ updates: updateMap }); + MessagePlugin.success(t('knowledgeBase.batchTagSuccess', { count: ids.length })); + clearSelection(); + batchMode.value = false; + loadKnowledgeFiles(kbId.value); + loadTags(kbId.value, true); + } catch (e: any) { + MessagePlugin.error(e?.message || t('knowledgeBase.batchTagFailed')); + } finally { + batchTagging.value = false; + } +}; + const confirmCancelParseKnowledge = async (item: KnowledgeCard) => { if (!item?.id) return; try { @@ -2337,8 +2371,9 @@ async function createNewSession(value: string): Promise {
+ :reparse-loading="batchReparsing" :tag-loading="batchTagging" :visible="batchMode || selectedIds.size > 0" + @cancel="handleBatchCancel" @delete="confirmBatchDelete" @reparse="confirmBatchReparse" + @batch-tag="handleBatchTag" />
@@ -2372,6 +2407,12 @@ async function createNewSession(value: string): Promise { @update:visible="tagEditDialogVisible = $event" @confirm="onTagEditConfirm" @tag-created="loadTags(kbId, true)" @open-manage="openTagManageFromEditDialog" /> + + + + + + +
+
+
+

{{ $t('knowledgeBase.batchTagSelectedSection') }}

+ + {{ $t('knowledgeBase.tagClearAction') }} + +
+
+ +
+

{{ $t('knowledgeBase.batchTagNoSelected') }}

+
+ +
+
+

{{ $t('knowledgeBase.batchTagAvailableSection') }}

+ + {{ $t('knowledgeBase.tagManageLink') }} + +
+ +
+ +
+
+ {{ searchQuery.trim() ? $t('knowledgeBase.tagEmptyResult') : $t('knowledgeBase.noTags') }} + + {{ $t('knowledgeBase.tagCreateAction') }} "{{ searchQuery.trim() }}" + +
+
+ +
+
+
+ + +
+ + + + + + + diff --git a/frontend/src/views/knowledge/components/DocumentBatchBar.vue b/frontend/src/views/knowledge/components/DocumentBatchBar.vue index 8dd30163..e1037c38 100644 --- a/frontend/src/views/knowledge/components/DocumentBatchBar.vue +++ b/frontend/src/views/knowledge/components/DocumentBatchBar.vue @@ -5,6 +5,7 @@ defineProps<{ count: number; deleteLoading?: boolean; reparseLoading?: boolean; + tagLoading?: boolean; // When true the bar stays visible even with 0 selections, so users can exit // batch mode from here without selecting anything first. visible?: boolean; @@ -14,6 +15,7 @@ const emit = defineEmits<{ (e: 'cancel'): void; (e: 'delete'): void; (e: 'reparse'): void; + (e: 'batchTag'): void; }>(); const { t } = useI18n(); @@ -35,17 +37,24 @@ const { t } = useI18n(); :confirm-btn="{ content: t('knowledgeBase.confirmBatchReparse'), theme: 'warning' }" :cancel-btn="{ content: t('common.cancel') }" placement="top" @confirm="emit('reparse')"> + :disabled="count === 0 || deleteLoading || reparseLoading || tagLoading" :loading="reparseLoading" @click.stop> {{ t('knowledgeBase.rebuildDocument') }} + + + {{ t('knowledgeBase.batchTag') }} + + + :disabled="count === 0 || deleteLoading || reparseLoading || tagLoading" :loading="deleteLoading" @click.stop> {{ t('knowledgeBase.batchDelete') }}