Files
pqs-9100_client/frontend/src/App.vue
2025-01-15 08:42:41 +08:00

55 lines
1.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!--element-plus语言国际化全局修改为中文-->
<el-config-provider
:locale='locale'
:size='assemblySize'
:button='buttonConfig'
>
<router-view />
</el-config-provider>
</template>
<script lang='ts' setup>
defineOptions({
name: 'App',
})
import { useI18n } from 'vue-i18n'
import { getBrowserLang } from '@/utils'
import { useTheme } from '@/hooks/useTheme'
import { ElConfigProvider } from 'element-plus'
import { LanguageType } from './stores/interface'
import { useGlobalStore } from '@/stores/modules/global'
import en from 'element-plus/es/locale/lang/en'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
const globalStore = useGlobalStore()
// init theme
const { initTheme } = useTheme()
initTheme()
// init language
const i18n = useI18n()
onMounted(() => {
const language = globalStore.language ?? getBrowserLang()
i18n.locale.value = language
globalStore.setGlobalState('language', language as LanguageType)
})
// element language
const locale = computed(() => {
if (globalStore.language == 'zh') return zhCn
if (globalStore.language == 'en') return en
return getBrowserLang() == 'zh' ? zhCn : en
})
// element assemblySize
const assemblySize = computed(() => globalStore.assemblySize)
// element button config
const buttonConfig = reactive({ autoInsertSpace: false })
document.getElementById('loadingPage')?.remove()
</script>
<style scoped></style>