fix(login): restore ?pick escape hatch and fix 返回一般登入 landing page#233
Merged
fix(login): restore ?pick escape hatch and fix 返回一般登入 landing page#233
返回一般登入 landing page#233Conversation
…ck escape hatch
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
QrForm.vue:goBack and GamepassForm.vue:goBack both pushed `/login?pick=1`, which sent the user back to the region picker. The button label is "返回一般登入" / "Back to Regular Login" — "regular login" means the id-pass form within the same region, not the region picker. This was the SPA side of the bug paired with the duplicate `onMounted` redirect fix earlier in this PR: 24a07af added the `?pick=1` escape hatch for legitimate "re-pick region" flows, but the QR / Gamepass back buttons were retrofitted to use the same mechanism even though their semantics are different (mode switch within a region, not region re-pick). WPF parity: `qr_form.xaml.cs::btn_back_Click` flips `App.LoginMethod = Regular` and re-runs `loginMethodChanged()`, which lands on the regular id-pass form — never the region picker. Both forms now `router.push('/login/id-pass')` directly. The `onMounted` HK pre-flight guards (QrForm:241, GamepassForm:274) keep their `?pick=1` redirect — that path *is* a region rejection and correctly belongs at the picker. Update the two affected specs to: - register a `/login/id-pass` route stub in the harness routers - assert the back-button target is `/login/id-pass` - document the regression in the test name + body
返回一般登入 landing page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修兩個會把使用者送到錯誤頁面的 navigation bug。兩個 bug 都是 commit
24a07af加?pick=1escape hatch 時引入的副作用。Bug 1: 區域選擇頁的
?pick=1escape hatch 失效LoginRegionSelection.vue同時有兩個 auto-redirect 機制互相打架:onMounted(舊邏輯):mount 時看loginRegion有就馬上router.replace('/login/id-pass')。沒檢查?pick、沒看loginMethod(永遠跳 id-pass)。watch(() => config.loaded, ..., { immediate: true })(commit24a07af加的):同樣的 redirect 意圖,但會檢查?pick=1、會根據loginMethod決定要跳/login/id-pass還是/login/qr。onMounted比 watcher 早一步同步執行,所以從登入表單按 back 帶?pick=1想回到區域選擇頁時,還沒看到頁面就被 onMounted 踢走 → 設好 region 之後永遠到不了區域選擇頁;QR 模式的 user 還會被 onMounted 默默改回 id-pass。看起來是 PR #230 cherry-pick
24a07af時,新的 watcher 加進來但舊的onMounted沒清乾淨。Bug 2: QR / Gamepass 表單的「返回一般登入」按鈕跳到錯地方
QrForm.vue:goBack跟GamepassForm.vue:goBack都 push/login?pick=1,把使用者送到區域選擇頁。但 button 上的 i18n keyBackRegularLogin→「返回一般登入」/「Back to Regular Login」,「一般登入」明確指 id-pass form,不是區域選擇。WPF 的對應行為(
qr_form.xaml.cs::btn_back_Click)是App.LoginMethod = Regular+loginMethodChanged(),意思是「在同一個 region 內把模式切回 id-pass」,而不是「重選 region」。24a07af 加
?pick=1的時候順手把 QR / Gamepass 的 goBack 也改成用這個機制,但語意上?pick=1是「我要重選 region」,跟「返回一般登入」(=mode switch) 不同。Changes
Bug 1
LoginRegionSelection.vue的onMountedblock 跟連帶的onMountedimport(watcher 已是 strict superset)loginMethod→ 跳/login/id-passloginMethod=1→ 跳/login/qrloginMethod=1→ 仍跳/login/id-pass(HK 無 QR)?pick=1→ 留在 pickerBug 2
QrForm.vue:goBack+GamepassForm.vue:goBack改成router.push('/login/id-pass')QrForm.vue的 docblock 對應更新(原 docblock 自己描述 WPF 行為跟 SPA implementation 已經對不上)GamepassForm.vue:goBack加 inline comment 說明為什麼不用?pick=1onMounted內 region != TW 的 fallback 仍然是?pick=1(那是 region 校驗失敗,本來就該回 picker)/login/id-passroute stub、改 expect、補 regression 註解Test plan
npx vitest run tests/unit/pages/{LoginRegionSelection,QrForm,GamepassForm}.spec.ts— 37 / 37 passnpx vue-tsc --noEmit— clean