refactor: use setup refactor

This commit is contained in:
xiaoxian521
2021-09-16 23:16:54 +08:00
parent 8f6986608d
commit d4302627e8
13 changed files with 462 additions and 600 deletions

View File

@@ -1,28 +1,25 @@
<template>
<el-config-provider :locale="currentLocale">
<router-view />
</el-config-provider>
</template>
<script>
<script setup lang="ts">
import { getCurrentInstance } from "vue";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import en from "element-plus/lib/locale/lang/en";
export default {
name: "app",
components: {
[ElConfigProvider.name]: ElConfigProvider
},
computed: {
// eslint-disable-next-line vue/return-in-computed-property
currentLocale() {
switch (this.$storage.locale?.locale) {
case "zh":
return zhCn;
case "en":
return en;
}
}
let locale: string =
getCurrentInstance().appContext.config.globalProperties.$storage?.locale
?.locale;
let currentLocale = () => {
switch (locale) {
case "zh":
return zhCn;
case "en":
return en;
}
};
</script>
<template>
<el-config-provider :locale="currentLocale()">
<router-view />
</el-config-provider>
</template>