优化交互

This commit is contained in:
GoEdgeLab
2021-06-28 21:09:22 +08:00
parent d6aa97e085
commit d03bdfe203
6 changed files with 26 additions and 11 deletions

View File

@@ -20,7 +20,10 @@ func (this *AddPortPopupAction) Init() {
func (this *AddPortPopupAction) RunGet(params struct { func (this *AddPortPopupAction) RunGet(params struct {
ServerType string ServerType string
Protocol string Protocol string
From string
}) { }) {
this.Data["from"] = params.From
protocols := serverconfigs.AllServerProtocolsForType(params.ServerType) protocols := serverconfigs.AllServerProtocolsForType(params.ServerType)
if len(params.Protocol) > 0 { if len(params.Protocol) > 0 {
result := []maps.Map{} result := []maps.Map{}

View File

@@ -1,5 +1,5 @@
Vue.component("network-addresses-box", { Vue.component("network-addresses-box", {
props: ["v-server-type", "v-addresses", "v-protocol", "v-name"], props: ["v-server-type", "v-addresses", "v-protocol", "v-name", "v-from"],
data: function () { data: function () {
let addresses = this.vAddresses let addresses = this.vAddresses
if (addresses == null) { if (addresses == null) {
@@ -15,10 +15,16 @@ Vue.component("network-addresses-box", {
name = "addresses" name = "addresses"
} }
let from = this.vFrom
if (from == null) {
from = ""
}
return { return {
addresses: addresses, addresses: addresses,
protocol: protocol, protocol: protocol,
name: name name: name,
from: from
} }
}, },
watch: { watch: {
@@ -35,7 +41,7 @@ Vue.component("network-addresses-box", {
addAddr: function () { addAddr: function () {
let that = this let that = this
window.UPDATING_ADDR = null window.UPDATING_ADDR = null
teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol, { teaweb.popup("/servers/addPortPopup?serverType=" + this.vServerType + "&protocol=" + this.protocol + "&from=" + this.from, {
height: "16em", height: "16em",
callback: function (resp) { callback: function (resp) {
var addr = resp.data.address var addr = resp.data.address

View File

@@ -12,7 +12,7 @@
<tr> <tr>
<td>GRPC监听端口 *</td> <td>GRPC监听端口 *</td>
<td> <td>
<network-addresses-box :v-name="'listensJSON'" :v-server-type="'httpWeb'" @change="changeListens"></network-addresses-box> <network-addresses-box :v-name="'listensJSON'" :v-server-type="'httpWeb'" @change="changeListens" :v-from="'apiNode'"></network-addresses-box>
<p class="comment">通过GRPC访问API节点进程监听的网络端口。</p> <p class="comment">通过GRPC访问API节点进程监听的网络端口。</p>
</td> </td>
</tr> </tr>

View File

@@ -17,7 +17,7 @@
<tr> <tr>
<td>GRPC监听端口 *</td> <td>GRPC监听端口 *</td>
<td> <td>
<network-addresses-box :v-name="'listensJSON'" :v-server-type="'httpWeb'" :v-addresses="node.listens" @change="changeListens"></network-addresses-box> <network-addresses-box :v-name="'listensJSON'" :v-server-type="'httpWeb'" :v-addresses="node.listens" @change="changeListens" :v-from="'apiNode'"></network-addresses-box>
<p class="comment">通过GRPC访问API节点进程监听的网络端口。</p> <p class="comment">通过GRPC访问API节点进程监听的网络端口。</p>
</td> </td>
</tr> </tr>

View File

@@ -17,8 +17,8 @@
<td> <td>
<input type="text" name="address" ref="focus" v-model="address"/> <input type="text" name="address" ref="focus" v-model="address"/>
<p class="comment">可以是一个数字端口通常不超过65535也可以是"地址:端口"的方式。 <p class="comment">可以是一个数字端口通常不超过65535也可以是"地址:端口"的方式。
<span v-if="protocol == 'http'">HTTP常用端口为<a href="" title="点击添加" @click.prevent="addPort('80')">80</a></span> <span v-if="from.length == 0 && protocol == 'http'">HTTP常用端口为<a href="" title="点击添加" @click.prevent="addPort('80')">80</a></span>
<span v-if="protocol == 'https'">HTTPS常用端口为<a href="" title="点击添加" @click.prevent="addPort('443')">443</a></span> <span v-if="from.length == 0 && protocol == 'https'">HTTPS常用端口为<a href="" title="点击添加" @click.prevent="addPort('443')">443</a></span>
</p> </p>
</td> </td>
</tr> </tr>

View File

@@ -7,10 +7,13 @@ Tea.context(function () {
this.protocol = this.protocols[0].code this.protocol = this.protocols[0].code
// 初始化 // 初始化
if (this.protocol == "http") { // from 用来标记是否为特殊的节点
this.address = "80" if (this.from.length == 0) {
} else if (this.protocol == "https") { if (this.protocol == "http") {
this.address = "443" this.address = "80"
} else if (this.protocol == "https") {
this.address = "443"
}
} }
if (window.parent.UPDATING_ADDR != null) { if (window.parent.UPDATING_ADDR != null) {
@@ -25,6 +28,9 @@ Tea.context(function () {
} }
this.changeProtocol = function () { this.changeProtocol = function () {
if (this.from.length > 0) {
return
}
switch (this.protocol) { switch (this.protocol) {
case "http": case "http":
this.address = "80" this.address = "80"