Commit 5242c5cb authored by tyyin lan's avatar tyyin lan

chore: 组件库多语言配置

parent 5270fd70
<script setup lang="ts">
import { zhCN, dateZhCN } from 'naive-ui'
import { zhCN, dateZhCN, zhTW, dateZhTW, enUS, dateEnUS } from 'naive-ui'
import { provide, ref } from 'vue'
import mitt from 'mitt'
import { themeOverrides } from '@/config/theme-config'
......@@ -7,16 +7,20 @@ import { useResizeObserver } from '@vueuse/core'
import { useDesignSettingStore } from '@/store/modules/design-setting'
import { useUserStore } from './store/modules/user'
import MessageTipModal from '@/components/message-tip-modal/message-tip-modal.vue'
import { useSystemLanguageStore } from '@/store/modules/system-language'
const designSettingStore = useDesignSettingStore()
const userStore = useUserStore()
const systemLanguageStore = useSystemLanguageStore()
const emitter = mitt<MittEvents>()
provide('emitter', emitter)
const currentLocale = ref(zhCN)
const currentDateLocale = ref(dateZhCN)
// const currentLocale = ref(zhCN)
const currentLocale = ref(localeParser())
// const currentDateLocale = ref(dateZhCN)
const currentDateLocale = ref(dateLocaleParser())
const rootContainer = ref<HTMLDivElement | null>(null)
......@@ -40,11 +44,35 @@ useResizeObserver(rootContainer, (entries) => {
designSettingStore.toggleSidebarDisplayStatus('expand')
}
})
/* created */
;(function () {
if (userStore.isLogin) {
userStore.fetchUpdateUserInfo()
}
})()
function localeParser() {
switch (systemLanguageStore.currentLanguageInfo.key) {
case 'zh-CN':
return zhCN
case 'zh-HK':
return zhTW
case 'en':
return enUS
}
}
function dateLocaleParser() {
switch (systemLanguageStore.currentLanguageInfo.key) {
case 'zh-CN':
return dateZhCN
case 'zh-HK':
return dateZhTW
case 'en':
return dateEnUS
}
}
</script>
<template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment