Skip to content

Commit

Permalink
添加账号信息配置
Browse files Browse the repository at this point in the history
  • Loading branch information
yaming116 committed May 16, 2019
1 parent 732cb1b commit 5893ee5
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 36 deletions.
72 changes: 72 additions & 0 deletions bizwechat-configurator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script type="text/javascript">
RED.nodes.registerType('bizwechat-configurator', {
category: 'config',
label() {
return this.name || '默认企业微信配置'
},
defaults: {
name: {
value: ''
},
port: {
value: '',
required: true
},
cropid: {
value: '',
required: true
},
agentid: {
value: '',
required: true
},
token: {
value: '',
required: true
},
corpsecret: {
value: '',
required: true
},
aeskey: {
value: '',
required: true
},

}
})
</script>
<script type="text/x-red" data-template-name="bizwechat-configurator">
<div class="form-row">
<label for="node-config-input-name"><i class="icon-tag"></i>名称</label>
<input type="text" id="node-config-input-name" placeholder="默认企业微信配置">
</div>
<div class="form-row">
<label for="node-config-input-port"><i></i>port</label>
<input type="text" id="node-config-input-port" placeholder="本服务端口">
</div>
<div class="form-row">
<label for="node-config-input-cropid"><i></i>Cropid</label>
<input type="text" id="node-config-input-cropid" placeholder="企业ID">
</div>
<div class="form-row">
<label for="node-config-input-agentid"><i></i>Agentid</label>
<input type="text" id="node-config-input-agentid" placeholder="应用ID">
</div>
<div class="form-row">
<label for="node-config-input-token"><i></i>Token</label>
<input type="text" id="node-config-input-token" placeholder="自建应用Token">
</div>
<div class="form-row">
<label for="node-config-input-corpsecret"><i></i>Secret</label>
<input type="text" id="node-config-input-corpsecret" placeholder="自建应用Secret">
</div>
<div class="form-row">
<label for="node-config-input-aeskey"><i></i>AESKey</label>
<input type="text" id="node-config-input-aeskey" placeholder="自建应用EncodingAESKey">
</div>
</script>
<script type="text/x-red" data-help-name="bizwechat-configurator">


</script>
17 changes: 17 additions & 0 deletions bizwechat-configurator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = (RED) => {
function bizWechatConfiguratorNode(n) {
RED.nodes.createNode(this, n);

this.name = n.name;
this.port = n.port;
this.cropid = n.cropid;
this.agentid = n.agentid;
this.token = n.token;
this.corpsecret = n.corpsecret
this.aeskey = n.aeskey;

var node = this;
}

RED.nodes.registerType("bizwechat-configurator", bizWechatConfiguratorNode);
}
55 changes: 27 additions & 28 deletions bizwechat.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,11 @@
name: {
value: ''
},
cropid: {
bizwechat: {
value: '',
required: true
type: 'bizwechat-configurator'
},
token: {
value: '',
required: true
},
aeskey: {
value: '',
required: true
},
port: {
value: '',
required: true
}

},
inputs: 0,
outputs: 1,
Expand All @@ -38,7 +27,16 @@
label() {
return this.name || '输出'
},
defaults: {},
defaults: {
name: {
value: ''
},
bizwechat: {
value: '',
type: 'bizwechat-configurator'
},

},
inputs: 1,
outputs: 0,
icon: 'white-globe.png',
Expand All @@ -47,25 +45,26 @@
</script>
<script type="text/x-red" data-template-name="bizwechat-input">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>名称</label>
<input type="text" id="node-input-name">
</div>
<div class="form-row">
<label for="node-input-port"><i></i>port</label>
<input type="text" id="node-input-port" placeholder="本服务端口">
<label for="node-input-bizwechat"><i class="icon-tag"></i>配置</label>
<input type="text" id="node-input-bizwechat">
</div>
<div class="form-row">
<label for="node-input-cropid"><i></i>Cropid</label>
<input type="text" id="node-input-cropid" placeholder="企业ID">
<label for="node-input-name"><i class="icon-tag"></i>名称</label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="bizwechat-input">
</script>

<script type="text/x-red" data-template-name="bizwechat-output">
<div class="form-row">
<label for="node-input-token"><i></i>Token</label>
<input type="text" id="node-input-token" placeholder="自建应用Token">
<label for="node-input-bizwechat"><i class="icon-tag"></i>配置</label>
<input type="text" id="node-input-bizwechat">
</div>
<div class="form-row">
<label for="node-input-aeskey"><i></i>AESKey</label>
<input type="text" id="node-input-aeskey" placeholder="自建应用EncodingAESKey">
<label for="node-input-name"><i class="icon-tag"></i>名称</label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="bizwechat-input">
<script type="text/x-red" data-help-name="bizwechat-output">
</script>
14 changes: 7 additions & 7 deletions bizwechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ module.exports = RED => {
constructor(config) {
const node = this
RED.nodes.createNode(node, config)
console.log('in config', config)
const bizwechat = RED.nodes.getNode(config.bizwechat);
this.newConfig = Object.assign({}, bizwechat, config)
// 建立server
const server = createServer(config, node, (res, req, message) => node.send({
res,
req,
config,
message
}))
const server = createServer(this.newConfig, node, (res, req, message) => {
node.send({res, req, config: this.newConfig, message })
}
)

server.on('error', ({
message
}) => {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
],
"node-red": {
"nodes": {
"bizwechat": "bizwechat.js"
"bizwechat": "bizwechat.js",
"bizwechat-configurator": "bizwechat-configurator.js"

}
},
"author": "FlashSoft",
Expand Down

0 comments on commit 5893ee5

Please sign in to comment.