优化代码

This commit is contained in:
刘祥超
2022-07-11 14:42:38 +08:00
parent a3412b2f95
commit 0415cd3719
2 changed files with 23 additions and 23 deletions

View File

@@ -44,7 +44,7 @@ func (this *IndexAction) RunGet(params struct {
}
// 常用的服务
latestServerMaps := []maps.Map{}
var latestServerMaps = []maps.Map{}
if !isSearching {
serversResp, err := this.RPC().ServerRPC().FindLatestServers(this.AdminContext(), &pb.FindLatestServersRequest{Size: 6})
if err != nil {
@@ -81,8 +81,8 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err)
return
}
count := countResp.Count
page := this.NewPage(count)
var count = countResp.Count
var page = this.NewPage(count)
this.Data["page"] = page.AsHTML()
// 服务列表
@@ -100,9 +100,9 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err)
return
}
serverMaps := []maps.Map{}
var serverMaps = []maps.Map{}
for _, server := range serversResp.Servers {
config := &serverconfigs.ServerConfig{}
var config = &serverconfigs.ServerConfig{}
err = json.Unmarshal(server.Config, config)
if err != nil {
this.ErrorPage(err)
@@ -110,8 +110,8 @@ func (this *IndexAction) RunGet(params struct {
}
// 端口列表
portMaps := []maps.Map{}
if len(server.HttpJSON) > 0 && config.HTTP.IsOn {
var portMaps = []maps.Map{}
if config.HTTP != nil && config.HTTP.IsOn {
for _, listen := range config.HTTP.Listen {
portMaps = append(portMaps, maps.Map{
"protocol": listen.Protocol,
@@ -161,7 +161,7 @@ func (this *IndexAction) RunGet(params struct {
}
// 分组
groupMaps := []maps.Map{}
var groupMaps = []maps.Map{}
if len(server.ServerGroups) > 0 {
for _, group := range server.ServerGroups {
groupMaps = append(groupMaps, maps.Map{
@@ -172,11 +172,11 @@ func (this *IndexAction) RunGet(params struct {
}
// 域名列表
serverNames := []*serverconfigs.ServerNameConfig{}
var serverNames = []*serverconfigs.ServerNameConfig{}
if server.IsAuditing || (server.AuditingResult != nil && !server.AuditingResult.IsOk) {
server.ServerNamesJSON = server.AuditingServerNamesJSON
}
auditingIsOk := true
var auditingIsOk = true
if !server.IsAuditing && server.AuditingResult != nil && !server.AuditingResult.IsOk {
auditingIsOk = false
}
@@ -187,7 +187,7 @@ func (this *IndexAction) RunGet(params struct {
return
}
}
countServerNames := 0
var countServerNames = 0
for _, serverName := range serverNames {
if len(serverName.SubNames) == 0 {
countServerNames++
@@ -248,7 +248,7 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err)
return
}
clusterMaps := []maps.Map{}
var clusterMaps = []maps.Map{}
for _, cluster := range clustersResp.NodeClusters {
clusterMaps = append(clusterMaps, maps.Map{
"id": cluster.Id,
@@ -263,9 +263,9 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err)
return
}
groupMaps := []maps.Map{}
var groupMaps = []maps.Map{}
for _, group := range groupsResp.ServerGroups {
groupName := group.Name
var groupName = group.Name
groupMaps = append(groupMaps, maps.Map{
"id": group.Id,
"name": groupName,