From 86b9e2de76283ac6ee1e7761dcf6ce0730f26e7a Mon Sep 17 00:00:00 2001 From: Mistivia Date: Wed, 5 Feb 2025 19:22:13 +0800 Subject: impl save deck --- src/components/MainPanel.svelte | 17 +++++++++++------ src/utils.js | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/components/MainPanel.svelte b/src/components/MainPanel.svelte index f5dcaf5..b5f5f2e 100644 --- a/src/components/MainPanel.svelte +++ b/src/components/MainPanel.svelte @@ -1,15 +1,15 @@ @@ -28,7 +33,7 @@
- +
diff --git a/src/utils.js b/src/utils.js index 05e519d..3176400 100644 --- a/src/utils.js +++ b/src/utils.js @@ -42,7 +42,23 @@ function genYdk(deck) { return ydkContent; } +function downloadStringAsFile(filename, text) { + const blob = new Blob([text], { type: 'text/plain' }); + const link = document.createElement('a'); + link.href = URL.createObjectURL(blob); + link.download = filename; + document.body.appendChild(link); + + link.click(); + + document.body.removeChild(link); + URL.revokeObjectURL(link.href); +} + + export { parseYdk, genYdk, + downloadStringAsFile, }; + -- cgit v1.0