[M] Move download function to libs/ui

This commit is contained in:
Azalea
2025-03-20 06:04:35 -04:00
parent 2f966d4fa9
commit 4e249601fe
2 changed files with 10 additions and 9 deletions

View File

@@ -212,3 +212,12 @@ export function pfp(node: HTMLImageElement, me?: AquaNetUser) {
node.src = me?.profilePicture ? `${AQUA_HOST}/uploads/net/portrait/${me.profilePicture}` : DEFAULT_PFP
node.onerror = e => pfpNotFound(e as Event)
}
export function download(data: string, filename: string) {
const blob = new Blob([data]);
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = filename;
link.click();
}