From 7e0a96857cc6af80b01aa72b3324d4a61edbe95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 6 Jun 2021 14:10:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=9C=8D=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E9=BB=98=E8=AE=A4=E5=A2=9E=E5=8A=A0http?= =?UTF-8?q?=E5=92=8Chttps=E7=AB=AF=E5=8F=A3=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/network-addresses-box.js | 5 +++ web/views/@default/servers/create.html | 2 +- web/views/@default/servers/create.js | 45 ++++++++++++++----- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/web/public/js/components/common/network-addresses-box.js b/web/public/js/components/common/network-addresses-box.js index a4e76317..f1c7c1aa 100644 --- a/web/public/js/components/common/network-addresses-box.js +++ b/web/public/js/components/common/network-addresses-box.js @@ -24,6 +24,11 @@ Vue.component("network-addresses-box", { watch: { "vServerType": function () { this.addresses = [] + }, + "vAddresses": function () { + if (this.vAddresses != null) { + this.addresses = this.vAddresses + } } }, methods: { diff --git a/web/views/@default/servers/create.html b/web/views/@default/servers/create.html index d251d3ba..df0fe6a6 100644 --- a/web/views/@default/servers/create.html +++ b/web/views/@default/servers/create.html @@ -32,7 +32,7 @@ 绑定端口 * - + diff --git a/web/views/@default/servers/create.js b/web/views/@default/servers/create.js index defa7d6c..7c876849 100644 --- a/web/views/@default/servers/create.js +++ b/web/views/@default/servers/create.js @@ -1,24 +1,49 @@ Tea.context(function () { - this.serverType = "httpProxy"; + this.serverType = "httpProxy" this.tlsProtocolName = "" - this.origins = []; + this.origins = [] + this.defaultAddresses = [] this.success = NotifySuccess("保存成功", "/servers"); this.changeServerType = function () { - this.origins = []; - this.tlsProtocolName = ""; - }; + this.origins = [] + this.tlsProtocolName = "" + this.addDefaultAddresses() + } + + // 初始化调用 + this.$delay(function () { + this.changeServerType() + }) this.addOrigin = function () { teaweb.popup("/servers/addOriginPopup?serverType=" + this.serverType, { callback: function (resp) { this.origins.push(resp.data.origin); } - }); - }; + }) + } this.removeOrigin = function (index) { - this.origins.$remove(index); - }; -}); \ No newline at end of file + this.origins.$remove(index) + } + + this.addDefaultAddresses = function () { + // 默认绑定的端口地址 + this.defaultAddresses = [] + if (this.serverType == "httpProxy" || this.serverType == "httpWeb") { + this.defaultAddresses.push({ + "host": "", + "portRange": "80", + "protocol": "http" + }) + this.defaultAddresses.push({ + "host": "", + "portRange": "443", + "protocol": "https" + }) + this.tlsProtocolName = "https" + } + } +}) \ No newline at end of file