* refactor(editor): 建立Clean Architecture领域模型层 * refactor(editor): 实现应用层架构 - 命令模式、用例和状态管理 * refactor(editor): 实现展示层核心Hooks * refactor(editor): 实现基础设施层和展示层组件 * refactor(editor): 迁移画布和连接渲染到 Clean Architecture 组件 * feat(editor): 集成应用层架构和命令模式,实现撤销/重做功能 * refactor(editor): UI组件拆分 * refactor(editor): 提取快速创建菜单逻辑 * refactor(editor): 重构BehaviorTreeEditor,提取组件和Hook * refactor(editor): 提取端口连接和键盘事件Hook * refactor(editor): 提取拖放处理Hook * refactor(editor): 提取画布交互Hook和工具函数 * refactor(editor): 完成核心重构 * fix(editor): 修复节点无法创建和连接 * refactor(behavior-tree,editor): 重构节点子节点约束系统,实现元数据驱动的架构
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
|
|
interface NodeContextMenuProps {
|
|
visible: boolean;
|
|
position: { x: number; y: number };
|
|
nodeId: string | null;
|
|
onReplaceNode: () => void;
|
|
}
|
|
|
|
export const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
|
|
visible,
|
|
position,
|
|
onReplaceNode
|
|
}) => {
|
|
if (!visible) return null;
|
|
|
|
return (
|
|
<div
|
|
style={{
|
|
position: 'fixed',
|
|
left: position.x,
|
|
top: position.y,
|
|
backgroundColor: '#2d2d30',
|
|
border: '1px solid #454545',
|
|
borderRadius: '4px',
|
|
boxShadow: '0 4px 16px rgba(0, 0, 0, 0.5)',
|
|
zIndex: 10000,
|
|
minWidth: '150px',
|
|
padding: '4px 0'
|
|
}}
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
<div
|
|
onClick={onReplaceNode}
|
|
style={{
|
|
padding: '8px 16px',
|
|
cursor: 'pointer',
|
|
color: '#cccccc',
|
|
fontSize: '13px',
|
|
transition: 'background-color 0.15s'
|
|
}}
|
|
onMouseEnter={(e) => e.currentTarget.style.backgroundColor = '#094771'}
|
|
onMouseLeave={(e) => e.currentTarget.style.backgroundColor = 'transparent'}
|
|
>
|
|
替换节点
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|