mirror of
https://github.com/hay-kot/mealie.git
synced 2025-07-12 08:07:14 -07:00
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend Tests (push) Waiting to run
Docker Nightly Production / Build Package (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Release Drafter / ✏️ Draft release (push) Waiting to run
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
18 lines
495 B
TypeScript
18 lines
495 B
TypeScript
export function useDownloader() {
|
|
function download(url: string, filename: string) {
|
|
useFetch(url, {
|
|
method: "GET",
|
|
responseType: "blob",
|
|
onResponse({ response }) {
|
|
const url = window.URL.createObjectURL(new Blob([response._data]));
|
|
const link = document.createElement("a");
|
|
link.href = url;
|
|
link.setAttribute("download", filename);
|
|
document.body.appendChild(link);
|
|
link.click();
|
|
},
|
|
});
|
|
}
|
|
|
|
return download;
|
|
}
|