Skip to content

Commit cbc3072

Browse files
committed
1 parent ff50aa2 commit cbc3072

8 files changed

Lines changed: 50 additions & 7 deletions

File tree

designs/groovy-script/DESiGN.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Groovy Script 脚本设计规范
2+
3+
## 脚本的实例写法如下
4+
```
5+
def run(request){
6+
return "Hello, ${request.name}!"
7+
}
8+
```
9+
10+
## 脚本规范
11+
request对象,根据脚本的不同,起传递的request对象也不同。
12+
return语句,return语句根据脚本的不同,起返回的对象也不同。
13+
14+
## 开发规范
15+
为了让脚本可以更好的呈现和使用,脚本的配置分为两种模式,一种是可视化配置模式,一种是代码配置模式。
16+
17+
* 代码配置模式
18+
代码配置模式的脚本中,将会通过注释的方式添加一行@CUSTOM_SCRIPT,来标识这是一个自定义脚本,这样在编辑器中就会以代码的形式展示出来。
19+
```
20+
// @CUSTOM_SCRIPT
21+
def run(request){
22+
return "Hello, ${request.name}!"
23+
}
24+
```
25+
26+
* 可视化配置模式
27+
可视化配置模式的脚本中,没有@CUSTOM_SCRIPT的注释标识,这样在编辑器中就会以可视化的形式展示出来。
28+
```
29+
def run(request){
30+
return "Hello, ${request.name}!"
31+
}
32+
```
33+
34+
## 脚本展示标题
35+
为了让脚本在在展示时可以更好的展示脚本的作用,所以在脚本中支持通过@SCRIPT_TITLE的注释来标识脚本的展示标题,这样在编辑器中就会以这个标题来展示脚本。
36+
37+
```
38+
// @SCRIPT_TITLE 这是一个示例脚本
39+
def run(request){
40+
return "Hello, ${request.name}!"
41+
}
42+
```
43+
上述的脚本在编辑器中就会以“这是一个示例脚本”来展示,而不是以代码的方式来展示。

frontend/apps/app-pc/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"@flow-engine/flow-types": "workspace:*",
1414
"@flow-engine/flow-pc-design": "workspace:*",
1515
"@flow-engine/flow-pc-ui": "workspace:*",
16-
"@flow-engine/flow-pc-form": "workspace:*",
1716
"@flow-engine/flow-pc-approval":"workspace:*",
1817
"antd": "^6.2.1",
1918
"dayjs": "^1.11.19",

frontend/apps/app-pc/src/config/plugin-view.tsx

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

frontend/apps/app-pc/src/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import zhCN from 'antd/locale/zh_CN';
77
import dayjs from 'dayjs';
88
import 'dayjs/locale/zh-cn';
99
import "./index.css";
10-
import "./config/plugin-view";
1110

1211
dayjs.locale('zh');
1312

frontend/packages/flow-pc/flow-pc-approval/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@flow-engine/flow-types": "workspace:*",
2929
"@flow-engine/flow-pc-design": "workspace:*",
3030
"@flow-engine/flow-pc-ui": "workspace:*",
31+
"@flow-engine/flow-pc-form": "workspace:*",
3132
"@reduxjs/toolkit": "^2.11.2",
3233
"antd": "^6.2.1",
3334
"immer": "^11.1.3",

frontend/packages/flow-pc/flow-pc-approval/src/components/flow-approval/components/form-view-component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import React from "react";
22
import {useApprovalContext} from "@/components/flow-approval/hooks/use-approval-context";
33
import {ViewBindPlugin} from "@flow-engine/flow-types";
44
import { Form } from "antd";
5+
import {FlowFormView} from "@flow-engine/flow-pc-form";
56

67
interface FormViewComponentProps{
78
onValuesChange?:(values:any)=>void;
89
}
910

1011
export const FormViewComponent: React.FC<FormViewComponentProps> = (props) => {
1112
const {state, context} = useApprovalContext();
12-
const ViewComponent = ViewBindPlugin.getInstance().get(state.flow?.view || 'default') ;
13+
const ViewComponent = ViewBindPlugin.getInstance().get(state.flow?.view || 'default') || FlowFormView ;
1314

1415
const formMeta = state.flow?.form;
1516

frontend/packages/flow-pc/flow-pc-design/src/components/design-panel/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const initStateData: State = {
117117
id:'',
118118
title:'',
119119
code:'',
120+
operatorCreateScript:'',
120121
form:{
121122
code:'',
122123
name:'',

frontend/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)