perf: 统一导出文件交互、自定义列交互
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user