Feature: 为网页标题添加国际化

This commit is contained in:
2025-07-12 15:21:22 +08:00
parent 4a375f117b
commit cead32f93d
2 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="icon" href="/favicon.ico"> <link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Vuetify 3</title> <title>Loading...</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>

View File

@ -83,6 +83,11 @@
const selectedIndex = ref(0) const selectedIndex = ref(0)
const windowWidth = ref(typeof window === 'undefined' ? 1200 : window.innerWidth) const windowWidth = ref(typeof window === 'undefined' ? 1200 : window.innerWidth)
// 动态设置网页标题
const pageTitle = computed(() => {
return t('appTitle')
})
// 监听窗口变化 // 监听窗口变化
const handleResize = () => { const handleResize = () => {
if (typeof window === 'undefined') return if (typeof window === 'undefined') return
@ -195,4 +200,12 @@
selectedIndex.value = index selectedIndex.value = index
drawer.value = false // 选择后自动关闭抽屉 drawer.value = false // 选择后自动关闭抽屉
} }
onMounted(() => {
document.title = pageTitle.value
})
watch(locale, () => {
document.title = pageTitle.value
})
</script> </script>