feat: download redemption codes as file (#12)

This commit is contained in:
JustSong
2023-04-26 17:13:08 +08:00
parent 9e2f2383b9
commit f62a671fbe
2 changed files with 20 additions and 4 deletions

View File

@@ -143,4 +143,13 @@ export function timestamp2string(timestamp) {
':' +
second
);
}
export function downloadTextAsFile(text, filename) {
let blob = new Blob([text], { type: 'text/plain;charset=utf-8' });
let url = URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
}