|
|
|
@ -57,10 +57,17 @@ interface NodeToolState { |
|
|
|
/** 当前单选节点派生出的面板(生成 composer / 高清),由选区控制器唯一写入。 */ |
|
|
|
selectionNodeId: string | null; |
|
|
|
selectionTool: SelectionToolType | null; |
|
|
|
/** |
|
|
|
* 当前恰好单选的节点 id(0 个或多个选中时为 null),由选区控制器唯一写入。 |
|
|
|
* 节点用 `soleSelectedNodeId === id` 做布尔等值订阅,替代每节点 O(N²) 的 |
|
|
|
* useSelectedNodeCount,用于「仅单选时」的行为(如视频加载/播放)。 |
|
|
|
*/ |
|
|
|
soleSelectedNodeId: string | null; |
|
|
|
openTool: (nodeId: string, tool: NodeToolType) => void; |
|
|
|
switchTool: (nodeId: string, tool: NodeToolType) => void; |
|
|
|
setSplitGridSelection: (selection: SplitGridSelection | null) => void; |
|
|
|
setSelectionTool: (nodeId: string | null, tool: SelectionToolType | null) => void; |
|
|
|
setSoleSelectedNodeId: (nodeId: string | null) => void; |
|
|
|
closeTool: () => void; |
|
|
|
closeToolForNode: (nodeId: string) => void; |
|
|
|
hideTool: () => void; |
|
|
|
@ -102,6 +109,7 @@ export const useNodeToolStore = create<NodeToolState>()((set, get) => ({ |
|
|
|
splitGridSelection: null, |
|
|
|
selectionNodeId: null, |
|
|
|
selectionTool: null, |
|
|
|
soleSelectedNodeId: null, |
|
|
|
openTool: (nodeId, tool) => set({ activeNodeId: nodeId, activeTool: tool, visible: true, splitGridSelection: null }), |
|
|
|
switchTool: (nodeId, tool) => set({ activeNodeId: nodeId, activeTool: tool, visible: true, splitGridSelection: null }), |
|
|
|
setSplitGridSelection: (selection) => set({ splitGridSelection: selection }), |
|
|
|
@ -111,6 +119,10 @@ export const useNodeToolStore = create<NodeToolState>()((set, get) => ({ |
|
|
|
if (state.selectionNodeId === nextNodeId && state.selectionTool === tool) return; |
|
|
|
set({ selectionNodeId: nextNodeId, selectionTool: tool }); |
|
|
|
}, |
|
|
|
setSoleSelectedNodeId: (nodeId) => { |
|
|
|
if (get().soleSelectedNodeId === nodeId) return; |
|
|
|
set({ soleSelectedNodeId: nodeId }); |
|
|
|
}, |
|
|
|
// 关闭仅清理显式工具状态,保留 selection* —— 关掉 crop 等工具后,选区派生的
|
|
|
|
// composer 能凭 selectionTool 自动重新出现,无需反向重开逻辑。
|
|
|
|
closeTool: () => set({ activeNodeId: null, activeTool: null, visible: false, splitGridSelection: null }), |
|
|
|
|