|
@@ -1,12 +1,12 @@
|
|
|
-import {deepCopy} from '@/utils/html-util'
|
|
|
+import system from '@/utils/system'
|
|
|
import toast from '@/utils/toast'
|
|
|
|
|
|
const MAX_SNAP_SHOT_LENGTH = 3
|
|
|
|
|
|
// 设置画布默认数据 https://github.com/woai3c/visual-drag-demo/issues/92
|
|
|
-let defaultComponentData = []
|
|
|
+let defaultComponentData: any[] = []
|
|
|
|
|
|
-function getDefaultComponentData() {
|
|
|
+function getDefaultComponentData() : any[] {
|
|
|
return defaultComponentData
|
|
|
}
|
|
|
|
|
@@ -23,8 +23,7 @@ export default {
|
|
|
undo(state) {
|
|
|
if (state.snapshotIndex >= 1) {
|
|
|
state.snapshotIndex--
|
|
|
- const componentData =
|
|
|
- deepCopy(state.snapshotData[state.snapshotIndex]) || getDefaultComponentData()
|
|
|
+ const componentData = system.deepCopy(state.snapshotData[state.snapshotIndex]) || getDefaultComponentData()
|
|
|
if (state.curComponent) {
|
|
|
// 如果当前组件不在 componentData 中,则置空
|
|
|
const needClean = !componentData.find(
|
|
@@ -49,7 +48,7 @@ export default {
|
|
|
state.snapshotIndex++
|
|
|
store.commit(
|
|
|
'printTemplateModule/setComponentData',
|
|
|
- deepCopy(state.snapshotData[state.snapshotIndex])
|
|
|
+ system.deepCopy(state.snapshotData[state.snapshotIndex])
|
|
|
)
|
|
|
} else {
|
|
|
toast('不能再恢复了')
|
|
@@ -58,8 +57,7 @@ export default {
|
|
|
|
|
|
recordSnapshot() {
|
|
|
// 添加新的快照
|
|
|
- // console.log("snapshotData >>> ", this.snapshotData)
|
|
|
- this.snapshotData[++this.snapshotIndex] = deepCopy(this.componentData)
|
|
|
+ this.snapshotData[++this.snapshotIndex] = system.deepCopy(this.componentData)
|
|
|
// 在 undo 过程中,添加新的快照时,要将它后面的快照清理掉
|
|
|
if (this.snapshotIndex < this.snapshotData.length - 1) {
|
|
|
this.snapshotData = this.snapshotData.slice(0, this.snapshotIndex + 1)
|