From 8413cf28fb74591b57924d26c6816bf80211ba29 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 3 Nov 2021 11:48:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E4=BB=AA=E8=A1=A8=E6=9D=BF=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=97=B6=EF=BC=8C=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E8=B7=B3=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/DeDrag/index.vue | 2 +- .../canvas/components/Editor/index.vue | 19 +++++++++++-------- .../src/components/canvas/store/snapshot.js | 6 +++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/DeDrag/index.vue b/frontend/src/components/DeDrag/index.vue index b5087c6f46..c0277b3f58 100644 --- a/frontend/src/components/DeDrag/index.vue +++ b/frontend/src/components/DeDrag/index.vue @@ -1603,7 +1603,7 @@ export default { style.height = height style.rotate = this.rotate // this.hasMove = true - console.log('recordMatrixCurShadowStyle:t1:' + JSON.stringify(style)) + // console.log('recordMatrixCurShadowStyle:t1:' + JSON.stringify(style)) this.$store.commit('setShapeStyle', style) diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index d5ce8a86b5..ad47254977 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -338,7 +338,7 @@ function recalcCellWidth() { } function init() { - console.log('init') + // console.log('init-cellWidth') this.cellWidth = this.baseWidth + this.baseMarginLeft this.cellHeight = this.baseHeight + this.baseMarginTop this.yourList = this.getList() @@ -993,7 +993,7 @@ export default { 'editor', 'linkageSettingStatus', 'curLinkageView', - 'snapshotIndex' + 'doSnapshotIndex' ]) }, watch: { @@ -1035,6 +1035,7 @@ export default { // 初始化时componentData 加载可能出现慢的情况 此时重新初始化一下matrix if (newVal.length !== this.lastComponentDataLength) { this.lastComponentDataLength = newVal.length + console.log('.initMatrix2') this.initMatrix() } }, @@ -1047,9 +1048,10 @@ export default { deep: true }, // 镜像索引有变化 刷新一下矩阵(撤销重做等) - snapshotIndex: { + doSnapshotIndex: { handler(newVal, oldVla) { // console.log('snapshotIndexChange:' + newVal) + // console.log('.initMatrix3') this.initMatrix() }, deep: true @@ -1061,11 +1063,11 @@ export default { this.$store.commit('getEditor') const _this = this // bus.$on('auxiliaryMatrixChange', this.initMatrix) - bus.$on('auxiliaryMatrixChange', () => { - _this.$nextTick(() => { - _this.initMatrix() - }) - }) + // bus.$on('auxiliaryMatrixChange', () => { + // _this.$nextTick(() => { + // _this.initMatrix() + // }) + // }) eventBus.$on('hideArea', () => { this.hideArea() }) @@ -1300,6 +1302,7 @@ export default { this.baseHeight = this.matrixStyle.height this.cellWidth = this.matrixStyle.width this.cellHeight = this.matrixStyle.height + // console.log('.initMatrix1') this.initMatrix() this.scaleWidth = this.outStyle.width * 100 / this.canvasStyleData.width diff --git a/frontend/src/components/canvas/store/snapshot.js b/frontend/src/components/canvas/store/snapshot.js index 1e26aded05..d9717c8c6b 100644 --- a/frontend/src/components/canvas/store/snapshot.js +++ b/frontend/src/components/canvas/store/snapshot.js @@ -8,13 +8,15 @@ export default { snapshotIndex: -1, // 快照索引 changeTimes: -1, // 修改次数 lastSaveSnapshotIndex: 0, // 最后保存是snapshotIndex的索引 - styleChangeTimes: 0 // 组件样式修改次数 + styleChangeTimes: 0, // 组件样式修改次数 + doSnapshotIndex: -1 // snapshot undo redo 时的索引记录 }, mutations: { undo(state) { store.commit('setCurComponent', { component: null, index: null }) if (state.snapshotIndex > 0) { state.snapshotIndex-- + state.doSnapshotIndex = state.snapshotIndex store.commit('setComponentData', deepCopy(state.snapshotData[state.snapshotIndex])) store.commit('setCanvasStyle', deepCopy(state.snapshotStyleData[state.snapshotIndex])) } @@ -24,6 +26,7 @@ export default { store.commit('setCurComponent', { component: null, index: null }) if (state.snapshotIndex < state.snapshotData.length - 1) { state.snapshotIndex++ + state.doSnapshotIndex = state.snapshotIndex store.commit('setComponentData', deepCopy(state.snapshotData[state.snapshotIndex])) store.commit('setCanvasStyle', deepCopy(state.snapshotStyleData[state.snapshotIndex])) } @@ -42,6 +45,7 @@ export default { } }, refreshSnapshot(state) { + console.log('refreshSnapshot') // 刷新快照 state.snapshotData = [] state.snapshotStyleData = []