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 ? '当前搜索和筛选条件下暂无匹配文档。' : '当前筛选条件下暂无匹配文档。') }}