feat(web): app add export & import

This commit is contained in:
zhaoying
2026-03-10 14:22:15 +08:00
parent 5c3d9717dd
commit 16e2c95965
7 changed files with 308 additions and 8 deletions

View File

@@ -347,6 +347,23 @@ export const request = {
document.body.removeChild(link);
callback?.()
});
},
getDownloadFile(url: string, fileName: string, data?: unknown, callback?: () => void) {
service.get(url, {
params: paramFilter(data as Record<string, string | number | boolean | ObjectWithPush | null | undefined>),
responseType: "blob",
})
.then(res => {
const link = document.createElement("a");
const blob = new Blob([res as unknown as BlobPart]);
link.style.display = "none";
link.href = URL.createObjectURL(blob);
link.setAttribute("download", decodeURI(fileName || fileName));
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
callback?.()
});
}
};