This commit is contained in:
X1627315083@163.com
2026-03-12 17:07:04 +08:00
parent deff3410bf
commit 01a843e71f
14 changed files with 328 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
import { ref, computed } from "vue";
import { NODE_TYPE } from '../tools/index.d'
import { NODE_TYPE, NODE_DATATYPE } from '../tools/index.d'
import { ElMessageBox } from 'element-plus'
import i18n from '@/lang'
const t = i18n.global.t
@@ -35,12 +35,14 @@ export class StateManager {
flowManager: any
nodeManager: any
toolManager: any
generateManager: any
// 设置管理器
setManager(options) {
options.eventManager && (this.eventManager = options.eventManager)
options.flowManager && (this.flowManager = options.flowManager)
options.nodeManager && (this.nodeManager = options.nodeManager)
options.toolManager && (this.toolManager = options.toolManager)
options.generateManager && (this.generateManager = options.generateManager)
}
constructor(options) {
this.vueFlow = options.vueFlow
@@ -87,12 +89,14 @@ export class StateManager {
source: source,
target: target,
selectable: false,
visible: (node.data.type !== NODE_DATATYPE.RESULT_IMAGE || node.data.isActive),
type: 'default'
})
}
})
return arr
})
window.nodes = this.nodes
}
/** 设置激活节点 */
@@ -132,7 +136,7 @@ export class StateManager {
getNodeById(id: string) { return this.nodes.value.find((node: NodesItem) => node.id === id) }
/** 获取下级节点 */
getSubordNodeByID(id: string) { return this.nodes.value.find((node: NodesItem) => node.data.superiorID === id) }
getLastNode() { return this.nodes.value[this.nodes.value.length - 1] }
getLastNode() { console.log(this.nodes.value); return this.nodes.value[this.nodes.value.length - 1] }
/** 设置工具 */
setTool(tool: string) { this.tool.value = tool }
/** 设置光标 */
@@ -183,6 +187,20 @@ export class StateManager {
this.nodes.value = JSON.parse(state.nodes)
}
/** 显示指定子节点和父节点连接线,隐藏父节点和其他子节点链接线, */
showNodeConnections(id: string) {
const node = this.getNodeById(id)
if(node.data.component != NODE_DATATYPE.RESULT_IMAGE && node.data.superiorID) return
let edges_ = JSON.parse(JSON.stringify(this.edges.value))
this.nodes.value.forEach((nodeItem) => {
if(node.data.superiorID === nodeItem.data.superiorID && nodeItem.id == id) {
nodeItem.data.isActive = true
}else if(node.data.superiorID == nodeItem.data.superiorID){
nodeItem.data.isActive = false
}
})
}
dispose() {
this.historyList.value = []
this.historyIndex.value = 0