perf(chat):1.chat回复查看源文件兼容手机端优化;2.知识库文件列表增加查询文件模糊搜索功能
This commit is contained in:
1 parent
35901425c7
commit
955faed27d
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) {
|
||||
|
||||
Reference in new issue
Block a user