diff --git a/frontend/src/components/canvas/components/RectangleAttr.vue b/frontend/src/components/canvas/components/RectangleAttr.vue index 060bdd7085..d7d15b6952 100644 --- a/frontend/src/components/canvas/components/RectangleAttr.vue +++ b/frontend/src/components/canvas/components/RectangleAttr.vue @@ -3,7 +3,7 @@
- + - +
- +
@@ -48,7 +48,7 @@
- +
@@ -158,6 +158,9 @@ export default { } else { return y } + }, + styleChange() { + this.$store.state.styleChangeTimes++ } } } diff --git a/frontend/src/components/canvas/store/snapshot.js b/frontend/src/components/canvas/store/snapshot.js index ba061b0045..4fb86cf075 100644 --- a/frontend/src/components/canvas/store/snapshot.js +++ b/frontend/src/components/canvas/store/snapshot.js @@ -7,7 +7,8 @@ export default { snapshotStyleData: [], // 样式改变也记录快照 snapshotIndex: -1, // 快照索引 changeTimes: -1, // 修改次数 - lastSaveSnapshotIndex: 0 // 最后保存是snapshotIndex的索引 + lastSaveSnapshotIndex: 0, // 最后保存是snapshotIndex的索引 + styleChangeTimes: 0 // 组件样式修改次数 }, mutations: { undo(state) { diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 214a689e4b..37f0ba8fe9 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -72,6 +72,7 @@ const data = { }, setCurComponent(state, { component, index }) { + state.styleChangeTimes = 0 state.curComponent = component state.curComponentIndex = index }, diff --git a/frontend/src/views/Tinymce/FilterTextAttr.vue b/frontend/src/views/Tinymce/FilterTextAttr.vue index fa0fcdb5ef..2b007edd48 100644 --- a/frontend/src/views/Tinymce/FilterTextAttr.vue +++ b/frontend/src/views/Tinymce/FilterTextAttr.vue @@ -7,7 +7,7 @@
- +
@@ -15,7 +15,7 @@
- +
@@ -23,7 +23,7 @@
- +
@@ -32,7 +32,7 @@
- +
@@ -42,7 +42,7 @@
- +
@@ -136,6 +136,10 @@ export default { } else { return y } + }, + styleChange() { + debugger + this.$store.state.styleChangeTimes++ } } } diff --git a/frontend/src/views/Tinymce/RectangleAttr.vue b/frontend/src/views/Tinymce/RectangleAttr.vue deleted file mode 100644 index 060bdd7085..0000000000 --- a/frontend/src/views/Tinymce/RectangleAttr.vue +++ /dev/null @@ -1,184 +0,0 @@ - - - - - diff --git a/frontend/src/views/Tinymce/TextAttr.vue b/frontend/src/views/Tinymce/TextAttr.vue index 02dbbc2c7e..1630a4989e 100644 --- a/frontend/src/views/Tinymce/TextAttr.vue +++ b/frontend/src/views/Tinymce/TextAttr.vue @@ -2,7 +2,7 @@
- +
- +
@@ -30,7 +30,7 @@
- +
@@ -38,7 +38,7 @@
- +
@@ -47,7 +47,7 @@
- +
@@ -57,7 +57,7 @@
- +
@@ -151,6 +151,9 @@ export default { } else { return y } + }, + styleChange() { + this.$store.state.styleChangeTimes++ } } } diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue index 91335813bc..92de4066d4 100644 --- a/frontend/src/views/panel/edit/index.vue +++ b/frontend/src/views/panel/edit/index.vue @@ -274,7 +274,8 @@ export default { currentDropElement: null, adviceGroupId: null, scrollLeft: 0, - scrollTop: 0 + scrollTop: 0, + timeMachine: null } }, @@ -305,6 +306,12 @@ export default { }, panelInfo(newVal, oldVal) { this.init(newVal.id) + }, + '$store.state.styleChangeTimes'() { + if (this.$store.state.styleChangeTimes > 0) { + this.destroyTimeMachine() + this.recordStyleChange(this.$store.state.styleChangeTimes) + } } }, created() { @@ -674,6 +681,21 @@ export default { debugger this.scrollLeft = event.target.scrollLeft this.scrollTop = event.target.scrollTop + }, + destroyTimeMachine() { + this.timeMachine && clearTimeout(this.timeMachine) + this.timeMachine = null + }, + + // 如果内部样式有变化 1秒钟后保存一个镜像 + recordStyleChange(index) { + this.timeMachine = setTimeout(() => { + if (index === this.$store.state.styleChangeTimes) { + this.$store.commit('recordSnapshot') + this.$store.state.styleChangeTimes = 0 + } + this.destroyTimeMachine() + }, 1000) } } }