From 5e3f143db9abae3ab4aa47521d06e11f335b757a Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 24 Apr 2023 17:27:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E5=A4=B1=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/main.js | 2 +- public/project/plugin/replay.js | 1 + src/types/core.d.ts | 2 +- src/ui/shop.vue | 9 +-------- 4 files changed, 4 insertions(+), 10 deletions(-) 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(() => {