Quellcode durchsuchen

解决跨分屏拖拽开窗宽高变成一样的bug

liuwei vor 4 Jahren
Ursprung
Commit
6392bae03d
1 geänderte Dateien mit 17 neuen und 14 gelöschten Zeilen
  1. 17 14
      src/renderer/components/BigShow.vue

+ 17 - 14
src/renderer/components/BigShow.vue

@@ -220,26 +220,29 @@
                     if(len>0){
                         const arr2 = []
                         arr.forEach(item => {arr2.push(JSON.parse(JSON.stringify(item)))})
-                        arr2.forEach((item,index) => {
-                            item.Id = guId()
-                            item.splitScreenStatus = this.$store.state.splitScreenStatus + 1
-                            item.width = this.currentBigshow[0].Width * this.$store.state.bigScale / item.splitScreenStatus
-                            item.height = this.currentBigshow[0].Height * this.$store.state.bigScale / item.splitScreenStatus
-                            item.widthScale = item.width / (this.currentBigshow[0].Width * this.$store.state.bigScale)
-                            item.heightScale = item.height / (this.currentBigshow[0].Height * this.$store.state.bigScale)
-                        })
-                        this.$store.dispatch('updateSignalPreList', arr2)
+                        arr2.pop()
+
+                        const signalObj = arr[len-1]
+
+                        // 给新增的信号源进行赋值
+                        signalObj.Id = guId()
+                        signalObj.splitScreenStatus = this.$store.state.splitScreenStatus + 1
+                        signalObj.width = this.currentBigshow[0].Width * this.$store.state.bigScale / (this.$store.state.splitScreenStatus+1)
+                        signalObj.height = this.currentBigshow[0].Height * this.$store.state.bigScale / (this.$store.state.splitScreenStatus+1)
+                        signalObj.widthScale = signalObj.width / (this.currentBigshow[0].Width * this.$store.state.bigScale)
+                        signalObj.heightScale = signalObj.height / (this.currentBigshow[0].Height * this.$store.state.bigScale)
+                        this.$store.dispatch('updateSignalPreList', [...arr2,signalObj])
 
                         setTimeout(() => {
-                            let width = this.currentBigshow[0].Width*this.$store.state.bigScale/(this.$store.state.splitScreenStatus+1)
-                            let height = this.currentBigshow[0].Height*this.$store.state.bigScale/(this.$store.state.splitScreenStatus+1)
+                            let width = this.currentBigshow[0].Width*this.$store.state.bigScale/(signalObj.splitScreenStatus)
+                            let height = this.currentBigshow[0].Height*this.$store.state.bigScale/(signalObj.splitScreenStatus)
 
                             const res = elePosition(width,height,this.newIndex,this.screenPosition.top,this.screenPosition.left,this.$store.state.splitScreenStatus+1)
 
-                            arr2[len-1].top = res.top
-                            arr2[len-1].left = res.left
+                            signalObj.top = res.top
+                            signalObj.left = res.left
 
-                            this.$store.dispatch('updateSignalPreList', arr2)
+                            this.$store.dispatch('updateSignalPreList', [...arr2,signalObj])
                         })
                     }else {
                         this.$store.dispatch('updateSignalPreList', arr)