feat: remove WorkflowSimpleNodeContent and update WorkflowNodeCard for optional children rendering
This commit is contained in:
@@ -3,7 +3,6 @@ import { Field, type WorkflowNodeRegistry, useNodeRender } from "@flowgram.ai/fr
|
||||
import type { AIWorkflowNodeSpec } from "@/lib/api/admin"
|
||||
import { WorkflowConditionNodeContent } from "./workflow-condition-node-content"
|
||||
import { WorkflowNodeCard } from "./workflow-node-card"
|
||||
import { WorkflowSimpleNodeContent } from "./workflow-simple-node-content"
|
||||
|
||||
export function buildFlowgramNodeRegistries(nodeSpecs: AIWorkflowNodeSpec[]): WorkflowNodeRegistry[] {
|
||||
const seen = new Set<string>()
|
||||
@@ -89,9 +88,7 @@ function FlowgramNodeForm({
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
) : (
|
||||
<WorkflowSimpleNodeContent spec={spec} />
|
||||
)}
|
||||
) : null}
|
||||
</WorkflowNodeCard>
|
||||
)}
|
||||
</Field>
|
||||
|
||||
@@ -18,7 +18,7 @@ export function WorkflowNodeCard({
|
||||
spec?: AIWorkflowNodeSpec
|
||||
selected: boolean
|
||||
width?: "normal" | "wide"
|
||||
children: ReactNode
|
||||
children?: ReactNode
|
||||
}) {
|
||||
const meta = getWorkflowNodeMeta(nodeType)
|
||||
|
||||
@@ -46,7 +46,7 @@ export function WorkflowNodeCard({
|
||||
{spec.description}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="border-t bg-muted/20 px-3 py-2.5">{children}</div>
|
||||
{children ? <div className="border-t bg-muted/20 px-3 py-2.5">{children}</div> : null}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
import type { AIWorkflowNodeSpec } from "@/lib/api/admin"
|
||||
|
||||
export function WorkflowSimpleNodeContent({
|
||||
spec,
|
||||
}: {
|
||||
spec?: AIWorkflowNodeSpec
|
||||
}) {
|
||||
const inputCount = spec?.inputSchema?.length ?? 0
|
||||
const outputCount = spec?.outputSchema?.length ?? 0
|
||||
const hasSchema = inputCount > 0 || outputCount > 0
|
||||
|
||||
if (!hasSchema && !spec?.riskLevel && !spec?.interruptible) {
|
||||
return (
|
||||
<div className="text-xs leading-5 text-muted-foreground">
|
||||
通过右侧面板配置节点参数
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap items-center gap-1.5">
|
||||
{inputCount > 0 ? <NodeInfoChip label={`入参 ${inputCount}`} /> : null}
|
||||
{outputCount > 0 ? <NodeInfoChip label={`出参 ${outputCount}`} /> : null}
|
||||
{spec?.riskLevel ? <NodeInfoChip label={riskLevelLabel(spec.riskLevel)} /> : null}
|
||||
{spec?.interruptible ? <NodeInfoChip label="可中断" /> : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function NodeInfoChip({ label }: { label: string }) {
|
||||
return (
|
||||
<span className="inline-flex h-5 items-center rounded-md border bg-background px-1.5 text-[11px] leading-none text-muted-foreground">
|
||||
{label}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function riskLevelLabel(riskLevel: AIWorkflowNodeSpec["riskLevel"]) {
|
||||
if (riskLevel === "high") return "高风险"
|
||||
if (riskLevel === "medium") return "中风险"
|
||||
return "低风险"
|
||||
}
|
||||
Reference in New Issue
Block a user