fix(knowdge-base): 知识库页面样式优化
This commit is contained in:
1 parent
09cd6fc3c7
commit
599475d4e2
5 files changed
+154
-189
No files matched your search
@@ -3,7 +3,8 @@
|
||||
* features/kb/views/KbWorkspaceView.vue
|
||||
* 知识库作业面视图壳:模板与弹窗布局,业务逻辑见 useKbWorkspace。
|
||||
*/
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Settings, Trash2, Upload } from 'lucide-vue-next';
|
||||
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Settings, SquareCheck, Trash2, Upload } from 'lucide-vue-next';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import KbWorkspaceOverlays from '../components/KbWorkspaceOverlays.vue';
|
||||
import { useKbWorkspace } from '../composables/useKbWorkspace';
|
||||
|
||||
@@ -45,14 +46,6 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button
|
||||
v-if="kb.viewMode !== 'group_overview'"
|
||||
@click="kb.refreshCurrentView"
|
||||
class="btn-secondary"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
{{ kb.t('kbWorkspace.actions.refreshDocuments') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.viewMode === 'group_overview'"
|
||||
type="button"
|
||||
@@ -233,12 +226,6 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<ChevronUp v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@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"
|
||||
@click="kb.handleRetryFailedPathUpload(kb.latestPathUploadJob)"
|
||||
@@ -293,57 +280,6 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
>
|
||||
<div class="flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
v-for="tab in kb.stageFilterTabs"
|
||||
:key="tab.key"
|
||||
@click="kb.documentStageFilter = tab.key"
|
||||
class="inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition-colors"
|
||||
:class="kb.documentStageFilter === tab.key
|
||||
? 'border-brand-200 bg-brand-50 text-brand-700'
|
||||
: 'border-default bg-surface text-secondary hover:bg-surface-soft'"
|
||||
>
|
||||
<span>{{ tab.label }}</span>
|
||||
<span class="rounded-full bg-surface-soft px-2 py-0.5 text-xs">{{ tab.count }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<label class="relative min-w-[260px] flex-1 xl:w-80 xl:flex-none">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
<input
|
||||
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="kb.t('kbWorkspace.documents.searchPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="kb.documentKeyword"
|
||||
type="button"
|
||||
@click="kb.documentKeyword = ''"
|
||||
class="inline-flex items-center rounded-xl border border-default bg-surface px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.documents.clearSearch') }}
|
||||
</button>
|
||||
<label class="inline-flex items-center gap-2">
|
||||
<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>{{ kb.t('kbWorkspace.common.countUnit') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-3 border-t border-default pt-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@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"
|
||||
>
|
||||
{{ kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="kb.isKbAdmin"
|
||||
@click="kb.handleBatchClean"
|
||||
@@ -370,17 +306,52 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
<Trash2 class="h-4 w-4" />
|
||||
{{ kb.batchActionLabel('delete', kb.batchSubmitting, kb.selectedDocuments.length) }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.openPathUploadHistoryModal()"
|
||||
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"
|
||||
>
|
||||
<FileText class="h-4 w-4" />
|
||||
{{ kb.t('kbWorkspace.documents.historyBatches') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<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 class="flex flex-wrap items-center gap-3 text-sm text-muted">
|
||||
<label class="relative w-full max-w-md">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
<input
|
||||
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="kb.t('kbWorkspace.documents.searchPlaceholder')"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="kb.documentKeyword"
|
||||
type="button"
|
||||
@click="kb.documentKeyword = ''"
|
||||
class="inline-flex items-center rounded-xl border border-default bg-surface px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.documents.clearSearch') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 border-t border-default pt-3 xl:flex-row xl:items-center xl:justify-between">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
@click="kb.toggleSelectAllFiltered"
|
||||
class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-muted transition-colors hover:bg-surface hover:text-brand-600"
|
||||
:class="kb.isAllFilteredSelected ? 'bg-brand-50 text-brand-600' : ''"
|
||||
:title="kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered')"
|
||||
:aria-label="kb.isAllFilteredSelected ? kb.t('kbWorkspace.pathUpload.deselectAllFiltered') : kb.t('kbWorkspace.pathUpload.selectAllFiltered')"
|
||||
>
|
||||
<SquareCheck class="h-[18px] w-[18px]" />
|
||||
</button>
|
||||
<button
|
||||
v-for="tab in kb.stageFilterTabs.filter((item) => item.key !== 'all')"
|
||||
:key="tab.key"
|
||||
@click="kb.documentStageFilter = kb.documentStageFilter === tab.key ? 'all' : tab.key"
|
||||
class="inline-flex items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium transition-colors"
|
||||
:class="kb.documentStageFilter === tab.key
|
||||
? 'border-brand-200 bg-brand-50 text-brand-700'
|
||||
: 'border-default bg-surface text-secondary hover:bg-surface-soft'"
|
||||
>
|
||||
<span>{{ tab.label }}</span>
|
||||
<span class="rounded-full bg-surface-soft px-2 py-0.5 text-xs">{{ tab.count }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -403,121 +374,111 @@ const kb = useKbWorkspace({ embedded: props.embedded });
|
||||
? 'border-brand-200 bg-brand-50/50 border-brand-200'
|
||||
: 'border-default'"
|
||||
>
|
||||
<div class="grid gap-3 2xl:grid-cols-[minmax(420px,1fr)_minmax(280px,auto)_minmax(320px,auto)] 2xl:items-center">
|
||||
<div class="flex min-w-0 gap-3">
|
||||
<label class="mt-1 inline-flex shrink-0 cursor-pointer items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
:checked="kb.selectedDocumentIds.includes(doc.id)"
|
||||
@change="kb.toggleDocumentSelection(doc.id)"
|
||||
/>
|
||||
</label>
|
||||
<div class="min-w-0 flex-1">
|
||||
<button
|
||||
@click="kb.openMarkdownEditor(doc)"
|
||||
class="block max-w-full truncate text-left font-semibold text-primary transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ kb.getDocumentDisplayTitle(doc) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
class="mt-1 block max-w-full truncate text-left text-sm text-muted transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ kb.getDocumentDisplayDescription(doc) }}
|
||||
</button>
|
||||
<div class="mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted">
|
||||
<span class="shrink-0">{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
|
||||
<span v-if="doc.latest_version" class="shrink-0">{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
|
||||
<div class="space-y-3">
|
||||
<div class="grid gap-3 lg:grid-cols-[minmax(360px,1fr)_auto] lg:items-start">
|
||||
<div class="flex min-w-0 gap-3">
|
||||
<label class="mt-1 inline-flex shrink-0 cursor-pointer items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-brand-600 focus:ring-brand-500"
|
||||
:checked="kb.selectedDocumentIds.includes(doc.id)"
|
||||
@change="kb.toggleDocumentSelection(doc.id)"
|
||||
/>
|
||||
</label>
|
||||
<div class="min-w-0 flex-1">
|
||||
<button
|
||||
@click="kb.openMarkdownEditor(doc)"
|
||||
class="block max-w-full truncate text-left font-semibold text-primary transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ kb.getDocumentDisplayTitle(doc) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="doc.latest_version"
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
class="min-w-0 max-w-full truncate text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
|
||||
class="mt-1 block max-w-full truncate text-left text-sm text-muted transition-colors hover:text-brand-600 hover:text-brand-600"
|
||||
>
|
||||
{{ doc.latest_version.source_file_name }}
|
||||
{{ kb.getDocumentDisplayDescription(doc) }}
|
||||
</button>
|
||||
<span class="shrink-0">{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}</span>
|
||||
<div class="mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted">
|
||||
<span class="shrink-0">{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
|
||||
<span v-if="doc.latest_version" class="shrink-0">{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
|
||||
<button
|
||||
v-if="doc.latest_version"
|
||||
type="button"
|
||||
@click="kb.openSourceInfo(doc)"
|
||||
class="min-w-0 max-w-full truncate text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
|
||||
>
|
||||
{{ doc.latest_version.source_file_name }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="kb.getDocumentWorkflowState(doc).primaryError"
|
||||
class="mt-1 max-w-xl text-xs text-rose-500"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: kb.getDocumentWorkflowState(doc).primaryError }) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2 lg:justify-end">
|
||||
<button
|
||||
@click="kb.openDocumentDetail(doc.id)"
|
||||
class="inline-flex shrink-0 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 shrink-0 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"
|
||||
@click="kb.handleSyncDocument(doc.id)"
|
||||
:disabled="kb.syncingDocumentId === doc.id || !doc.latest_version"
|
||||
class="inline-flex shrink-0 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 ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleDeleteDocument(doc)"
|
||||
class="inline-flex shrink-0 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="grid gap-3 border-t border-default pt-3 lg:grid-cols-[minmax(260px,1fr)_auto] lg:items-center">
|
||||
<span class="min-w-0 text-xs text-muted">
|
||||
{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}
|
||||
</span>
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2 lg:justify-end">
|
||||
<div
|
||||
v-if="kb.getDocumentWorkflowState(doc).primaryError"
|
||||
class="mt-1 max-w-xl text-xs text-rose-500"
|
||||
v-for="badge in kb.getWorkflowBadges(doc)"
|
||||
:key="`${doc.id}-${badge.label}`"
|
||||
class="inline-flex shrink-0 items-center rounded-full border px-3 py-1 text-xs font-semibold"
|
||||
:class="badge.className"
|
||||
>
|
||||
{{ kb.t('kbWorkspace.common.failureReason', { reason: kb.getDocumentWorkflowState(doc).primaryError }) }}
|
||||
{{ badge.label }}:{{ badge.value }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2 2xl:justify-end">
|
||||
<div
|
||||
v-for="badge in kb.getWorkflowBadges(doc)"
|
||||
:key="`${doc.id}-${badge.label}`"
|
||||
class="inline-flex shrink-0 items-center rounded-full border px-3 py-1 text-xs font-semibold"
|
||||
:class="badge.className"
|
||||
>
|
||||
{{ badge.label }}:{{ badge.value }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-2 2xl:justify-end">
|
||||
<button
|
||||
@click="kb.openDocumentDetail(doc.id)"
|
||||
class="inline-flex shrink-0 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 shrink-0 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"
|
||||
@click="kb.handleSyncDocument(doc.id)"
|
||||
:disabled="kb.syncingDocumentId === doc.id || !doc.latest_version"
|
||||
class="inline-flex shrink-0 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 ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
|
||||
</button>
|
||||
<button
|
||||
@click="kb.handleDeleteDocument(doc)"
|
||||
class="inline-flex shrink-0 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>
|
||||
<div
|
||||
<PaginationBar
|
||||
v-if="kb.filteredDocuments.length > 0"
|
||||
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.t('kbWorkspace.documents.pageInfo', { page: kb.documentListPage, totalPages: kb.filteredDocumentTotalPages, total: kb.filteredDocuments.length }) }}
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
@click="kb.documentListPage = Math.max(1, kb.documentListPage - 1)"
|
||||
: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>
|
||||
v-model:page="kb.documentListPage"
|
||||
v-model:page-size="kb.documentListPageSize"
|
||||
:total="kb.filteredDocuments.length"
|
||||
:pages="kb.filteredDocumentTotalPages"
|
||||
:page-size-options="[...kb.DOCUMENT_PAGE_SIZE_OPTIONS]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user