App.vue 626 B

1234567891011121314151617181920212223242526272829
  1. <script setup lang="ts">
  2. import { RouterView } from "vue-router";
  3. import dayjs from "dayjs";
  4. import "dayjs/locale/zh-cn";
  5. import zhCN from "ant-design-vue/es/locale/zh_CN";
  6. import { onMounted, ref } from "vue";
  7. import { useAuthStore } from "./stores/auth.store";
  8. import { routeToLogin } from "./router";
  9. dayjs.locale("zh-cn");
  10. const locale = ref(zhCN);
  11. const authStore = useAuthStore();
  12. onMounted(() => {
  13. authStore.checkLogin().then((isLogin) => {
  14. if (!isLogin) {
  15. routeToLogin();
  16. }
  17. });
  18. });
  19. </script>
  20. <template>
  21. <a-config-provider :locale="locale">
  22. <RouterView />
  23. </a-config-provider>
  24. </template>