This commit is contained in:
X1627315083@163.com
2026-03-05 10:27:41 +08:00
parent a9b07b24ca
commit 5ec768f4ed
4 changed files with 40 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ export interface NodesItem {
type: string
class: string
position: { x: number, y: number }
data: { component: any, type: string, superiorID?: string }
data: { component: any, type: string, superiorID?: string, scale: { x: number, y: number } }
}
export class StateManager {
vueFlow: any
@@ -127,12 +127,27 @@ export class StateManager {
setNodesDraggable(v: boolean) { this.nodesDraggable.value = v }
/** 设置是否可以平移画布 */
setPanOnDrag(v: boolean) { this.panOnDrag.value = v }
/** 获取节点最大zIndex值 */
getMaxZIndex() {
return this.nodes.value.reduce((max, node) => Math.max(max, node.zIndex), 0)
/** 设置节点层级至最顶部 */
bringToFont(id) {
const fromIndex = this.nodes.value.findIndex(item => item.id === id)
if (fromIndex === -1) return console.warn(`没有找到指定id:${id}`)
this.nodes.value.splice(this.nodes.value.length - 1, 0, ...this.nodes.value.splice(fromIndex, 1))
}
/** 获取节点最小zIndex值 */
getMinZIndex() {
return this.nodes.value.reduce((min, node) => Math.min(min, node.zIndex), 0)
/** 设置节点层级至最低部 */
sendToBack(id) {
const fromIndex = this.nodes.value.findIndex(item => item.id === id)
if (fromIndex === -1) return console.warn(`没有找到指定id:${id}`)
this.nodes.value.splice(0, 0, ...this.nodes.value.splice(fromIndex, 1))
}
/** 设置水平或者垂直翻转 */
setNodeFlip(id,direction) {
const node = this.getNodeById(id)
if (!node) return console.warn(`没有找到指定id:${id}`)
if (direction === 'X') {
node.data.scale.x = -node.data.scale.x
} else if (direction === 'Y') {
node.data.scale.y = -node.data.scale.y
}
console.log(node,direction)
}
}