From 955faed27df0a40183a7b3e801a88e9b234340c3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Sun, 7 Jun 2026 18:21:13 +0800 Subject: [PATCH] =?UTF-8?q?perf(chat):1.chat=E5=9B=9E=E5=A4=8D=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E6=BA=90=E6=96=87=E4=BB=B6=E5=85=BC=E5=AE=B9=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E7=AB=AF=E4=BC=98=E5=8C=96=EF=BC=9B2.=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=BA=93=E6=96=87=E4=BB=B6=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=9F=A5=E8=AF=A2=E6=96=87=E4=BB=B6=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/ChatView.vue | 25 +++++++++++++ frontend/src/views/KbWorkspaceView.vue | 52 +++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index 3e218f8b..d1e61286 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -600,6 +600,27 @@ const shouldShowThinkingBubble = computed(() => { const filePreviewVisible = ref(false); const previewFile = ref<{ name: string; url: string; actualExt?: string } | null>(null); +const getSourcePreviewExt = (file: { name?: string; url?: string; actualExt?: string }) => { + const actual = String(file?.actualExt || '').trim().toLowerCase(); + if (actual) return actual; + const byName = getUrlExt(file?.name || ''); + if (byName) return byName; + return getUrlExt(file?.url || ''); +}; + +const isWeComMobileWebView = () => { + if (typeof navigator === 'undefined') return false; + const ua = navigator.userAgent || ''; + return /wxwork/i.test(ua) && /mobile/i.test(ua); +}; + +const shouldBypassEmbeddedPreview = (file: { name?: string; url?: string; actualExt?: string }) => { + const ext = getSourcePreviewExt(file); + if (!isMobile.value || !isWeComMobileWebView()) return false; + if (!/^https?:\/\//i.test(file?.url || '')) return false; + return ['pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx'].includes(ext); +}; + const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string; url: string; actualExt?: string }> => { if (file.datasetId && file.remoteDocumentId) { const data = await resolveChatSourceFile({ @@ -633,6 +654,10 @@ const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string; const openPreview = async (file: SourceFileLink) => { try { const resolvedFile = await resolveSourceLink(file); + if (shouldBypassEmbeddedPreview(resolvedFile)) { + window.location.href = resolvedFile.url; + return; + } previewFile.value = resolvedFile; filePreviewVisible.value = true; } catch (error: any) { diff --git a/frontend/src/views/KbWorkspaceView.vue b/frontend/src/views/KbWorkspaceView.vue index 07181c25..2dfe8a95 100644 --- a/frontend/src/views/KbWorkspaceView.vue +++ b/frontend/src/views/KbWorkspaceView.vue @@ -2,7 +2,7 @@ import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; import { useRouter } from 'vue-router'; import { useI18n } from 'vue-i18n'; -import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, FolderPlus, Info, Pencil, RefreshCw, Trash2, Upload, X } from 'lucide-vue-next'; +import { ArrowLeft, BookOpen, ChevronDown, ChevronUp, FileText, FolderPlus, Info, Pencil, RefreshCw, Search, Trash2, Upload, X } from 'lucide-vue-next'; import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue'; import { createKbGroup, @@ -87,7 +87,8 @@ const failureModalPage = ref(1); const retryingFailureKey = ref(''); const documentStageFilter = ref<'all' | 'upload' | 'clean' | 'sync'>('all'); const documentListPage = ref(1); -const documentListPageSize = ref(50); +const documentListPageSize = ref(20); +const documentKeyword = ref(''); const batchSubmitting = ref(false); const selectedDocumentIds = ref([]); const pathUploadDraftText = ref(''); @@ -387,6 +388,19 @@ const matchesDocumentStageFilter = ( return ['pending', 'running', 'failed'].includes(workflow.sync.code); }; +const matchesDocumentKeyword = (doc: KbDocumentItem, keyword: string) => { + const normalizedKeyword = keyword.trim().toLowerCase(); + if (!normalizedKeyword) return true; + const candidates = [ + getDocumentDisplayTitle(doc), + getDocumentDisplayDescription(doc), + doc.title, + doc.description, + doc.latest_version?.source_file_name, + ]; + return candidates.some((item) => String(item || '').toLowerCase().includes(normalizedKeyword)); +}; + const stageFilterTabs = computed(() => { const filters: Array<{ key: 'all' | 'upload' | 'clean' | 'sync'; label: string }> = [ { key: 'all', label: '全部' }, @@ -396,12 +410,17 @@ const stageFilterTabs = computed(() => { ]; return filters.map((item) => ({ ...item, - count: documents.value.filter((doc) => matchesDocumentStageFilter(doc, item.key)).length, + count: documents.value.filter((doc) => + matchesDocumentStageFilter(doc, item.key) && matchesDocumentKeyword(doc, documentKeyword.value) + ).length, })); }); const filteredDocuments = computed(() => - documents.value.filter((doc) => matchesDocumentStageFilter(doc, documentStageFilter.value)) + documents.value.filter((doc) => + matchesDocumentStageFilter(doc, documentStageFilter.value) + && matchesDocumentKeyword(doc, documentKeyword.value) + ) ); const filteredDocumentTotalPages = computed(() => @@ -1896,6 +1915,10 @@ watch(documentStageFilter, () => { documentListPage.value = 1; }); +watch(documentKeyword, () => { + documentListPage.value = 1; +}); + watch(documentListPageSize, () => { documentListPage.value = 1; }); @@ -2188,6 +2211,25 @@ onUnmounted(() => { 历史批次 +
+ + +

{ 正在加载文档...

- {{ documents.length === 0 ? '当前分组暂无文档,可直接在上方创建第一条文档记录。' : '当前筛选条件下暂无匹配文档。' }} + {{ documents.length === 0 ? '当前分组暂无文档,可直接在上方创建第一条文档记录。' : (documentKeyword ? '当前搜索和筛选条件下暂无匹配文档。' : '当前筛选条件下暂无匹配文档。') }}