vite_ts_auto/src/App.vue

32 lines
670 B
Vue
Raw Normal View History

2024-05-08 13:43:24 +08:00
<template>
<RouterView />
2024-05-08 13:43:24 +08:00
</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>
2024-05-08 13:43:24 +08:00
<style scoped></style>