App.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <a-config-provider :locale="zhCN">
  3. <router-view> </router-view>
  4. <a-spin
  5. v-if="spinning"
  6. size="large"
  7. :spinning="spinning"
  8. :delay="1000"
  9. class="global-mask fade-in"
  10. />
  11. </a-config-provider>
  12. </template>
  13. <script setup lang="ts">
  14. import { watch, watchEffect, computed } from "vue";
  15. import { store } from "@/store/store";
  16. import zhCN from "ant-design-vue/es/locale/zh_CN";
  17. let spinning = $ref(false);
  18. watch(
  19. () => store.globalMask,
  20. () => (spinning = store.globalMask)
  21. );
  22. watchEffect(() => {
  23. const bodyScrollProp = spinning ? "hidden" : "auto";
  24. document.body.style.overflow = bodyScrollProp;
  25. });
  26. </script>
  27. <style>
  28. #app {
  29. font-family: "PingFang SC", tahoma, "Hiragino Sans GB", "宋体", "微软雅黑",
  30. arial, sans-serif;
  31. -webkit-font-smoothing: antialiased;
  32. -moz-osx-font-smoothing: grayscale;
  33. background-color: var(--app-main-bg-color);
  34. width: 100%;
  35. color: var(--app-main-text-color);
  36. }
  37. .global-mask {
  38. position: absolute;
  39. top: 0;
  40. left: 0;
  41. height: 100vh;
  42. width: 100vw;
  43. /* 不知道为啥在窗口宽度小于#app min-width 的时候,遮罩层覆盖不全。要控制body的overflow。 */
  44. min-width: var(--app-min-width);
  45. overflow: hidden;
  46. display: flex;
  47. place-content: center;
  48. align-items: center;
  49. background-color: rgba(0, 0, 0, 0.7);
  50. z-index: 6000;
  51. }
  52. .fade-in {
  53. opacity: 0.7;
  54. animation-name: fadeInOpacity;
  55. animation-iteration-count: 1;
  56. animation-timing-function: ease-in;
  57. animation-duration: 2s;
  58. }
  59. @keyframes fadeInOpacity {
  60. 0% {
  61. opacity: 0;
  62. }
  63. 100% {
  64. opacity: 0.7;
  65. }
  66. }
  67. </style>