fix(knowledge-base): 优化知识库页面,重构后端job队列
This commit is contained in:
1 parent
7e4a2037d8
commit
b476b58a91
38 files changed
+992
-428
No files matched your search
@@ -77,9 +77,9 @@ export function createKbWorkspaceState(options: CreateKbWorkspaceStateOptions =
|
||||
const failureModalPage = ref(1);
|
||||
const retryingFailureKey = ref('');
|
||||
|
||||
const documentStageFilter = ref<'all' | 'upload' | 'clean' | 'sync'>('all');
|
||||
const documentStageFilter = ref<'all' | 'pending_clean' | 'cleaning' | 'pending_sync' | 'failed'>('all');
|
||||
const documentListPage = ref(1);
|
||||
const documentListPageSize = ref(20);
|
||||
const documentListPageSize = ref(10);
|
||||
const documentKeyword = ref('');
|
||||
const batchSubmitting = ref(false);
|
||||
const selectedDocumentIds = ref<number[]>([]);
|
||||
|
||||
@@ -98,17 +98,20 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
|
||||
const matchesDocumentStageFilter = (
|
||||
doc: KbDocumentItem,
|
||||
filter: 'all' | 'upload' | 'clean' | 'sync',
|
||||
filter: 'all' | 'pending_clean' | 'cleaning' | 'pending_sync' | 'failed',
|
||||
) => {
|
||||
const workflow = resolveWorkflowState(doc);
|
||||
if (filter === 'all') return true;
|
||||
if (filter === 'upload') {
|
||||
return workflow.upload.code !== 'success';
|
||||
if (filter === 'pending_clean') {
|
||||
return workflow.clean.code === 'pending';
|
||||
}
|
||||
if (filter === 'clean') {
|
||||
return ['pending', 'queued', 'running', 'failed'].includes(workflow.clean.code);
|
||||
if (filter === 'cleaning') {
|
||||
return ['queued', 'running'].includes(workflow.clean.code);
|
||||
}
|
||||
return ['pending', 'running', 'failed'].includes(workflow.sync.code);
|
||||
if (filter === 'pending_sync') {
|
||||
return workflow.sync.code === 'pending';
|
||||
}
|
||||
return [workflow.upload.code, workflow.clean.code, workflow.sync.code].includes('failed');
|
||||
};
|
||||
|
||||
const matchesDocumentKeyword = (doc: KbDocumentItem, keyword: string) => {
|
||||
@@ -125,11 +128,12 @@ export function useKbWorkspaceComputed(state: KbWorkspaceState) {
|
||||
};
|
||||
|
||||
const stageFilterTabs = computed(() => {
|
||||
const filters: Array<{ key: 'all' | 'upload' | 'clean' | 'sync'; label: string }> = [
|
||||
const filters: Array<{ key: 'all' | 'pending_clean' | 'cleaning' | 'pending_sync' | 'failed'; label: string }> = [
|
||||
{ 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') },
|
||||
{ key: 'pending_clean', label: t('kbWorkspace.filters.pendingClean') },
|
||||
{ key: 'cleaning', label: t('kbWorkspace.filters.cleaning') },
|
||||
{ key: 'pending_sync', label: t('kbWorkspace.filters.pendingSync') },
|
||||
{ key: 'failed', label: t('kbWorkspace.filters.failed') },
|
||||
];
|
||||
return filters.map((item) => ({
|
||||
...item,
|
||||
|
||||
@@ -46,6 +46,7 @@ export function useKbWorkspaceData(
|
||||
selectedDocumentIds,
|
||||
showPathUploadDetails,
|
||||
selectedPathUploadHistoryJobId,
|
||||
router,
|
||||
} = state;
|
||||
|
||||
const { t } = state;
|
||||
@@ -189,6 +190,9 @@ export function useKbWorkspaceData(
|
||||
};
|
||||
|
||||
const openGroupDetail = async (groupId: number) => {
|
||||
if (viewMode.value === 'group_overview') {
|
||||
await router.push({ name: 'workspace-knowledge-base-group', params: { groupId } });
|
||||
}
|
||||
selectedGroupId.value = groupId;
|
||||
viewMode.value = 'group_detail';
|
||||
feedback.value = '';
|
||||
@@ -197,6 +201,9 @@ export function useKbWorkspaceData(
|
||||
};
|
||||
|
||||
const backToGroupOverview = () => {
|
||||
if (viewMode.value === 'group_detail') {
|
||||
void router.push({ name: 'workspace-knowledge-base' });
|
||||
}
|
||||
viewMode.value = 'group_overview';
|
||||
selectedGroupId.value = null;
|
||||
documents.value = [];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* features/kb/composables/useKbWorkspace.ts
|
||||
* 知识库作业面编排入口:组合 state / computed / data / pathUpload / documents / modals。
|
||||
*/
|
||||
import { onMounted, onUnmounted, reactive, watch } from 'vue';
|
||||
import { computed as vueComputed, onMounted, onUnmounted, reactive, watch } from 'vue';
|
||||
import {
|
||||
DOCUMENT_PAGE_SIZE_OPTIONS,
|
||||
FAILURE_PAGE_SIZE,
|
||||
@@ -76,6 +76,29 @@ export function useKbWorkspace(options: UseKbWorkspaceOptions = {}) {
|
||||
} = computed;
|
||||
|
||||
const { applyPathUploadJob } = pathUpload;
|
||||
const routeGroupId = vueComputed(() => {
|
||||
const raw = state.router.currentRoute.value.params.groupId;
|
||||
const value = Array.isArray(raw) ? raw[0] : raw;
|
||||
const parsed = Number(value);
|
||||
return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
|
||||
});
|
||||
|
||||
const syncViewModeFromRoute = () => {
|
||||
const groupId = routeGroupId.value;
|
||||
if (groupId) {
|
||||
state.viewMode.value = 'group_detail';
|
||||
if (selectedGroupId.value !== groupId) {
|
||||
selectedGroupId.value = groupId;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (state.embedded) {
|
||||
state.viewMode.value = 'group_overview';
|
||||
if (selectedGroupId.value !== null) {
|
||||
selectedGroupId.value = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// --- 筛选/分页/路径上传历史联动 ---
|
||||
watch(selectedGroupId, (groupId) => {
|
||||
@@ -90,6 +113,10 @@ export function useKbWorkspace(options: UseKbWorkspaceOptions = {}) {
|
||||
applyPathUploadJob(latestPathUploadJob.value);
|
||||
});
|
||||
|
||||
watch(routeGroupId, () => {
|
||||
syncViewModeFromRoute();
|
||||
});
|
||||
|
||||
watch(documentStageFilter, () => {
|
||||
documentListPage.value = 1;
|
||||
});
|
||||
@@ -117,6 +144,7 @@ export function useKbWorkspace(options: UseKbWorkspaceOptions = {}) {
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
syncViewModeFromRoute();
|
||||
await Promise.all([data.loadGroups(), data.loadJobs()]);
|
||||
if (state.viewMode.value === 'group_detail') {
|
||||
await data.loadDocuments(selectedGroupId.value);
|
||||
|
||||
Reference in new issue
Block a user