mirror of
https://github.com/xiaorouji/openwrt-passwall2.git
synced 2025-05-01 05:29:05 +08:00
luci: optimize backup file download code
This commit is contained in:
parent
58dea197bc
commit
aa4289ef9a
@ -95,10 +95,15 @@ local api = require "luci.passwall2.api"
|
||||
if (!response.ok) {
|
||||
throw new Error("备份失败!");
|
||||
}
|
||||
const filename = response.headers.get("X-Backup-Filename") || "passwall2-backup.tar.gz";
|
||||
const filename = response.headers.get("X-Backup-Filename");
|
||||
if (!filename) {
|
||||
return;
|
||||
}
|
||||
return response.blob().then(blob => ({ blob, filename }));
|
||||
})
|
||||
.then(({ blob, filename }) => {
|
||||
.then(result => {
|
||||
if (!result) return;
|
||||
const { blob, filename } = result;
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
|
Loading…
Reference in New Issue
Block a user