perf: 统一导出文件交互、自定义列交互

This commit is contained in:
rd
2025-07-04 16:05:45 +08:00
parent c49e12d988
commit 11bc19907c
9 changed files with 82 additions and 15 deletions

View File

@ -93,3 +93,16 @@ export function exactFormatTime(val: number, curYearFmt = 'MM-DD HH:mm', otherYe
const fmt = diff === 0 ? curYearFmt : otherYearFmt;
return dayjs(val * 1000).format(fmt);
}
// 导出文件
export function downloadByUrl(url: string, filename?: string) {
const a = document.createElement('a');
a.href = url;
if (filename) {
a.download = filename;
}
a.style.display = 'none';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}