fix(i18n): 브라우저 탭 타이틀을 common.app.title 기반으로 국제화 동기화

라우터 afterEach에서 가장 깊은 meta.titleKey 사용, locale 변경 watch에서 동일 로직으로 재계산, 초기 진입 시 common.app.title로 교체. docs에 검증 기록 추가.
This commit is contained in:
Yu Sung
2026-05-08 16:00:57 +09:00
parent ab6660fa16
commit aba06048b3
3 changed files with 57 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '@/store';
import i18n from '@/i18n'
import DefaultLayout from '@/layouts/default'
@@ -99,7 +100,8 @@ const routes = [
{
path: '/signature',
name: 'SignatureManagement',
component: () => import(/* webpackChunkName: "signature" */ '../views/Signature/SignatureManagement.vue')
component: () => import(/* webpackChunkName: "signature" */ '../views/Signature/SignatureManagement.vue'),
meta: { titleKey: 'view.signature.title' }
}
]
},
@@ -135,4 +137,19 @@ router.beforeEach((to, from, next) => {
}
})
// 라우트 변경 시 문서 타이틀을 i18n으로 갱신
router.afterEach((to) => {
try {
// 가장 깊은 매칭 라우트에서 titleKey 탐색
const matched = (to && to.matched) ? to.matched : []
const deepest = matched.length ? matched[matched.length - 1] : to
const key = deepest && deepest.meta && deepest.meta.titleKey
const appTitle = i18n && typeof i18n.t === 'function' ? i18n.t('common.app.title') : 'Soda Admin'
const localized = key ? i18n.t(key) : ''
document.title = key ? `${localized} - ${appTitle}` : `${appTitle}`
} catch (e) {
// ignore
}
})
export default router