Преглед изворни кода

804暂停屏蔽,上下步动画加载

tangjunhao пре 1 месец
родитељ
комит
0cf5e629c2
2 измењених фајлова са 34 додато и 12 уклоњено
  1. 16 6
      src/view/index/explode.vue
  2. 18 6
      src/view/index/explode3d.vue

+ 16 - 6
src/view/index/explode.vue

@@ -35,8 +35,8 @@
                       </el-slider>
                       <div class="tanniu">
                         <div><el-image :src="t1" fit="contain" @click="Prev"></el-image></div>
-                        <div v-show="suspendshow"><el-image :src="t2" fit="contain" @click="play(500)"></el-image></div>
-                        <div v-show="playshow"><el-image :src="t3" fit="contain" @click="play(500)"></el-image></div>
+                        <!-- <div v-show="suspendshow"><el-image :src="t2" fit="contain" @click="play(500)"></el-image></div>
+                        <div v-show="playshow"><el-image :src="t3" fit="contain" @click="play(500)"></el-image></div> -->
                         <div><el-image :src="t4" fit="contain" @click="increment"></el-image></div>
 
                       </div>
@@ -155,6 +155,10 @@ let initFlag=false;
 let aid = ref()
 let vtkObj = {}
 let max, min;
+
+// 定义一个全局 loading 变量(只创建一个)
+let scalarLoadingInstance = null;
+
 watch(
   () => [formInline.value.region, count.value, aid.value],
   (newVal, oldVal) => {
@@ -165,7 +169,7 @@ watch(
       console.log("步数改变", newVal[1], oldVal[1]);
       if (vtkObj.fcon) {
         console.log(count.value);
-        vtkScalarRead(count.value); //步数
+        vtkScalarRead(count.value, true); //步数
       }
     }
     if (newVal[0] != oldVal[0]) {
@@ -488,10 +492,15 @@ function vtkGridRead() {
   })
 }
 function vtkScalarRead(step, isshowloading = false) {
-  let loadingInstance = null;
+  // 如果已有 loading,则先关闭
+  if (scalarLoadingInstance) {
+    scalarLoadingInstance.close();
+    scalarLoadingInstance = null;
+  }
+
   if (isshowloading) {
     // 创建 loading 实例,绑定到 expleft1 容器
-    loadingInstance = ElLoading.service({
+    scalarLoadingInstance = ElLoading.service({
       target: '#expleft1',
       lock: true,
       text: '加载中...',
@@ -526,7 +535,8 @@ function vtkScalarRead(step, isshowloading = false) {
     })
     .finally(() => {
       if (isshowloading) {
-        loadingInstance.close(); // 无论成功失败都关闭 loading
+        scalarLoadingInstance?.close(); // 无论成功失败都关闭 loading
+        scalarLoadingInstance = null; // 清除全局 loading 变量
       }
     });
 }

+ 18 - 6
src/view/index/explode3d.vue

@@ -35,8 +35,8 @@
                       </el-slider>
                       <div class="tanniu">
                         <div><el-image :src="t1" fit="contain" @click="Prev"></el-image></div>
-                        <div v-show="suspendshow"><el-image :src="t2" fit="contain" @click="play(500)"></el-image></div>
-                        <div v-show="playshow"><el-image :src="t3" fit="contain" @click="play(500)"></el-image></div>
+                        <!-- <div v-show="suspendshow"><el-image :src="t2" fit="contain" @click="play(500)"></el-image></div>
+                        <div v-show="playshow"><el-image :src="t3" fit="contain" @click="play(500)"></el-image></div> -->
                         <div><el-image :src="t4" fit="contain" @click="increment"></el-image></div>
 
                       </div>
@@ -138,6 +138,11 @@ let initFlag=false;
 let aid = ref()
 let vtkObj = {}
 let max, min;
+
+// 定义一个全局 loading 变量(只创建一个)
+let scalarLoadingInstance = null;
+
+
 watch(
   () => [formInline.value.region, count.value, aid.value],
   (newVal, oldVal) => {
@@ -148,7 +153,7 @@ watch(
       console.log("步数改变", newVal[1], oldVal[1]);
       if (vtkObj.fcon) {
         console.log(count.value);
-        vtkScalarRead(count.value); //步数
+        vtkScalarRead(count.value, true); //步数
       }
     }
     if (newVal[0] != oldVal[0]) {
@@ -492,11 +497,17 @@ function vtkGridRead() {
     loadingInstance.close();
   })
 }
+
 function vtkScalarRead(step, isshowloading = false) {
-  let loadingInstance = null;
+  // 如果已有 loading,则先关闭
+  if (scalarLoadingInstance) {
+    scalarLoadingInstance.close();
+    scalarLoadingInstance = null;
+  }
+
   if (isshowloading) {
     // 创建 loading 实例,绑定到 expleft3 容器
-    loadingInstance = ElLoading.service({
+    scalarLoadingInstance = ElLoading.service({
       target: '#expleft3',
       lock: true,
       text: '加载中...',
@@ -532,7 +543,8 @@ function vtkScalarRead(step, isshowloading = false) {
     })
     .finally(() => {
       if (isshowloading) {
-        loadingInstance.close();
+        scalarLoadingInstance?.close();
+        scalarLoadingInstance = null; // 清除全局 loading 变量
       }
     });
 }