Ver código fonte

编辑器-导航-场景导航:整理代码

任一存 3 anos atrás
pai
commit
4ed723d5f1

+ 34 - 36
packages/code/src/components/insertPositionTipInEditor.vue

@@ -151,46 +151,45 @@ export default {
 
       switch (this.dragInfo.type) {
         case 'scene': // 被拖拽的是场景
-          // console.log('情况3:被拖拽的是场景,插入到二级分组中');
+          {
+            // console.log('情况3:被拖拽的是场景,插入到二级分组中')
 
-          /**
-           * 确定要插入的分组中各场景应有的weight(从1开始递增,小的先显示)
-           */
-          // eslint-disable-next-line no-case-declarations
-          const belongGroupCopy = deepClone(this.parentNode.children)
-          // eslint-disable-next-line no-case-declarations
-          const draggedNodeCopy = deepClone(this.dragInfo.node)
-          draggedNodeCopy.isCopy = true
-          belongGroupCopy.splice(this.index, 0, draggedNodeCopy)
-          // eslint-disable-next-line no-case-declarations
-          const toDeleteIndex = belongGroupCopy.findIndex((item) => {
-            return (item.id === this.dragInfo.node.id && !item.isCopy)
-          })
-          if (toDeleteIndex >= 0) {
-            belongGroupCopy.splice(toDeleteIndex, 1)
-          }
-          for (let [index, elem] of belongGroupCopy.entries()) {
-            elem.weight = index + 1
-          }
+            /**
+             * 确定要插入的分组中各场景应有的weight(从1开始递增,小的先显示)
+             */
+            const belongGroupCopy = deepClone(this.parentNode.children)
+            const draggedNodeCopy = deepClone(this.dragInfo.node)
+            draggedNodeCopy.isCopy = true
+            belongGroupCopy.splice(this.index, 0, draggedNodeCopy)
+            const toDeleteIndex = belongGroupCopy.findIndex((item) => {
+              return (item.id === this.dragInfo.node.id && !item.isCopy)
+            })
+            if (toDeleteIndex >= 0) {
+              belongGroupCopy.splice(toDeleteIndex, 1)
+            }
+            for (let [index, elem] of belongGroupCopy.entries()) {
+              elem.weight = index + 1
+            }
 
-          /**
-           * 真正修改场景原始数据的weight和所属分组
-           */
-          for (const eachSceneCopy of belongGroupCopy) {
-            for (const eachScene of this.info.scenes) {
-              if (eachSceneCopy.id === eachScene.id) {
-                this.$set( eachScene, 'weight', eachSceneCopy.weight )
-              }
-              if (this.dragInfo.node.id === eachScene.id) {
-                eachScene.category = this.parentNode.id // 注意category拼写!
+            /**
+             * 真正修改场景原始数据的weight和所属分组
+             */
+            for (const eachSceneCopy of belongGroupCopy) {
+              for (const eachScene of this.info.scenes) {
+                if (eachSceneCopy.id === eachScene.id) {
+                  this.$set( eachScene, 'weight', eachSceneCopy.weight )
+                }
+                if (this.dragInfo.node.id === eachScene.id) {
+                  eachScene.category = this.parentNode.id // 注意category拼写!
+                }
               }
             }
           }
-
           break;
         case 'topologyGroupLevel2': // 被拖拽的是拓扑结构中二级分组
           if (this.topologyLevel === 1) {
             // console.log('情况5:被拖拽的是拓扑结构中二级分组,拖拽到一级分组列表');
+
             /**
              * 在拖拽到的位置新增一个一级分组,name是原二级分组的name;唯一child的id赋值为被拖拽的二级分组的id
              */
@@ -201,18 +200,15 @@ export default {
             }
             this.info.catalogRoot.splice(this.index, 0, newGroupLevel1)
 
-            /**
-             * 被拖拽的二级分组名称改为“默认二级分组”;
-             */
+            // 被拖拽的二级分组名称改为“默认二级分组”;
             const draggedGroup = this.info.catalogs.find((item) => {
               return item.id === this.dragInfo.node.id
             })
             draggedGroup.name = '默认二级分组'
 
             /**
-             * 
+             * 被拖拽的二级分组原属的一级分组的children中,删除【被拖拽的二级分组对应的元素】
              */
-            // 被拖拽的二级分组原属的一级分组的children中,删除【被拖拽的二级分组对应的元素】
             const parentGroup = this.info.catalogRoot.find((item) => {
               return item.id === this.dragInfo.node.parentId
             })
@@ -347,6 +343,8 @@ export default {
             this.info.catalogRoot.splice(originalGroupLevel1Idx, 1)
           }
           break;
+        default:
+          break;
       }
     }
   }