Skip to content

Commit 3a9807d

Browse files
committed
fix flow
1 parent 30fd641 commit 3a9807d

File tree

9 files changed

+194
-336
lines changed

9 files changed

+194
-336
lines changed

admin-pro-ui/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
"monaco-editor": "^0.51.0",
2929
"react": "^18.3.1",
3030
"react-dom": "^18.3.1",
31+
"react-markdown": "^10.0.0",
3132
"react-redux": "^9.1.2",
3233
"react-router": "^6.26.2",
3334
"react-router-dom": "^6.26.2",
35+
"remark-gfm": "^4.0.1",
3436
"typescript": "^5.6.2",
3537
"web-vitals": "^2.1.4"
3638
},

admin-pro-ui/src/components/flow/CodeEditor/index.tsx

Lines changed: 0 additions & 117 deletions
This file was deleted.

admin-pro-ui/src/components/flow/ProFormCode/index.tsx

Lines changed: 0 additions & 26 deletions
This file was deleted.

admin-pro-ui/src/components/flow/nodes/panel/ButtonPanel.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
2121

2222
const formAction = React.useRef<FormAction>(null);
2323

24-
const [form] = ProForm.useForm();
25-
26-
const [groovyForm] = ProForm.useForm();
24+
const groovyFormAction = React.useRef<FormAction>(null);
2725

2826
const [visible, setVisible] = React.useState(false);
2927

