From 66c6e1233f92a83ffdfad25c899e561c1f6ad475 Mon Sep 17 00:00:00 2001 From: YCC3741 Date: Tue, 21 Apr 2026 07:53:44 +0800 Subject: [PATCH 1/2] fix(login-region): remove duplicate onMounted redirect that broke ?pick escape hatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LoginRegionSelection.vue had two competing auto-redirect mechanisms: 1. `onMounted` (legacy): if `loginRegion` was saved, immediately `router.replace('/login/id-pass')`. Did NOT check `route.query.pick`, did NOT consult `loginMethod` (always landed on id-pass). 2. `watch(() => config.loaded, ..., { immediate: true })` added by commit 24a07af: same redirect intent, but correctly honours the `?pick=1` escape hatch and routes to `/login/qr` when `loginMethod === '1'` on TW. Because `onMounted` ran synchronously before the watcher's config-loaded trigger, every back-button navigation from a login form (which appends `?pick=1` per 24a07af's design) got bounced straight back to id-pass — the picker became unreachable after first launch, and QR-mode users were silently downgraded to id-pass on every return trip. This looks like a leftover from cherry-picking 24a07af in PR #230: the new watcher was added but the old `onMounted` was never removed. Drop the `onMounted` block (and its now-unused import). The watcher with `immediate: true` already covers first-mount, and its logic is strictly a superset of the deleted block. Add regression tests covering all five branches of the redirect decision so the duplication can't silently come back: - saved TW + default loginMethod → /login/id-pass - saved TW + loginMethod=1 → /login/qr - saved HK + loginMethod=1 → /login/id-pass (HK has no QR) - saved region + ?pick=1 → stays on picker - no saved region → stays on picker --- src/pages/LoginRegionSelection.vue | 12 +-- tests/unit/pages/LoginRegionSelection.spec.ts | 94 ++++++++++++++++++- 2 files changed, 93 insertions(+), 13 deletions(-) diff --git a/src/pages/LoginRegionSelection.vue b/src/pages/LoginRegionSelection.vue index f7381ad..800b7f0 100644 --- a/src/pages/LoginRegionSelection.vue +++ b/src/pages/LoginRegionSelection.vue @@ -31,7 +31,7 @@ * picker without triggering the redirect again. */ -import { computed, onMounted, watch } from 'vue' +import { computed, watch } from 'vue' import { useI18n } from 'vue-i18n' import { useRoute, useRouter } from 'vue-router' import { useConfigStore } from '../stores/config' @@ -44,16 +44,6 @@ const route = useRoute() const router = useRouter() const config = useConfigStore() -/** - * Skip the region picker if a region is already saved — go - * straight to the login form. First-launch users see the picker. - */ -onMounted(() => { - if (config.get('loginRegion')) { - void router.replace('/login/id-pass') - } -}) - /** * Tile descriptors. Kept declarative so the template stays a flat * `v-for` rather than two near-duplicate `