From 5df19d53a05b411a91e3622fc40dbd5112b7aee1 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:23:29 +0900 Subject: [PATCH] fix --- .vitepress/theme/Layout.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.vitepress/theme/Layout.vue b/.vitepress/theme/Layout.vue index 320f3a3..de5a635 100644 --- a/.vitepress/theme/Layout.vue +++ b/.vitepress/theme/Layout.vue @@ -16,20 +16,20 @@ const locales = Object.keys(data.site.value.locales) as string[]; const localesRegex = new RegExp(`^/(${locales.join('|')})`); const savedLocale = localStorage.getItem('ais:locale'); -if (inBrowser && !localesRegex.test(route.path)) { - if (savedLocale != null && locales.includes(savedLocale)) { - location.replace('/' + savedLocale + location.pathname + location.search); - } else if (locales.includes(navigator.language.split('-')[0])) { - location.replace('/' + navigator.language.split('-')[0] + location.pathname + location.search); +if (inBrowser) { + if (!localesRegex.test(route.path)) { + if (savedLocale != null && locales.includes(savedLocale)) { + location.replace('/' + savedLocale + location.pathname + location.search); + } else if (locales.includes(navigator.language.split('-')[0])) { + location.replace('/' + navigator.language.split('-')[0] + location.pathname + location.search); + } else { + location.replace('/ja' + location.pathname + location.search); + } } else { - location.replace('/ja' + location.pathname + location.search); + loaded.value = true; } } -if (inBrowser) { - loaded.value = true; -} - watch(data.lang, (lang) => { if (inBrowser) { localStorage.setItem('ais:locale', lang.split('-')[0]);