|
|
@@ -101,11 +101,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import { ref, computed, watch, onUnmounted } from 'vue';
|
|
|
+ import { ref, computed, watch, onUnmounted, defineAsyncComponent } from 'vue';
|
|
|
import { message } from 'ant-design-vue';
|
|
|
import { saveReportText } from '../../api';
|
|
|
- import VueOfficeDocx from '@vue-office/docx/lib/v3/vue-office-docx.mjs';
|
|
|
- import * as XLSX from 'xlsx';
|
|
|
import {
|
|
|
isImageFile,
|
|
|
isPdfFile,
|
|
|
@@ -122,6 +120,10 @@
|
|
|
} from './utils';
|
|
|
import type { AttachedFile } from './types';
|
|
|
|
|
|
+ // [perf-base-v1] 卡2c: VueOfficeDocx 改异步加载,仅打开 docx 预览时才拉取 office-preview chunk
|
|
|
+ const VueOfficeDocx = defineAsyncComponent(() => import('@vue-office/docx/lib/v3/vue-office-docx.mjs'));
|
|
|
+ // [perf-base-v1] 卡2c: xlsx 改为 parseExcel 内 await import 按需加载(见下)
|
|
|
+
|
|
|
const getCssUrl = (varName: string) => {
|
|
|
const val = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
|
return val.replace(/^url\(["']?/, '').replace(/["']?\)$/, '');
|
|
|
@@ -209,6 +211,8 @@
|
|
|
buffer = await file.originalFile.arrayBuffer();
|
|
|
}
|
|
|
if (!buffer) return;
|
|
|
+ // [perf-base-v1] 卡2c: 仅在解析 Excel 时才动态加载 xlsx 库
|
|
|
+ const XLSX = await import('xlsx');
|
|
|
const workbook = XLSX.read(buffer, { type: 'array' });
|
|
|
excelSheets.value = workbook.SheetNames.map((name) => {
|
|
|
const sheet = workbook.Sheets[name];
|