Files
FiDA_Front/src/components/Canvas/DepthCanvas/manager/StateManager.ts

71 lines
1.9 KiB
TypeScript
Raw Normal View History

2026-03-06 15:50:05 +08:00
import { ref, computed } from "vue";
import { NODE_TYPE } from '../tools/index.d'
import { ElMessageBox } from 'element-plus'
import i18n from '@/lang'
const t = i18n.global.t
2026-03-09 13:44:32 +08:00
export class StateManager {
2026-03-06 15:50:05 +08:00
// 历史记录-撤回/重做
mxHistory: any
historyList: any
historyIndex: any
// 管理器
2026-03-09 13:44:32 +08:00
canvasManager: any
2026-03-09 16:45:30 +08:00
layerManager: any
eventManager: any
2026-03-06 15:50:05 +08:00
toolManager: any
// 设置管理器
setManager(options) {
options.eventManager && (this.eventManager = options.eventManager)
2026-03-09 13:44:32 +08:00
options.canvasManager && (this.canvasManager = options.canvasManager)
2026-03-09 16:45:30 +08:00
options.layerManager && (this.layerManager = options.layerManager)
2026-03-06 15:50:05 +08:00
options.toolManager && (this.toolManager = options.toolManager)
}
constructor(options) {
this.mxHistory = ref(50)
this.historyList = ref([])
this.historyIndex = ref(0)
this.activeNodeID = ref("")
}
/** 设置激活节点 */
setActiveNodeID(id: string) { this.activeNodeID.value = id }
2026-03-09 13:44:32 +08:00
2026-03-06 15:50:05 +08:00
/** 记录状态 */
recordState() {
2026-03-09 13:44:32 +08:00
// if (this.historyIndex.value < this.historyList.value.length - 1) {
// this.historyList.value.splice(this.historyIndex.value + 1)
// }
// const state = {
// nodes: JSON.stringify(this.nodes.value)
// }
// this.historyList.value.push(state)
// const size = this.historyList.value.length - this.mxHistory.value
// if (size > 0) this.historyList.value.splice(0, size)
// this.historyIndex.value = this.historyList.value.length - 1
2026-03-06 15:50:05 +08:00
}
/** 撤回状态 */
undoState() {
2026-03-09 13:44:32 +08:00
// var index = this.historyIndex.value - 1
// const state = this.historyList.value[index]
// if (!state) return
// this.historyIndex.value = index
// this.nodes.value = JSON.parse(state.nodes)
2026-03-06 15:50:05 +08:00
}
/** 重做状态 */
redoState() {
2026-03-09 13:44:32 +08:00
// var index = this.historyIndex.value + 1
// const state = this.historyList.value[index]
// if (!state) return
// this.historyIndex.value = index
// this.nodes.value = JSON.parse(state.nodes)
2026-03-06 15:50:05 +08:00
}
}