diff --git a/public/main.js b/public/main.js index 316bdc2..8d41cd9 100644 --- a/public/main.js +++ b/public/main.js @@ -328,7 +328,7 @@ main.prototype.init = async function (mode, callback) { ].forEach(function (t) { coreData[t] = main[t]; }); - core.init(coreData, callback); + await core.init(coreData, callback); core.resize(); main.core = core; diff --git a/public/project/plugin/replay.js b/public/project/plugin/replay.js index 24012a7..67a58f4 100644 --- a/public/project/plugin/replay.js +++ b/public/project/plugin/replay.js @@ -44,6 +44,7 @@ let shopOpened = false; let openedShopId = ''; core.registerReplayAction('openShop', name => { if (!name.startsWith('openShop:')) return false; + if (shopOpened) return false; openedShopId = name.slice(9); shopOpened = true; core.replay(); diff --git a/src/types/core.d.ts b/src/types/core.d.ts index 5a75455..57ba984 100644 --- a/src/types/core.d.ts +++ b/src/types/core.d.ts @@ -1070,7 +1070,7 @@ interface Core extends Pick { * @param coreData 初始化信息 * @param callback 初始化完成后的回调函数 */ - init(coreData: MainData, callback?: () => void): void; + init(coreData: MainData, callback?: () => void): Promise; /** * @deprecated diff --git a/src/ui/shop.vue b/src/ui/shop.vue index c17b0be..84051d5 100644 --- a/src/ui/shop.vue +++ b/src/ui/shop.vue @@ -175,10 +175,6 @@ import { isMobile } from '../plugin/use'; import BoxAnimate from '../components/boxAnimate.vue'; import { KeyCode } from '../plugin/keyCodes'; import { sleep } from 'mutate-animate'; -import { - completeAchievement, - hasCompletedAchievement -} from '../plugin/ui/achievement'; const id = core.plugin.openedShopId; const shop = core.status.shops[core.plugin.openedShopId] as ItemShopEvent; @@ -201,8 +197,6 @@ const count = ref(0); const nowMoney = ref(core.status.hero.money); const update = ref(false); -let achiN = 0; - let bought = false; watch(count, n => { @@ -248,10 +242,8 @@ function confirm() { if (count.value === 0) { return; } - achiN = 0; const money = core.status.hero.money; bought = true; - core.status.route.push(`openShop:${id}`); if (mode.value === 'buy') { if (cost.value <= money) { core.getItem(item.value.id, count.value); @@ -319,6 +311,7 @@ onMounted(async () => { if (core.plugin.transition.value) await sleep(600); document.addEventListener('keyup', keyup); document.addEventListener('keydown', keydown); + core.status.route.push(`openShop:${id}`); }); onUnmounted(() => {