mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-22 00:43:50 +01:00
fix switchLocalePath
This commit is contained in:
parent
eae0677fcd
commit
633c545c7c
@ -115,7 +115,7 @@ const navOpen = ref(false);
|
||||
|
||||
const { locales, locale: currentLocale } = useI18n();
|
||||
const route = useRoute();
|
||||
const { afterEach, push } = useRouter();
|
||||
const { push } = useRouter();
|
||||
const currentPath = ref(route.path);
|
||||
|
||||
watch(() => route.path,(to) => {
|
||||
@ -124,7 +124,7 @@ watch(() => route.path,(to) => {
|
||||
immediate: true,
|
||||
});
|
||||
|
||||
const switchLocalePath = useSwitchLocalePath();
|
||||
const switchLocalePath = useGSwitchLocalePath();
|
||||
const localePath = useGLocalePath();
|
||||
const spLocaleOption = ref<string>(currentLocale.value);
|
||||
function changeLocale() {
|
||||
|
17
composables/useGSwitchLocalePath.ts
Normal file
17
composables/useGSwitchLocalePath.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {
|
||||
useSwitchLocalePath as _useSwitchLocalePath,
|
||||
getComposer,
|
||||
} from 'vue-i18n-routing';
|
||||
|
||||
/** useSwitchLocalePathのラッパー関数。 */
|
||||
export function useGSwitchLocalePath(
|
||||
options?: NonNullable<Parameters<typeof _useSwitchLocalePath>[0]>
|
||||
): ReturnType<typeof _useSwitchLocalePath> {
|
||||
const { route, router, i18n, strategy } = options || {}
|
||||
return _useSwitchLocalePath({
|
||||
route: route || useRoute(),
|
||||
router: router || useRouter(),
|
||||
i18n: i18n || getComposer(useNuxtApp().$i18n),
|
||||
strategy: strategy ?? 'prefix', // ←リンクではprefixつきにする
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user