index.vue
978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<script lang="ts" setup>
import { ConfigProvider } from 'ant-design-vue'
import zhCN from 'ant-design-vue/locale/zh_CN'
import enUS from 'ant-design-vue/locale/en_US'
import dayjs from 'dayjs'
import { computed, unref, watch } from 'vue'
import type { DrawioConfig } from '../Library/types'
// import 'dayjs/locale/zh-cn'
// import 'dayjs/locale/en-us'
import { useParseParams } from '../LoadData'
const { locale } = useParseParams()
const { language } = (JSON.parse(localStorage.getItem('.drawio-config') || '') || {}) as DrawioConfig
const getLocale = computed(
() => {
return {
dayjs: language || (locale && locale === 'en' ? 'en-us' : 'zh-cn'),
antd: (language && locale === 'en' ? enUS : zhCN) || (locale && locale === 'en' ? enUS : zhCN),
}
},
)
watch(
() => unref(getLocale).dayjs,
(target) => {
dayjs.locale(target)
},
)
</script>
<template>
<ConfigProvider :locale="getLocale.antd">
<slot />
</ConfigProvider>
</template>