refactor(frontend): 前端重构 V3
This commit is contained in:
1 parent
8d8b40812d
commit
ec97ea8787
80 files changed
+6887
-3733
No files matched your search
@@ -0,0 +1,635 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/kb/components/KbWorkspaceOverlays.vue
|
||||
* 知识库作业面弹窗层:记录/Markdown/来源/失败/路径上传等。
|
||||
*/
|
||||
import { Upload, X } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import type { useKbWorkspace } from '../composables/useKbWorkspace';
|
||||
|
||||
defineProps<{
|
||||
kb: ReturnType<typeof useKbWorkspace>;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="kb.showRecordModal"
|
||||
class="dialog-overlay z-[55] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-5xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.recordModal.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.recordModal.viewing', { name: kb.documentDisplayName(kb.selectedDocument, kb.selectedDocumentId) }) }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeDocumentDetail"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.isRecordLoading" class="flex min-h-[360px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.recordModal.loading') }}
|
||||
</div>
|
||||
<div v-else class="space-y-6 overflow-y-auto pr-1">
|
||||
<div>
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h3 class="text-base font-semibold text-primary">{{ kb.t('kbWorkspace.recordModal.versionsTitle') }}</h3>
|
||||
<span class="text-xs text-muted">{{ kb.t('kbWorkspace.recordModal.versionsCount', { count: kb.selectedDocumentVersions.length }) }}</span>
|
||||
</div>
|
||||
<div v-if="kb.selectedDocumentVersions.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.recordModal.versionsEmpty') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="version in kb.selectedDocumentVersions"
|
||||
:key="version.id"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-primary">
|
||||
v{{ version.version_no }} · {{ version.source_file_name }}
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(version.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(version.status) }}
|
||||
</span>
|
||||
<span>{{ kb.t('kbWorkspace.recordModal.sizeBytes', { size: version.source_file_size ?? 0 }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.formatDateTime(version.created_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h3 class="text-base font-semibold text-primary">{{ kb.t('kbWorkspace.recordModal.syncTitle') }}</h3>
|
||||
<span class="text-xs text-muted">{{ kb.t('kbWorkspace.recordModal.versionsCount', { count: kb.selectedDocumentSyncRecords.length }) }}</span>
|
||||
</div>
|
||||
<div v-if="kb.selectedDocumentSyncRecords.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.recordModal.syncEmpty') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="record in kb.selectedDocumentSyncRecords"
|
||||
:key="record.id"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-primary">
|
||||
{{ record.dataset_name || record.dataset_id }} · {{ record.remote_document_name || record.remote_document_id }}
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(record.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(record.status) }}
|
||||
</span>
|
||||
<span>{{ kb.t('kbWorkspace.recordModal.versionLabel', { id: record.document_version_id }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.formatDateTime(record.updated_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.showMarkdownModal"
|
||||
class="dialog-overlay z-[60] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-5xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<h3 class="truncate text-lg font-semibold text-primary">{{ kb.markdownModalTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ kb.markdownVersionLabel || kb.t('kbWorkspace.markdownModal.readingVersion') }}
|
||||
<span class="ml-2 rounded-full bg-surface-soft px-2 py-0.5 text-xs text-muted">
|
||||
{{ kb.markdownKind === 'preview' ? kb.t('kbWorkspace.markdownModal.previewText') : kb.t('kbWorkspace.markdownModal.cleanMarkdown') }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeMarkdownModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="kb.markdownError"
|
||||
class="mb-4 text-sm text-rose-500"
|
||||
>
|
||||
{{ kb.markdownError }}
|
||||
</p>
|
||||
|
||||
<div v-if="kb.isMarkdownLoading" class="flex min-h-[420px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.markdownModal.loading') }}
|
||||
</div>
|
||||
<textarea
|
||||
v-else
|
||||
v-model="kb.markdownContent"
|
||||
spellcheck="false"
|
||||
class="min-h-[420px] w-full flex-1 rounded-2xl border border-default bg-surface-soft px-4 py-3 font-mono text-sm text-primary outline-none transition-colors focus:border-brand-300 focus:bg-surface"
|
||||
:placeholder="kb.t('kbWorkspace.markdownModal.placeholder')"
|
||||
/>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.closeMarkdownModal"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.close') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleSaveMarkdown"
|
||||
:disabled="kb.isMarkdownLoading || kb.isMarkdownSaving || !kb.markdownDocumentId"
|
||||
class="inline-flex items-center justify-center rounded-xl bg-brand-600px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{{ kb.isMarkdownSaving ? kb.t('kbWorkspace.markdownModal.saving') : kb.t('kbWorkspace.markdownModal.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.showSourceInfoModal"
|
||||
class="dialog-overlay z-[58] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-4xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<h3 class="truncate text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.sourceInfoModal.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.sourceInfoModal.viewing', { name: kb.documentDisplayName(kb.sourceInfoDocument, kb.sourceInfoDocumentId) }) }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeSourceInfoModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.isSourceInfoLoading" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.sourceInfoModal.loading') }}
|
||||
</div>
|
||||
<div v-else-if="kb.sourceInfoVersions.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.sourceInfoModal.empty') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="version in kb.sourceInfoVersions"
|
||||
:key="version.id"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.openOriginalSourceFile(version)"
|
||||
class="font-semibold text-primary underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
|
||||
>
|
||||
v{{ version.version_no }} · {{ version.source_file_name }}
|
||||
</button>
|
||||
<span
|
||||
v-if="version.is_current"
|
||||
class="inline-flex items-center rounded-full border border-brand-200 bg-brand-50 px-2.5 py-1 text-xs font-semibold text-brand-700 border-brand-200"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.sourceInfoModal.currentVersion') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="kb.openingSourceVersionId === version.id"
|
||||
class="text-xs text-muted"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.sourceInfoModal.opening') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(version.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(version.status) }}
|
||||
</span>
|
||||
<span>{{ kb.t('kbWorkspace.sourceInfoModal.fileName', { name: version.source_file_name }) }}</span>
|
||||
<span>{{ kb.t('kbWorkspace.sourceInfoModal.fileSize', { size: kb.formatFileSize(version.source_file_size) }) }}</span>
|
||||
<span v-if="version.source_file_ext">{{ kb.t('kbWorkspace.sourceInfoModal.fileType', { ext: version.source_file_ext }) }}</span>
|
||||
</div>
|
||||
<div v-if="version.error_message" class="mt-2 text-sm text-rose-500">
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: version.error_message }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.formatDateTime(version.created_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.closeSourceInfoModal"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.close') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.showFailureModal"
|
||||
class="dialog-overlay z-[65] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-6xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ kb.failureModalTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.failureModal.summary', { count: kb.failureModalItems.length, pageSize: kb.FAILURE_PAGE_SIZE }) }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeFailureModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.failureModalItems.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.failureModal.empty') }}
|
||||
</div>
|
||||
<div v-else class="space-y-4 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="item in kb.pagedFailureModalItems"
|
||||
:key="item.key"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<div class="max-w-full truncate text-base font-semibold text-primary">
|
||||
{{ kb.getDocumentDisplayTitle(item.document) }}
|
||||
</div>
|
||||
<span class="inline-flex items-center rounded-full border border-rose-200 bg-rose-50 px-2.5 py-1 text-xs font-semibold text-rose-700 border-rose-200">
|
||||
{{ item.stageLabel }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.failureModal.currentVersion') }}
|
||||
<span v-if="item.document.latest_version">
|
||||
v{{ item.document.latest_version.version_no }} · {{ item.document.latest_version.source_file_name }}
|
||||
</span>
|
||||
<span v-else>{{ kb.t('kbWorkspace.failureModal.noVersion') }}</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-rose-500">
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: item.errorMessage }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="shrink-0 text-right text-sm text-muted">
|
||||
{{ kb.formatDateTime(item.updatedAt) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@click="kb.handleRetryFailedItem(item, 'submit')"
|
||||
:disabled="kb.retryingFailureKey === `${item.key}-submit`"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-sky-200 px-3 py-2 text-xs font-medium text-sky-700 transition-colors hover:bg-sky-50 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{{ kb.retryingFailureKey === `${item.key}-submit` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.failureModal.resubmit') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleRetryFailedItem(item, 'clean')"
|
||||
:disabled="kb.retryingFailureKey === `${item.key}-clean` || !item.document.latest_version"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-amber-200 px-3 py-2 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-60 border-amber-200"
|
||||
>
|
||||
{{ kb.retryingFailureKey === `${item.key}-clean` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.failureModal.reclean') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleRetryFailedItem(item, 'sync')"
|
||||
:disabled="kb.retryingFailureKey === `${item.key}-sync` || !item.document.latest_version"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
|
||||
>
|
||||
{{ kb.retryingFailureKey === `${item.key}-sync` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.failureModal.resync') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.failureModalItems.length > kb.FAILURE_PAGE_SIZE"
|
||||
class="mt-5 flex items-center justify-between gap-3 border-t border-default pt-4 "
|
||||
>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.failureModal.pageInfo', { page: kb.failureModalPage, totalPages: kb.failureModalTotalPages }) }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="kb.failureModalPage = Math.max(1, kb.failureModalPage - 1)"
|
||||
:disabled="kb.failureModalPage === 1"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.prevPage') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.failureModalPage = Math.min(kb.failureModalTotalPages, kb.failureModalPage + 1)"
|
||||
:disabled="kb.failureModalPage === kb.failureModalTotalPages"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.nextPage') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.showPathUploadModal"
|
||||
class="dialog-overlay z-[66] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-4xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.pathUploadModal.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closePathUploadModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4 overflow-y-auto pr-1">
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-primary">{{ kb.t('kbWorkspace.pathUploadModal.localPickerTitle') }}</div>
|
||||
<div class="mt-1 text-xs text-muted">
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.localPickerHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.triggerPathUploadSelection"
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-brand-200 px-4 py-2.5 text-sm font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
|
||||
>
|
||||
<Upload class="h-4 w-4" />
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.pickFolder') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label-field block mb-2">{{ kb.t('kbWorkspace.pathUploadModal.pathListLabel') }}</label>
|
||||
<textarea
|
||||
v-model="kb.pathUploadDraftText"
|
||||
rows="5"
|
||||
class="input-field"
|
||||
:placeholder="kb.t('kbWorkspace.pathUploadModal.pathListPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-2 flex items-center justify-between gap-3">
|
||||
<div class="text-sm font-medium text-secondary">
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.pendingFiles') }}
|
||||
<span class="ml-2 text-xs text-muted">{{ kb.t('kbWorkspace.recordModal.versionsCount', { count: kb.pathUploadSelectedFiles.length }) }}</span>
|
||||
</div>
|
||||
<div class="text-xs text-muted">
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.selectedRoots', { paths: kb.selectedPathRoots.length ? kb.selectedPathRoots.join('、') : kb.t('kbWorkspace.pathUploadModal.noRoots') }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="kb.pathUploadSelectedFiles.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.pickFolderFirst') }}
|
||||
</div>
|
||||
<div v-else class="max-h-72 space-y-2 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="item in kb.pathUploadSelectedFiles"
|
||||
:key="item.key"
|
||||
class="flex items-start justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
|
||||
>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate text-sm font-medium text-primary">{{ item.file.name }}</div>
|
||||
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.removeSelectedPathFile(item.key)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.remove') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.closePathUploadModal"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleConfirmPathUpload"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-brand-600px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700"
|
||||
>
|
||||
<Upload class="h-4 w-4" />
|
||||
{{ kb.t('kbWorkspace.pathUploadModal.confirmUpload') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.showPathUploadHistoryModal"
|
||||
class="dialog-overlay z-[67] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-6xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.pathUploadHistoryModal.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ kb.t('kbWorkspace.pathUploadHistoryModal.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closePathUploadHistoryModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.pathUploadHistoryJobs.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
{{ kb.t('kbWorkspace.pathUpload.emptyHistory') }}
|
||||
</div>
|
||||
<div v-else class="grid min-h-0 flex-1 grid-cols-1 gap-4 lg:grid-cols-[320px_minmax(0,1fr)]">
|
||||
<div class="space-y-3 overflow-y-auto pr-1">
|
||||
<button
|
||||
v-for="job in kb.pathUploadHistoryJobs"
|
||||
:key="job.id"
|
||||
@click="kb.selectedPathUploadHistoryJobId = job.id"
|
||||
class="w-full rounded-2xl border px-4 py-4 text-left transition-colors"
|
||||
:class="String(kb.selectedPathUploadHistoryJobId || kb.selectedPathUploadHistoryJob?.id) === String(job.id)
|
||||
? 'border-brand-200 bg-brand-50 border-brand-200 '
|
||||
: 'border-default bg-surface hover:bg-surface-soft hover-surface-soft'"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-semibold text-primary">{{ kb.t('kbWorkspace.pathUpload.batchLabel', { id: job.id }) }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ kb.formatDateTime(job.created_at) }}</div>
|
||||
</div>
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(job.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(job.status) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3 grid grid-cols-2 gap-2 text-xs text-muted">
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.total', { count: kb.getPathUploadJobSummary(job).total }) }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.success', { count: kb.getPathUploadJobSummary(job).success }) }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.failed', { count: kb.getPathUploadJobSummary(job).failed }) }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.pendingProcess', { count: kb.getPathUploadJobSummary(job).pending }) }}</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.selectedPathUploadHistoryJob" class="min-h-0 rounded-2xl border border-default p-4 ">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-base font-semibold text-primary">{{ kb.t('kbWorkspace.pathUpload.batchLabel', { id: kb.selectedPathUploadHistoryJob.id }) }}</div>
|
||||
<div class="mt-1 text-sm text-muted">
|
||||
{{ kb.t('kbWorkspace.pathUpload.createdAt', { time: kb.formatDateTime(kb.selectedPathUploadHistoryJob.created_at) }) }}
|
||||
<span v-if="kb.selectedPathUploadHistoryJob.finished_at">{{ kb.t('kbWorkspace.pathUpload.finishedAt', { time: kb.formatDateTime(kb.selectedPathUploadHistoryJob.finished_at) }) }}</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-muted">{{ kb.selectedPathUploadHistoryJob.message || kb.t('kbWorkspace.pathUpload.noBatchMessage') }}</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(kb.selectedPathUploadHistoryJob.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(kb.selectedPathUploadHistoryJob.status) }}
|
||||
</span>
|
||||
<button
|
||||
v-if="kb.selectedPathUploadHistoryItems.length && !kb.pathUploadRunning"
|
||||
@click="kb.toggleSelectAllPathUploadHistoryItems"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.isAllPathUploadHistoryItemsSelected ? kb.t('kbWorkspace.pathUpload.deselectAll') : kb.t('kbWorkspace.pathUpload.selectAll') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!kb.pathUploadRunning"
|
||||
@click="kb.handleBatchDeletePathUploadItems"
|
||||
:disabled="!kb.selectedPathUploadHistorySelectedItems.length || kb.deletingPathUploadBatch"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{{ kb.pathUploadBatchDeleteLabel(kb.deletingPathUploadBatch, kb.selectedPathUploadHistorySelectedItems.length) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.hasRetryablePathUploadFailure(kb.selectedPathUploadHistoryJob) && !kb.pathUploadRunning"
|
||||
@click="kb.handleRetryFailedPathUpload(kb.selectedPathUploadHistoryJob)"
|
||||
:disabled="kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:all`"
|
||||
class="inline-flex items-center rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
{{ kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:all` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.pathUpload.retryAllFailed') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-2 gap-3 text-sm text-secondary md:grid-cols-4">
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.total', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).total }) }}</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.success', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).success }) }}</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.failed', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).failed }) }}</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">{{ kb.t('kbWorkspace.pathUpload.pendingProcess', { count: kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).pending }) }}</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 max-h-[50vh] space-y-2 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="item in kb.selectedPathUploadHistoryItems"
|
||||
:key="item.key"
|
||||
class="flex flex-wrap items-start justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
|
||||
>
|
||||
<label class="flex items-center pt-1">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="kb.selectedPathUploadHistoryItemKeys.includes(item.key)"
|
||||
@change="kb.togglePathUploadHistoryItemSelection(item.key)"
|
||||
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
/>
|
||||
</label>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate text-sm font-medium text-primary">{{ item.title }}</div>
|
||||
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
|
||||
<div v-if="item.error" class="mt-1 text-xs text-rose-500">{{ kb.t('kbWorkspace.common.failureReason', { reason: item.error }) }}</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getPathUploadItemDisplayState(item).className"
|
||||
>
|
||||
{{ kb.getPathUploadItemDisplayState(item).label }}
|
||||
</span>
|
||||
<button
|
||||
v-if="item.retryable && !kb.pathUploadRunning"
|
||||
@click="kb.handleRetryFailedPathUpload(kb.selectedPathUploadHistoryJob, [item.displayPath])"
|
||||
:disabled="kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:${item.displayPath}`"
|
||||
class="inline-flex items-center rounded-xl border border-rose-200 px-2.5 py-1 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
{{ kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:${item.displayPath}` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.common.retry') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!kb.pathUploadRunning"
|
||||
@click="kb.handleDeletePathUploadItem(kb.selectedPathUploadHistoryJob, item)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="kb.showDeleteConfirmDialog"
|
||||
:message="kb.deleteConfirmMessage"
|
||||
@confirm="kb.handleDeleteConfirm"
|
||||
@cancel="kb.closeDeleteConfirmDialog"
|
||||
/>
|
||||
</template>
|
||||
@@ -135,7 +135,7 @@ export function createKbWorkspaceState(options: CreateKbWorkspaceStateOptions =
|
||||
await pendingDeleteAction();
|
||||
} catch (err) {
|
||||
console.error('[deleteConfirm]', err);
|
||||
feedback.value = String(err) || '操作失败';
|
||||
feedback.value = String(err) || t('kbWorkspace.msg.operationFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
closeDeleteConfirmDialog();
|
||||
|
||||
@@ -47,6 +47,7 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
selectedPathUploadHistoryJobId,
|
||||
selectedPathUploadHistoryItemKeys,
|
||||
groups,
|
||||
t,
|
||||
} = state;
|
||||
|
||||
const selectedDocument = computed(() =>
|
||||
@@ -60,7 +61,7 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
);
|
||||
const markdownModalTitle = computed(() => {
|
||||
const current = documents.value.find((item) => item.id === markdownDocumentId.value);
|
||||
return current ? getDocumentDisplayTitle(current) : 'Markdown 编辑器';
|
||||
return current ? getDocumentDisplayTitle(current, t) : t('kbWorkspace.markdownModal.editorTitle');
|
||||
});
|
||||
const activeGroupJobs = computed(() =>
|
||||
jobs.value.filter((item) => item.group_id === selectedGroupId.value),
|
||||
@@ -68,13 +69,13 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
|
||||
const getLatestJobForDocument = buildGetLatestJobForDocument(() => activeGroupJobs.value);
|
||||
const resolveWorkflowState = (doc: KbDocumentItem) =>
|
||||
getDocumentWorkflowState(doc, getLatestJobForDocument);
|
||||
getDocumentWorkflowState(doc, getLatestJobForDocument, t);
|
||||
const getWorkflowBadgesForDoc = (doc: KbDocumentItem) =>
|
||||
getWorkflowBadges(doc, getLatestJobForDocument);
|
||||
getWorkflowBadges(doc, getLatestJobForDocument, t);
|
||||
const getMarkdownUnavailableMessageForDoc = (
|
||||
doc: KbDocumentItem,
|
||||
fallback?: string | null,
|
||||
) => getMarkdownUnavailableMessage(doc, getLatestJobForDocument, fallback);
|
||||
) => getMarkdownUnavailableMessage(doc, getLatestJobForDocument, t, fallback);
|
||||
|
||||
const groupSummaryItems = computed(() => {
|
||||
const docItems = documents.value;
|
||||
@@ -86,12 +87,12 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
const syncFailedCount = workflowStates.filter((item) => item.sync.code === 'failed').length;
|
||||
|
||||
return [
|
||||
{ label: '当前知识库分组', value: groupName, wide: true, clickable: false },
|
||||
{ label: '文档数量', value: String(docItems.length), wide: false, clickable: false },
|
||||
{ label: '待同步数量', value: String(pendingSyncCount), wide: false, clickable: false },
|
||||
{ label: '上传失败数量', value: String(uploadFailedCount), wide: false, clickable: uploadFailedCount > 0, failureType: 'upload' as const },
|
||||
{ label: '清洗失败数量', value: String(cleanFailedCount), wide: false, clickable: cleanFailedCount > 0, failureType: 'clean' as const },
|
||||
{ label: '同步失败数量', value: String(syncFailedCount), wide: false, clickable: syncFailedCount > 0, failureType: 'sync' as const },
|
||||
{ label: t('kbWorkspace.summary.currentGroup'), value: groupName, wide: true, clickable: false },
|
||||
{ label: t('kbWorkspace.summary.documentCount'), value: String(docItems.length), wide: false, clickable: false },
|
||||
{ label: t('kbWorkspace.summary.pendingSync'), value: String(pendingSyncCount), wide: false, clickable: false },
|
||||
{ label: t('kbWorkspace.summary.uploadFailed'), value: String(uploadFailedCount), wide: false, clickable: uploadFailedCount > 0, failureType: 'upload' as const },
|
||||
{ label: t('kbWorkspace.summary.cleanFailed'), value: String(cleanFailedCount), wide: false, clickable: cleanFailedCount > 0, failureType: 'clean' as const },
|
||||
{ label: t('kbWorkspace.summary.syncFailed'), value: String(syncFailedCount), wide: false, clickable: syncFailedCount > 0, failureType: 'sync' as const },
|
||||
];
|
||||
});
|
||||
|
||||
@@ -114,8 +115,8 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
const normalizedKeyword = keyword.trim().toLowerCase();
|
||||
if (!normalizedKeyword) return true;
|
||||
const candidates = [
|
||||
getDocumentDisplayTitle(doc),
|
||||
getDocumentDisplayDescription(doc),
|
||||
getDocumentDisplayTitle(doc, t),
|
||||
getDocumentDisplayDescription(doc, t),
|
||||
doc.title,
|
||||
doc.description,
|
||||
doc.latest_version?.source_file_name,
|
||||
@@ -125,10 +126,10 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
|
||||
const stageFilterTabs = computed(() => {
|
||||
const filters: Array<{ key: 'all' | 'upload' | 'clean' | 'sync'; label: string }> = [
|
||||
{ key: 'all', label: '全部' },
|
||||
{ key: 'upload', label: '上传' },
|
||||
{ key: 'clean', label: '清洗' },
|
||||
{ key: 'sync', label: '同步' },
|
||||
{ key: 'all', label: t('kbWorkspace.filters.all') },
|
||||
{ key: 'upload', label: t('kbWorkspace.filters.upload') },
|
||||
{ key: 'clean', label: t('kbWorkspace.filters.clean') },
|
||||
{ key: 'sync', label: t('kbWorkspace.filters.sync') },
|
||||
];
|
||||
return filters.map((item) => ({
|
||||
...item,
|
||||
@@ -189,8 +190,8 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
key: `${doc.id}-clean`,
|
||||
document: doc,
|
||||
stage: 'clean',
|
||||
stageLabel: '清洗失败',
|
||||
errorMessage: workflow.clean.errorMessage || workflow.primaryError || '清洗失败',
|
||||
stageLabel: t('kbWorkspace.failureModal.stageCleanFailed'),
|
||||
errorMessage: workflow.clean.errorMessage || workflow.primaryError || t('kbWorkspace.failureModal.stageCleanFailed'),
|
||||
latestJob: getLatestJobForDocument(doc, 'clean'),
|
||||
updatedAt: doc.updated_at || doc.latest_version?.created_at || null,
|
||||
}];
|
||||
@@ -200,8 +201,8 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
key: `${doc.id}-sync`,
|
||||
document: doc,
|
||||
stage: 'sync',
|
||||
stageLabel: '同步失败',
|
||||
errorMessage: workflow.sync.errorMessage || workflow.primaryError || '同步失败',
|
||||
stageLabel: t('kbWorkspace.failureModal.stageSyncFailed'),
|
||||
errorMessage: workflow.sync.errorMessage || workflow.primaryError || t('kbWorkspace.failureModal.stageSyncFailed'),
|
||||
latestJob: getLatestJobForDocument(doc, 'sync_dify'),
|
||||
updatedAt: doc.updated_at || doc.latest_version?.created_at || null,
|
||||
}];
|
||||
@@ -211,8 +212,8 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
key: `${doc.id}-upload`,
|
||||
document: doc,
|
||||
stage: 'upload',
|
||||
stageLabel: '上传失败',
|
||||
errorMessage: workflow.upload.errorMessage || workflow.primaryError || '上传失败',
|
||||
stageLabel: t('kbWorkspace.failureModal.stageUploadFailed'),
|
||||
errorMessage: workflow.upload.errorMessage || workflow.primaryError || t('kbWorkspace.failureModal.stageUploadFailed'),
|
||||
latestJob: getLatestJobForDocument(doc, 'upload'),
|
||||
updatedAt: doc.updated_at || doc.latest_version?.created_at || null,
|
||||
}];
|
||||
@@ -232,11 +233,11 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
|
||||
const failureModalTitle = computed(() => {
|
||||
const map = {
|
||||
upload: '上传失败数据',
|
||||
clean: '清洗失败数据',
|
||||
sync: '同步失败数据',
|
||||
upload: t('kbWorkspace.failureModal.uploadData'),
|
||||
clean: t('kbWorkspace.failureModal.cleanData'),
|
||||
sync: t('kbWorkspace.failureModal.syncData'),
|
||||
};
|
||||
return failureModalType.value ? map[failureModalType.value] : '失败数据';
|
||||
return failureModalType.value ? map[failureModalType.value] : t('kbWorkspace.failureModal.generic');
|
||||
});
|
||||
|
||||
const documentById = computed(() =>
|
||||
@@ -273,7 +274,7 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
);
|
||||
|
||||
const selectedPathUploadHistoryItems = computed(() =>
|
||||
getPathUploadJobItems(selectedPathUploadHistoryJob.value),
|
||||
getPathUploadJobItems(selectedPathUploadHistoryJob.value, t),
|
||||
);
|
||||
|
||||
const selectedPathUploadHistorySelectedItems = computed(() => {
|
||||
@@ -290,7 +291,7 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
if (item.status === 'failed') {
|
||||
return {
|
||||
normalized: 'failed',
|
||||
label: '失败',
|
||||
label: t('kbWorkspace.status.failed'),
|
||||
className: getStatusBadgeClass('failed'),
|
||||
};
|
||||
}
|
||||
@@ -299,27 +300,27 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
const latestStatus = String(doc?.latest_version?.status || doc?.status || '').toLowerCase();
|
||||
|
||||
if (latestStatus === 'processing') {
|
||||
return { normalized: 'processing', label: '清洗中', className: getStatusBadgeClass('processing') };
|
||||
return { normalized: 'processing', label: t('kbWorkspace.status.cleaning'), className: getStatusBadgeClass('processing') };
|
||||
}
|
||||
if (['cleaned', 'ready'].includes(latestStatus)) {
|
||||
return { normalized: latestStatus, label: '已清洗', className: getStatusBadgeClass(latestStatus) };
|
||||
return { normalized: latestStatus, label: t('kbWorkspace.status.cleaned'), className: getStatusBadgeClass(latestStatus) };
|
||||
}
|
||||
if (latestStatus === 'syncing') {
|
||||
return { normalized: 'syncing', label: '同步中', className: getStatusBadgeClass('processing') };
|
||||
return { normalized: 'syncing', label: t('kbWorkspace.status.syncing'), className: getStatusBadgeClass('processing') };
|
||||
}
|
||||
if (latestStatus === 'synced') {
|
||||
return { normalized: 'synced', label: '已同步', className: getStatusBadgeClass('synced') };
|
||||
return { normalized: 'synced', label: t('kbWorkspace.status.synced'), className: getStatusBadgeClass('synced') };
|
||||
}
|
||||
if (latestStatus === 'uploaded') {
|
||||
return { normalized: 'uploaded', label: '待清洗', className: getStatusBadgeClass('uploaded') };
|
||||
return { normalized: 'uploaded', label: t('kbWorkspace.status.pendingClean'), className: getStatusBadgeClass('uploaded') };
|
||||
}
|
||||
if (item.status === 'success' || item.documentId) {
|
||||
return { normalized: 'success', label: '已上传', className: getStatusBadgeClass('success') };
|
||||
return { normalized: 'success', label: t('kbWorkspace.status.uploaded'), className: getStatusBadgeClass('success') };
|
||||
}
|
||||
if (item.status === 'uploading') {
|
||||
return { normalized: 'uploading', label: '上传中', className: getStatusBadgeClass('processing') };
|
||||
return { normalized: 'uploading', label: t('kbWorkspace.status.uploading'), className: getStatusBadgeClass('processing') };
|
||||
}
|
||||
return { normalized: 'queued', label: '待上传', className: getStatusBadgeClass('queued') };
|
||||
return { normalized: 'queued', label: t('kbWorkspace.status.draft'), className: getStatusBadgeClass('queued') };
|
||||
};
|
||||
|
||||
const pathUploadSummary = computed(() => {
|
||||
|
||||
@@ -48,6 +48,8 @@ export function useKbWorkspaceData(
|
||||
selectedPathUploadHistoryJobId,
|
||||
} = state;
|
||||
|
||||
const { t } = state;
|
||||
|
||||
const {
|
||||
kbJobPollingActive,
|
||||
latestPathUploadJob,
|
||||
@@ -63,7 +65,7 @@ export function useKbWorkspaceData(
|
||||
try {
|
||||
const result = await getKbGroupsSafe();
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '加载知识库分组失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +95,7 @@ export function useKbWorkspaceData(
|
||||
}
|
||||
const result = await getKbGroupFilesSafe(groupId);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '加载文档列表失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.loadDocumentsFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -126,13 +128,13 @@ export function useKbWorkspaceData(
|
||||
const hadActiveKbJobs = kbJobPollingActive.value;
|
||||
const result = await getKbJobsSafe();
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '加载任务列表失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.loadJobsFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
jobs.value = result.data;
|
||||
applyPathUploadJob(latestPathUploadJob.value);
|
||||
if (latestPathUploadJob.value && getPathUploadJobSummary(latestPathUploadJob.value).failed > 0) {
|
||||
if (latestPathUploadJob.value && getPathUploadJobSummary(latestPathUploadJob.value, t).failed > 0) {
|
||||
showPathUploadDetails.value = true;
|
||||
}
|
||||
if (
|
||||
|
||||
@@ -48,6 +48,8 @@ export function useKbWorkspaceDocuments(
|
||||
openDeleteConfirmDialog,
|
||||
} = state;
|
||||
|
||||
const { t } = state;
|
||||
|
||||
const {
|
||||
filteredDocuments,
|
||||
selectedDocuments,
|
||||
@@ -86,10 +88,10 @@ export function useKbWorkspaceDocuments(
|
||||
};
|
||||
|
||||
const handleDeleteDocument = async (doc: KbDocumentItem) => {
|
||||
openDeleteConfirmDialog(`确认删除文档「${getDocumentDisplayTitle(doc)}」吗?`, async () => {
|
||||
openDeleteConfirmDialog(t('kbWorkspace.msg.deleteDocumentConfirm', { name: getDocumentDisplayTitle(doc, t) }), async () => {
|
||||
const result = await deleteKbDocument(doc.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除文档失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.deleteDocumentFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +100,7 @@ export function useKbWorkspaceDocuments(
|
||||
selectedDocumentId.value = null;
|
||||
showRecordModal.value = false;
|
||||
}
|
||||
feedback.value = '文档已删除';
|
||||
feedback.value = t('kbWorkspace.msg.documentDeleted');
|
||||
feedbackType.value = 'success';
|
||||
await Promise.all([loadGroups(), loadDocuments(selectedGroupId.value), loadJobs()]);
|
||||
selectedDocumentVersions.value = [];
|
||||
@@ -108,7 +110,7 @@ export function useKbWorkspaceDocuments(
|
||||
|
||||
const handleBatchSync = async () => {
|
||||
if (!selectedDocuments.value.length) {
|
||||
feedback.value = '请先选择要批量同步的文档';
|
||||
feedback.value = t('kbWorkspace.msg.selectDocumentsToSync');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -123,10 +125,12 @@ export function useKbWorkspaceDocuments(
|
||||
const successCount = results.filter(({ result }) => result.ok).length;
|
||||
const failResults = results.filter(({ result }) => !result.ok);
|
||||
const failCount = failResults.length;
|
||||
const errors = failResults.map(({ doc, result }) => `${getDocumentDisplayTitle(doc)}: ${result.error || '同步失败'}`);
|
||||
const errors = failResults.map(({ doc, result }) =>
|
||||
`${getDocumentDisplayTitle(doc, t)}: ${result.error || t('kbWorkspace.failureModal.stageSyncFailed')}`,
|
||||
);
|
||||
feedback.value = failCount
|
||||
? `批量同步任务已提交:成功 ${successCount} 条,失败 ${failCount} 条。${errors[0] || ''}`
|
||||
: `批量同步任务已提交:共成功 ${successCount} 条`;
|
||||
? t('kbWorkspace.msg.batchSyncResult', { success: successCount, fail: failCount, detail: errors[0] || '' })
|
||||
: t('kbWorkspace.msg.batchSyncSuccess', { success: successCount });
|
||||
feedbackType.value = failCount ? 'error' : 'success';
|
||||
if (successCount > 0) {
|
||||
startPathUploadPolling();
|
||||
@@ -139,12 +143,12 @@ export function useKbWorkspaceDocuments(
|
||||
|
||||
const handleBatchClean = async () => {
|
||||
if (!selectedDocuments.value.length) {
|
||||
feedback.value = '请先选择要清洗的文档';
|
||||
feedback.value = t('kbWorkspace.msg.selectDocumentsToClean');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
if (!selectedCleanableDocuments.value.length) {
|
||||
feedback.value = '当前所选文档没有可重新清洗的项';
|
||||
feedback.value = t('kbWorkspace.msg.noDocumentsToClean');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -159,10 +163,12 @@ export function useKbWorkspaceDocuments(
|
||||
const successCount = results.filter(({ result }) => result.ok).length;
|
||||
const failResults = results.filter(({ result }) => !result.ok);
|
||||
const failCount = failResults.length;
|
||||
const errors = failResults.map(({ doc, result }) => `${getDocumentDisplayTitle(doc)}: ${result.error || '提交清洗失败'}`);
|
||||
const errors = failResults.map(({ doc, result }) =>
|
||||
`${getDocumentDisplayTitle(doc, t)}: ${result.error || t('kbWorkspace.failureModal.stageCleanFailed')}`,
|
||||
);
|
||||
feedback.value = failCount
|
||||
? `批量清洗任务已提交:成功 ${successCount} 条,失败 ${failCount} 条。${errors[0] || ''}`
|
||||
: `批量清洗任务已提交:共成功 ${successCount} 条`;
|
||||
? t('kbWorkspace.msg.batchCleanResult', { success: successCount, fail: failCount, detail: errors[0] || '' })
|
||||
: t('kbWorkspace.msg.batchCleanSuccess', { success: successCount });
|
||||
feedbackType.value = failCount ? 'error' : 'success';
|
||||
if (successCount > 0) {
|
||||
startPathUploadPolling();
|
||||
@@ -175,12 +181,12 @@ export function useKbWorkspaceDocuments(
|
||||
|
||||
const handleBatchDelete = async () => {
|
||||
if (!selectedDocuments.value.length) {
|
||||
feedback.value = '请先选择要批量删除的文档';
|
||||
feedback.value = t('kbWorkspace.msg.selectDocumentsToDelete');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
openDeleteConfirmDialog(
|
||||
`确认批量删除已选中的 ${selectedDocuments.value.length} 条文档吗?会同步删除 Dify 对应文档。`,
|
||||
t('kbWorkspace.msg.batchDeleteDocumentsConfirm', { count: selectedDocuments.value.length }),
|
||||
async () => {
|
||||
batchSubmitting.value = true;
|
||||
let successCount = 0;
|
||||
@@ -193,12 +199,12 @@ export function useKbWorkspaceDocuments(
|
||||
successCount += 1;
|
||||
} else {
|
||||
failCount += 1;
|
||||
errors.push(`${getDocumentDisplayTitle(doc)}: ${result.error || '删除失败'}`);
|
||||
errors.push(`${getDocumentDisplayTitle(doc, t)}: ${result.error || t('kbWorkspace.msg.deleteDocumentFailed')}`);
|
||||
}
|
||||
}
|
||||
feedback.value = failCount
|
||||
? `批量删除完成:成功 ${successCount} 条,失败 ${failCount} 条。${errors[0] || ''}`
|
||||
: `批量删除完成:共成功 ${successCount} 条`;
|
||||
? t('kbWorkspace.msg.batchDeleteResult', { success: successCount, fail: failCount, detail: errors[0] || '' })
|
||||
: t('kbWorkspace.msg.batchDeleteSuccess', { success: successCount });
|
||||
feedbackType.value = failCount ? 'error' : 'success';
|
||||
selectedDocumentIds.value = [];
|
||||
await Promise.all([loadGroups(), loadDocuments(selectedGroupId.value), loadJobs()]);
|
||||
@@ -223,28 +229,30 @@ export function useKbWorkspaceDocuments(
|
||||
try {
|
||||
if (action === 'submit') {
|
||||
triggerUploadForDocument(item.document.id);
|
||||
feedback.value = `请重新为「${getDocumentDisplayTitle(item.document)}」选择文件后提交`;
|
||||
feedback.value = t('kbWorkspace.msg.reselectFile', { name: getDocumentDisplayTitle(item.document, t) });
|
||||
feedbackType.value = 'success';
|
||||
return;
|
||||
}
|
||||
if (action === 'clean') {
|
||||
const result = await submitKbDocumentClean(item.document.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '重新清洗失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.recleanFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
feedback.value = result.message || `已重新提交清洗:${getDocumentDisplayTitle(item.document)}`;
|
||||
feedback.value = result.message || t('kbWorkspace.msg.recleanSubmitted', { name: getDocumentDisplayTitle(item.document, t) });
|
||||
feedbackType.value = 'success';
|
||||
startPathUploadPolling();
|
||||
} else {
|
||||
const result = await syncKbDocumentToDify(item.document.id);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error ? `重新同步失败:${result.error}` : '重新同步失败';
|
||||
feedback.value = result.error
|
||||
? t('kbWorkspace.msg.resyncFailed', { detail: result.error })
|
||||
: t('kbWorkspace.failureModal.stageSyncFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
feedback.value = result.job?.message || `已重新提交同步:${getDocumentDisplayTitle(item.document)}`;
|
||||
feedback.value = result.job?.message || t('kbWorkspace.msg.resyncSubmitted', { name: getDocumentDisplayTitle(item.document, t) });
|
||||
feedbackType.value = 'success';
|
||||
startPathUploadPolling();
|
||||
}
|
||||
@@ -270,7 +278,7 @@ export function useKbWorkspaceDocuments(
|
||||
}
|
||||
|
||||
isSubmitting.value = true;
|
||||
feedback.value = '开始处理文件...';
|
||||
feedback.value = t('kbWorkspace.msg.processingFile');
|
||||
feedbackType.value = 'success';
|
||||
|
||||
if (activeUploadDocumentId.value) {
|
||||
@@ -278,10 +286,10 @@ export function useKbWorkspaceDocuments(
|
||||
if (!file) return;
|
||||
const result = await uploadKbDocumentVersion(activeUploadDocumentId.value, file);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '文件上传失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.uploadFailed');
|
||||
feedbackType.value = 'error';
|
||||
} else {
|
||||
feedback.value = result.message || `版本文件「${file.name}」上传成功,清洗已排队`;
|
||||
feedback.value = result.message || t('kbWorkspace.msg.versionUploaded', { file: file.name });
|
||||
feedbackType.value = 'success';
|
||||
startPathUploadPolling();
|
||||
}
|
||||
@@ -296,7 +304,11 @@ export function useKbWorkspaceDocuments(
|
||||
for (let i = 0; i < fileArray.length; i++) {
|
||||
const file = fileArray[i];
|
||||
if (!file) continue;
|
||||
feedback.value = `正在上传 ${i + 1}/${fileArray.length}: ${file.name}`;
|
||||
feedback.value = t('kbWorkspace.msg.uploadingProgress', {
|
||||
current: i + 1,
|
||||
total: fileArray.length,
|
||||
file: file.name,
|
||||
});
|
||||
|
||||
const createResult = await createKbDocument(selectedGroupId.value, {
|
||||
title: file.name,
|
||||
@@ -305,18 +317,21 @@ export function useKbWorkspaceDocuments(
|
||||
|
||||
if (!createResult.ok || !createResult.document) {
|
||||
failCount++;
|
||||
errors.push(`${file.name}: ${normalizeDuplicateDocumentError(createResult.error || '创建文档失败')}`);
|
||||
const createError = createResult.error
|
||||
? normalizeDuplicateDocumentError(createResult.error, t)
|
||||
: t('kbWorkspace.msg.createDocumentFailed');
|
||||
errors.push(`${file.name}: ${createError}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const uploadResult = await uploadKbDocumentVersion(createResult.document.id, file);
|
||||
if (!uploadResult.ok) {
|
||||
failCount++;
|
||||
const uploadError = uploadResult.error || '上传文档版本失败';
|
||||
const uploadError = uploadResult.error || t('kbWorkspace.msg.uploadVersionFailed');
|
||||
errors.push(`${file.name}: ${uploadError}`);
|
||||
const cleanupResult = await deleteKbDocument(createResult.document.id);
|
||||
if (!cleanupResult.ok) {
|
||||
errors.push(`${file.name}: 上传失败后未能自动清理空文档(${cleanupResult.error || '删除失败'})`);
|
||||
errors.push(`${file.name}: ${t('kbWorkspace.msg.uploadCleanupFailed', { detail: cleanupResult.error || t('kbWorkspace.msg.deleteDocumentFailed') })}`);
|
||||
}
|
||||
} else {
|
||||
successCount++;
|
||||
@@ -324,10 +339,14 @@ export function useKbWorkspaceDocuments(
|
||||
}
|
||||
|
||||
if (failCount > 0) {
|
||||
feedback.value = `上传完成:成功 ${successCount} 个,失败 ${failCount} 个。${errors[0] || ''}`;
|
||||
feedback.value = t('kbWorkspace.msg.uploadSummary', {
|
||||
success: successCount,
|
||||
fail: failCount,
|
||||
detail: errors[0] || '',
|
||||
});
|
||||
feedbackType.value = successCount > 0 ? 'success' : 'error';
|
||||
} else {
|
||||
feedback.value = `成功上传 ${successCount} 个文件,清洗任务已排队`;
|
||||
feedback.value = t('kbWorkspace.msg.uploadAllSuccess', { count: successCount });
|
||||
feedbackType.value = 'success';
|
||||
}
|
||||
if (successCount > 0) {
|
||||
@@ -355,14 +374,16 @@ export function useKbWorkspaceDocuments(
|
||||
syncingDocumentId.value = null;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error ? `同步到 Dify 失败:${result.error}` : '同步到 Dify 失败';
|
||||
feedback.value = result.error
|
||||
? t('kbWorkspace.msg.syncDifyFailed', { detail: result.error })
|
||||
: t('kbWorkspace.msg.syncDifyFailedGeneric');
|
||||
feedbackType.value = 'error';
|
||||
await loadDocuments(selectedGroupId.value, { silent: true });
|
||||
await loadJobs();
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = result.job?.message || '同步任务已提交,等待后台处理';
|
||||
feedback.value = result.job?.message || t('kbWorkspace.msg.syncSubmitted');
|
||||
feedbackType.value = 'success';
|
||||
startPathUploadPolling();
|
||||
await loadDocuments(selectedGroupId.value, { silent: true });
|
||||
|
||||
@@ -46,6 +46,7 @@ export function useKbWorkspaceModals(
|
||||
selectedGroupId,
|
||||
} = state;
|
||||
|
||||
const { t } = state;
|
||||
const { getMarkdownUnavailableMessageForDoc } = computed;
|
||||
const { loadDocumentVersions, loadSourceInfoVersions, loadDocuments, loadJobs } = data;
|
||||
|
||||
@@ -78,7 +79,7 @@ export function useKbWorkspaceModals(
|
||||
const result = await getKbDocumentVersionSourceFile(version.id);
|
||||
openingSourceVersionId.value = null;
|
||||
if (!result.ok || !result.blob) {
|
||||
feedback.value = result.error || '读取原始文件失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.readSourceFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -112,7 +113,7 @@ export function useKbWorkspaceModals(
|
||||
markdownKind.value = payload.kind;
|
||||
markdownVersionLabel.value = payload.version
|
||||
? `v${payload.version.version_no} · ${payload.version.source_file_name}`
|
||||
: '暂无版本';
|
||||
: t('kbWorkspace.msg.noVersion');
|
||||
};
|
||||
|
||||
const openMarkdownEditor = async (doc: KbDocumentItem) => {
|
||||
@@ -127,7 +128,10 @@ export function useKbWorkspaceModals(
|
||||
const result = await getKbDocumentMarkdown(doc.id);
|
||||
isMarkdownLoading.value = false;
|
||||
if (!result.ok || !result.data) {
|
||||
markdownError.value = getMarkdownUnavailableMessageForDoc(doc, result.error || '读取清洗后的 Markdown 失败');
|
||||
markdownError.value = getMarkdownUnavailableMessageForDoc(
|
||||
doc,
|
||||
result.error || t('kbWorkspace.msg.readMarkdownFailed'),
|
||||
);
|
||||
return;
|
||||
}
|
||||
applyMarkdownPayload(result.data);
|
||||
@@ -156,13 +160,13 @@ export function useKbWorkspaceModals(
|
||||
if (!result.ok || !result.data) {
|
||||
const currentDoc = documents.value.find((item) => item.id === markdownDocumentId.value) || null;
|
||||
markdownError.value = currentDoc
|
||||
? getMarkdownUnavailableMessageForDoc(currentDoc, result.error || '保存 Markdown 失败')
|
||||
: (result.error || '保存 Markdown 失败');
|
||||
? getMarkdownUnavailableMessageForDoc(currentDoc, result.error || t('kbWorkspace.msg.saveMarkdownFailed'))
|
||||
: (result.error || t('kbWorkspace.msg.saveMarkdownFailed'));
|
||||
return;
|
||||
}
|
||||
|
||||
applyMarkdownPayload(result.data);
|
||||
feedback.value = '清洗后的 Markdown 已保存';
|
||||
feedback.value = t('kbWorkspace.msg.markdownSaved');
|
||||
feedbackType.value = 'success';
|
||||
await loadDocuments(selectedGroupId.value);
|
||||
await loadJobs();
|
||||
|
||||
@@ -50,6 +50,8 @@ export function useKbWorkspacePathUpload(
|
||||
openDeleteConfirmDialog,
|
||||
} = state;
|
||||
|
||||
const { t } = state;
|
||||
|
||||
const {
|
||||
pathUploadRunning,
|
||||
kbJobPollingActive,
|
||||
@@ -77,7 +79,12 @@ export function useKbWorkspacePathUpload(
|
||||
const updatePathUploadFeedback = () => {
|
||||
const summary = pathUploadSummary.value;
|
||||
if (!pathUploadTask.value.total) return;
|
||||
feedback.value = `路径上传进度:总计 ${summary.total} 条,待上传 ${summary.pending} 条,已上传 ${summary.uploaded} 条,失败 ${summary.failed} 条`;
|
||||
feedback.value = t('kbWorkspace.msg.pathUploadProgress', {
|
||||
total: summary.total,
|
||||
pending: summary.pending,
|
||||
uploaded: summary.uploaded,
|
||||
failed: summary.failed,
|
||||
});
|
||||
feedbackType.value = summary.failed > 0 ? 'error' : 'success';
|
||||
};
|
||||
|
||||
@@ -102,9 +109,9 @@ export function useKbWorkspacePathUpload(
|
||||
const items = Array.isArray(payload.files)
|
||||
? payload.files.map((item: Record<string, unknown>, index: number) => ({
|
||||
key: String(item.relative_path || item.original_name || index),
|
||||
title: String(item.original_name || item.relative_path || `文件${index + 1}`),
|
||||
title: String(item.original_name || item.relative_path || t('kbWorkspace.errors.fileFallback', { index: index + 1 })),
|
||||
displayPath: String(item.relative_path || item.original_name || ''),
|
||||
rootLabel: String(item.relative_path || item.original_name || '').split('/')[0] || '本地目录',
|
||||
rootLabel: String(item.relative_path || item.original_name || '').split('/')[0] || t('kbWorkspace.errors.localFolder'),
|
||||
status: (['queued', 'uploading', 'success', 'failed'].includes(String(item.status)) ? item.status : 'queued') as PathUploadStatus,
|
||||
error: item.error as string | undefined,
|
||||
documentId: item.document_id as number | undefined,
|
||||
@@ -148,7 +155,7 @@ export function useKbWorkspacePathUpload(
|
||||
|
||||
const openPathUploadModal = () => {
|
||||
if (pathUploadRunning.value) {
|
||||
feedback.value = '有文件正在上传请稍等再试~';
|
||||
feedback.value = t('kbWorkspace.msg.pathUploadBusy');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -224,17 +231,17 @@ export function useKbWorkspacePathUpload(
|
||||
|
||||
const handleConfirmPathUpload = async () => {
|
||||
if (pathUploadRunning.value) {
|
||||
feedback.value = '有文件正在上传请稍等再试~';
|
||||
feedback.value = t('kbWorkspace.msg.pathUploadBusy');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
if (!selectedGroupId.value) {
|
||||
feedback.value = '请先选择知识库分组';
|
||||
feedback.value = t('kbWorkspace.msg.selectGroupFirst');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
if (!pathUploadSelectedFiles.value.length) {
|
||||
feedback.value = '请先选择至少一个本地目录或文件';
|
||||
feedback.value = t('kbWorkspace.msg.selectPathFiles');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -249,13 +256,13 @@ export function useKbWorkspacePathUpload(
|
||||
})),
|
||||
});
|
||||
if (!createResult.ok || !createResult.job) {
|
||||
feedback.value = createResult.error || '创建上传路径任务失败';
|
||||
feedback.value = createResult.error || t('kbWorkspace.msg.createPathJobFailed');
|
||||
feedbackType.value = 'error';
|
||||
isPathUploadStaging.value = false;
|
||||
return;
|
||||
}
|
||||
const createdJob = createResult.job;
|
||||
const existingJobItems = getPathUploadJobItems(createdJob);
|
||||
const existingJobItems = getPathUploadJobItems(createdJob, t);
|
||||
const existingItemMap = new Map(existingJobItems.map((item) => [item.displayPath, item]));
|
||||
const selectedPathSet = new Set(pathUploadSelectedFiles.value.map((item) => item.displayPath));
|
||||
const pendingFiles = pathUploadSelectedFiles.value.filter((item) => {
|
||||
@@ -302,7 +309,9 @@ export function useKbWorkspacePathUpload(
|
||||
|
||||
const stageResult = await uploadKbPathJobFile(createdJob.id, item.file, item.displayPath);
|
||||
if (!stageResult.ok) {
|
||||
const errorMessage = normalizeDuplicateDocumentError(stageResult.error || '路径文件暂存失败');
|
||||
const errorMessage = stageResult.error
|
||||
? normalizeDuplicateDocumentError(stageResult.error, t)
|
||||
: t('kbWorkspace.msg.pathStageFailed');
|
||||
const failedResult = await markKbPathJobFileFailed(createdJob.id, {
|
||||
relative_path: item.displayPath,
|
||||
original_name: item.file.name,
|
||||
@@ -345,7 +354,7 @@ export function useKbWorkspacePathUpload(
|
||||
|
||||
isPathUploadStaging.value = false;
|
||||
pathUploadTask.value.currentFile = '';
|
||||
feedback.value = '路径文件已逐个上传并提交清洗';
|
||||
feedback.value = t('kbWorkspace.msg.pathUploadDone');
|
||||
feedbackType.value = 'success';
|
||||
startPathUploadPolling();
|
||||
resetPathUploadDraft();
|
||||
@@ -354,14 +363,16 @@ export function useKbWorkspacePathUpload(
|
||||
|
||||
const handleDeletePathUploadItem = async (job: KbJob | null, item: PathUploadTaskItem) => {
|
||||
if (!job) return;
|
||||
openDeleteConfirmDialog(`确认删除路径文件「${item.displayPath || item.title}」吗?`, async () => {
|
||||
openDeleteConfirmDialog(t('kbWorkspace.msg.deletePathFileConfirm', { path: item.displayPath || item.title }), async () => {
|
||||
const result = await deleteKbPathJobFile(job.id, item.displayPath);
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || '删除路径上传文件失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.deletePathFileFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
feedback.value = result.document_deleted ? '已删除路径记录,并同步删除对应文档' : '已删除路径记录';
|
||||
feedback.value = result.document_deleted
|
||||
? t('kbWorkspace.msg.pathRecordDeletedWithDoc')
|
||||
: t('kbWorkspace.msg.pathRecordDeleted');
|
||||
feedbackType.value = 'success';
|
||||
if (pathUploadTask.value.items.length <= 1) {
|
||||
showPathUploadDetails.value = false;
|
||||
@@ -374,11 +385,11 @@ export function useKbWorkspacePathUpload(
|
||||
const job = selectedPathUploadHistoryJob.value;
|
||||
const items = selectedPathUploadHistorySelectedItems.value;
|
||||
if (!job || !items.length) {
|
||||
feedback.value = '请先选择要删除的文件';
|
||||
feedback.value = t('kbWorkspace.msg.selectPathFilesToDelete');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
openDeleteConfirmDialog(`确认批量删除已选中的 ${items.length} 条路径文件吗?`, async () => {
|
||||
openDeleteConfirmDialog(t('kbWorkspace.msg.batchDeletePathConfirm', { count: items.length }), async () => {
|
||||
deletingPathUploadBatch.value = true;
|
||||
let successCount = 0;
|
||||
let failCount = 0;
|
||||
@@ -391,11 +402,11 @@ export function useKbWorkspacePathUpload(
|
||||
continue;
|
||||
}
|
||||
failCount += 1;
|
||||
errors.push(`${item.displayPath}: ${result.error || '删除失败'}`);
|
||||
errors.push(`${item.displayPath}: ${result.error || t('kbWorkspace.msg.deleteDocumentFailed')}`);
|
||||
}
|
||||
feedback.value = failCount
|
||||
? `批量删除完成:成功 ${successCount} 条,失败 ${failCount} 条。${errors[0] || ''}`
|
||||
: `批量删除完成:共成功 ${successCount} 条`;
|
||||
? t('kbWorkspace.msg.batchDeletePathResult', { success: successCount, fail: failCount, detail: errors[0] || '' })
|
||||
: t('kbWorkspace.msg.batchDeletePathSuccess', { success: successCount });
|
||||
feedbackType.value = failCount ? 'error' : 'success';
|
||||
selectedPathUploadHistoryItemKeys.value = [];
|
||||
await Promise.all([
|
||||
@@ -419,13 +430,15 @@ export function useKbWorkspacePathUpload(
|
||||
const result = await retryFailedKbPathUploadJob(job.id, relativePaths?.length ? { relative_paths: relativePaths } : {});
|
||||
retryingPathUploadKey.value = '';
|
||||
if (!result.ok || !result.job) {
|
||||
feedback.value = result.error || '重试失败文件失败';
|
||||
feedback.value = result.error || t('kbWorkspace.msg.retryPathFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
applyPathUploadJob(result.job);
|
||||
startPathUploadPolling();
|
||||
feedback.value = relativePaths?.length === 1 ? '已重新提交该失败文件' : '已重新提交失败文件';
|
||||
feedback.value = relativePaths?.length === 1
|
||||
? t('kbWorkspace.msg.retryPathOne')
|
||||
: t('kbWorkspace.msg.retryPathAll');
|
||||
feedbackType.value = 'success';
|
||||
await bridge.refreshWorkflowStatusOnly();
|
||||
};
|
||||
|
||||
@@ -30,6 +30,7 @@ import { useKbWorkspaceData } from './kb-workspace/useKbWorkspaceData';
|
||||
import { useKbWorkspaceDocuments } from './kb-workspace/useKbWorkspaceDocuments';
|
||||
import { useKbWorkspaceModals } from './kb-workspace/useKbWorkspaceModals';
|
||||
import { useKbWorkspacePathUpload } from './kb-workspace/useKbWorkspacePathUpload';
|
||||
import type { KbDocumentItem } from '../api/kb.api';
|
||||
|
||||
export interface UseKbWorkspaceOptions {
|
||||
embedded?: boolean;
|
||||
@@ -108,7 +109,7 @@ export function useKbWorkspace(options: UseKbWorkspaceOptions = {}) {
|
||||
});
|
||||
|
||||
watch(selectedPathUploadHistoryJob, (job) => {
|
||||
const validKeys = new Set(getPathUploadJobItems(job).map((item) => item.key));
|
||||
const validKeys = new Set(getPathUploadJobItems(job, t).map((item) => item.key));
|
||||
selectedPathUploadHistoryItemKeys.value = selectedPathUploadHistoryItemKeys.value.filter((key) => validKeys.has(key));
|
||||
if (!job) {
|
||||
selectedPathUploadHistoryItemKeys.value = [];
|
||||
@@ -128,6 +129,37 @@ export function useKbWorkspace(options: UseKbWorkspaceOptions = {}) {
|
||||
pathUpload.stopPathUploadPollTimer();
|
||||
});
|
||||
|
||||
const { t } = state;
|
||||
|
||||
const batchActionLabel = (action: 'clean' | 'sync' | 'delete', submitting: boolean, count: number) => {
|
||||
if (submitting) return t('kbWorkspace.common.processing');
|
||||
const keys = {
|
||||
clean: ['batchClean', 'batchCleanCount'],
|
||||
sync: ['batchSync', 'batchSyncCount'],
|
||||
delete: ['batchDelete', 'batchDeleteCount'],
|
||||
} as const;
|
||||
const [base, withCount] = keys[action];
|
||||
return count > 0
|
||||
? t(`kbWorkspace.documents.${withCount}`, { count })
|
||||
: t(`kbWorkspace.documents.${base}`);
|
||||
};
|
||||
|
||||
const pathUploadBatchDeleteLabel = (submitting: boolean, count: number) => {
|
||||
if (submitting) return t('kbWorkspace.pathUpload.deleting');
|
||||
return count > 0
|
||||
? t('kbWorkspace.pathUpload.batchDeleteCount', { count })
|
||||
: t('kbWorkspace.pathUpload.batchDelete');
|
||||
};
|
||||
|
||||
const documentEmptyMessage = (documentsLength: number, hasKeyword: boolean) => {
|
||||
if (documentsLength === 0) return t('kbWorkspace.documents.emptyNoDocs');
|
||||
if (hasKeyword) return t('kbWorkspace.documents.emptyNoSearchMatch');
|
||||
return t('kbWorkspace.documents.emptyNoFilterMatch');
|
||||
};
|
||||
|
||||
const documentDisplayName = (doc: KbDocumentItem | null | undefined, id: number | null) =>
|
||||
doc ? getDocumentDisplayTitle(doc, t) : t('kbWorkspace.documents.documentFallback', { id });
|
||||
|
||||
// reactive 便于模板以 kb.xxx 统一访问,ref/computed 在属性读取时自动解包
|
||||
return reactive({
|
||||
...state,
|
||||
@@ -140,17 +172,22 @@ export function useKbWorkspace(options: UseKbWorkspaceOptions = {}) {
|
||||
getDocumentWorkflowState: computed.resolveWorkflowState,
|
||||
formatDateTime,
|
||||
formatFileSize,
|
||||
getDocumentDisplayTitle,
|
||||
getDocumentDisplayDescription,
|
||||
getStatusLabel,
|
||||
getDocumentDisplayTitle: (doc: KbDocumentItem) => getDocumentDisplayTitle(doc, t),
|
||||
getDocumentDisplayDescription: (doc: KbDocumentItem) => getDocumentDisplayDescription(doc, t),
|
||||
getStatusLabel: (status: string | null | undefined) => getStatusLabel(status, t),
|
||||
getStatusBadgeClass,
|
||||
getPathUploadJobItems,
|
||||
hasRetryablePathUploadFailure,
|
||||
getPathUploadJobSummary,
|
||||
getPathUploadJobItems: (job: Parameters<typeof getPathUploadJobItems>[0]) => getPathUploadJobItems(job, t),
|
||||
hasRetryablePathUploadFailure: (job: Parameters<typeof hasRetryablePathUploadFailure>[0]) =>
|
||||
hasRetryablePathUploadFailure(job, t),
|
||||
getPathUploadJobSummary: (job: Parameters<typeof getPathUploadJobSummary>[0]) => getPathUploadJobSummary(job, t),
|
||||
DOCUMENT_PAGE_SIZE_OPTIONS,
|
||||
FAILURE_PAGE_SIZE,
|
||||
PATH_UPLOAD_BATCH_SIZE,
|
||||
PATH_UPLOAD_BATCH_INTERVAL_MS,
|
||||
PATH_UPLOAD_CONCURRENCY,
|
||||
batchActionLabel,
|
||||
pathUploadBatchDeleteLabel,
|
||||
documentEmptyMessage,
|
||||
documentDisplayName,
|
||||
});
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
* 文档标题、时间、文件大小与状态徽标等纯展示工具。
|
||||
*/
|
||||
import type { KbDocumentItem } from '../api/kb.api';
|
||||
import type { KbTranslateFn } from './kb-i18n.types';
|
||||
|
||||
export const formatDateTime = (value?: string | null) => {
|
||||
if (!value) return '--';
|
||||
@@ -27,40 +28,43 @@ const trimPathText = (value?: string | null) => {
|
||||
return text.split(/[\\/]/).filter(Boolean).pop() || text;
|
||||
};
|
||||
|
||||
export const getDocumentDisplayTitle = (doc: KbDocumentItem) => trimPathText(doc.title) || '未命名文档';
|
||||
const STATUS_I18N_KEYS: Record<string, string> = {
|
||||
draft: 'kbWorkspace.status.draft',
|
||||
uploaded: 'kbWorkspace.status.uploaded',
|
||||
processing: 'kbWorkspace.status.processing',
|
||||
cleaned: 'kbWorkspace.status.cleaned',
|
||||
ready: 'kbWorkspace.status.ready',
|
||||
synced: 'kbWorkspace.status.synced',
|
||||
syncing: 'kbWorkspace.status.syncing',
|
||||
failed: 'kbWorkspace.status.failed',
|
||||
queued: 'kbWorkspace.status.queued',
|
||||
running: 'kbWorkspace.status.running',
|
||||
success: 'kbWorkspace.status.success',
|
||||
cancelled: 'kbWorkspace.status.cancelled',
|
||||
};
|
||||
|
||||
export const getDocumentDisplayDescription = (doc: KbDocumentItem) => {
|
||||
export const getDocumentDisplayTitle = (doc: KbDocumentItem, t: KbTranslateFn) =>
|
||||
trimPathText(doc.title) || t('kbWorkspace.status.unnamedDocument');
|
||||
|
||||
export const getDocumentDisplayDescription = (doc: KbDocumentItem, t: KbTranslateFn) => {
|
||||
const text = trimPathText(doc.description);
|
||||
return text || getDocumentDisplayTitle(doc);
|
||||
return text || getDocumentDisplayTitle(doc, t);
|
||||
};
|
||||
|
||||
/** 将后端重复文档错误归一为前端可展示的简短文案 */
|
||||
export const normalizeDuplicateDocumentError = (message?: string | null) => {
|
||||
export const normalizeDuplicateDocumentError = (message: string | null | undefined, t: KbTranslateFn) => {
|
||||
const text = String(message || '').trim();
|
||||
if (!text) return '知识库接口请求失败';
|
||||
if (!text) return t('kbWorkspace.errors.apiRequestFailed');
|
||||
if (text.includes('当前分组下已存在同名文档') || text.includes('上传失败,文件已存在')) {
|
||||
return '上传失败,文件已存在';
|
||||
return t('kbWorkspace.errors.duplicateFile');
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
export const getStatusLabel = (status?: string | null) => {
|
||||
export const getStatusLabel = (status: string | null | undefined, t: KbTranslateFn) => {
|
||||
const normalized = String(status || '').toLowerCase();
|
||||
const map: Record<string, string> = {
|
||||
draft: '待上传',
|
||||
uploaded: '已上传',
|
||||
processing: '清洗中',
|
||||
cleaned: '已清洗',
|
||||
ready: '已就绪',
|
||||
synced: '已同步',
|
||||
syncing: '同步中',
|
||||
failed: '失败',
|
||||
queued: '排队中',
|
||||
running: '进行中',
|
||||
success: '成功',
|
||||
cancelled: '已取消',
|
||||
};
|
||||
return map[normalized] || status || '未知状态';
|
||||
const key = STATUS_I18N_KEYS[normalized];
|
||||
return key ? t(key) : (status || t('kbWorkspace.status.unknown'));
|
||||
};
|
||||
|
||||
export const getStatusBadgeClass = (status?: string | null) => {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/** 知识库作业面 i18n 翻译函数(vue-i18n `t` 的简化类型) */
|
||||
export type KbTranslateFn = (key: string, params?: Record<string, unknown>) => string;
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
import type { KbJob } from '../api/kb.api';
|
||||
import type { PathUploadStatus, PathUploadTaskItem } from '../types/kb-workspace.types';
|
||||
import type { KbTranslateFn } from './kb-i18n.types';
|
||||
|
||||
export const getPathUploadJobProgress = (job: KbJob | null) => {
|
||||
const payload = job?.payload_json || {};
|
||||
@@ -32,22 +33,22 @@ export const getPathUploadJobPriority = (job: KbJob) => {
|
||||
return (hasProgress ? 1000 : 0) + statusScore;
|
||||
};
|
||||
|
||||
export const getPathUploadJobItems = (job: KbJob | null): PathUploadTaskItem[] => {
|
||||
export const getPathUploadJobItems = (job: KbJob | null, t: KbTranslateFn): PathUploadTaskItem[] => {
|
||||
if (!job || job.job_type !== 'path_upload') return [];
|
||||
const payload = job.payload_json || {};
|
||||
const files = Array.isArray(payload.files) ? payload.files : [];
|
||||
const failedCount = files.filter((item: { status?: string }) => String(item?.status || '').toLowerCase() === 'failed').length;
|
||||
return files.map((item: Record<string, unknown>, index: number) => ({
|
||||
key: `${job.id}-${item.relative_path || item.original_name || index}`,
|
||||
title: String(item.original_name || item.relative_path || `文件${index + 1}`),
|
||||
title: String(item.original_name || item.relative_path || t('kbWorkspace.errors.fileFallback', { index: index + 1 })),
|
||||
displayPath: String(item.relative_path || item.original_name || ''),
|
||||
rootLabel: String(item.relative_path || item.original_name || '').split('/')[0] || '本地目录',
|
||||
rootLabel: String(item.relative_path || item.original_name || '').split('/')[0] || t('kbWorkspace.errors.localFolder'),
|
||||
status: (['queued', 'uploading', 'success', 'failed'].includes(String(item.status))
|
||||
? item.status
|
||||
: 'queued') as PathUploadStatus,
|
||||
error: (item.error as string | undefined)
|
||||
|| (String(item.status || '').toLowerCase() === 'failed' && failedCount === 1
|
||||
? (job.error_message || job.message || '上传失败')
|
||||
? (job.error_message || job.message || t('kbWorkspace.errors.uploadFailed'))
|
||||
: undefined),
|
||||
documentId: (item.document_id as number | undefined) || undefined,
|
||||
retryable: Boolean(String(item.staged_path || '').trim()) && String(item.status || '').toLowerCase() === 'failed',
|
||||
@@ -56,11 +57,11 @@ export const getPathUploadJobItems = (job: KbJob | null): PathUploadTaskItem[] =
|
||||
}));
|
||||
};
|
||||
|
||||
export const hasRetryablePathUploadFailure = (job: KbJob | null) =>
|
||||
getPathUploadJobItems(job).some((item) => item.retryable);
|
||||
export const hasRetryablePathUploadFailure = (job: KbJob | null, t: KbTranslateFn) =>
|
||||
getPathUploadJobItems(job, t).some((item) => item.retryable);
|
||||
|
||||
export const getPathUploadJobSummary = (job: KbJob | null) => {
|
||||
const items = getPathUploadJobItems(job);
|
||||
export const getPathUploadJobSummary = (job: KbJob | null, t: KbTranslateFn) => {
|
||||
const items = getPathUploadJobItems(job, t);
|
||||
const total = Number(job?.payload_json?.total_files || job?.result_json?.total || items.length || 0);
|
||||
const success = Number(job?.result_json?.success || items.filter((item) => item.status === 'success').length || 0);
|
||||
const failed = Number(job?.result_json?.failed || items.filter((item) => item.status === 'failed').length || 0);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import type { KbDocumentItem, KbJob } from '../api/kb.api';
|
||||
import { IDLE_BADGE_CLASS, type WorkflowStageState } from '../types/kb-workspace.types';
|
||||
import { getStatusBadgeClass } from './kb-display.utils';
|
||||
import type { KbTranslateFn } from './kb-i18n.types';
|
||||
|
||||
export const isUnreadableErrorMessage = (value: string | null | undefined) => {
|
||||
const text = String(value || '').trim();
|
||||
@@ -17,27 +18,24 @@ export const isUnreadableErrorMessage = (value: string | null | undefined) => {
|
||||
export const normalizeWorkflowErrorMessage = (
|
||||
value: string | null | undefined,
|
||||
stage: 'upload' | 'clean' | 'sync',
|
||||
t: KbTranslateFn,
|
||||
) => {
|
||||
const text = String(value || '').trim();
|
||||
if (!text) return null;
|
||||
const upper = text.toUpperCase();
|
||||
if (isUnreadableErrorMessage(text)) {
|
||||
if (stage === 'clean') {
|
||||
return '历史失败任务原因不可读,请重新点击“清洗数据”发起清洗';
|
||||
}
|
||||
if (stage === 'sync') {
|
||||
return '历史同步失败原因不可读,请重新发起同步';
|
||||
}
|
||||
return '历史上传失败原因不可读,请重新上传文件';
|
||||
if (stage === 'clean') return t('kbWorkspace.errors.unreadableClean');
|
||||
if (stage === 'sync') return t('kbWorkspace.errors.unreadableSync');
|
||||
return t('kbWorkspace.errors.unreadableUpload');
|
||||
}
|
||||
if (upper.includes('LEGACY_CLEAN_TASK_RECOVERED_MANUALLY')) {
|
||||
return '历史遗留清洗任务已人工回收,请重新点击“清洗数据”发起清洗';
|
||||
return t('kbWorkspace.errors.legacyCleanRecovered');
|
||||
}
|
||||
if (upper.includes('SOURCE_FILE_NOT_FOUND') || text.includes('源文件不存在')) {
|
||||
return '原始文件不存在,请重新上传后再清洗';
|
||||
return t('kbWorkspace.errors.sourceFileNotFound');
|
||||
}
|
||||
if (upper.includes('CLEAN_TIMEOUT') || text.includes('清洗超时')) {
|
||||
return '文件清洗超时,请稍后重试;若多次失败,请检查源文件是否损坏';
|
||||
return t('kbWorkspace.errors.cleanTimeout');
|
||||
}
|
||||
return text;
|
||||
};
|
||||
@@ -69,6 +67,7 @@ export type GetLatestJobForDocument = ReturnType<typeof buildGetLatestJobForDocu
|
||||
export const getDocumentWorkflowState = (
|
||||
doc: KbDocumentItem,
|
||||
getLatestJobForDocument: GetLatestJobForDocument,
|
||||
t: KbTranslateFn,
|
||||
) => {
|
||||
const latestStatus = String(doc.latest_version?.status || '').toLowerCase();
|
||||
const uploadJob = getLatestJobForDocument(doc, 'upload');
|
||||
@@ -76,72 +75,73 @@ export const getDocumentWorkflowState = (
|
||||
const syncJob = getLatestJobForDocument(doc, 'sync_dify');
|
||||
|
||||
const uploadStage: WorkflowStageState = !doc.latest_version
|
||||
? { code: 'pending', label: '待上传', className: getStatusBadgeClass('draft') }
|
||||
? { code: 'pending', label: t('kbWorkspace.status.draft'), className: getStatusBadgeClass('draft') }
|
||||
: uploadJob?.status === 'failed'
|
||||
? {
|
||||
code: 'failed',
|
||||
label: '失败',
|
||||
label: t('kbWorkspace.status.failed'),
|
||||
className: getStatusBadgeClass('failed'),
|
||||
errorMessage: normalizeWorkflowErrorMessage(uploadJob.error_message || uploadJob.message, 'upload'),
|
||||
errorMessage: normalizeWorkflowErrorMessage(uploadJob.error_message || uploadJob.message, 'upload', t),
|
||||
}
|
||||
: { code: 'success', label: '已完成', className: getStatusBadgeClass('success') };
|
||||
: { code: 'success', label: t('kbWorkspace.status.done'), className: getStatusBadgeClass('success') };
|
||||
|
||||
let cleanStage: WorkflowStageState;
|
||||
if (!doc.latest_version) {
|
||||
cleanStage = { code: 'idle', label: '未开始', className: IDLE_BADGE_CLASS };
|
||||
cleanStage = { code: 'idle', label: t('kbWorkspace.status.idle'), className: IDLE_BADGE_CLASS };
|
||||
} else if (cleanJob?.status === 'failed' || latestStatus === 'failed') {
|
||||
cleanStage = {
|
||||
code: 'failed',
|
||||
label: '失败',
|
||||
label: t('kbWorkspace.status.failed'),
|
||||
className: getStatusBadgeClass('failed'),
|
||||
errorMessage: normalizeWorkflowErrorMessage(
|
||||
cleanJob?.error_message || doc.latest_version?.error_message || cleanJob?.message || null,
|
||||
'clean',
|
||||
t,
|
||||
),
|
||||
};
|
||||
} else if (['cleaned', 'ready', 'syncing', 'synced'].includes(latestStatus)) {
|
||||
cleanStage = { code: 'success', label: '已完成', className: getStatusBadgeClass('success') };
|
||||
cleanStage = { code: 'success', label: t('kbWorkspace.status.done'), className: getStatusBadgeClass('success') };
|
||||
} else if (['running', 'queued'].includes(String(cleanJob?.status || '').toLowerCase()) || latestStatus === 'processing') {
|
||||
cleanStage = {
|
||||
code: 'running',
|
||||
label: latestStatus === 'processing' ? '清洗中' : '待清洗',
|
||||
label: latestStatus === 'processing' ? t('kbWorkspace.status.cleaning') : t('kbWorkspace.status.pendingClean'),
|
||||
className: getStatusBadgeClass(latestStatus === 'processing' ? 'processing' : 'uploaded'),
|
||||
};
|
||||
} else if (latestStatus === 'uploaded') {
|
||||
cleanStage = { code: 'pending', label: '待清洗', className: getStatusBadgeClass('uploaded') };
|
||||
cleanStage = { code: 'pending', label: t('kbWorkspace.status.pendingClean'), className: getStatusBadgeClass('uploaded') };
|
||||
} else {
|
||||
cleanStage = { code: 'idle', label: '未开始', className: IDLE_BADGE_CLASS };
|
||||
cleanStage = { code: 'idle', label: t('kbWorkspace.status.idle'), className: IDLE_BADGE_CLASS };
|
||||
}
|
||||
|
||||
let syncStage: WorkflowStageState;
|
||||
if (!doc.latest_version || cleanStage.code === 'failed') {
|
||||
syncStage = { code: 'idle', label: '未开始', className: IDLE_BADGE_CLASS };
|
||||
syncStage = { code: 'idle', label: t('kbWorkspace.status.idle'), className: IDLE_BADGE_CLASS };
|
||||
} else if (syncJob?.status === 'failed') {
|
||||
syncStage = {
|
||||
code: 'failed',
|
||||
label: '失败',
|
||||
label: t('kbWorkspace.status.failed'),
|
||||
className: getStatusBadgeClass('failed'),
|
||||
errorMessage: normalizeWorkflowErrorMessage(syncJob.error_message || syncJob.message, 'sync'),
|
||||
errorMessage: normalizeWorkflowErrorMessage(syncJob.error_message || syncJob.message, 'sync', t),
|
||||
};
|
||||
} else if (latestStatus === 'synced' || syncJob?.status === 'success') {
|
||||
syncStage = { code: 'success', label: '已完成', className: getStatusBadgeClass('success') };
|
||||
syncStage = { code: 'success', label: t('kbWorkspace.status.done'), className: getStatusBadgeClass('success') };
|
||||
} else if (['running', 'queued'].includes(String(syncJob?.status || '').toLowerCase()) || latestStatus === 'syncing') {
|
||||
syncStage = {
|
||||
code: 'running',
|
||||
label: latestStatus === 'syncing' ? '同步中' : '待同步',
|
||||
label: latestStatus === 'syncing' ? t('kbWorkspace.status.syncing') : t('kbWorkspace.status.pendingSync'),
|
||||
className: getStatusBadgeClass(latestStatus === 'syncing' ? 'processing' : 'uploaded'),
|
||||
};
|
||||
} else if (['cleaned', 'ready'].includes(latestStatus)) {
|
||||
syncStage = { code: 'pending', label: '待同步', className: getStatusBadgeClass('uploaded') };
|
||||
syncStage = { code: 'pending', label: t('kbWorkspace.status.pendingSync'), className: getStatusBadgeClass('uploaded') };
|
||||
} else {
|
||||
syncStage = { code: 'idle', label: '未开始', className: IDLE_BADGE_CLASS };
|
||||
syncStage = { code: 'idle', label: t('kbWorkspace.status.idle'), className: IDLE_BADGE_CLASS };
|
||||
}
|
||||
|
||||
const primaryError =
|
||||
syncStage.errorMessage ||
|
||||
cleanStage.errorMessage ||
|
||||
uploadStage.errorMessage ||
|
||||
normalizeWorkflowErrorMessage(doc.latest_version?.error_message, 'clean') ||
|
||||
normalizeWorkflowErrorMessage(doc.latest_version?.error_message, 'clean', t) ||
|
||||
null;
|
||||
|
||||
return {
|
||||
@@ -155,39 +155,42 @@ export const getDocumentWorkflowState = (
|
||||
export const getWorkflowBadges = (
|
||||
doc: KbDocumentItem,
|
||||
getLatestJobForDocument: GetLatestJobForDocument,
|
||||
t: KbTranslateFn,
|
||||
) => {
|
||||
const workflow = getDocumentWorkflowState(doc, getLatestJobForDocument);
|
||||
const workflow = getDocumentWorkflowState(doc, getLatestJobForDocument, t);
|
||||
return [
|
||||
{ label: '上传', value: workflow.upload.label, className: workflow.upload.className },
|
||||
{ label: '清洗', value: workflow.clean.label, className: workflow.clean.className },
|
||||
{ label: '同步', value: workflow.sync.label, className: workflow.sync.className },
|
||||
{ label: t('kbWorkspace.workflow.upload'), value: workflow.upload.label, className: workflow.upload.className },
|
||||
{ label: t('kbWorkspace.workflow.clean'), value: workflow.clean.label, className: workflow.clean.className },
|
||||
{ label: t('kbWorkspace.workflow.sync'), value: workflow.sync.label, className: workflow.sync.className },
|
||||
];
|
||||
};
|
||||
|
||||
export const getMarkdownUnavailableMessage = (
|
||||
doc: KbDocumentItem,
|
||||
_getLatestJobForDocument: GetLatestJobForDocument,
|
||||
t: KbTranslateFn,
|
||||
fallback?: string | null,
|
||||
) => {
|
||||
const latestStatus = String(doc.latest_version?.status || '').toLowerCase();
|
||||
const normalizedReason = normalizeWorkflowErrorMessage(
|
||||
doc.latest_version?.error_message,
|
||||
'clean',
|
||||
t,
|
||||
);
|
||||
|
||||
if (latestStatus === 'failed') {
|
||||
return normalizedReason
|
||||
? `当前文档清洗失败,尚未生成 Markdown。失败原因:${normalizedReason}`
|
||||
: '当前文档清洗失败,尚未生成 Markdown,请重新清洗后重试';
|
||||
? t('kbWorkspace.msg.markdownFailedWithReason', { reason: normalizedReason })
|
||||
: t('kbWorkspace.msg.markdownFailedRetry');
|
||||
}
|
||||
|
||||
if (latestStatus === 'processing') {
|
||||
return '当前文档正在清洗中,暂未生成 Markdown,请稍后再试';
|
||||
return t('kbWorkspace.msg.markdownProcessing');
|
||||
}
|
||||
|
||||
if (latestStatus === 'uploaded') {
|
||||
return '当前文档待清洗,暂未生成 Markdown,请先发起清洗';
|
||||
return t('kbWorkspace.msg.markdownPendingClean');
|
||||
}
|
||||
|
||||
return fallback || '当前文档尚未生成 Markdown';
|
||||
return fallback || t('kbWorkspace.msg.markdownNotGenerated');
|
||||
};
|
||||
@@ -3,8 +3,8 @@
|
||||
* features/kb/views/KbWorkspaceView.vue
|
||||
* 知识库作业面视图壳:模板与弹窗布局,业务逻辑见 useKbWorkspace。
|
||||
*/
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Trash2, Upload, X } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Trash2, Upload } from 'lucide-vue-next';
|
||||
import KbWorkspaceOverlays from '../components/KbWorkspaceOverlays.vue';
|
||||
import { useKbWorkspace } from '../composables/useKbWorkspace';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -131,13 +131,12 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
/>
|
||||
<section class="kb-ws-section">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h2 class="text-lg font-semibold text-primary">分组列表</h2>
|
||||
<span class="text-xs text-muted">接口壳已接入</span>
|
||||
<h2 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.sidebar.groupsTitle') }}</h2>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.isLoading" class="py-10 text-center text-sm text-muted">正在加载分组...</div>
|
||||
<div v-if="kb.isLoading" class="py-10 text-center text-sm text-muted">{{ kb.t('kbWorkspace.sidebar.loadingGroups') }}</div>
|
||||
<div v-else-if="kb.groups.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
暂无知识库分组。后续接通 `/api/kb/groups` 后将在这里显示真实数据。
|
||||
{{ kb.t('kbWorkspace.sidebar.emptyGroups') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<button
|
||||
@@ -150,7 +149,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-semibold">{{ group.name }}</div>
|
||||
<div class="mt-1 text-sm opacity-80">{{ group.description || '暂无描述' }}</div>
|
||||
<div class="mt-1 text-sm opacity-80">{{ group.description || kb.t('kbWorkspace.sidebar.noDescription') }}</div>
|
||||
</div>
|
||||
<span class="rounded-full bg-surface/70 px-2 py-1 text-xs ">
|
||||
{{ group.document_count ?? 0 }}
|
||||
@@ -165,7 +164,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<div class="mb-4 space-y-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<h2 class="text-lg font-semibold text-primary">文档列表</h2>
|
||||
<h2 class="text-lg font-semibold text-primary">{{ kb.t('kbWorkspace.documents.title') }}</h2>
|
||||
<div class="group relative">
|
||||
<button
|
||||
type="button"
|
||||
@@ -174,7 +173,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<Info class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<div class="pointer-events-none absolute left-0 top-8 z-10 hidden w-80 rounded-2xl border border-default bg-surface px-4 py-3 text-sm text-muted shadow-xl group-hover:block">
|
||||
当前分组下的基础文档条目,上传文件后将自动创建文档并开始清洗流程。
|
||||
{{ kb.t('kbWorkspace.documents.infoTip') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -186,7 +185,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-brand-200 px-4 py-2.5 text-sm font-medium text-brand-700 transition-colors hover:bg-brand-50 disabled:cursor-not-allowed disabled:opacity-60 border-brand-200 hover:bg-brand-50"
|
||||
>
|
||||
<Upload class="h-4 w-4" />
|
||||
上传路径
|
||||
{{ kb.t('kbWorkspace.documents.uploadPath') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.selectedGroupId"
|
||||
@@ -195,7 +194,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="btn-primary"
|
||||
>
|
||||
<Upload class="h-4 w-4" />
|
||||
上传文件
|
||||
{{ kb.t('kbWorkspace.documents.uploadFile') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -207,7 +206,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-amber-200 px-4 py-2.5 text-sm font-medium text-amber-700 transition-colors hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
{{ kb.batchSubmitting ? '处理中...' : `清洗数据${kb.selectedDocuments.length ? `(${kb.selectedDocuments.length})` : ''}` }}
|
||||
{{ kb.batchActionLabel('clean', kb.batchSubmitting, kb.selectedDocuments.length) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin && kb.selectedGroupId"
|
||||
@@ -216,7 +215,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-emerald-200 px-4 py-2.5 text-sm font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
{{ kb.batchSubmitting ? '处理中...' : `批量同步${kb.selectedDocuments.length ? `(${kb.selectedDocuments.length})` : ''}` }}
|
||||
{{ kb.batchActionLabel('sync', kb.batchSubmitting, kb.selectedDocuments.length) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.selectedGroupId"
|
||||
@@ -225,7 +224,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-rose-200 px-4 py-2.5 text-sm font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
<Trash2 class="h-4 w-4" />
|
||||
{{ kb.batchSubmitting ? '处理中...' : `批量删除${kb.selectedDocuments.length ? `(${kb.selectedDocuments.length})` : ''}` }}
|
||||
{{ kb.batchActionLabel('delete', kb.batchSubmitting, kb.selectedDocuments.length) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.selectedGroupId"
|
||||
@@ -233,7 +232,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="btn-secondary"
|
||||
>
|
||||
<FileText class="h-4 w-4" />
|
||||
历史批次
|
||||
{{ kb.t('kbWorkspace.documents.historyBatches') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="kb.selectedGroupId" class="flex flex-wrap items-center gap-3">
|
||||
@@ -243,7 +242,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
v-model.trim="kb.documentKeyword"
|
||||
type="text"
|
||||
class="w-full rounded-2xl border border-default bg-surface py-2.5 pl-10 pr-4 text-sm text-primary outline-none transition-colors focus:border-brand-300"
|
||||
placeholder="按文件名称模糊搜索"
|
||||
:placeholder="kb.t('kbWorkspace.documents.searchPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
@@ -252,7 +251,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
@click="kb.documentKeyword = ''"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
清空搜索
|
||||
{{ kb.t('kbWorkspace.documents.clearSearch') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -271,29 +270,29 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
路径上传进度
|
||||
{{ kb.t('kbWorkspace.pathUpload.progressTitle') }}
|
||||
<span
|
||||
class="ml-2 inline-flex items-center rounded-full border px-2.5 py-1 text-xs"
|
||||
:class="kb.pathUploadRunning
|
||||
? 'border-amber-200 bg-amber-50 text-amber-700 border-amber-200'
|
||||
: 'border-emerald-200 bg-emerald-50 text-emerald-700 border-emerald-200 '"
|
||||
>
|
||||
{{ kb.pathUploadRunning ? '上传中' : '已完成' }}
|
||||
{{ kb.pathUploadRunning ? kb.t('kbWorkspace.pathUpload.uploading') : kb.t('kbWorkspace.pathUpload.completed') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-muted">
|
||||
建议每批 {{ kb.pathUploadTask.batchSize }} 条,间隔 {{ kb.PATH_UPLOAD_BATCH_INTERVAL_MS / 1000 }} 秒自动继续。
|
||||
{{ kb.t('kbWorkspace.pathUpload.batchHint', { batchSize: kb.pathUploadTask.batchSize, seconds: kb.PATH_UPLOAD_BATCH_INTERVAL_MS / 1000 }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-2 text-sm text-secondary md:grid-cols-4">
|
||||
<div>总计 {{ kb.pathUploadSummary.total }}</div>
|
||||
<div>待上传 {{ kb.pathUploadSummary.pending }}</div>
|
||||
<div>已上传 {{ kb.pathUploadSummary.uploaded }}</div>
|
||||
<div>失败 {{ kb.pathUploadSummary.failed }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.total', { count: kb.pathUploadSummary.total }) }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.pending', { count: kb.pathUploadSummary.pending }) }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.uploaded', { count: kb.pathUploadSummary.uploaded }) }}</div>
|
||||
<div>{{ kb.t('kbWorkspace.pathUpload.failed', { count: kb.pathUploadSummary.failed }) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="kb.pathUploadTask.currentFile" class="mt-3 text-sm text-brand-600 ">
|
||||
当前文件:{{ kb.pathUploadTask.currentFile }}
|
||||
{{ kb.t('kbWorkspace.pathUpload.currentFile', { name: kb.pathUploadTask.currentFile }) }}
|
||||
</div>
|
||||
<div class="mt-4 space-y-2">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
@@ -302,7 +301,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
@click="kb.showPathUploadDetails = !kb.showPathUploadDetails"
|
||||
class="inline-flex items-center gap-2 text-sm font-medium text-secondary transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
<span>上传详情</span>
|
||||
<span>{{ kb.t('kbWorkspace.pathUpload.details') }}</span>
|
||||
<ChevronDown v-if="!kb.showPathUploadDetails" class="h-4 w-4" />
|
||||
<ChevronUp v-else class="h-4 w-4" />
|
||||
</button>
|
||||
@@ -311,7 +310,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
@click="kb.openPathUploadHistoryModal(kb.latestPathUploadJob?.id || null)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
查看历史
|
||||
{{ kb.t('kbWorkspace.pathUpload.viewHistory') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.latestPathUploadJob && kb.hasRetryablePathUploadFailure(kb.latestPathUploadJob) && !kb.pathUploadRunning"
|
||||
@@ -319,7 +318,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
:disabled="kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:all`"
|
||||
class="inline-flex items-center rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
{{ kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:all` ? '处理中...' : '重试失败文件' }}
|
||||
{{ kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:all` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.pathUpload.retryFailedFiles') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -332,7 +331,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate font-medium text-primary">{{ item.title }}</div>
|
||||
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
|
||||
<div v-if="item.error" class="mt-1 text-xs text-rose-500">失败原因:{{ item.error }}</div>
|
||||
<div v-if="item.error" class="mt-1 text-xs text-rose-500">{{ kb.t('kbWorkspace.common.failureReason', { reason: item.error }) }}</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
@@ -347,14 +346,14 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
:disabled="kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:${item.displayPath}`"
|
||||
class="inline-flex items-center rounded-xl border border-rose-200 px-2.5 py-1 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
{{ kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:${item.displayPath}` ? '处理中...' : '重试' }}
|
||||
{{ kb.retryingPathUploadKey === `${kb.latestPathUploadJob.id}:${item.displayPath}` ? kb.t('kbWorkspace.common.processing') : kb.t('kbWorkspace.common.retry') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.latestPathUploadJob && !kb.pathUploadRunning"
|
||||
@click="kb.handleDeletePathUploadItem(kb.latestPathUploadJob, item)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
删除
|
||||
{{ kb.t('kbWorkspace.common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -370,7 +369,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
@click="kb.toggleSelectAllFiltered"
|
||||
class="inline-flex items-center gap-2 rounded-full border border-default bg-surface px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.isAllFilteredSelected ? '取消全选' : '全选当前筛选' }}
|
||||
{{ kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="tab in kb.stageFilterTabs"
|
||||
@@ -387,28 +386,28 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<label class="inline-flex items-center gap-2">
|
||||
<span>每页</span>
|
||||
<span>{{ kb.t('kbWorkspace.common.perPage') }}</span>
|
||||
<select
|
||||
v-model.number="kb.documentListPageSize"
|
||||
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-secondary outline-none transition-colors focus:border-brand-300"
|
||||
>
|
||||
<option v-for="size in kb.DOCUMENT_PAGE_SIZE_OPTIONS" :key="size" :value="size">{{ size }}</option>
|
||||
</select>
|
||||
<span>条</span>
|
||||
<span>{{ kb.t('kbWorkspace.common.countUnit') }}</span>
|
||||
</label>
|
||||
<span>已选 {{ kb.selectedDocuments.length }} 条 · 共 {{ kb.filteredDocuments.length }} 条</span>
|
||||
<span v-if="kb.filteredDocuments.length > 0">当前显示 {{ kb.pagedDocumentRange.start }}-{{ kb.pagedDocumentRange.end }} 条</span>
|
||||
<span>{{ kb.t('kbWorkspace.documents.selectedCount', { selected: kb.selectedDocuments.length, total: kb.filteredDocuments.length }) }}</span>
|
||||
<span v-if="kb.filteredDocuments.length > 0">{{ kb.t('kbWorkspace.documents.showingRange', { start: kb.pagedDocumentRange.start, end: kb.pagedDocumentRange.end }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!kb.selectedGroupId" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
|
||||
请选择一个知识库分组。
|
||||
{{ kb.t('kbWorkspace.documents.selectGroup') }}
|
||||
</div>
|
||||
<div v-else-if="kb.isDocumentsLoading" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
|
||||
正在加载文档...
|
||||
{{ kb.t('kbWorkspace.documents.loadingDocuments') }}
|
||||
</div>
|
||||
<div v-else-if="kb.filteredDocuments.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
|
||||
{{ kb.documents.length === 0 ? '当前分组暂无文档,可直接在上方创建第一条文档记录。' : (kb.documentKeyword ? '当前搜索和筛选条件下暂无匹配文档。' : '当前筛选条件下暂无匹配文档。') }}
|
||||
{{ kb.documentEmptyMessage(kb.documents.length, !!kb.documentKeyword) }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
@@ -444,9 +443,9 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
{{ kb.getDocumentDisplayDescription(doc) }}
|
||||
</button>
|
||||
<div class="mt-2 text-xs text-muted">
|
||||
<span>版本数:{{ doc.version_count ?? 0 }}</span>
|
||||
<span>{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
|
||||
<span v-if="doc.latest_version">
|
||||
<span> · 当前版本:v{{ doc.latest_version.version_no }} · </span>
|
||||
<span>{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
@@ -464,14 +463,14 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
>
|
||||
<FileText class="h-3.5 w-3.5" />
|
||||
查看记录
|
||||
{{ kb.t('kbWorkspace.documents.viewRecord') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.triggerUploadForDocument(doc.id)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
|
||||
>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
上传版本
|
||||
{{ kb.t('kbWorkspace.documents.uploadVersion') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@@ -480,27 +479,27 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ kb.syncingDocumentId === doc.id ? '同步中...' : '同步 Dify' }}
|
||||
{{ kb.syncingDocumentId === doc.id ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleDeleteDocument(doc)"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
删除
|
||||
{{ kb.t('kbWorkspace.common.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex items-end justify-between gap-3 border-kb.t border-default pt-3 ">
|
||||
<div class="mt-4 flex items-end justify-between gap-3 border-t border-default pt-3 ">
|
||||
<div class="space-y-1">
|
||||
<div class="text-xs text-muted">
|
||||
更新时间:{{ kb.formatDateTime(doc.updated_at) }}
|
||||
{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.getDocumentWorkflowState(doc).primaryError"
|
||||
class="max-w-xl text-xs text-rose-500"
|
||||
>
|
||||
失败原因:{{ kb.getDocumentWorkflowState(doc).primaryError }}
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: kb.getDocumentWorkflowState(doc).primaryError }) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center justify-end gap-2">
|
||||
@@ -520,7 +519,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
class="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
|
||||
>
|
||||
<div class="text-sm text-muted">
|
||||
第 {{ kb.documentListPage }} / {{ kb.filteredDocumentTotalPages }} 页 · 共 {{ kb.filteredDocuments.length }} 条
|
||||
{{ kb.t('kbWorkspace.documents.pageInfo', { page: kb.documentListPage, totalPages: kb.filteredDocumentTotalPages, total: kb.filteredDocuments.length }) }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@@ -528,14 +527,14 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
:disabled="kb.documentListPage === 1"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
上一页
|
||||
{{ kb.t('kbWorkspace.common.prevPage') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.documentListPage = Math.min(kb.filteredDocumentTotalPages, kb.documentListPage + 1)"
|
||||
:disabled="kb.documentListPage === kb.filteredDocumentTotalPages"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
下一页
|
||||
{{ kb.t('kbWorkspace.common.nextPage') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -546,621 +545,8 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.showRecordModal"
|
||||
class="dialog-overlay z-[55] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-5xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">文档记录</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
当前查看:{{ kb.selectedDocument ? kb.getDocumentDisplayTitle(kb.selectedDocument) : `文档 #${kb.selectedDocumentId}` }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeDocumentDetail"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.isRecordLoading" class="flex min-h-[360px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
正在加载文档记录...
|
||||
</div>
|
||||
<div v-else class="space-y-6 overflow-y-auto pr-1">
|
||||
<div>
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h3 class="text-base font-semibold text-primary">版本记录</h3>
|
||||
<span class="text-xs text-muted">{{ kb.selectedDocumentVersions.length }} 条</span>
|
||||
</div>
|
||||
<div v-if="kb.selectedDocumentVersions.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
暂无版本记录,上传版本后会显示在这里。
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="version in kb.selectedDocumentVersions"
|
||||
:key="version.id"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-primary">
|
||||
v{{ version.version_no }} · {{ version.source_file_name }}
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(version.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(version.status) }}
|
||||
</span>
|
||||
<span>大小:{{ version.source_file_size ?? 0 }} bytes</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.formatDateTime(version.created_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h3 class="text-base font-semibold text-primary">Dify 同步记录</h3>
|
||||
<span class="text-xs text-muted">{{ kb.selectedDocumentSyncRecords.length }} 条</span>
|
||||
</div>
|
||||
<div v-if="kb.selectedDocumentSyncRecords.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
暂无 Dify 同步记录,手动点击“同步 Dify”后会显示在这里。
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
v-for="record in kb.selectedDocumentSyncRecords"
|
||||
:key="record.id"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-primary">
|
||||
{{ record.dataset_name || record.dataset_id }} · {{ record.remote_document_name || record.remote_document_id }}
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(record.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(record.status) }}
|
||||
</span>
|
||||
<span>版本:{{ record.document_version_id }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.formatDateTime(record.updated_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.showMarkdownModal"
|
||||
class="dialog-overlay z-[60] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-5xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<h3 class="truncate text-lg font-semibold text-primary">{{ kb.markdownModalTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ kb.markdownVersionLabel || '正在读取当前版本...' }}
|
||||
<span class="ml-2 rounded-full bg-surface-soft px-2 py-0.5 text-xs text-muted">
|
||||
{{ kb.markdownKind === 'preview' ? '预览文本' : '清洗 Markdown' }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeMarkdownModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="kb.markdownError"
|
||||
class="mb-4 text-sm text-rose-500"
|
||||
>
|
||||
{{ kb.markdownError }}
|
||||
</p>
|
||||
|
||||
<div v-if="kb.isMarkdownLoading" class="flex min-h-[420px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
正在加载清洗后的 Markdown...
|
||||
</div>
|
||||
<textarea
|
||||
v-else
|
||||
v-model="kb.markdownContent"
|
||||
spellcheck="false"
|
||||
class="min-h-[420px] w-full flex-1 rounded-2xl border border-default bg-surface-soft px-4 py-3 font-mono text-sm text-primary outline-none transition-colors focus:border-brand-300 focus:bg-surface"
|
||||
placeholder="当前文档尚未生成 Markdown,可在此粘贴或编辑内容。"
|
||||
/>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.closeMarkdownModal"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
关闭
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleSaveMarkdown"
|
||||
:disabled="kb.isMarkdownLoading || kb.isMarkdownSaving || !kb.markdownDocumentId"
|
||||
class="inline-flex items-center justify-center rounded-xl bg-brand-600px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{{ kb.isMarkdownSaving ? '保存中...' : '保存 Markdown' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.showSourceInfoModal"
|
||||
class="dialog-overlay z-[58] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-4xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<h3 class="truncate text-lg font-semibold text-primary">源文件信息</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
当前查看:{{ kb.sourceInfoDocument ? kb.getDocumentDisplayTitle(kb.sourceInfoDocument) : `文档 #${kb.sourceInfoDocumentId}` }}
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeSourceInfoModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.isSourceInfoLoading" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
正在加载源文件信息...
|
||||
</div>
|
||||
<div v-else-if="kb.sourceInfoVersions.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
暂无源文件信息,上传版本后会显示在这里。
|
||||
</div>
|
||||
<div v-else class="space-y-3 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="version in kb.sourceInfoVersions"
|
||||
:key="version.id"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.openOriginalSourceFile(version)"
|
||||
class="font-semibold text-primary underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
|
||||
>
|
||||
v{{ version.version_no }} · {{ version.source_file_name }}
|
||||
</button>
|
||||
<span
|
||||
v-if="version.is_current"
|
||||
class="inline-flex items-center rounded-full border border-brand-200 bg-brand-50 px-2.5 py-1 text-xs font-semibold text-brand-700 border-brand-200"
|
||||
>
|
||||
当前版本
|
||||
</span>
|
||||
<span
|
||||
v-if="kb.openingSourceVersionId === version.id"
|
||||
class="text-xs text-muted"
|
||||
>
|
||||
正在打开...
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(version.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(version.status) }}
|
||||
</span>
|
||||
<span>文件名:{{ version.source_file_name }}</span>
|
||||
<span>大小:{{ kb.formatFileSize(version.source_file_size) }}</span>
|
||||
<span v-if="version.source_file_ext">类型:{{ version.source_file_ext }}</span>
|
||||
</div>
|
||||
<div v-if="version.error_message" class="mt-2 text-sm text-rose-500">
|
||||
失败原因:{{ version.error_message }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ kb.formatDateTime(version.created_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.closeSourceInfoModal"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
关闭
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.showFailureModal"
|
||||
class="dialog-overlay z-[65] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-6xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ kb.failureModalTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
当前分组共 {{ kb.failureModalItems.length }} 条失败记录,每页 {{ kb.FAILURE_PAGE_SIZE }} 条。
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closeFailureModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.failureModalItems.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
当前没有失败数据。
|
||||
</div>
|
||||
<div v-else class="space-y-4 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="item in kb.pagedFailureModalItems"
|
||||
:key="item.key"
|
||||
class="rounded-2xl border border-default px-4 py-4 "
|
||||
>
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<div class="max-w-full truncate text-base font-semibold text-primary">
|
||||
{{ kb.getDocumentDisplayTitle(item.document) }}
|
||||
</div>
|
||||
<span class="inline-flex items-center rounded-full border border-rose-200 bg-rose-50 px-2.5 py-1 text-xs font-semibold text-rose-700 border-rose-200">
|
||||
{{ item.stageLabel }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-muted">
|
||||
当前版本:
|
||||
<span v-if="item.document.latest_version">
|
||||
v{{ item.document.latest_version.version_no }} · {{ item.document.latest_version.source_file_name }}
|
||||
</span>
|
||||
<span v-else>暂无版本</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-rose-500">
|
||||
失败原因:{{ item.errorMessage }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="shrink-0 text-right text-sm text-muted">
|
||||
{{ kb.formatDateTime(item.updatedAt) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@click="kb.handleRetryFailedItem(item, 'submit')"
|
||||
:disabled="kb.retryingFailureKey === `${item.key}-submit`"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-sky-200 px-3 py-2 text-xs font-medium text-sky-700 transition-colors hover:bg-sky-50 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{{ kb.retryingFailureKey === `${item.key}-submit` ? '处理中...' : '重新提交' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleRetryFailedItem(item, 'clean')"
|
||||
:disabled="kb.retryingFailureKey === `${item.key}-clean` || !item.document.latest_version"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-amber-200 px-3 py-2 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50 disabled:cursor-not-allowed disabled:opacity-60 border-amber-200"
|
||||
>
|
||||
{{ kb.retryingFailureKey === `${item.key}-clean` ? '处理中...' : '重新清洗' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleRetryFailedItem(item, 'sync')"
|
||||
:disabled="kb.retryingFailureKey === `${item.key}-sync` || !item.document.latest_version"
|
||||
class="inline-flex items-center gap-2 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
|
||||
>
|
||||
{{ kb.retryingFailureKey === `${item.key}-sync` ? '处理中...' : '重新同步' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="kb.failureModalItems.length > kb.FAILURE_PAGE_SIZE"
|
||||
class="mt-5 flex items-center justify-between gap-3 border-kb.t border-default pt-4 "
|
||||
>
|
||||
<div class="text-sm text-muted">
|
||||
第 {{ kb.failureModalPage }} / {{ kb.failureModalTotalPages }} 页
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="kb.failureModalPage = Math.max(1, kb.failureModalPage - 1)"
|
||||
:disabled="kb.failureModalPage === 1"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
上一页
|
||||
</button>
|
||||
<button
|
||||
@click="kb.failureModalPage = Math.min(kb.failureModalTotalPages, kb.failureModalPage + 1)"
|
||||
:disabled="kb.failureModalPage === kb.failureModalTotalPages"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60 hover-surface-soft"
|
||||
>
|
||||
下一页
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.showPathUploadModal"
|
||||
class="dialog-overlay z-[66] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-4xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">上传路径</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
选择本地目录后,系统会按批次将该路径下文件导入当前分组并自动进入清洗流程。
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closePathUploadModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4 overflow-y-auto pr-1">
|
||||
<div class="rounded-2xl border border-default bg-surface-soft p-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-sm font-medium text-primary">本地路径选择</div>
|
||||
<div class="mt-1 text-xs text-muted">
|
||||
支持多次选择目录追加文件;当前浏览器安全限制下,手动粘贴任意本机路径不能直接读取文件内容。
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.triggerPathUploadSelection"
|
||||
class="inline-flex items-center gap-2 rounded-2xl border border-brand-200 px-4 py-2.5 text-sm font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
|
||||
>
|
||||
<Upload class="h-4 w-4" />
|
||||
选择本地目录
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label-field block mb-2">路径清单</label>
|
||||
<textarea
|
||||
v-model="kb.pathUploadDraftText"
|
||||
rows="5"
|
||||
class="input-field"
|
||||
placeholder="目录选择后会自动填充路径清单;如需记录多路径,可在此粘贴备注。"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-2 flex items-center justify-between gap-3">
|
||||
<div class="text-sm font-medium text-secondary">
|
||||
待上传文件
|
||||
<span class="ml-2 text-xs text-muted">{{ kb.pathUploadSelectedFiles.length }} 条</span>
|
||||
</div>
|
||||
<div class="text-xs text-muted">
|
||||
已选根路径:{{ kb.selectedPathRoots.length ? kb.selectedPathRoots.join('、') : '暂无' }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="kb.pathUploadSelectedFiles.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-8 text-center text-sm text-muted ">
|
||||
请选择本地目录后再确认上传。
|
||||
</div>
|
||||
<div v-else class="max-h-72 space-y-2 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="item in kb.pathUploadSelectedFiles"
|
||||
:key="item.key"
|
||||
class="flex items-start justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
|
||||
>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate text-sm font-medium text-primary">{{ item.file.name }}</div>
|
||||
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.removeSelectedPathFile(item.key)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
移除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.closePathUploadModal"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleConfirmPathUpload"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-brand-600px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700"
|
||||
>
|
||||
<Upload class="h-4 w-4" />
|
||||
确认上传
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.showPathUploadHistoryModal"
|
||||
class="dialog-overlay z-[67] items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-6xl max-h-[90vh] p-6">
|
||||
<div class="mb-4 flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">上传路径历史批次</h3>
|
||||
<p class="mt-1 text-sm text-muted">查看每次路径上传的批次结果、失败文件与重试入口。</p>
|
||||
</div>
|
||||
<button
|
||||
@click="kb.closePathUploadHistoryModal"
|
||||
class="rounded-full p-1 text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
<X class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.pathUploadHistoryJobs.length === 0" class="flex min-h-[320px] items-center justify-center rounded-2xl border border-dashed border-default text-sm text-muted ">
|
||||
当前暂无上传路径历史批次。
|
||||
</div>
|
||||
<div v-else class="grid min-h-0 flex-1 grid-cols-1 gap-4 lg:grid-cols-[320px_minmax(0,1fr)]">
|
||||
<div class="space-y-3 overflow-y-auto pr-1">
|
||||
<button
|
||||
v-for="job in kb.pathUploadHistoryJobs"
|
||||
:key="job.id"
|
||||
@click="kb.selectedPathUploadHistoryJobId = job.id"
|
||||
class="w-full rounded-2xl border px-4 py-4 text-left transition-colors"
|
||||
:class="String(kb.selectedPathUploadHistoryJobId || kb.selectedPathUploadHistoryJob?.id) === String(job.id)
|
||||
? 'border-brand-200 bg-brand-50 border-brand-200 '
|
||||
: 'border-default bg-surface hover:bg-surface-soft hover-surface-soft'"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-semibold text-primary">批次 #{{ job.id }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ kb.formatDateTime(job.created_at) }}</div>
|
||||
</div>
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(job.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(job.status) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3 grid grid-cols-2 gap-2 text-xs text-muted">
|
||||
<div>总计 {{ kb.getPathUploadJobSummary(job).total }}</div>
|
||||
<div>成功 {{ kb.getPathUploadJobSummary(job).success }}</div>
|
||||
<div>失败 {{ kb.getPathUploadJobSummary(job).failed }}</div>
|
||||
<div>待处理 {{ kb.getPathUploadJobSummary(job).pending }}</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="kb.selectedPathUploadHistoryJob" class="min-h-0 rounded-2xl border border-default p-4 ">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-base font-semibold text-primary">批次 #{{ kb.selectedPathUploadHistoryJob.id }}</div>
|
||||
<div class="mt-1 text-sm text-muted">
|
||||
创建时间:{{ kb.formatDateTime(kb.selectedPathUploadHistoryJob.created_at) }}
|
||||
<span v-if="kb.selectedPathUploadHistoryJob.finished_at"> · 完成时间:{{ kb.formatDateTime(kb.selectedPathUploadHistoryJob.finished_at) }}</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-muted">{{ kb.selectedPathUploadHistoryJob.message || '暂无批次说明' }}</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getStatusBadgeClass(kb.selectedPathUploadHistoryJob.status)"
|
||||
>
|
||||
{{ kb.getStatusLabel(kb.selectedPathUploadHistoryJob.status) }}
|
||||
</span>
|
||||
<button
|
||||
v-if="kb.selectedPathUploadHistoryItems.length && !kb.pathUploadRunning"
|
||||
@click="kb.toggleSelectAllPathUploadHistoryItems"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
{{ kb.isAllPathUploadHistoryItemsSelected ? '取消全选' : '全选' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!kb.pathUploadRunning"
|
||||
@click="kb.handleBatchDeletePathUploadItems"
|
||||
:disabled="!kb.selectedPathUploadHistorySelectedItems.length || kb.deletingPathUploadBatch"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
{{ kb.deletingPathUploadBatch ? '删除中...' : `批量删除${kb.selectedPathUploadHistorySelectedItems.length ? ` (${kb.selectedPathUploadHistorySelectedItems.length})` : ''}` }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.hasRetryablePathUploadFailure(kb.selectedPathUploadHistoryJob) && !kb.pathUploadRunning"
|
||||
@click="kb.handleRetryFailedPathUpload(kb.selectedPathUploadHistoryJob)"
|
||||
:disabled="kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:all`"
|
||||
class="inline-flex items-center rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
{{ kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:all` ? '处理中...' : '重试全部失败文件' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-2 gap-3 text-sm text-secondary md:grid-cols-4">
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">总计 {{ kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).total }}</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">成功 {{ kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).success }}</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">失败 {{ kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).failed }}</div>
|
||||
<div class="rounded-xl bg-surface-soft px-3 py-2 ">待处理 {{ kb.getPathUploadJobSummary(kb.selectedPathUploadHistoryJob).pending }}</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 max-h-[50vh] space-y-2 overflow-y-auto pr-1">
|
||||
<div
|
||||
v-for="item in kb.selectedPathUploadHistoryItems"
|
||||
:key="item.key"
|
||||
class="flex flex-wrap items-start justify-between gap-3 rounded-2xl border border-default px-4 py-3 "
|
||||
>
|
||||
<label class="flex items-center pt-1">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="kb.selectedPathUploadHistoryItemKeys.includes(item.key)"
|
||||
@change="kb.togglePathUploadHistoryItemSelection(item.key)"
|
||||
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
/>
|
||||
</label>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="truncate text-sm font-medium text-primary">{{ item.title }}</div>
|
||||
<div class="mt-1 truncate text-xs text-muted">{{ item.displayPath }}</div>
|
||||
<div v-if="item.error" class="mt-1 text-xs text-rose-500">失败原因:{{ item.error }}</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-semibold"
|
||||
:class="kb.getPathUploadItemDisplayState(item).className"
|
||||
>
|
||||
{{ kb.getPathUploadItemDisplayState(item).label }}
|
||||
</span>
|
||||
<button
|
||||
v-if="item.retryable && !kb.pathUploadRunning"
|
||||
@click="kb.handleRetryFailedPathUpload(kb.selectedPathUploadHistoryJob, [item.displayPath])"
|
||||
:disabled="kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:${item.displayPath}`"
|
||||
class="inline-flex items-center rounded-xl border border-rose-200 px-2.5 py-1 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60 border-rose-200 hover:bg-rose-50"
|
||||
>
|
||||
{{ kb.retryingPathUploadKey === `${kb.selectedPathUploadHistoryJob.id}:${item.displayPath}` ? '处理中...' : '重试' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!kb.pathUploadRunning"
|
||||
@click="kb.handleDeletePathUploadItem(kb.selectedPathUploadHistoryJob, item)"
|
||||
class="inline-flex items-center rounded-xl border border-default px-2.5 py-1 text-xs font-medium text-muted transition-colors hover:bg-surface-soft hover-surface-soft"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="kb.showDeleteConfirmDialog"
|
||||
:message="kb.deleteConfirmMessage"
|
||||
@confirm="kb.handleDeleteConfirm"
|
||||
@cancel="kb.closeDeleteConfirmDialog"
|
||||
/>
|
||||
<KbWorkspaceOverlays :kb="kb" />
|
||||
</template>
|
||||
|
||||
|
||||
Reference in new issue
Block a user