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