Compare commits
No commits in common. "63b1f0f10bac90e8905ad16010859de140e1bdf0" and "acba77a8dab85256fbba37432c8508356bc14304" have entirely different histories.
63b1f0f10b
...
acba77a8da
|
|
@ -5,7 +5,6 @@ import os
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import uuid
|
import uuid
|
||||||
import time
|
import time
|
||||||
from tool import format_content_uuid
|
|
||||||
import models.db as DB
|
import models.db as DB
|
||||||
import nodes as F
|
import nodes as F
|
||||||
from tortoise.transactions import in_transaction
|
from tortoise.transactions import in_transaction
|
||||||
|
|
@ -203,20 +202,10 @@ def create_app():
|
||||||
nodes = []
|
nodes = []
|
||||||
params = {}
|
params = {}
|
||||||
status = {}
|
status = {}
|
||||||
uuids = []
|
|
||||||
first_uuid = next((x['uuid'] for x in work_content.content if x.get("type") == "first"), "")
|
|
||||||
if not first_uuid:
|
|
||||||
work_log.status = DB.WorkLogsStatus.FAILED
|
|
||||||
await work_log.save()
|
|
||||||
app.state.tasks.pop(task_id, None)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for x in work_content.content:
|
for x in work_content.content:
|
||||||
node_id = x["uuid"]
|
node_id = x["uuid"]
|
||||||
node_type = x["type"]
|
node_type = x["type"]
|
||||||
node_info = x["detail"]
|
node_info = x["detail"]
|
||||||
node_edge = x.get("edge")
|
|
||||||
params[node_id] = node_info
|
params[node_id] = node_info
|
||||||
status[node_id] = "wait"
|
status[node_id] = "wait"
|
||||||
node_class_map = {
|
node_class_map = {
|
||||||
|
|
@ -309,11 +298,11 @@ def create_app():
|
||||||
if not work_content:
|
if not work_content:
|
||||||
work_content = DB.WorkContent(
|
work_content = DB.WorkContent(
|
||||||
user_id=work.creator_id,
|
user_id=work.creator_id,
|
||||||
content=[],
|
content=body.content,
|
||||||
is_deleted=0,
|
is_deleted=0,
|
||||||
work_id=work.id,
|
work_id=work.id,
|
||||||
)
|
)
|
||||||
work_content.content = format_content_uuid(body.content)
|
work_content.content = body.content
|
||||||
work_content.update_time = datetime.datetime.now()
|
work_content.update_time = datetime.datetime.now()
|
||||||
await work_content.save()
|
await work_content.save()
|
||||||
return BaseResponse()
|
return BaseResponse()
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
|
|
||||||
def format_content_uuid(content:list[dict]):
|
|
||||||
"""替换所有由前端生成的 uuid 字段"""
|
|
||||||
uuid_mapping = {k.get('uuid', ''): uuid4().hex for k in list(filter(lambda x: "temp_" in x.get("uuid", "") , content))}
|
|
||||||
for x in content:
|
|
||||||
edge = x.get('edge')
|
|
||||||
x_uuid = x.get('uuid', '')
|
|
||||||
x["uuid"] = uuid_mapping.get(x_uuid) or x_uuid
|
|
||||||
if edge:
|
|
||||||
source_uuid = edge.get('source', '')
|
|
||||||
target_uuid = edge.get('target', '')
|
|
||||||
edge["source"] = uuid_mapping.get(source_uuid) or source_uuid
|
|
||||||
edge["target"] = uuid_mapping.get(target_uuid) or target_uuid
|
|
||||||
return content
|
|
||||||
|
|
@ -90,7 +90,6 @@ const FlowDetail = () => {
|
||||||
sourcePosition: 'right',
|
sourcePosition: 'right',
|
||||||
targetPosition: 'left',
|
targetPosition: 'left',
|
||||||
type: type,
|
type: type,
|
||||||
detail: { title: type}
|
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
@ -143,13 +142,11 @@ const FlowDetail = () => {
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
const content = [];
|
const content = [];
|
||||||
nodes.forEach(e => {
|
nodes.forEach(e => {
|
||||||
const edge = edges.find(obj => obj.source === e.id);
|
const edge = edges.find(obj => obj.target === e.id);
|
||||||
content.push({
|
content.push({
|
||||||
...e.detail,
|
...e.detail,
|
||||||
position: e.position,
|
position: e.position,
|
||||||
edge: edge ? { source: edge.source, target: edge.target } : undefined,
|
edge: edge ? { source: edge.source, target: edge.target } : undefined
|
||||||
type: e.type,
|
|
||||||
uuid: e.id
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const res = await flowUpdate(record.uuid, {
|
const res = await flowUpdate(record.uuid, {
|
||||||
|
|
@ -157,8 +154,7 @@ const FlowDetail = () => {
|
||||||
...formRef.current.getFieldsValue()
|
...formRef.current.getFieldsValue()
|
||||||
})
|
})
|
||||||
if (res?.success) {
|
if (res?.success) {
|
||||||
message.success("保存成功");
|
message.success("保持成功");
|
||||||
loadDetail();
|
|
||||||
} else {
|
} else {
|
||||||
message.error(res.message);
|
message.error(res.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { memo } from 'react';
|
import React, { memo } from 'react';
|
||||||
import { Position } from '@xyflow/react';
|
import { Handle, Position } from '@xyflow/react';
|
||||||
import './CustomNode.css';
|
import './CustomNode.css';
|
||||||
import OnlyOneHandle from './OnlyOneHandle';
|
|
||||||
|
|
||||||
const CustomNode = memo(({ data: { style, position, ...data}, isConnectable }) => {
|
const CustomNode = memo(({ data: { style, position, ...data}, isConnectable }) => {
|
||||||
return (
|
return (
|
||||||
|
|
@ -9,8 +8,8 @@ const CustomNode = memo(({ data: { style, position, ...data}, isConnectable }) =
|
||||||
<div >
|
<div >
|
||||||
{data.label}
|
{data.label}
|
||||||
</div>
|
</div>
|
||||||
{position?.includes('left') && <OnlyOneHandle connectionCount={1} type="target" position={Position.Left} isConnectable={isConnectable} />}
|
{position?.includes('left') && <Handle type="target" position={Position.Left} isConnectable={isConnectable} />}
|
||||||
{position?.includes('right') && <OnlyOneHandle connectionCount={1} type="source" position={Position.Right} isConnectable={isConnectable} />}
|
{position?.includes('right') && <Handle type="source" position={Position.Right} isConnectable={isConnectable} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import { Handle, useNodeConnections } from '@xyflow/react';
|
|
||||||
|
|
||||||
const OnlyOneHandle = (props) => {
|
|
||||||
const connections = useNodeConnections({
|
|
||||||
handleType: props.type,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Handle
|
|
||||||
{...props}
|
|
||||||
isConnectable={connections.length < props.connectionCount}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default OnlyOneHandle;
|
|
||||||
Loading…
Reference in New Issue