| 12345678910111213141516171819202122232425262728 |
- from __future__ import annotations
- import time
- from typing import Any
- from ..context import WorkflowContext
- from ..registry import control_ports, field_def, register_node
- def seconds_node(node: dict[str, Any], inputs: dict[str, Any], context: WorkflowContext) -> dict[str, Any]:
- seconds = float(inputs.get("seconds", node.get("params", {}).get("seconds", 1)))
- seconds = max(0, min(seconds, 3600))
- time.sleep(seconds)
- return {"seconds": seconds}
- register_node(
- {
- "type": "wait.seconds",
- "category": "wait",
- "label": "等待秒数",
- "params": {"seconds": field_def("number", "秒数", 1, minimum=0, maximum=3600)},
- "inputs": {"seconds": field_def("number", "秒数")},
- "outputs": {"seconds": {"type": "number", "label": "实际等待秒数"}},
- "control_ports": control_ports(),
- },
- seconds_node,
- )
|