Files
svgeditor2.0/src/stores/menuList/index.ts
2025-11-12 09:52:48 +08:00

95 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineStore } from 'pinia'
import type { DataStoreState } from './types'
// 图例
export const useDataStore = defineStore('data-store', {
state: (): DataStoreState => {
return {
dataTree: [],
pid: '',
id: '',
name: '',
identifying: '0',
mqttID: '',
preview: '',
keyName: '',//选中的name
wxqr: '',
loading: true,
display: false, //无锡项目进去是true其他项目是false 控制预览的时候返回按钮的展示
graphicDisplay: 'zl' //无锡项目进去是true其他项目是false 控制点击设计的时候左侧列表数据绑定图元的展示
}
},
actions: {
set(key: keyof DataStoreState, val: any) {
;(this as any)[key] = val
},
setmqttID(val: string) {
this.mqttID = val
},
//
interface(val: any) {
this.dataTree = val
},
// 追加
append(val: string) {
this.dataTree.push({
pid: this.pid,
kId: Math.random(),
name: val,
path: JSON.stringify({
canvasCfg: {
width: 1920,
height: 1080,
scale: 1,
color: '',
img: '',
guide: true,
adsorp: true,
adsorp_diff: 5,
transform_origin: {
x: 0,
y: 0
},
drag_offset: {
x: 0,
y: 0
}
},
gridCfg: {
enabled: true,
align: true,
size: 10
},
json: []
})
})
// console.log(this.dataTree, 123)
},
// 修改
modify(kId: number, val: string) {
this.dataTree.forEach((item: any) => {
if (item.kId == kId) {
}
})
},
// 放置kid
placeKid(id: String) {
this.identifying = id
this.dataTree.forEach((item: any) => {
if (item.kId == id) {
this.keyName = item.name
}
})
},
setUpPath(data: String) {
this.dataTree.forEach((item: any) => {
if (item.kId == this.identifying) {
item.path = data
}
})
}
}
})