From 897f59c2eb87360c529bcfea02c15a56725dabc8 Mon Sep 17 00:00:00 2001 From: CaiHQ Date: Wed, 30 Mar 2022 11:17:08 +0800 Subject: [PATCH] add nodecenterws config --- NodePortal.html | 15 +++++++++++++++ js/NodeConfig.js | 20 +++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/NodePortal.html b/NodePortal.html index 5a72d03..bfda802 100644 --- a/NodePortal.html +++ b/NodePortal.html @@ -1084,6 +1084,21 @@ +
+
+
+ 加入网络WS +
+ +
+ +
+
+
diff --git a/js/NodeConfig.js b/js/NodeConfig.js index 2ec6eda..b2d7e9e 100644 --- a/js/NodeConfig.js +++ b/js/NodeConfig.js @@ -10,11 +10,12 @@ function loadNodeConfig(event) { function onLoadNodeConfig(data) { global.config = data.data; + showNodeConfig(data); if (!global.centerportalws) { - let port = global.config.nodeCenter.replace(/.*:/g, ""); - const len = global.config.nodeCenter.length - port.length; - port = port - 1; - let url = global.config.nodeCenter.substring(0, len) + port + "/NodeCenterWS"; + let url = global.config.nodeCenterWS; + if (window.location.origin.startsWith("https")){ + url = url.replace("ws://","wss://"); + } if (window.location.origin === "https://contract.internetapi.cn") { url = "wss://cluster.contract.internetapi.cn/NodeCenterWS"; } @@ -28,7 +29,7 @@ function onLoadNodeConfig(data) { })); }, centerportalWSHandler); } - showNodeConfig(data); + } function showNodeConfig(data) { @@ -44,6 +45,7 @@ function showNodeConfig(data) { $("#expireTime").html(global.config.expireTime); $("#yjsInput")[0].value = global.config.yjsPath; nodeCenterInputEl[0].value = global.config.nodeCenter; + $("#nodeCenterWSInput")[0].value = global.config.nodeCenterWS; if (global.config.clusterConnected && global.config.clusterConnected === "true") { nodeCenterInputEl.css("color", "green"); } else { @@ -167,6 +169,14 @@ function changeNodeCenter(event) { })); } +function changeNodeCenterWS(event) { + console.log("changeNodeCenterWS"); + global.wssocket.send(JSON.stringify({ + action: 'changeNodeCenterWS', + data: $("#nodeCenterWSInput")[0].value + })); +} + function onChangeNodeCenter(event) { // console.log("onChangeNodeCenter", data); myToast("成功", "修改NodeCenter成功")