App.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <a-config-provider :locale="locale">
  3. <div class="public_local_loading" :class="{ 'hidden-loading': !systemStore.getLocalLoading }">
  4. <div class="public_local_loading_bg">
  5. <a-spin class="public_local_loading_logo" dot />
  6. </div>
  7. </div>
  8. <router-view v-if="isRouterActive" />
  9. </a-config-provider>
  10. </template>
  11. <script setup>
  12. import { ref, onMounted, nextTick, provide } from "vue"
  13. import { useDarkThemeHook, useLang } from '@/hooks'
  14. import { useSystemStore } from '@/store/modules/systemStore'
  15. import { dictionaryList } from "@/api/path/dict"
  16. const isRouterActive = ref(true)
  17. // 全局语言
  18. const { locale } = useLang()
  19. const systemStore = useSystemStore()
  20. // 暗黑主题
  21. useDarkThemeHook()
  22. provide('reloadRoutePage', () => {
  23. isRouterActive.value = false
  24. nextTick(() => {
  25. isRouterActive.value = true
  26. })
  27. })
  28. onMounted(async () => {
  29. const getLoadingNode = document.getElementById('Loading')
  30. const { body } = document
  31. if (getLoadingNode) {
  32. body.removeChild(getLoadingNode)
  33. }
  34. if (systemStore?.token) {
  35. const { code, data } = await dictionaryList({
  36. size: 99999,
  37. current: 1,
  38. })
  39. if (code == 200) {
  40. window.localStorage.setItem('dictList', JSON.stringify(data.records))
  41. }
  42. }
  43. })
  44. </script>
  45. <style lang="less">
  46. body {
  47. overflow: hidden;
  48. }
  49. // 加载loading css
  50. .public_local_loading {
  51. position: fixed;
  52. top: 0;
  53. left: 0;
  54. width: 100%;
  55. height: 100%;
  56. z-index: 2000;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. .public_local_loading_bg {
  61. width: 12rem;
  62. height: 12rem;
  63. position: sticky;
  64. left: 50%;
  65. top: 50%;
  66. transform: translate3d(-50%, -50%, 0);
  67. display: flex;
  68. flex-direction: column;
  69. align-items: center;
  70. justify-content: center;
  71. }
  72. .public_local_loading_logo {
  73. font-size: 2rem;
  74. user-select: none;
  75. }
  76. }
  77. .hidden-loading.public_local_loading {
  78. opacity: 0;
  79. z-index: -10 !important;
  80. cursor: auto !important;
  81. }
  82. @keyframes r-loading {
  83. 0% {
  84. transform: rotate(0deg);
  85. }
  86. 100% {
  87. transform: rotate(360deg);
  88. }
  89. }
  90. </style>