fix: 聊天导出改用原生保存对话框,清理 downloadFile
- exportAsMarkdown/Html/Txt 全部改用 dialog.saveFile + fs.writeFile - 删除 utils.ts 中的 downloadFile 函数(不再使用) - 两处 a.download 保留为 fallback(bridge 不可用时降级)
This commit is contained in:
@@ -48,17 +48,6 @@ export function escapeHtml(str: string): string {
|
||||
return String(str).replace(/[&<>"']/g, (c) => map[c]);
|
||||
}
|
||||
|
||||
/** 下载文件 */
|
||||
export function downloadFile(filename: string, content: string, type: string): void {
|
||||
const blob = new Blob([content], { type: type + ';charset=utf-8' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
/** 根据文件名检测语言标识(用于 Markdown 代码块) */
|
||||
export function detectLanguage(filename: string): string {
|
||||
const ext = filename.split('.').pop()?.toLowerCase() || '';
|
||||
|
||||
Reference in New Issue
Block a user