深度画布-平铺设置

This commit is contained in:
lzp
2026-03-16 16:51:12 +08:00
parent 1667d8d3a9
commit dc5d932b11
15 changed files with 539 additions and 59 deletions

View File

@@ -3,6 +3,23 @@ import { ElMessageBox } from 'element-plus'
import i18n from '@/lang'
const t = i18n.global.t
class Event {
list: any[]
constructor() {
this.list = []
}
add(name, call) {
this.list.push({ name, call })
}
remove(name, call) {
this.list = this.list.filter(item => item.name != name && item.call != call)
}
emit(name, data) {
this.list.forEach(item => {
if (item.name == name) item.call(data)
})
}
}
export class StateManager {
// 历史记录-撤回/重做
@@ -11,6 +28,8 @@ export class StateManager {
historyIndex: any
running: any
event: Event
// 管理器
canvasManager: any
layerManager: any
@@ -18,6 +37,7 @@ export class StateManager {
toolManager: any
brushManager: any
keyEventManager: any
objectManager: any
// 设置管理器
setManager(options) {
options.eventManager && (this.eventManager = options.eventManager)
@@ -26,16 +46,16 @@ export class StateManager {
options.toolManager && (this.toolManager = options.toolManager)
options.brushManager && (this.brushManager = options.brushManager)
options.keyEventManager && (this.keyEventManager = options.keyEventManager)
options.objectManager && (this.objectManager = options.objectManager)
}
constructor(options) {
this.mxHistory = ref(50)
this.historyList = ref([])
this.historyIndex = ref(0)
this.running = ref(false)
this.event = new Event()
}
onMounted() { }
/** 设置是否开始记录状态 */
setIsRecord(isRecord: boolean) {
@@ -73,6 +93,7 @@ export class StateManager {
this.running.value = true
this.historyIndex.value = index
this.canvasManager.loadJSON(state.canvas, () => {
this.event.emit('canvas:undo', state)
this.running.value = false
})
}
@@ -85,6 +106,7 @@ export class StateManager {
this.running.value = true
this.historyIndex.value = index
this.canvasManager.loadJSON(state.canvas, () => {
this.event.emit('canvas:redo', state)
this.running.value = false
})
}