fix
This commit is contained in:
@@ -270,7 +270,7 @@ export class CanvasManager {
|
|||||||
return JSON.stringify(json)
|
return JSON.stringify(json)
|
||||||
}
|
}
|
||||||
/** 加载画布JSON */
|
/** 加载画布JSON */
|
||||||
loadJSON(json: string) {
|
loadJSON(json: string, rerecord = true) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let jsonObj = null;
|
let jsonObj = null;
|
||||||
try {
|
try {
|
||||||
@@ -280,9 +280,11 @@ export class CanvasManager {
|
|||||||
}
|
}
|
||||||
if (!jsonObj) return resolve(false)
|
if (!jsonObj) return resolve(false)
|
||||||
this.canvas.loadFromJSON(jsonObj, () => {
|
this.canvas.loadFromJSON(jsonObj, () => {
|
||||||
|
if (rerecord) this.stateManager.clearState()
|
||||||
this.resetZoom(false)
|
this.resetZoom(false)
|
||||||
this.layerManager.updateLayers()
|
this.layerManager.updateLayers()
|
||||||
this.renderAll()
|
this.renderAll()
|
||||||
|
if (rerecord) this.stateManager.recordState()
|
||||||
|
|
||||||
resolve(true)
|
resolve(true)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export class StateManager {
|
|||||||
if (!state) return
|
if (!state) return
|
||||||
this.running.value = true
|
this.running.value = true
|
||||||
this.historyIndex.value = index
|
this.historyIndex.value = index
|
||||||
this.canvasManager.loadJSON(state.canvas).then(() => {
|
this.canvasManager.loadJSON(state.canvas, false).then(() => {
|
||||||
this.event.emit('canvas:undo', state)
|
this.event.emit('canvas:undo', state)
|
||||||
this.running.value = false
|
this.running.value = false
|
||||||
})
|
})
|
||||||
@@ -105,7 +105,7 @@ export class StateManager {
|
|||||||
if (!state) return
|
if (!state) return
|
||||||
this.running.value = true
|
this.running.value = true
|
||||||
this.historyIndex.value = index
|
this.historyIndex.value = index
|
||||||
this.canvasManager.loadJSON(state.canvas).then(() => {
|
this.canvasManager.loadJSON(state.canvas, false).then(() => {
|
||||||
this.event.emit('canvas:redo', state)
|
this.event.emit('canvas:redo', state)
|
||||||
this.running.value = false
|
this.running.value = false
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user