@@ -74,8 +72,8 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
7472
<a
7573
key={"edit"}
7674
onClick={() => {
77-
form.resetFields();
78-
form.setFieldsValue(record);
75+
groovyFormAction.current?.reset();
76+
groovyFormAction.current?.setFieldsValue(record);
7977
setType(record.type);
8078
setVisible(true);
8179
}}
@@ -117,7 +115,7 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
117115
<Button
118116
type={"primary"}
119117
onClick={() => {
120-
form.resetFields();
118+
groovyFormAction.current?.reset();
121119
setVisible(true);
122120
}}
123121
>添加按钮</Button>
@@ -171,9 +169,9 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
171169
{type === 'CUSTOM' && (
172170
<EyeOutlined
173171
onClick={() => {
174-
groovyForm.resetFields();
175-
const script = form.getFieldValue('groovy') || 'def run(content){\n //你的代码 \n return content.createMessageResult(\'我是自定义标题\');\n}';
176-
groovyForm.setFieldsValue({
172+
groovyFormAction.current?.reset();
173+
const script = groovyFormAction.current?.getFieldValue('groovy') || 'def run(content){\n //你的代码 \n return content.createMessageResult(\'我是自定义标题\');\n}';
174+
groovyFormAction.current?.setFieldsValue({
177175
'script': script
178176
});
179177
setScriptVisible(!scriptVisible);
@@ -215,11 +213,11 @@ const ButtonPanel: React.FC<ButtonPanelProps> = (props) => {
215213

216214
<ScriptModal
217215
onFinish={(values) => {
218-
form.setFieldsValue({
216+
groovyFormAction.current?.setFieldsValue({
219217
'groovy': values.script
220218
});
221219
}}
222-
form={groovyForm}
220+
formAction={groovyFormAction}
223221
setVisible={setScriptVisible}
224222
visible={scriptVisible}/>
225223

admin-pro-ui/src/components/flow/nodes/panel/EdgePanel.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from "react";
2-
import {ActionType, ProForm, ProTable} from "@ant-design/pro-components";
2+
import {ActionType, ProTable} from "@ant-design/pro-components";
33
import {Input, InputNumber, Popconfirm, Space} from "antd";
44
import {CheckOutlined, EditOutlined, SettingOutlined} from "@ant-design/icons";
55
import FlowUtils from "@/components/flow/utils";
66
import ScriptModal from "@/components/flow/nodes/panel/ScriptModal";
7+
import {FormAction} from "@/components/form";
78

89
interface EdgePanelProps {
910
id?: string;
@@ -17,7 +18,7 @@ const EdgePanel: React.FC<EdgePanelProps> = (props) => {
1718
const [name, setName] = React.useState("");
1819
const [order, setOrder] = React.useState(0);
1920

20-
const [form] = ProForm.useForm();
21+
const groovyFormAction = React.useRef<FormAction>(null);
2122
const actionRef = React.useRef<ActionType>();
2223

2324
const handlerChangeName = (id: any) => {
@@ -94,8 +95,8 @@ const EdgePanel: React.FC<EdgePanelProps> = (props) => {
9495
<Space>
9596
<SettingOutlined
9697
onClick={() => {
97-
form.setFieldValue("script", record.outTrigger);
98-
form.setFieldValue("type", record.id);
98+
groovyFormAction.current?.setFieldValue("script", record.outTrigger);
99+
groovyFormAction.current?.setFieldValue("type", record.id);
99100
setVisible(true);
100101
}}/>
101102
{record.outTrigger ? (<CheckOutlined/>) : null}
@@ -183,7 +184,7 @@ const EdgePanel: React.FC<EdgePanelProps> = (props) => {
183184
onFinish={(values) => {
184185
handlerChangeOutTrigger(values.type, values.script);
185186
}}
186-
form={form}
187+
formAction={groovyFormAction}
187188
setVisible={setVisible}
188189
visible={visible}/>
189190
</>

admin-pro-ui/src/components/flow/nodes/panel/NodePanel.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from "react";
22
import {Button, Divider, Space} from "antd";
3-
import {ProForm} from "@ant-design/pro-components";
43
import {EyeOutlined, SettingOutlined} from "@ant-design/icons";
54
import GroovyScript from "@/components/flow/utils/script";
65
import ScriptModal from "@/components/flow/nodes/panel/ScriptModal";
@@ -22,7 +21,7 @@ interface NodePanelProps {
2221

2322
const NodePanel: React.FC<NodePanelProps> = (props) => {
2423

25-
const [form] = ProForm.useForm();
24+
const groovyFormAction = React.useRef<FormAction>(null);
2625

2726
const [visible, setVisible] = React.useState(false);
2827

@@ -143,8 +142,8 @@ const NodePanel: React.FC<NodePanelProps> = (props) => {
143142
<EyeOutlined
144143
onClick={() => {
145144
const value = props.formAction.current?.getFieldValue("operatorMatcher");
146-
form.setFieldValue("type", "operatorMatcher");
147-
form.setFieldValue("script", value);
145+
groovyFormAction.current?.setFieldValue("type", "operatorMatcher");
146+
groovyFormAction.current?.setFieldValue("script", value);
148147
setVisible(true);
149148
}}/>
150149

@@ -197,8 +196,8 @@ const NodePanel: React.FC<NodePanelProps> = (props) => {
197196
<EyeOutlined
198197
onClick={() => {
199198
const value = props.formAction.current?.getFieldValue("titleGenerator");
200-
form.setFieldValue("type", "titleGenerator");
201-
form.setFieldValue("script", value);
199+
groovyFormAction.current?.setFieldValue("type", "titleGenerator");
200+
groovyFormAction.current?.setFieldValue("script", value);
202201
setVisible(true);
203202
}}/>
204203
)}
@@ -239,8 +238,8 @@ const NodePanel: React.FC<NodePanelProps> = (props) => {
239238
<EyeOutlined
240239
onClick={() => {
241240
const value = props.formAction.current?.getFieldValue("errTrigger");
242-
form.setFieldValue("type", "errTrigger");
243-
form.setFieldValue("script", value);
241+
groovyFormAction.current?.setFieldValue("type", "errTrigger");
242+
groovyFormAction.current?.setFieldValue("script", value);
244243
setVisible(true);
245244
}}/>
246245
)}
@@ -255,7 +254,7 @@ const NodePanel: React.FC<NodePanelProps> = (props) => {
255254
[type]: values.script
256255
});
257256
}}
258-
form={form}
257+
formAction={groovyFormAction}
259258
setVisible={setVisible}
260259
visible={visible}/>
261260

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
/* 样式化 pre 代码块 */
2-
pre {
3-
background-color: #f5f5f5;
4-
border: 1px solid #ccc;
5-
padding: 15px;
6-
border-radius: 5px;
7-
font-family: Consolas, "Courier New", monospace;
8-
white-space: pre-wrap; /* 保留换行和空格 */
9-
}
1+
.flow-script-modal {
2+
height: 50vh !important;
3+
width: 80vw !important;
104

11-
/* 样式化 code 标签内的代码 */
12-
code {
13-
background-color: #eef;
14-
padding: 2px 5px;
15-
border-radius: 3px;
16-
color: #d63384;
17-
}
5+
.flow-script-content {
6+
display: flex;
7+
height: 100%;
188

19-
/* 备注样式 */
20-
.comment {
21-
color: #999;
22-
font-style: italic;
23-
margin-top: 10px;
24-
display: block;
25-
}
9+
.flow-script-help {
10+
flex: 1;
11+
12+
.flow-script-help-markdown {
13+
height: 65vh;
14+
overflow: auto;
15+
*{
16+
white-space: pre-wrap;
17+
}
2618

27-
.ScriptModal {
28-
height: 69vh;
29-
overflow: auto;
19+
pre{
20+
background-color: #1e2022;
21+
code{
22+
padding: 2px;
23+
border-radius: 2px;
24+
color: #8df823;
25+
}
26+
}
27+
}
28+
}
29+
.flow-script-form {
30+
flex: 2;
31+
}
32+
}
3033
}

0 commit comments

Comments
 (0)