feat(home): add quick account switcher in landscape header#74
feat(home): add quick account switcher in landscape header#74gushishang wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd6fe94e0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| async function switchAccount(account: QuickAccount) { | ||
| showSwitchPanel.value = false | ||
| sm.setObj('userAuthInfo', { token: account.token, authCode: account.authCode }, 30 * 24 * 60 * 60 * 1000) |
There was a problem hiding this comment.
Write switched credentials after successful authentication
Persisting userAuthInfo before checking login(...) success can overwrite a currently valid session with invalid/stale credentials. When a quick-switch account token has expired or been revoked, switchAccount returns early at !res.Data?.User but leaves userAuthInfo set to the bad token/authCode, so subsequent app startup/auth flows use broken credentials instead of the prior working account.
Useful? React with 👍 / 👎.
Motivation
Description
rightslot tosrc/components/utils/Header.vueso views can inject controls into the header right area.src/views/Home.vuethat shows an avatar on the header right in non-portrait layout, opens a small panel with up to 3 saved accounts, and allows immediate switching by clicking an account.quickSwitchAccounts(declared insrc/services/storage/index.ts) and deduplicate by user id while keeping previous storage keys and values untouched.userAuthInfoand callslogin(token, authCode, true)to refresh the current user state; current account is saved to the quick list on auth refresh or login events.Testing
npm run -s eslintwhich completed successfully (repo pre-existing warnings remain; no new errors introduced).Codex Task