节点初步完成
This commit is contained in:
351
app/components/flow-nodes/nodes.ts
Normal file
351
app/components/flow-nodes/nodes.ts
Normal file
@@ -0,0 +1,351 @@
|
||||
export interface FlowNode {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
taskId: string
|
||||
icon: string
|
||||
backgroundColor: string
|
||||
shape: "square" | "circle" | "rounded"
|
||||
textColor: string
|
||||
category: "控制类" | "设备类" | "媒体类" | "灯光类" | "延时类"
|
||||
config?: Record<string, any>
|
||||
}
|
||||
|
||||
export const nodeDefinitions: Record<string, FlowNode> = {
|
||||
// 控制类
|
||||
"control-poweroff": {
|
||||
id: "control-poweroff",
|
||||
name: "一键关机",
|
||||
type: "control",
|
||||
taskId: "power_off_all",
|
||||
icon: "power",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "控制类"
|
||||
},
|
||||
"control-poweron": {
|
||||
id: "control-poweron",
|
||||
name: "一键开机",
|
||||
type: "control",
|
||||
taskId: "power_on_all",
|
||||
icon: "power",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "控制类"
|
||||
},
|
||||
|
||||
// 设备类
|
||||
"device-poweroff-host1": {
|
||||
id: "device-poweroff-host1",
|
||||
name: "关 [!] 主机1",
|
||||
type: "device",
|
||||
taskId: "power_off_host1",
|
||||
icon: "computer",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweron-host1": {
|
||||
id: "device-poweron-host1",
|
||||
name: "开 [!] 主机1",
|
||||
type: "device",
|
||||
taskId: "power_on_host1",
|
||||
icon: "computer",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweroff-host2": {
|
||||
id: "device-poweroff-host2",
|
||||
name: "关 [!] 主机2",
|
||||
type: "device",
|
||||
taskId: "power_off_host2",
|
||||
icon: "computer",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweron-host2": {
|
||||
id: "device-poweron-host2",
|
||||
name: "开 [!] 主机2",
|
||||
type: "device",
|
||||
taskId: "power_on_host2",
|
||||
icon: "computer",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweron-projector1": {
|
||||
id: "device-poweron-projector1",
|
||||
name: "开 [!] 投影1",
|
||||
type: "device",
|
||||
taskId: "power_on_projector1",
|
||||
icon: "monitor",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweroff-projector1": {
|
||||
id: "device-poweroff-projector1",
|
||||
name: "关 [!] 投影1",
|
||||
type: "device",
|
||||
taskId: "power_off_projector1",
|
||||
icon: "monitor",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweron-projector2": {
|
||||
id: "device-poweron-projector2",
|
||||
name: "开 [!] 投影2",
|
||||
type: "device",
|
||||
taskId: "power_on_projector2",
|
||||
icon: "monitor",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweroff-projector2": {
|
||||
id: "device-poweroff-projector2",
|
||||
name: "关 [!] 投影2",
|
||||
type: "device",
|
||||
taskId: "power_off_projector2",
|
||||
icon: "monitor",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweron-projector3": {
|
||||
id: "device-poweron-projector3",
|
||||
name: "开 [!] 投影3",
|
||||
type: "device",
|
||||
taskId: "power_on_projector3",
|
||||
icon: "monitor",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
"device-poweroff-projector3": {
|
||||
id: "device-poweroff-projector3",
|
||||
name: "关 [!] 投影3",
|
||||
type: "device",
|
||||
taskId: "power_off_projector3",
|
||||
icon: "monitor",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "square",
|
||||
textColor: "#ffffff",
|
||||
category: "设备类"
|
||||
},
|
||||
|
||||
// 媒体类
|
||||
"media-button3": {
|
||||
id: "media-button3",
|
||||
name: "BUTTON3",
|
||||
type: "media",
|
||||
taskId: "media_button3",
|
||||
icon: "square",
|
||||
backgroundColor: "#3b82f6",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-play": {
|
||||
id: "media-play",
|
||||
name: "播放",
|
||||
type: "media",
|
||||
taskId: "media_play",
|
||||
icon: "play",
|
||||
backgroundColor: "#22c55e",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-pause": {
|
||||
id: "media-pause",
|
||||
name: "暂停",
|
||||
type: "media",
|
||||
taskId: "media_pause",
|
||||
icon: "pause",
|
||||
backgroundColor: "#f97316",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-stop": {
|
||||
id: "media-stop",
|
||||
name: "停止",
|
||||
type: "media",
|
||||
taskId: "media_stop",
|
||||
icon: "square",
|
||||
backgroundColor: "#ef4444",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-prev": {
|
||||
id: "media-prev",
|
||||
name: "上一曲",
|
||||
type: "media",
|
||||
taskId: "media_prev",
|
||||
icon: "skip-back",
|
||||
backgroundColor: "#8b5cf6",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-next": {
|
||||
id: "media-next",
|
||||
name: "下一曲",
|
||||
type: "media",
|
||||
taskId: "media_next",
|
||||
icon: "skip-forward",
|
||||
backgroundColor: "#8b5cf6",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-volume-down": {
|
||||
id: "media-volume-down",
|
||||
name: "音量减",
|
||||
type: "media",
|
||||
taskId: "media_volume_down",
|
||||
icon: "volume-2",
|
||||
backgroundColor: "#06b6d4",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-volume-up": {
|
||||
id: "media-volume-up",
|
||||
name: "音量加",
|
||||
type: "media",
|
||||
taskId: "media_volume_up",
|
||||
icon: "volume-2",
|
||||
backgroundColor: "#06b6d4",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-mute": {
|
||||
id: "media-mute",
|
||||
name: "静音",
|
||||
type: "media",
|
||||
taskId: "media_mute",
|
||||
icon: "volume-x",
|
||||
backgroundColor: "#f97316",
|
||||
shape: "circle",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-video1": {
|
||||
id: "media-video1",
|
||||
name: "视频一",
|
||||
type: "media",
|
||||
taskId: "media_video1",
|
||||
icon: "play-square",
|
||||
backgroundColor: "#6366f1",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-video2": {
|
||||
id: "media-video2",
|
||||
name: "视频二",
|
||||
type: "media",
|
||||
taskId: "media_video2",
|
||||
icon: "play-square",
|
||||
backgroundColor: "#6366f1",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-video3": {
|
||||
id: "media-video3",
|
||||
name: "视频三",
|
||||
type: "media",
|
||||
taskId: "media_video3",
|
||||
icon: "play-square",
|
||||
backgroundColor: "#6366f1",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
"media-button1": {
|
||||
id: "media-button1",
|
||||
name: "BUTTON1",
|
||||
type: "media",
|
||||
taskId: "media_button1",
|
||||
icon: "square",
|
||||
backgroundColor: "#3b82f6",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "媒体类"
|
||||
},
|
||||
|
||||
// 延时类
|
||||
"delay-2s": {
|
||||
id: "delay-2s",
|
||||
name: "延时2秒",
|
||||
type: "delay",
|
||||
taskId: "delay_2s",
|
||||
icon: "clock",
|
||||
backgroundColor: "#f59e0b",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "延时类",
|
||||
config: { duration: 2000 }
|
||||
},
|
||||
"delay-5s": {
|
||||
id: "delay-5s",
|
||||
name: "延时5秒",
|
||||
type: "delay",
|
||||
taskId: "delay_5s",
|
||||
icon: "clock",
|
||||
backgroundColor: "#f59e0b",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "延时类",
|
||||
config: { duration: 5000 }
|
||||
},
|
||||
"delay-custom": {
|
||||
id: "delay-custom",
|
||||
name: "自定义延时时间",
|
||||
type: "delay",
|
||||
taskId: "delay_custom",
|
||||
icon: "clock",
|
||||
backgroundColor: "#f59e0b",
|
||||
shape: "rounded",
|
||||
textColor: "#ffffff",
|
||||
category: "延时类",
|
||||
config: { duration: 1000, editable: true }
|
||||
}
|
||||
};
|
||||
|
||||
export const getNodesByCategory = () => {
|
||||
const categories = {
|
||||
控制类: [] as FlowNode[],
|
||||
设备类: [] as FlowNode[],
|
||||
媒体类: [] as FlowNode[],
|
||||
灯光类: [] as FlowNode[],
|
||||
延时类: [] as FlowNode[]
|
||||
};
|
||||
|
||||
Object.values(nodeDefinitions).forEach((node) => {
|
||||
if (categories[node.category]) {
|
||||
categories[node.category].push(node);
|
||||
}
|
||||
});
|
||||
|
||||
return categories;
|
||||
};
|
Reference in New Issue
Block a user