优化会话关闭处理逻辑.

This commit is contained in:
lijiahang
2024-06-11 12:31:16 +08:00
parent 4b060a864a
commit ae03460a33
10 changed files with 131 additions and 65 deletions

View File

@@ -84,6 +84,27 @@ export function getParentPath(path: string) {
return parent;
}
/**
* 打开下载文件
*/
export function openDownloadFile(url: string) {
try {
// 创建隐藏的可下载链接
let element = document.createElement('a');
element.setAttribute('href', url);
element.setAttribute('download', '');
element.style.display = 'none';
// 将其附加到文档中
document.body.appendChild(element);
// 点击该下载链接
element.click();
// 移除已下载的链接
document.body.removeChild(element);
} catch (e) {
window.open(url, 'newWindow');
}
}
/**
* 下载文件
*/