From 3c29d3517de511e67d9cb8a9486d2ace9043d52b Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Tue, 26 Nov 2024 20:13:32 +0100 Subject: [PATCH] Fix --- app/components/AppHeader.vue | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/components/AppHeader.vue b/app/components/AppHeader.vue index 2b360d7..61ebd4e 100644 --- a/app/components/AppHeader.vue +++ b/app/components/AppHeader.vue @@ -5,7 +5,6 @@ watch(isDark, () => { colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark' }) -const config = useRuntimeConfig() const navs = [ { label: { @@ -78,6 +77,8 @@ async function toggleTheme() { const { locale, setLocale, locales, t, availableLocales } = useI18n() const currentLocale = computed(() => locales.value.filter(l => l.code === locale.value)[0]) +const lang = ref(locale.value) +watch(lang, () => changeLocale(lang.value)) async function changeLocale(newLocale?: string) { document.body.style.animation = 'switch-on .2s' @@ -87,7 +88,7 @@ async function changeLocale(newLocale?: string) { const currentLocaleIndex = availableLocales.findIndex(l => l === locale.value) const nextLocaleIndex = (currentLocaleIndex + 1) % availableLocales.length newLocale = availableLocales[nextLocaleIndex] - lang.value = newLocale + lang.value = newLocale! } await setLocale(newLocale ?? 'en') @@ -97,9 +98,6 @@ async function changeLocale(newLocale?: string) { document.body.style.animation = '' } -const currentLocale = computed(() => locales.value.filter(l => l.code === locale.value)[0]) -const lang = ref(locale.value) -watch(lang, () => changeLocale(lang.value)) const router = useRouter() defineShortcuts({