feat(i18n): 切换语言时同步更新页面标题#650
Merged
Wei-Shaw merged 1 commit intoWei-Shaw:mainfrom Feb 27, 2026
Merged
Conversation
- resolveDocumentTitle() 新增 titleKey 参数,优先通过 i18n 翻译 - router beforeEach 中将路由 meta.titleKey 传入标题解析函数 - setLocale() 切换语言后同步刷新 document.title
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic page title synchronization when users switch languages in the application. The implementation extends the existing i18n title infrastructure (titleKey) to support three authentication-related routes: Login, Register, and Forgot Password.
Changes:
- Enhanced
resolveDocumentTitle()to prioritize i18n translations via titleKey parameter - Added titleKey metadata to Login, Register, and Forgot Password routes
- Implemented automatic title refresh in
setLocale()to update browser tab title after language change
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| frontend/src/router/title.ts | Added i18n integration with optional titleKey parameter and fallback logic to existing title resolver |
| frontend/src/router/index.ts | Added titleKey metadata to Login, Register, and Forgot Password routes for i18n support |
| frontend/src/i18n/index.ts | Added dynamic title refresh logic after locale change to synchronize browser tab title |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
xuebkgithub
pushed a commit
to xuebkgithub/sub2api
that referenced
this pull request
Mar 3, 2026
…locale-change feat(i18n): 切换语言时同步更新页面标题
liafonx
pushed a commit
to liafonx/sub2api
that referenced
this pull request
Mar 20, 2026
…locale-change feat(i18n): 切换语言时同步更新页面标题
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.
问题
切换语言后,浏览器页签标题不会跟随更新,仍显示旧语言的标题文本。
解决方案
1.
router/title.ts— 新增titleKey参数resolveDocumentTitle()新增可选参数titleKey,优先通过 i18n 翻译生成标题,翻译失败时回退到静态routeTitle。2.
router/index.ts— 传入路由 meta.titleKeybeforeEach守卫调用resolveDocumentTitle时,将路由meta.titleKey一并传入,使导航时的标题即可国际化。3.
i18n/index.ts— setLocale 后同步刷新标题setLocale()完成语言切换后,读取当前路由的meta.titleKey并重新调用resolveDocumentTitle,更新document.title,确保页签标题与 UI 语言保持一致。测试