#
Junjie
2024-07-01 076844f4c54c75350e8354ad10cd125f98e86458
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
38
39
40
<script setup>
import { getCurrentInstance, provide } from "vue";
import IndexView from './views/IndexView.vue'
import LoginView from './views/login/LoginView.vue'
import { globalState } from './config.js'
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import enUS from 'ant-design-vue/es/locale/en_US';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
const context = getCurrentInstance()?.appContext.config.globalProperties;
dayjs.locale('zh-cn');
provide('globalState', globalState);
 
const localeType = {
  zhCN,
  enUS,
};
 
if (globalState.token == '' || globalState.token == null) {
  let token = localStorage.getItem('token')
  let user = JSON.parse(localStorage.getItem('user'))
  globalState.token = token;
  globalState.user = user;
}
</script>
 
<template>
  <a-config-provider :locale="localeType[globalState.locale]">
    <div v-if="globalState.token == '' || globalState.token == null">
      <LoginView />
      {{ context.$config }}
    </div>
    <div v-else>
      <IndexView />
      {{ context.$config }}
    </div>
  </a-config-provider>
</template>
 
<style scoped></style>