提交 8413cf28 authored 作者: wangjiahao's avatar wangjiahao

refactor:仪表板编辑时,可能出现的跳动问题

上级 5145b193
...@@ -1603,7 +1603,7 @@ export default { ...@@ -1603,7 +1603,7 @@ export default {
style.height = height style.height = height
style.rotate = this.rotate style.rotate = this.rotate
// this.hasMove = true // this.hasMove = true
console.log('recordMatrixCurShadowStyle:t1:' + JSON.stringify(style)) // console.log('recordMatrixCurShadowStyle:t1:' + JSON.stringify(style))
this.$store.commit('setShapeStyle', style) this.$store.commit('setShapeStyle', style)
......
...@@ -338,7 +338,7 @@ function recalcCellWidth() { ...@@ -338,7 +338,7 @@ function recalcCellWidth() {
} }
function init() { function init() {
console.log('init') // console.log('init-cellWidth')
this.cellWidth = this.baseWidth + this.baseMarginLeft this.cellWidth = this.baseWidth + this.baseMarginLeft
this.cellHeight = this.baseHeight + this.baseMarginTop this.cellHeight = this.baseHeight + this.baseMarginTop
this.yourList = this.getList() this.yourList = this.getList()
...@@ -993,7 +993,7 @@ export default { ...@@ -993,7 +993,7 @@ export default {
'editor', 'editor',
'linkageSettingStatus', 'linkageSettingStatus',
'curLinkageView', 'curLinkageView',
'snapshotIndex' 'doSnapshotIndex'
]) ])
}, },
watch: { watch: {
...@@ -1035,6 +1035,7 @@ export default { ...@@ -1035,6 +1035,7 @@ export default {
// 初始化时componentData 加载可能出现慢的情况 此时重新初始化一下matrix // 初始化时componentData 加载可能出现慢的情况 此时重新初始化一下matrix
if (newVal.length !== this.lastComponentDataLength) { if (newVal.length !== this.lastComponentDataLength) {
this.lastComponentDataLength = newVal.length this.lastComponentDataLength = newVal.length
console.log('.initMatrix2')
this.initMatrix() this.initMatrix()
} }
}, },
...@@ -1047,9 +1048,10 @@ export default { ...@@ -1047,9 +1048,10 @@ export default {
deep: true deep: true
}, },
// 镜像索引有变化 刷新一下矩阵(撤销重做等) // 镜像索引有变化 刷新一下矩阵(撤销重做等)
snapshotIndex: { doSnapshotIndex: {
handler(newVal, oldVla) { handler(newVal, oldVla) {
// console.log('snapshotIndexChange:' + newVal) // console.log('snapshotIndexChange:' + newVal)
// console.log('.initMatrix3')
this.initMatrix() this.initMatrix()
}, },
deep: true deep: true
...@@ -1061,11 +1063,11 @@ export default { ...@@ -1061,11 +1063,11 @@ export default {
this.$store.commit('getEditor') this.$store.commit('getEditor')
const _this = this const _this = this
// bus.$on('auxiliaryMatrixChange', this.initMatrix) // bus.$on('auxiliaryMatrixChange', this.initMatrix)
bus.$on('auxiliaryMatrixChange', () => { // bus.$on('auxiliaryMatrixChange', () => {
_this.$nextTick(() => { // _this.$nextTick(() => {
_this.initMatrix() // _this.initMatrix()
}) // })
}) // })
eventBus.$on('hideArea', () => { eventBus.$on('hideArea', () => {
this.hideArea() this.hideArea()
}) })
...@@ -1300,6 +1302,7 @@ export default { ...@@ -1300,6 +1302,7 @@ export default {
this.baseHeight = this.matrixStyle.height this.baseHeight = this.matrixStyle.height
this.cellWidth = this.matrixStyle.width this.cellWidth = this.matrixStyle.width
this.cellHeight = this.matrixStyle.height this.cellHeight = this.matrixStyle.height
// console.log('.initMatrix1')
this.initMatrix() this.initMatrix()
this.scaleWidth = this.outStyle.width * 100 / this.canvasStyleData.width this.scaleWidth = this.outStyle.width * 100 / this.canvasStyleData.width
......
...@@ -8,13 +8,15 @@ export default { ...@@ -8,13 +8,15 @@ export default {
snapshotIndex: -1, // 快照索引 snapshotIndex: -1, // 快照索引
changeTimes: -1, // 修改次数 changeTimes: -1, // 修改次数
lastSaveSnapshotIndex: 0, // 最后保存是snapshotIndex的索引 lastSaveSnapshotIndex: 0, // 最后保存是snapshotIndex的索引
styleChangeTimes: 0 // 组件样式修改次数 styleChangeTimes: 0, // 组件样式修改次数
doSnapshotIndex: -1 // snapshot undo redo 时的索引记录
}, },
mutations: { mutations: {
undo(state) { undo(state) {
store.commit('setCurComponent', { component: null, index: null }) store.commit('setCurComponent', { component: null, index: null })
if (state.snapshotIndex > 0) { if (state.snapshotIndex > 0) {
state.snapshotIndex-- state.snapshotIndex--
state.doSnapshotIndex = state.snapshotIndex
store.commit('setComponentData', deepCopy(state.snapshotData[state.snapshotIndex])) store.commit('setComponentData', deepCopy(state.snapshotData[state.snapshotIndex]))
store.commit('setCanvasStyle', deepCopy(state.snapshotStyleData[state.snapshotIndex])) store.commit('setCanvasStyle', deepCopy(state.snapshotStyleData[state.snapshotIndex]))
} }
...@@ -24,6 +26,7 @@ export default { ...@@ -24,6 +26,7 @@ export default {
store.commit('setCurComponent', { component: null, index: null }) store.commit('setCurComponent', { component: null, index: null })
if (state.snapshotIndex < state.snapshotData.length - 1) { if (state.snapshotIndex < state.snapshotData.length - 1) {
state.snapshotIndex++ state.snapshotIndex++
state.doSnapshotIndex = state.snapshotIndex
store.commit('setComponentData', deepCopy(state.snapshotData[state.snapshotIndex])) store.commit('setComponentData', deepCopy(state.snapshotData[state.snapshotIndex]))
store.commit('setCanvasStyle', deepCopy(state.snapshotStyleData[state.snapshotIndex])) store.commit('setCanvasStyle', deepCopy(state.snapshotStyleData[state.snapshotIndex]))
} }
...@@ -42,6 +45,7 @@ export default { ...@@ -42,6 +45,7 @@ export default {
} }
}, },
refreshSnapshot(state) { refreshSnapshot(state) {
console.log('refreshSnapshot')
// 刷新快照 // 刷新快照
state.snapshotData = [] state.snapshotData = []
state.snapshotStyleData = [] state.snapshotStyleData = []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论