App.vue 1.8 KB

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