<template>
  <a-config-provider :locale="antdLocal">
    <router-view></router-view>
  </a-config-provider>
</template>
<script>
  import {useStore} from "vuex";
  import {computed, defineComponent, ref} from "vue";
  import zhCN from '@hwork/ant-design-vue/es/locale/zh_CN';
  import enUS from '@hwork/ant-design-vue/es/locale/en_US';
  import dayjs from "dayjs";
  import "dayjs/locale/zh-cn";

  export default defineComponent({
    name: 'App',
    setup() {

      const store = useStore()
      const language = computed(() => store.getters['language'])
      const color = computed(() => store.getters.color);

      const antdLocal = ref(
      computed(() => {
        switch (language.value) {
          case 'zh-cn':
            dayjs.locale(zhCN.locale);
            return zhCN;
          case 'en-us':
            dayjs.locale(enUS.locale);
            return enUS;
          default:
            dayjs.locale(zhCN.locale);
            return zhCN;
        }
      })
    )

    return {
      antdLocal,
      dayjs
    }
  }
})
</script>
