From 593b42830c9e4de47cd3a688d904eeefda183e76 Mon Sep 17 00:00:00 2001 From: saopig1 <4x7sw862st@gmail.com> Date: Sat, 30 May 2026 15:22:51 +0800 Subject: [PATCH] fix(scope): await router.isReady before mount so refreshed ?bot locks the right bot --- web/src/App.vue | 5 ++++- web/src/main.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/App.vue b/web/src/App.vue index adc1834..3781225 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -149,7 +149,10 @@ onMounted(async () => { // router guard sets scopedBotId tentatively from ?bot, but applyScopeFromQuery // validates it against the loaded bots (locks if it exists, clears if stale). await playerStore.fetchBots(); - const qBot = typeof route.query.bot === 'string' ? route.query.bot : null; + // Read from the authoritative current route (not a possibly-stale reactive + // snapshot) so the scope reconciles against the ?bot present at refresh time. + const routeBot = router.currentRoute.value.query.bot; + const qBot = typeof routeBot === 'string' ? routeBot : null; playerStore.applyScopeFromQuery(qBot); }); diff --git a/web/src/main.ts b/web/src/main.ts index 89568a9..6e34c52 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -11,4 +11,7 @@ installApiClient(); const app = createApp(App); app.use(createPinia()); app.use(router); -app.mount('#app'); +// Wait for the initial navigation (and the beforeEach guard that reads ?bot) +// to fully resolve before mounting, so the reactive route query is populated +// when App.onMounted runs and the dedicated-bot scope locks the right bot. +router.isReady().then(() => app.mount('#app'));