fex(kb):知识库数据清洗针对pdf含有大量图片ocr清洗超时问题优化;perf(chat):问答回复点击doc移动端无法预览问题优化
This commit is contained in:
1 parent
0890c79070
commit
900a13722c
8 files changed
+170
-18
No files matched your search
@@ -14,6 +14,7 @@ import { marked } from 'marked';
|
||||
import * as XLSX from 'xlsx';
|
||||
import VueOfficeDocx from '@vue-office/docx';
|
||||
import VueOfficeExcel from '@vue-office/excel';
|
||||
import VueOfficePdf from '@vue-office/pdf';
|
||||
import '@vue-office/docx/lib/index.css';
|
||||
import '@vue-office/excel/lib/index.css';
|
||||
|
||||
@@ -32,7 +33,7 @@ interface ExcelPreviewData {
|
||||
truncated: boolean;
|
||||
}
|
||||
|
||||
type OfficeKind = 'docx' | 'excel' | null;
|
||||
type OfficeKind = 'docx' | 'excel' | 'pdf' | null;
|
||||
type PreviewMode = 'markdown' | 'image' | 'iframe' | 'sheet' | 'office';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -290,6 +291,15 @@ const loadPdfContent = async (): Promise<'iframe' | 'office' | 'sheet'> => {
|
||||
if (ext.value === 'pdf' || ['doc', 'ppt', 'pptx'].includes(ext.value)) fallbackType = 'application/pdf';
|
||||
else if (ext.value === 'docx') fallbackType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
||||
const effectiveBlob = blob.type ? blob : new Blob([blob], { type: fallbackType });
|
||||
if (
|
||||
['doc', 'ppt', 'pptx'].includes(ext.value)
|
||||
&& effectiveBlob.type.toLowerCase().includes('pdf')
|
||||
) {
|
||||
officeSrc.value = effectiveBlob;
|
||||
officeRenderKey.value += 1;
|
||||
officeKind.value = 'pdf';
|
||||
return 'office';
|
||||
}
|
||||
officeObjectUrl.value = URL.createObjectURL(effectiveBlob);
|
||||
return 'iframe';
|
||||
};
|
||||
@@ -525,6 +535,12 @@ watch(
|
||||
:src="officeSrc"
|
||||
style="height: 100%; width: 100%;"
|
||||
/>
|
||||
<VueOfficePdf
|
||||
v-else-if="officeKind === 'pdf'"
|
||||
:key="`pdf-${officeRenderKey}`"
|
||||
:src="officeSrc"
|
||||
style="height: 100%; width: 100%;"
|
||||
/>
|
||||
</div>
|
||||
<div v-else-if="resolvedMode === 'image'" class="dialog-preview-frame h-full flex items-center justify-center p-2">
|
||||
<img :src="imageSrc" :alt="file.name" class="max-w-full max-h-full object-contain" />
|
||||
|
||||
@@ -618,7 +618,7 @@ const shouldBypassEmbeddedPreview = (file: { name?: string; url?: string; actual
|
||||
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);
|
||||
return ['pdf', 'xls', 'xlsx'].includes(ext);
|
||||
};
|
||||
|
||||
const resolveSourceLink = async (file: SourceFileLink): Promise<{ name: string; url: string; actualExt?: string }> => {
|
||||
|
||||
Reference in new issue
Block a user