Skip to content

Commit 7d8b7c9

Browse files
committed
fix: fix locale title in toggleLocale fn
1 parent e46d11d commit 7d8b7c9

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
.DS_Store
66
.output
77
.eslintcache
8+
.idea

src/composables/locale.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ export function useLocale() {
1313
}
1414

1515
locale.value = _locale as string
16+
setLocaleTitle()
1617
}
1718

1819
const title = useTitle()
1920

20-
const setLocaleTitle = (locale?: string, isKey: boolean = false) => {
21-
const _t = isKey ? t(locale || 'app.title') : locale
21+
function setLocaleTitle(locale?: string, isKey: boolean = false) {
22+
const _t = isKey ? t(locale || 'app.title') : locale || t('app.title')
2223
title.value = _t === t('app.title') ? _t : `${_t} - ${t('app.title')}`
2324
}
2425

src/locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"page": {
77
"index": {
8-
"title": "Vite + Vue 3 启动模板"
8+
"title": "首页"
99
},
1010
"about": {
1111
"title": "关于",

typings/auto-imports.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ declare global {
330330
export type { ContentTypeEnum } from '../src/constants/enums'
331331
import('../src/constants/enums')
332332
}
333+
333334
// for vue template auto import
334335
import { UnwrapRef } from 'vue'
335336
declare module 'vue' {
@@ -650,4 +651,4 @@ declare module 'vue' {
650651
readonly watchWithFilter: UnwrapRef<typeof import('@vueuse/core')['watchWithFilter']>
651652
readonly whenever: UnwrapRef<typeof import('@vueuse/core')['whenever']>
652653
}
653-
}
654+
}

0 commit comments

Comments
 (0)