|
@@ -1,7 +1,17 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { NConfigProvider, NMessageProvider, useMessage } from "naive-ui";
|
|
import { NConfigProvider, NMessageProvider, useMessage } from "naive-ui";
|
|
import { zhCN, dateZhCN } from "naive-ui";
|
|
import { zhCN, dateZhCN } from "naive-ui";
|
|
-import { defineComponent } from "vue";
|
|
|
|
|
|
+import { defineComponent, watch, watchEffect } from "vue";
|
|
|
|
+import { store } from "./store/store";
|
|
|
|
+
|
|
|
|
+let spinning = $ref(false);
|
|
|
|
+
|
|
|
|
+setTimeout(() => {
|
|
|
|
+ watch(
|
|
|
|
+ () => store?.hasGlobalMask,
|
|
|
|
+ () => (spinning = store?.hasGlobalMask)
|
|
|
|
+ );
|
|
|
|
+});
|
|
|
|
|
|
const DummyComp = defineComponent({
|
|
const DummyComp = defineComponent({
|
|
setup() {
|
|
setup() {
|
|
@@ -12,6 +22,11 @@ const DummyComp = defineComponent({
|
|
return null;
|
|
return null;
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+watchEffect(() => {
|
|
|
|
+ const bodyScrollProp = spinning ? "hidden" : "auto";
|
|
|
|
+ document.body.style.overflow = bodyScrollProp;
|
|
|
|
+});
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -21,6 +36,12 @@ const DummyComp = defineComponent({
|
|
<DummyComp />
|
|
<DummyComp />
|
|
</n-config-provider>
|
|
</n-config-provider>
|
|
</n-message-provider>
|
|
</n-message-provider>
|
|
|
|
+ <div
|
|
|
|
+ v-if="spinning"
|
|
|
|
+ style="position: absolute; top: 0; left: 0; width: 100vw; height: 100vh"
|
|
|
|
+ >
|
|
|
|
+ <n-spin :show="spinning" size="large" class="global-mask fade-in"> </n-spin>
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<style>
|
|
<style>
|
|
@@ -32,4 +53,37 @@ const DummyComp = defineComponent({
|
|
color: #2c3e50;
|
|
color: #2c3e50;
|
|
margin-top: 60px;
|
|
margin-top: 60px;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+.global-mask {
|
|
|
|
+ position: absolute;
|
|
|
|
+ top: 0;
|
|
|
|
+ left: 0;
|
|
|
|
+ height: 100vh;
|
|
|
|
+ width: 100vw;
|
|
|
|
+ /* 不知道为啥在窗口宽度小于#app min-width 的时候,遮罩层覆盖不全。要控制body的overflow。 */
|
|
|
|
+ min-width: var(--app-min-width);
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ display: flex;
|
|
|
|
+ place-content: center;
|
|
|
|
+ align-items: center;
|
|
|
|
+ background-color: rgba(0, 0, 0, 0.7);
|
|
|
|
+ z-index: 6000;
|
|
|
|
+}
|
|
|
|
+.fade-in {
|
|
|
|
+ opacity: 0;
|
|
|
|
+ animation-name: fadeInOpacity;
|
|
|
|
+ animation-delay: 1.5s;
|
|
|
|
+ animation-iteration-count: 1;
|
|
|
|
+ animation-timing-function: ease-in;
|
|
|
|
+ animation-duration: 5s;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+@keyframes fadeInOpacity {
|
|
|
|
+ 0% {
|
|
|
|
+ opacity: 0;
|
|
|
|
+ }
|
|
|
|
+ 100% {
|
|
|
|
+ opacity: 0.7;
|
|
|
|
+ }
|
|
|
|
+}
|
|
</style>
|
|
</style>
|