diff options
| author | Mistivia <i@mistivia.com> | 2025-02-10 23:21:24 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-02-10 23:21:24 +0800 |
| commit | 39c98aef0b1077001571a11adfd6b4c80dec256a (patch) | |
| tree | 495455d698594b7f3fa0dcf7be39b7e549eedf28 /src/control/loading.js | |
| parent | 45337902f925e8d826aae5a2347029ab03753113 (diff) | |
add loading page
Diffstat (limited to 'src/control/loading.js')
| -rw-r--r-- | src/control/loading.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/control/loading.js b/src/control/loading.js new file mode 100644 index 0000000..93114d7 --- /dev/null +++ b/src/control/loading.js @@ -0,0 +1,29 @@ +import { writable } from 'svelte/store'; +import { initSearch } from './search'; +import { initDeck } from './deck'; +import { setCardDb } from '../data/cardDb'; + +let isLoading = writable(true); + +async function fetchCardDb() { + try { + const response = await fetch("https://121.40.137.206/ygo-deck-builder/card_db.json"); + if (!response.ok) { + throw new Error('Network response was not ok'); + } + const data = await response.json(); + setCardDb(data); + } catch (error) { + alert("加载失败!请刷新重试"); + return; + } + isLoading.set(false); + initDeck(); + initSearch(); +} + +fetchCardDb(); + +export { + isLoading, +}; |
