From 2cfc8fcb962e6392228ef9279fd1949366458943 Mon Sep 17 00:00:00 2001 From: liqiang <974923609@qq.com> Date: Thu, 25 Mar 2021 15:38:03 +0800 Subject: [PATCH] chore: web addon frontend add drop message --- addon/web/client/src/App.js | 11 ++- addon/web/client/src/components/BreakPoint.js | 71 ++++++++++--------- addon/web/client/src/message.js | 12 +++- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/addon/web/client/src/App.js b/addon/web/client/src/App.js index de96f04..5584f57 100644 --- a/addon/web/client/src/App.js +++ b/addon/web/client/src/App.js @@ -108,12 +108,19 @@ class App extends React.Component { !flow.waitIntercept ? null :
- +
} diff --git a/addon/web/client/src/components/BreakPoint.js b/addon/web/client/src/components/BreakPoint.js index 00b63c0..18399dd 100644 --- a/addon/web/client/src/components/BreakPoint.js +++ b/addon/web/client/src/components/BreakPoint.js @@ -16,7 +16,9 @@ class BreakPoint extends React.Component { method: 'ALL', url: '', action: '1', - } + }, + + haveRules: false, } this.handleClose = this.handleClose.bind(this) @@ -45,14 +47,17 @@ class BreakPoint extends React.Component { this.props.onSave(rules) this.handleClose() + + this.setState({ haveRules: rules.length ? true : false }) } render() { - const { rule } = this.state + const { rule, haveRules } = this.state + const variant = haveRules ? 'success' : 'primary' return (
- + @@ -60,36 +65,34 @@ class BreakPoint extends React.Component { -
- - Method - - { this.setState({ rule: { ...rule, method: e.target.value } }) }}> - - - - - - - - - - - URL - { this.setState({ rule: { ...rule, url: e.target.value } }) }} /> - - - - Action - - { this.setState({ rule: { ...rule, action: e.target.value } }) }}> - - - - - - -
+ + Method + + { this.setState({ rule: { ...rule, method: e.target.value } }) }}> + + + + + + + + + + + URL + { this.setState({ rule: { ...rule, url: e.target.value } }) }} /> + + + + Action + + { this.setState({ rule: { ...rule, action: e.target.value } }) }}> + + + + + +
@@ -97,7 +100,7 @@ class BreakPoint extends React.Component { Close
diff --git a/addon/web/client/src/message.js b/addon/web/client/src/message.js index 6205b5c..5490491 100644 --- a/addon/web/client/src/message.js +++ b/addon/web/client/src/message.js @@ -52,13 +52,23 @@ export const parseMessage = data => { export const sendMessageEnum = { 'changeRequest': 11, 'changeResponse': 12, + 'dropRequest': 13, + 'dropResponse': 14, 'changeBreakPointRules': 21, } -// type: 11/12 +// type: 11/12/13/14 // messageEdit // version 1 byte + type 1 byte + id 36 byte + header len 4 byte + header content bytes + body len 4 byte + [body content bytes] export const buildMessageEdit = (messageType, flow) => { + if (messageType === sendMessageEnum.dropRequest || messageType === sendMessageEnum.dropResponse) { + const view = new Uint8Array(38) + view[0] = 1 + view[1] = messageType + view.set(new TextEncoder().encode(flow.id), 2) + return view + } + let header, body if (messageType === sendMessageEnum.changeRequest) {