Merge branch 'dev' into test
This commit is contained in:
commit
f036182650
2 files changed
+72
-5
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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<number[]>([]);
|
||||
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(() => {
|
||||
历史批次
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="selectedGroupId" class="flex flex-wrap items-center gap-3">
|
||||
<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="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="按文件名称模糊搜索"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
v-if="documentKeyword"
|
||||
type="button"
|
||||
@click="documentKeyword = ''"
|
||||
class="inline-flex items-center rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
清空搜索
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
@@ -2341,7 +2383,7 @@ onUnmounted(() => {
|
||||
正在加载文档...
|
||||
</div>
|
||||
<div v-else-if="filteredDocuments.length === 0" class="rounded-2xl border border-dashed border-default px-4 py-12 text-center text-sm text-muted ">
|
||||
{{ documents.length === 0 ? '当前分组暂无文档,可直接在上方创建第一条文档记录。' : '当前筛选条件下暂无匹配文档。' }}
|
||||
{{ documents.length === 0 ? '当前分组暂无文档,可直接在上方创建第一条文档记录。' : (documentKeyword ? '当前搜索和筛选条件下暂无匹配文档。' : '当前筛选条件下暂无匹配文档。') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user