perf: 优化依赖与首屏加载
This commit is contained in:
@@ -18,7 +18,6 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import * as XLSX from 'xlsx';
|
||||
import { Modal, Button, Checkbox, Radio, RadioGroup } from '@douyinfe/semi-ui';
|
||||
import { CheckSquare, Eraser, FileSpreadsheet, X } from 'lucide-react';
|
||||
import {
|
||||
@@ -232,7 +231,7 @@ const UsageLogsExportModal = ({
|
||||
// 不用可能过期的 logCount 来禁用按钮(避免编辑筛选未查询时被误禁用)
|
||||
const pageNoData = scope === 'page' && pageCount === 0;
|
||||
|
||||
const buildSheet = (rows, fields, header) => {
|
||||
const buildSheet = (XLSX, rows, fields, header) => {
|
||||
const aoa = [header, ...rows.map((r) => fields.map((f) => f.value(r, t)))];
|
||||
const ws = XLSX.utils.aoa_to_sheet(aoa);
|
||||
ws['!cols'] = fields.map((f) => ({ wch: f.width || 14 }));
|
||||
@@ -267,10 +266,11 @@ const UsageLogsExportModal = ({
|
||||
return;
|
||||
}
|
||||
const header = fields.map((f) => t(f.label));
|
||||
const XLSX = await import('xlsx');
|
||||
const wb = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(
|
||||
wb,
|
||||
buildSheet(rows, fields, header),
|
||||
buildSheet(XLSX, rows, fields, header),
|
||||
t('消耗明细'),
|
||||
);
|
||||
XLSX.writeFile(wb, buildExportFilename());
|
||||
|
||||
Reference in New Issue
Block a user