|
|
|
@ -146,7 +146,7 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
: false;
|
|
|
|
: false;
|
|
|
|
|
|
|
|
|
|
|
|
// 在应用编排模式下(useDefault为false)禁用删除功能
|
|
|
|
// 在应用编排模式下(useDefault为false)禁用删除功能
|
|
|
|
const isDeleteDisabled = !useDefault || currentAppIsRunning;
|
|
|
|
const isDeleteDisabled = currentAppIsRunning;
|
|
|
|
|
|
|
|
|
|
|
|
// 监听键盘事件实现快捷键
|
|
|
|
// 监听键盘事件实现快捷键
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
@ -199,7 +199,13 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
elementsSelectable={!currentAppIsRunning} // 运行时禁用元素选择
|
|
|
|
elementsSelectable={!currentAppIsRunning} // 运行时禁用元素选择
|
|
|
|
connectOnClick={!currentAppIsRunning} // 运行时禁用点击连接
|
|
|
|
connectOnClick={!currentAppIsRunning} // 运行时禁用点击连接
|
|
|
|
disableKeyboardA11y={currentAppIsRunning} // 运行时禁用键盘交互
|
|
|
|
disableKeyboardA11y={currentAppIsRunning} // 运行时禁用键盘交互
|
|
|
|
onBeforeDelete={async ({ nodes }) => {
|
|
|
|
onBeforeDelete={async ({ nodes, edges }) => {
|
|
|
|
|
|
|
|
// 在应用编排模式下(useDefault为false)只允许删除边,不允许删除节点
|
|
|
|
|
|
|
|
if (!useDefault && nodes.length > 0) {
|
|
|
|
|
|
|
|
console.warn('在应用编排模式下不允许删除节点');
|
|
|
|
|
|
|
|
return false; // 阻止删除节点操作
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 检查是否有开始或结束节点
|
|
|
|
// 检查是否有开始或结束节点
|
|
|
|
const hasStartOrEndNode = nodes.some(node => node.type === 'start' || node.type === 'end');
|
|
|
|
const hasStartOrEndNode = nodes.some(node => node.type === 'start' || node.type === 'end');
|
|
|
|
if (hasStartOrEndNode) {
|
|
|
|
if (hasStartOrEndNode) {
|
|
|
|
@ -213,11 +219,17 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// 允许删除操作继续进行
|
|
|
|
// 允许删除操作继续进行
|
|
|
|
return !isDeleteDisabled; // 在应用编排模式或运行时禁止删除节点
|
|
|
|
return !currentAppIsRunning; // 在运行时禁止删除任何元素
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onNodesDelete={(deleted) => {
|
|
|
|
onNodesDelete={(deleted) => {
|
|
|
|
// 如果在应用编排模式或运行时,禁止删除
|
|
|
|
// 在应用编排模式下(useDefault为false)不允许删除节点
|
|
|
|
if (isDeleteDisabled) {
|
|
|
|
if (!useDefault) {
|
|
|
|
|
|
|
|
console.warn('在应用编排模式下不允许删除节点');
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果在运行时,禁止删除
|
|
|
|
|
|
|
|
if (currentAppIsRunning) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -349,8 +361,8 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/*边右键上下文 - 仅在默认模式且非运行时显示*/}
|
|
|
|
{/*边右键上下文 - 在非运行时显示,应用编排模式下也允许*/}
|
|
|
|
{!currentAppIsRunning && useDefault && menu && menu.type === 'edge' && (
|
|
|
|
{!currentAppIsRunning && menu && menu.type === 'edge' && (
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
position: 'absolute',
|
|
|
|
|