mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	[网站域名]在列表中可以查看网站域名列表,并可以筛选
This commit is contained in:
		@@ -19,6 +19,7 @@ func init() {
 | 
			
		||||
			GetPost("/addPortPopup", new(AddPortPopupAction)).
 | 
			
		||||
			GetPost("/addServerNamePopup", new(AddServerNamePopupAction)).
 | 
			
		||||
			GetPost("/addOriginPopup", new(AddOriginPopupAction)).
 | 
			
		||||
			Get("/serverNamesPopup", new(ServerNamesPopupAction)).
 | 
			
		||||
			EndAll()
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										46
									
								
								internal/web/actions/default/servers/serverNamesPopup.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								internal/web/actions/default/servers/serverNamesPopup.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
package servers
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type ServerNamesPopupAction struct {
 | 
			
		||||
	actionutils.ParentAction
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *ServerNamesPopupAction) Init() {
 | 
			
		||||
	this.Nav("", "", "")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *ServerNamesPopupAction) RunGet(params struct {
 | 
			
		||||
	ServerId int64
 | 
			
		||||
}) {
 | 
			
		||||
	serverNamesResp, err := this.RPC().ServerRPC().FindServerNames(this.AdminContext(), &pb.FindServerNamesRequest{ServerId: params.ServerId})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	serverNames := []*serverconfigs.ServerNameConfig{}
 | 
			
		||||
	if len(serverNamesResp.ServerNamesJSON) > 0 {
 | 
			
		||||
		err = json.Unmarshal(serverNamesResp.ServerNamesJSON, &serverNames)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			this.ErrorPage(err)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	result := []string{}
 | 
			
		||||
	for _, serverName := range serverNames {
 | 
			
		||||
		if len(serverName.SubNames) == 0 {
 | 
			
		||||
			result = append(result, serverName.Name)
 | 
			
		||||
		} else {
 | 
			
		||||
			result = append(result, serverName.SubNames...)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	this.Data["serverNames"] = result
 | 
			
		||||
 | 
			
		||||
	this.Show()
 | 
			
		||||
}
 | 
			
		||||
@@ -40,6 +40,18 @@ Vue.component("link-popup", {
 | 
			
		||||
	template: `<a href="" :title="title" @click.prevent="clickPrevent"><slot></slot></a>`
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
Vue.component("popup-icon", {
 | 
			
		||||
	props: ["title", "href", "height"],
 | 
			
		||||
	methods: {
 | 
			
		||||
		clickPrevent: function () {
 | 
			
		||||
			teaweb.popup(this.href, {
 | 
			
		||||
				height: this.height
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	template: `<span><slot></slot> <a href="" :title="title" @click.prevent="clickPrevent"><i class="icon clone outline small"></i></a></span>`
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
// 小提示
 | 
			
		||||
Vue.component("tip-icon", {
 | 
			
		||||
	props: ["content"],
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@
 | 
			
		||||
			<span v-if="server.serverNames.length > 0">
 | 
			
		||||
				<span v-if="server.serverNames[0].subNames == null || server.serverNames[0].subNames.length == 0">{{server.serverNames[0].name}}</span>
 | 
			
		||||
				<span v-else>{{server.serverNames[0].subNames[0]}}</span>
 | 
			
		||||
				<span v-if="server.countServerNames > 1">等{{server.countServerNames}}个域名</span>
 | 
			
		||||
				<span v-if="server.countServerNames > 1">等{{server.countServerNames}}个域名 <popup-icon :href="'/servers/serverNamesPopup?serverId=' + server.id" height="20em"></popup-icon></span>
 | 
			
		||||
			</span>
 | 
			
		||||
			<span v-else class="disabled">-</span>
 | 
			
		||||
		</td>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								web/views/@default/servers/serverNamesPopup.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								web/views/@default/servers/serverNamesPopup.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
{$layout "layout_popup"}
 | 
			
		||||
 | 
			
		||||
<h3>查看域名</h3>
 | 
			
		||||
 | 
			
		||||
<form class="ui form">
 | 
			
		||||
    <input type="text" name="keyword" v-model="keyword" placeholder="输入关键词搜索" ref="focus" autocomplete="off"/>
 | 
			
		||||
</form>
 | 
			
		||||
 | 
			
		||||
<div style="margin-top: 1em">
 | 
			
		||||
    <span v-for="serverName in serverNames" class="ui label basic" style="margin-bottom: 0.5em">{{serverName}}</span>
 | 
			
		||||
</div>
 | 
			
		||||
							
								
								
									
										14
									
								
								web/views/@default/servers/serverNamesPopup.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								web/views/@default/servers/serverNamesPopup.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
Tea.context(function () {
 | 
			
		||||
	let allServerNames = this.serverNames.$copy();
 | 
			
		||||
 | 
			
		||||
	this.keyword = ""
 | 
			
		||||
 | 
			
		||||
	this.$delay(function () {
 | 
			
		||||
		let that = this
 | 
			
		||||
		this.$watch("keyword", function (keyword) {
 | 
			
		||||
			that.serverNames = allServerNames.$findAll(function (k, serverName) {
 | 
			
		||||
				return teaweb.match(serverName, keyword)
 | 
			
		||||
			})
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
})
 | 
			
		||||
		Reference in New Issue
	
	Block a user