fix(admin): 优化知识库

This commit is contained in:
sophie committed 2026-06-29 09:30:04 +08:00
1 parent 3b771fc0b6
commit a3420c5266
6 files changed
+32 -13

No files matched your search

@@ -36,6 +36,7 @@ import {
type KbGroup,
type KbJob,
} from '../api/kb.api';
import { formatDateTime } from '../utils/kb-display.utils';
type GroupFilterMode = 'all' | 'withDocs' | 'empty';
type GroupSortMode = 'updatedDesc' | 'updatedAsc' | 'docsDesc' | 'docsAsc' | 'nameAsc';
@@ -99,6 +100,9 @@ const pagedGroups = computed(() => {
return filteredGroups.value.slice(start, start + pageSize.value);
});
/** 格式化分组更新时间,避免管理台表格直接暴露后端 ISO 时间字符串。 */
const formatGroupUpdatedAt = (value?: string | null) => formatDateTime(value);
/** 加载知识库治理页的分组与任务队列,供页面初始渲染和操作后刷新复用。 */
const loadData = async () => {
isRefreshing.value = true;
@@ -315,8 +319,8 @@ defineExpose({ loadData });
{{ group.description || t('kbAdmin.noDescription') }}
</div>
</td>
<td class="px-6 py-4 align-middle"><span class="kb-admin-badge whitespace-nowrap">{{ t('kbAdmin.documentCount', { count: group.document_count ?? 0 }) }}</span></td>
<td class="px-6 py-4 align-middle text-sm text-muted"><div class="truncate" :title="group.updated_at || '--'">{{ group.updated_at || '--' }}</div></td>
<td class="px-6 py-4 align-middle"><span class="kb-admin-badge whitespace-nowrap">{{ group.document_count ?? 0 }}</span></td>
<td class="px-6 py-4 align-middle text-sm text-muted"><div class="truncate" :title="formatGroupUpdatedAt(group.updated_at)">{{ formatGroupUpdatedAt(group.updated_at) }}</div></td>
<td class="px-6 py-4 align-middle">
<div class="flex justify-end gap-1.5">
<button type="button" class="btn-icon-ds border border-default" @click="openEditDrawer(group)" :title="t('common.edit')"><Pencil class="h-4 w-4" /></button>
@@ -335,10 +339,10 @@ defineExpose({ loadData });
<h3 class="font-semibold text-primary">{{ group.name }}</h3>
<p class="mt-1 line-clamp-2 text-sm text-muted" :title="group.description || t('kbAdmin.noDescription')">{{ group.description || t('kbAdmin.noDescription') }}</p>
</div>
<span class="kb-admin-badge">{{ t('kbAdmin.documentCount', { count: group.document_count ?? 0 }) }}</span>
<span class="kb-admin-badge">{{ group.document_count ?? 0 }}</span>
</div>
<div class="mt-3 flex items-center justify-between gap-3">
<span class="text-xs text-muted">{{ group.updated_at || '--' }}</span>
<span class="text-xs text-muted">{{ formatGroupUpdatedAt(group.updated_at) }}</span>
<div class="flex gap-1.5">
<button type="button" class="btn-icon-ds border border-default" @click="openEditDrawer(group)" :title="t('common.edit')"><Pencil class="h-4 w-4" /></button>
<button type="button" class="btn-icon-ds border border-rose-200 text-rose-600" @click="handleDeleteGroup(group)" :title="t('common.delete')"><Trash2 class="h-4 w-4" /></button>
@@ -3,7 +3,7 @@
* features/kb/views/KbWorkspaceView.vue
* 知识库作业面视图壳:模板与弹窗布局,业务逻辑见 useKbWorkspace。
*/
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Trash2, Upload } from 'lucide-vue-next';
import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, Info, RefreshCw, Search, Settings, Trash2, Upload } from 'lucide-vue-next';
import KbWorkspaceOverlays from '../components/KbWorkspaceOverlays.vue';
import { useKbWorkspace } from '../composables/useKbWorkspace';
@@ -52,6 +52,15 @@ const kb = useKbWorkspace({ embedded: props.embedded });
<RefreshCw class="h-4 w-4" />
{{ kb.viewMode === 'group_overview' ? kb.t('kbWorkspace.actions.refreshGroups') : kb.t('kbWorkspace.actions.refreshDocuments') }}
</button>
<button
v-if="kb.viewMode === 'group_overview'"
type="button"
@click="kb.router.push('/admin/knowledge-base')"
class="btn-primary"
>
<Settings class="h-4 w-4" />
{{ kb.t('kbWorkspace.actions.manageGroups') }}
</button>
</div>
</div>
@@ -65,24 +74,26 @@ const kb = useKbWorkspace({ embedded: props.embedded });
<div v-else-if="kb.groups.length === 0" class="kb-ws-empty py-10 text-center text-sm text-muted">
{{ kb.t('kbWorkspace.overview.emptyGroups') }}
</div>
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr">
<div v-else class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4">
<div
v-for="group in kb.groups"
:key="group.id"
@click="kb.openGroupDetail(group.id)"
class="kb-ws-card--interactive"
class="kb-ws-card--interactive !min-h-[150px]"
>
<div class="w-full text-left">
<div class="flex items-start justify-between gap-3">
<div class="min-w-0">
<div class="text-xl font-bold leading-tight text-primary break-words">{{ group.name }}</div>
<div class="mt-1 text-sm text-muted">{{ group.description || kb.t('kbWorkspace.overview.noDescription') }}</div>
<div class="mt-1 line-clamp-2 text-sm text-muted" :title="group.description || kb.t('kbWorkspace.overview.noDescription')">
{{ group.description || kb.t('kbWorkspace.overview.noDescription') }}
</div>
</div>
<div class="rounded-full bg-surface-soft px-2.5 py-1 text-xs font-medium text-secondary whitespace-nowrap">
{{ kb.t('kbWorkspace.overview.documentCount', { count: group.document_count ?? 0 }) }}
</div>
</div>
<div class="mt-4 text-xs text-muted">{{ kb.t('kbWorkspace.overview.updatedAt') }}{{ kb.formatDateTime(group.updated_at) }}</div>
<div class="mt-3 text-xs text-muted">{{ kb.t('kbWorkspace.overview.updatedAt') }}{{ kb.formatDateTime(group.updated_at) }}</div>
</div>
</div>
</div>
+2 -1
View File
@@ -117,7 +117,8 @@
"backToOverview": "Back to Group Overview",
"backToWorkspace": "Back to Workspace",
"refreshGroups": "Refresh Groups",
"refreshDocuments": "Refresh Documents"
"refreshDocuments": "Refresh Documents",
"manageGroups": "Manage Groups"
},
"overview": {
"title": "Select a Group",
+2 -1
View File
@@ -117,7 +117,8 @@
"backToOverview": "กลับไปรายการกลุ่ม",
"backToWorkspace": "กลับไปเวิร์กสเปซ",
"refreshGroups": "รีเฟรชกลุ่ม",
"refreshDocuments": "รีเฟรชเอกสาร"
"refreshDocuments": "รีเฟรชเอกสาร",
"manageGroups": "จัดการกลุ่ม"
},
"overview": {
"title": "เลือกกลุ่ม",
+2 -1
View File
@@ -117,7 +117,8 @@
"backToOverview": "返回分组列表",
"backToWorkspace": "返回工作台",
"refreshGroups": "刷新分组",
"refreshDocuments": "刷新文档"
"refreshDocuments": "刷新文档",
"manageGroups": "管理分组"
},
"overview": {
"title": "选择分组",
+2 -1
View File
@@ -117,7 +117,8 @@
"backToOverview": "返回分組列表",
"backToWorkspace": "返回工作台",
"refreshGroups": "刷新分組",
"refreshDocuments": "刷新文檔"
"refreshDocuments": "刷新文檔",
"manageGroups": "管理分組"
},
"overview": {
"title": "選擇分組",