feat(theme): add lang switch to update html lang attr (#867)

This commit is contained in:
pengzhanbo 2026-03-05 14:42:48 +08:00 committed by GitHub
parent 916e9141d9
commit fd1dd7c695
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -90,6 +90,7 @@ export function registerWatchers() {
}, { passive: true })
}
const { lang } = useData()
const route = useRoute()
const { disableSidebar, toggleSidebarCollapse } = useSidebarControl()
watch(() => route.path, () => {
@ -97,5 +98,11 @@ export function registerWatchers() {
toggleSidebarCollapse(false)
})
if (inBrowser) {
watch(lang, (newLang) => {
document.documentElement.lang = newLang
}, { immediate: true })
}
useCloseSidebarOnEscape()
}