|
|
@@ -1,5 +1,6 @@
|
|
|
import type { SheetConfig } from '@/client/member/components/ExcelToJson/types';
|
|
|
import * as XLSX from 'xlsx';
|
|
|
+import { performance } from 'node:perf_hooks'
|
|
|
|
|
|
// Excel数据行类型
|
|
|
export interface ExcelRow {
|
|
|
@@ -517,19 +518,22 @@ export class ExcelParser {
|
|
|
console.log(`[ExcelParser] 检测到URL: ${input.substring(0, 50)}...`);
|
|
|
|
|
|
// 处理URL
|
|
|
- try {
|
|
|
- console.log(`[ExcelParser] 开始从URL获取文件`);
|
|
|
- const response = await fetch(input);
|
|
|
-
|
|
|
- if (!response.ok) {
|
|
|
- console.error(`[ExcelParser] 获取文件失败: ${response.status} ${response.statusText}`);
|
|
|
- throw new Error(`获取文件失败: ${response.statusText}`);
|
|
|
- }
|
|
|
-
|
|
|
- const buffer = await response.arrayBuffer();
|
|
|
- console.log(`[ExcelParser] 成功从URL获取文件,大小: ${buffer.byteLength} 字节`);
|
|
|
-
|
|
|
- return buffer;
|
|
|
+ try {
|
|
|
+ const startTime = performance.now();
|
|
|
+ console.log(`[ExcelParser] 开始从URL获取文件`);
|
|
|
+ const response = await fetch(input);
|
|
|
+
|
|
|
+ if (!response.ok) {
|
|
|
+ console.error(`[ExcelParser] 获取文件失败: ${response.status} ${response.statusText}`);
|
|
|
+ throw new Error(`获取文件失败: ${response.statusText}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ const buffer = await response.arrayBuffer();
|
|
|
+ const endTime = performance.now();
|
|
|
+ const duration = (endTime - startTime).toFixed(2);
|
|
|
+ console.log(`[ExcelParser] 成功从URL获取文件,大小: ${buffer.byteLength} 字节,耗时: ${duration}ms`);
|
|
|
+
|
|
|
+ return buffer;
|
|
|
} catch (error) {
|
|
|
console.error(`[ExcelParser] 从URL获取文件时出错:`, error);
|
|
|
throw new Error(`从URL获取文件时出错: ${error instanceof Error ? error.message : String(error)}`);
|