<script setup lang="ts">
import { RouterView } from "vue-router";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import zhCN from "ant-design-vue/es/locale/zh_CN";
import { onMounted, ref } from "vue";
import { useAuthStore } from "./stores/auth.store";
import { routeToLogin } from "./router";
dayjs.locale("zh-cn");

const locale = ref(zhCN);

const authStore = useAuthStore();

onMounted(() => {
  authStore.checkLogin().then((isLogin) => {
    if (!isLogin) {
      routeToLogin();
    }
  });
});
</script>

<template>
  <a-config-provider :locale="locale">
    <RouterView />
  </a-config-provider>
</template>
