feat: 完善后台导入日志权限与备份恢复

This commit is contained in:
Nixevol
2026-07-04 09:06:35 +08:00
parent 5ae3b12fff
commit d484da3862
61 changed files with 2743 additions and 436 deletions
+12 -1
View File
@@ -13,5 +13,16 @@ export function saveBlob(blob: Blob, filename: string): void {
export async function downloadFile(url: string, filename: string, params?: object): Promise<void> {
const res = await download(url, params);
saveBlob(res.data, filename);
saveBlob(res.data, pickFilename(res.headers, filename));
}
function pickFilename(headers: Record<string, string>, fallback: string): string {
const disposition = headers['content-disposition'] || headers['Content-Disposition'];
const match = disposition?.match(/filename\*?=(?:UTF-8''|")?([^";]+)/i);
if (!match?.[1]) return fallback;
try {
return decodeURIComponent(match[1].replace(/"/g, ''));
} catch {
return match[1].replace(/"/g, '');
}
}