From 2745af94c6dee580aa1f6777e821cff89b51d255 Mon Sep 17 00:00:00 2001 From: zonemeen Date: Wed, 6 Mar 2024 20:08:01 +0800 Subject: [PATCH] fix(i18n): page changes reset the hash when with i18n --- src/client/theme-default/composables/langs.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/theme-default/composables/langs.ts b/src/client/theme-default/composables/langs.ts index 1d237257..3581d91e 100644 --- a/src/client/theme-default/composables/langs.ts +++ b/src/client/theme-default/composables/langs.ts @@ -1,4 +1,4 @@ -import { computed } from 'vue' +import { computed, watch } from 'vue' import { ensureStartingSlash } from '../../shared' import { useData } from './data' import { hashRef } from './hash' @@ -15,6 +15,10 @@ export function useLangs({ (localeIndex.value === 'root' ? '/' : `/${localeIndex.value}/`) })) + watch(page, () => { + hashRef.value = location.hash ? location.hash : '' + }) + const localeLinks = computed(() => Object.entries(site.value.locales).flatMap(([key, value]) => removeCurrent && currentLang.value.label === value.label