refactor: 国际化方法迁移
Former-commit-id: f8b53cf2e08b31b2729a4d6c472337b472debfbd
This commit is contained in:
37
src/App.vue
37
src/App.vue
@@ -1,34 +1,11 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ElConfigProvider } from 'element-plus';
|
||||||
|
import { useAppStore } from '@/store/modules/app';
|
||||||
|
const appStore = useAppStore();
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-config-provider :locale="locale" :size="size">
|
<el-config-provider :locale="appStore.locale" :size="appStore.size">
|
||||||
<router-view />
|
<router-view />
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { computed, ref, watch } from 'vue';
|
|
||||||
import { ElConfigProvider } from 'element-plus';
|
|
||||||
|
|
||||||
import useStore from '@/store';
|
|
||||||
|
|
||||||
// 导入 Element Plus 语言包
|
|
||||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
|
||||||
import en from 'element-plus/es/locale/lang/en';
|
|
||||||
|
|
||||||
const { app } = useStore();
|
|
||||||
|
|
||||||
const language = computed(() => app.language);
|
|
||||||
const size: any = computed(() => app.size);
|
|
||||||
|
|
||||||
const locale = ref();
|
|
||||||
|
|
||||||
watch(
|
|
||||||
language,
|
|
||||||
value => {
|
|
||||||
locale.value = value == 'en' ? en : zhCn;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// 初始化立即执行
|
|
||||||
immediate: true
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user