Skip to content

Commit f9d4997

Browse files
committed
fix: 修改了导入逻辑,避免导入不可识别的log格式
1 parent 91fc55f commit f9d4997

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

src/composables/useImporter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export async function importFiles(
3030
console.log(`文件 ${name} 使用适配器: ${adapter.name}`);
3131
} catch (error) {
3232
console.error(`解析文件 ${name} 失败:`, error);
33+
throw new Error(
34+
`文件 "${name}" 解析失败: ${error instanceof Error ? error.message : '未知错误'}`,
35+
);
3336
}
3437
}
3538
return documents;

src/io/import/importAdapters.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export function dispatchAdapter(text: string): ImportAdapter {
1717
bestAdapter = adapter;
1818
}
1919
}
20+
// 如果所有 adapter 得分都小于 10
21+
if (maxScore < 10) {
22+
throw new Error('无法识别该文件的格式,暂不支持导入。');
23+
}
2024

2125
return bestAdapter;
2226
}

0 commit comments

Comments
 (0)