diff --git a/frontend/app/(main)/waf/rules/editor/components/rule-flow-canvas.tsx b/frontend/app/(main)/waf/rules/editor/components/rule-flow-canvas.tsx index fd2e0fd9..07ba89b9 100644 --- a/frontend/app/(main)/waf/rules/editor/components/rule-flow-canvas.tsx +++ b/frontend/app/(main)/waf/rules/editor/components/rule-flow-canvas.tsx @@ -25,10 +25,9 @@ import { type NodeChange, type ReactFlowInstance, } from '@xyflow/react'; -import { AlignHorizontalSpaceAround, Trash2 } from 'lucide-react'; +import { Trash2 } from 'lucide-react'; import '@xyflow/react/dist/style.css'; -import { Button } from '@/components/ui/button'; import type { WAFRuleEdge, WAFRuleGraph } from '@/lib/services/openflare'; import { cn } from '@/lib/utils'; @@ -39,7 +38,6 @@ import { isConnectionAllowed, isPersistentEdgeChange, } from './editor-behavior'; -import { layoutRuleGraph } from './graph-layout'; import { type GraphIssue, removeEdgeFromGraph, @@ -328,18 +326,6 @@ export function RuleFlowCanvas({ [], ); - const formatLayout = useCallback(() => { - const next = layoutRuleGraph(graph); - onGraphChange(next); - setContextMenu(null); - requestAnimationFrame(() => { - void instance.current?.fitView({ - ...initialFitViewOptions, - duration: 280, - }); - }); - }, [graph, onGraphChange]); - const contextNode = contextMenu?.kind === 'node' ? graph.nodes.find((node) => node.id === contextMenu.id) @@ -357,18 +343,8 @@ export function RuleFlowCanvas({ className='relative min-w-0 flex-1 bg-muted/20' onContextMenu={suppressBrowserContextMenu} > -
+
-
{ + if (!graph) return; + changeGraph(layoutRuleGraph(graph)); + }, [changeGraph, graph]); const leave = () => { if (!dirty || window.confirm('存在未保存的更改,确定离开吗?')) router.push('/waf'); @@ -186,58 +196,72 @@ function EditorContent() { return (
-
-
- -

- {ruleQuery.data.name} -

- - {ruleQuery.data.enabled ? '已启用' : '已停用'} - - - {issues.length === 0 ? '图校验通过' : `${issues.length} 个问题`} - - {dirty && 未保存} -
-
-
- 0 || - saveMutation.isPending || - metaMutation.isPending - } - onCheckedChange={(enabled) => metaMutation.mutate(enabled)} - /> - -
- - {conflict && ( +
+
+
+ +

+ {ruleQuery.data.name} +

+ + {ruleQuery.data.enabled ? '已启用' : '已停用'} + + + {issues.length === 0 ? '图校验通过' : `${issues.length} 个问题`} + + {dirty && 未保存} +
+
+
+ 0 || + saveMutation.isPending || + metaMutation.isPending + } + onCheckedChange={(enabled) => metaMutation.mutate(enabled)} + /> + +
+ {conflict && ( + + )} - )} - + +