<template>
	<RouterView />
</template>

<script lang="ts" setup>
import { userI18nStore } from '@/store/i18n.ts';
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';

const i18nStore = userI18nStore();
const i18n = useI18n();
/**
 * * 设置多语言内容
 */
const setI18n = async () => {
	await i18nStore.fetchI18n();
	const languageData = JSON.parse(localStorage.getItem('i18nStore') as any);
	const local = languageData.i18n.local;

	// 初始化设置多语言内容
	i18n.locale.value = local;
	i18n.mergeLocaleMessage(local, languageData.i18n[local]);
};

onMounted(async () => {
	await setI18n();
});
</script>

<style scoped></style>
