BindEvent 元素绑定事件
1. 结构声明
- TS Declaration
- JSON Schema
class BindEvent extends BaseNode {
name: string = '';
logics: Array<Logic>;
calleeNamespace?: string;
calleeName?: string;
arguments?: Array<Argument>;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"logics": {
"type": "array",
"items": {
"$ref": "#/definitions/Logic"
}
},
"calleeNamespace": {
"type": "string"
},
"calleeName": {
"type": "string"
},
"arguments": {
"type": "array",
"items": {
"$ref": "#/definitions/Argument"
}
}
},
"required": [
"name",
"logics"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "BindEvent",
"name": "click",
"logics": [
{
"concept": "Logic",
"name": "click",
"params": [],
"returns": [],
"variables": [],
"body": [
{
"concept": "Start",
"label": "开始"
},
{
"uuid": "bc414eb6611e417c92a25ca5c125a2ed",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "elements.modal_1.logics",
"calleeName": "close",
"arguments": []
},
{
"concept": "End",
"label": "结束"
}
],
"playground": []
}
],
"arguments": []
}
concept: BindEvent
name: click
logics:
- concept: Logic
name: click
params: []
returns: []
variables: []
body:
- concept: Start
label: 开始
- uuid: bc414eb6611e417c92a25ca5c125a2ed
concept: CallLogic
label: 调用逻辑
calleeNamespace: elements.modal_1.logics
calleeName: close
arguments: []
- concept: End
label: 结束
playground: []
arguments: []
对应的代码如下:
- 文本化 NASL
onClick: [
logic click(event) {
$refs::modal_1::close()
end
},
]
(2) 绑定多个事件逻辑
AST 如下:
- JSON
- YAML
{
"concept": "BindEvent",
"name": "click",
"logics": [
{
"concept": "Logic",
"name": "click",
"params": [],
"returns": [],
"variables": [],
"body": [
{
"concept": "Start",
"label": "开始"
},
{
"uuid": "0550e0f6863a4d849ee643d16336e420",
"concept": "CallLogic",
"label": "弹出消息",
"calleeNamespace": "nasl.ui",
"calleeName": "showMessage",
"shortcut": true,
"arguments": [
{
"concept": "Argument",
"keyword": "text",
"expression": {
"concept": "StringLiteral",
"value": "点击了“创 建”按钮"
}
}
]
},
{
"concept": "End",
"label": "结束"
}
],
"playground": []
},
{
"concept": "Logic",
"name": "create",
"params": [],
"returns": [],
"variables": [],
"body": [
{
"concept": "Start",
"label": "开始"
},
{
"concept": "Assignment",
"label": "赋值",
"left": {
"concept": "Identifier",
"namespace": "",
"name": "input"
},
"right": {
"concept": "CallFunction",
"label": "调用逻辑",
"calleeNamespace": "nasl.util",
"calleeName": "Clone",
"arguments": [
{
"concept": "Argument",
"keyword": "obj",
"expression": {
"concept": "Identifier",
"namespace": "",
"name": "student"
}
}
]
}
},
{
"uuid": "43a14fc183ed4b1bab03a839ea7fce9f",
"concept": "CallLogic",
"label": "调用逻辑",
"calleeNamespace": "elements.saveModal_1.logics",
"calleeName": "open",
"arguments": []
},
{
"concept": "End",
"label": "结束"
}
],
"playground": []
}
]
}
concept: BindEvent
name: click
logics:
- concept: Logic
name: click
params: []
returns: []
variables: []
body:
- concept: Start
label: 开始
- uuid: 0550e0f6863a4d849ee643d16336e420
concept: CallLogic
label: 弹出消息
calleeNamespace: nasl.ui
calleeName: showMessage
shortcut: true
arguments:
- concept: Argument
keyword: text
expression:
concept: StringLiteral
value: 点击了“创 建”按钮
- concept: End
label: 结束
playground: []
- concept: Logic
name: create
params: []
returns: []
variables: []
body:
- concept: Start
label: 开始
- concept: Assignment
label: 赋值
left:
concept: Identifier
namespace: ""
name: input
right:
concept: CallFunction
label: 调用逻辑
calleeNamespace: nasl.util
calleeName: Clone
arguments:
- concept: Argument
keyword: obj
expression:
concept: Identifier
namespace: ""
name: student
- uuid: 43a14fc183ed4b1bab03a839ea7fce9f
concept: CallLogic
label: 调用逻辑
calleeNamespace: elements.saveModal_1.logics
calleeName: open
arguments: []
- concept: End
label: 结束
playground: []
对应的代码如下:
- 文本化 NASL
onClick: [
logic click(event) {
nasl::ui::showMessage('点击了“创 建”按钮')
end
},
logic create(event) {
input = nasl::util::Clone(student)
$refs::saveModal_1::open()
end
},
]