diff options
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, +}; |
