Sfoglia il codice sorgente

Merge branch 'v1.9.0-position' of http://192.168.0.115:3000/bill/fuse-code into v1.9.0-position

xzw 3 giorni fa
parent
commit
208e29c721
1 ha cambiato i file con 36 aggiunte e 50 eliminazioni
  1. 36 50
      src/layout/model-list/floor-tab.vue

+ 36 - 50
src/layout/model-list/floor-tab.vue

@@ -1,6 +1,11 @@
 <template>
-  <div class="floor-btn" v-if="floorList.length > 2">
-    <div v-for="item in floorList" :key="item.key" :class="['quisk-item', item.key == nowSelect ? 'active' : '']" @click="floor(item.key)">
+  <div class="floor-btn" v-if="floorCount > 1">
+    <div
+      v-for="item in floorList"
+      :key="item.key"
+      :class="['quisk-item', item.key == nowSelect ? 'active' : '']"
+      @click="floor(item.key)"
+    >
       <span>{{ item.text }}</span>
     </div>
   </div>
@@ -15,58 +20,39 @@ import { ref, onMounted, watch } from "vue";
 import { SDK, sdk } from "@/sdk";
 import { useViewStack } from "@/hook";
 
-const nowSelect = ref('all');
-const floorList = ref([{
-  key: "all",
-  text: "全部"
-}] as any[]);
+const nowSelect = ref("all");
+const floorList = ref([
+  {
+    key: "all",
+    text: "全部",
+  },
+] as any[]);
 
 const floor = (num: any) => {
   sdk.goFloor(num);
   nowSelect.value = num;
-}
-const floorCount = ref(0);
-
-watch(floorCount, (newVal) => {
-  for(let i = 0; i < newVal; i++) {
-    floorList.value.push({
-      key: i,
-      text: `${i + 1}楼`
-    })
-  }
-}, {immediate: true})
-
-
-let timer: any = null;
-let previousFloorCount = 0;
-
-onMounted(() => {
-  sdk.sceneBus.on("floorCount", (num: any) => {
-    floorCount.value = num;
-  });
-  
-  // 初始化上一次的值
-  previousFloorCount = sdk.getFloorCount();
-  
-  timer = setInterval(() => {
-    const currentCount = sdk.getFloorCount();
-    console.log(currentCount, 'setInterval');
-    
-    // 检查值是否发生变化
-    if (currentCount !== previousFloorCount) {
-      floorCount.value = currentCount;
-      console.log('floorCount changed, clearing interval');
-      clearInterval(timer);
-      timer = null;
-    }
-    
-    previousFloorCount = currentCount;
-  }, 1000);
+};
+const floorCount = ref(sdk.getFloorCount());
+sdk.sceneBus.on("floorCount", (count) => {
+  floorCount.value = count;
 });
+watch(
+  floorCount,
+  (newVal) => {
+    console.log("watch", newVal);
+    for (let i = 0; i < newVal; i++) {
+      floorList.value.push({
+        key: i,
+        text: `${i + 1}楼`,
+      });
+    }
+  },
+  { immediate: true }
+);
 </script>
 
 <style lang="scss" scoped>
-.floor-btn{
+.floor-btn {
   position: absolute;
   bottom: calc(var(--editor-menu-bottom, 0px) + 10px);
   left: calc(var(--left-pano-left) + var(--left-pano-width));
@@ -74,17 +60,17 @@ onMounted(() => {
   // display: flex;
   // flex-direction: column;
   // align-items: center;
-  z-index:100;
+  z-index: 100;
   width: 60px;
   min-height: 126px;
   background: rgba(27, 27, 28, 0.8);
   border-radius: 20px;
   padding: 8px;
-  transition: all .3s ease;
-  .active{
+  transition: all 0.3s ease;
+  .active {
     background: #00c8af;
   }
-  .quisk-item{
+  .quisk-item {
     width: 100%;
     height: 40px;
     border-radius: 10px;