App.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. const isRouterActive = ref(true)
  16. // 全局语言
  17. const { locale } = useLang()
  18. const systemStore = useSystemStore()
  19. // 暗黑主题
  20. useDarkThemeHook()
  21. provide('reloadRoutePage', () => {
  22. isRouterActive.value = false
  23. nextTick(() => {
  24. isRouterActive.value = true
  25. })
  26. })
  27. onMounted(async () => {
  28. const getLoadingNode = document.getElementById('Loading')
  29. const { body } = document
  30. if (getLoadingNode) {
  31. body.removeChild(getLoadingNode)
  32. }
  33. })
  34. </script>
  35. <style lang="less">
  36. body {
  37. overflow: hidden;
  38. }
  39. // 加载loading css
  40. .public_local_loading {
  41. position: fixed;
  42. top: 0;
  43. left: 0;
  44. width: 100%;
  45. height: 100%;
  46. z-index: 2000;
  47. display: flex;
  48. justify-content: center;
  49. align-items: center;
  50. .public_local_loading_bg {
  51. width: 12rem;
  52. height: 12rem;
  53. position: sticky;
  54. left: 50%;
  55. top: 50%;
  56. transform: translate3d(-50%, -50%, 0);
  57. display: flex;
  58. flex-direction: column;
  59. align-items: center;
  60. justify-content: center;
  61. }
  62. .public_local_loading_logo {
  63. font-size: 2rem;
  64. user-select: none;
  65. }
  66. }
  67. .hidden-loading.public_local_loading {
  68. opacity: 0;
  69. z-index: -10 !important;
  70. cursor: auto !important;
  71. }
  72. @keyframes r-loading {
  73. 0% {
  74. transform: rotate(0deg);
  75. }
  76. 100% {
  77. transform: rotate(360deg);
  78. }
  79. }
  80. </style>