优化代码

This commit is contained in:
GoEdgeLab
2022-01-06 11:13:36 +08:00
parent c3104f88ce
commit 62a327befd
13 changed files with 52 additions and 20 deletions

View File

@@ -47,7 +47,7 @@ func (this *IndexAction) RunGet(params struct {
return return
} }
countryMaps := []maps.Map{} countryMaps := []maps.Map{}
for _, country := range countriesResp.Countries { for _, country := range countriesResp.RegionCountries {
countryMaps = append(countryMaps, maps.Map{ countryMaps = append(countryMaps, maps.Map{
"id": country.Id, "id": country.Id,
"name": country.Name, "name": country.Name,

View File

@@ -43,14 +43,14 @@ func (this *ProvincesAction) RunGet(params struct {
} }
provincesResp, err := this.RPC().RegionProvinceRPC().FindAllEnabledRegionProvincesWithCountryId(this.AdminContext(), &pb.FindAllEnabledRegionProvincesWithCountryIdRequest{ provincesResp, err := this.RPC().RegionProvinceRPC().FindAllEnabledRegionProvincesWithCountryId(this.AdminContext(), &pb.FindAllEnabledRegionProvincesWithCountryIdRequest{
CountryId: int64(ChinaCountryId), RegionCountryId: int64(ChinaCountryId),
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
provinceMaps := []maps.Map{} provinceMaps := []maps.Map{}
for _, province := range provincesResp.Provinces { for _, province := range provincesResp.RegionProvinces {
provinceMaps = append(provinceMaps, maps.Map{ provinceMaps = append(provinceMaps, maps.Map{
"id": province.Id, "id": province.Id,
"name": province.Name, "name": province.Name,

View File

@@ -52,7 +52,7 @@ func (this *CountriesAction) RunGet(params struct {
return return
} }
countryMaps := []maps.Map{} countryMaps := []maps.Map{}
for _, country := range countriesResp.Countries { for _, country := range countriesResp.RegionCountries {
countryMaps = append(countryMaps, maps.Map{ countryMaps = append(countryMaps, maps.Map{
"id": country.Id, "id": country.Id,
"name": country.Name, "name": country.Name,

View File

@@ -47,14 +47,14 @@ func (this *ProvincesAction) RunGet(params struct {
} }
provincesResp, err := this.RPC().RegionProvinceRPC().FindAllEnabledRegionProvincesWithCountryId(this.AdminContext(), &pb.FindAllEnabledRegionProvincesWithCountryIdRequest{ provincesResp, err := this.RPC().RegionProvinceRPC().FindAllEnabledRegionProvincesWithCountryId(this.AdminContext(), &pb.FindAllEnabledRegionProvincesWithCountryIdRequest{
CountryId: int64(ChinaCountryId), RegionCountryId: int64(ChinaCountryId),
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
provinceMaps := []maps.Map{} provinceMaps := []maps.Map{}
for _, province := range provincesResp.Provinces { for _, province := range provincesResp.RegionProvinces {
provinceMaps = append(provinceMaps, maps.Map{ provinceMaps = append(provinceMaps, maps.Map{
"id": province.Id, "id": province.Id,
"name": province.Name, "name": province.Name,

View File

@@ -31,12 +31,12 @@ func (this *IndexAction) RunGet(params struct{}) {
// 国家和地区 // 国家和地区
countryMaps := []maps.Map{} countryMaps := []maps.Map{}
for _, countryId := range config.AllowCountryIds { for _, countryId := range config.AllowCountryIds {
countryResp, err := this.RPC().RegionCountryRPC().FindEnabledRegionCountry(this.AdminContext(), &pb.FindEnabledRegionCountryRequest{CountryId: countryId}) countryResp, err := this.RPC().RegionCountryRPC().FindEnabledRegionCountry(this.AdminContext(), &pb.FindEnabledRegionCountryRequest{RegionCountryId: countryId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
country := countryResp.Country country := countryResp.RegionCountry
if country != nil { if country != nil {
countryMaps = append(countryMaps, maps.Map{ countryMaps = append(countryMaps, maps.Map{
"id": country.Id, "id": country.Id,
@@ -49,12 +49,12 @@ func (this *IndexAction) RunGet(params struct{}) {
// 省份 // 省份
provinceMaps := []maps.Map{} provinceMaps := []maps.Map{}
for _, provinceId := range config.AllowProvinceIds { for _, provinceId := range config.AllowProvinceIds {
provinceResp, err := this.RPC().RegionProvinceRPC().FindEnabledRegionProvince(this.AdminContext(), &pb.FindEnabledRegionProvinceRequest{ProvinceId: provinceId}) provinceResp, err := this.RPC().RegionProvinceRPC().FindEnabledRegionProvince(this.AdminContext(), &pb.FindEnabledRegionProvinceRequest{RegionProvinceId: provinceId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
province := provinceResp.Province province := provinceResp.RegionProvince
if province != nil { if province != nil {
provinceMaps = append(provinceMaps, maps.Map{ provinceMaps = append(provinceMaps, maps.Map{
"id": province.Id, "id": province.Id,

View File

@@ -29,7 +29,7 @@ func (this *SelectCountriesPopupAction) RunGet(params struct {
return return
} }
countryMaps := []maps.Map{} countryMaps := []maps.Map{}
for _, country := range countriesResp.Countries { for _, country := range countriesResp.RegionCountries {
countryMaps = append(countryMaps, maps.Map{ countryMaps = append(countryMaps, maps.Map{
"id": country.Id, "id": country.Id,
"name": country.Name, "name": country.Name,
@@ -50,12 +50,12 @@ func (this *SelectCountriesPopupAction) RunPost(params struct {
}) { }) {
countryMaps := []maps.Map{} countryMaps := []maps.Map{}
for _, countryId := range params.CountryIds { for _, countryId := range params.CountryIds {
countryResp, err := this.RPC().RegionCountryRPC().FindEnabledRegionCountry(this.AdminContext(), &pb.FindEnabledRegionCountryRequest{CountryId: countryId}) countryResp, err := this.RPC().RegionCountryRPC().FindEnabledRegionCountry(this.AdminContext(), &pb.FindEnabledRegionCountryRequest{RegionCountryId: countryId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
country := countryResp.Country country := countryResp.RegionCountry
if country == nil { if country == nil {
continue continue
} }

View File

@@ -24,13 +24,13 @@ func (this *SelectProvincesPopupAction) RunGet(params struct {
}) { }) {
selectedProvinceIds := utils.SplitNumbers(params.ProvinceIds) selectedProvinceIds := utils.SplitNumbers(params.ProvinceIds)
provincesResp, err := this.RPC().RegionProvinceRPC().FindAllEnabledRegionProvincesWithCountryId(this.AdminContext(), &pb.FindAllEnabledRegionProvincesWithCountryIdRequest{CountryId: ChinaCountryId}) provincesResp, err := this.RPC().RegionProvinceRPC().FindAllEnabledRegionProvincesWithCountryId(this.AdminContext(), &pb.FindAllEnabledRegionProvincesWithCountryIdRequest{RegionCountryId: ChinaCountryId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
provinceMaps := []maps.Map{} provinceMaps := []maps.Map{}
for _, province := range provincesResp.Provinces { for _, province := range provincesResp.RegionProvinces {
provinceMaps = append(provinceMaps, maps.Map{ provinceMaps = append(provinceMaps, maps.Map{
"id": province.Id, "id": province.Id,
"name": province.Name, "name": province.Name,
@@ -50,12 +50,12 @@ func (this *SelectProvincesPopupAction) RunPost(params struct {
}) { }) {
provinceMaps := []maps.Map{} provinceMaps := []maps.Map{}
for _, provinceId := range params.ProvinceIds { for _, provinceId := range params.ProvinceIds {
provinceResp, err := this.RPC().RegionProvinceRPC().FindEnabledRegionProvince(this.AdminContext(), &pb.FindEnabledRegionProvinceRequest{ProvinceId: provinceId}) provinceResp, err := this.RPC().RegionProvinceRPC().FindEnabledRegionProvince(this.AdminContext(), &pb.FindEnabledRegionProvinceRequest{RegionProvinceId: provinceId})
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
province := provinceResp.Province province := provinceResp.RegionProvince
if province == nil { if province == nil {
continue continue
} }

View File

@@ -13,4 +13,17 @@
.node-logs-box::-webkit-scrollbar { .node-logs-box::-webkit-scrollbar {
width: 4px; width: 4px;
} }
.server-name-td {
position: relative;
}
.server-name-td .icon.setting {
display: none;
position: absolute;
right: 1em;
top: 50%;
margin-top: -1em;
}
.server-name-td:hover .icon.setting {
display: inline;
}
/*# sourceMappingURL=index.css.map */ /*# sourceMappingURL=index.css.map */

View File

@@ -1 +1 @@
{"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,GAAG,QACF,MAAK;EACJ,kBAAA;EACA,UAAA;EACA,UAAA;;AAJF,GAAG,QAOF;EACC,kBAAA;;AAIF;EACC,gBAAA;EACA,gBAAA;;AAGD,cAAc;EACb,UAAA","file":"index.css"} {"version":3,"sources":["index.less"],"names":[],"mappings":"AAAA,GAAG,QACF,MAAK;EACJ,kBAAA;EACA,UAAA;EACA,UAAA;;AAJF,GAAG,QAOF;EACC,kBAAA;;AAIF;EACC,gBAAA;EACA,gBAAA;;AAGD,cAAc;EACb,UAAA;;AAGD;EACC,kBAAA;;AADD,eAGC,MAAK;EACJ,aAAA;EACA,kBAAA;EACA,UAAA;EACA,QAAA;EACA,gBAAA;;AAIF,eAAe,MACd,MAAK;EACJ,eAAA","file":"index.css"}

View File

@@ -81,7 +81,7 @@
</tr> </tr>
</thead> </thead>
<tr v-for="server in servers"> <tr v-for="server in servers">
<td><a :href="'/servers/server?serverId=' + server.id"><keyword :v-word="keyword">{{server.name}}</keyword></a> <td class="server-name-td"><a :href="'/servers/server?serverId=' + server.id"><keyword :v-word="keyword">{{server.name}}</keyword></a> &nbsp; <a :href="'/servers/server/settings?serverId=' + server.id" title="设置"><i class="icon setting grey"></i></a>
<div style="margin-top:0.4em"> <div style="margin-top:0.4em">
<grey-label>{{server.serverTypeName}}</grey-label> <grey-label>{{server.serverTypeName}}</grey-label>
</div> </div>

View File

@@ -17,4 +17,22 @@
.node-logs-box::-webkit-scrollbar { .node-logs-box::-webkit-scrollbar {
width: 4px; width: 4px;
}
.server-name-td {
position: relative;
.icon.setting {
display: none;
position: absolute;
right: 1em;
top: 50%;
margin-top: -1em;
}
}
.server-name-td:hover {
.icon.setting {
display: inline;
}
} }

View File

@@ -26,7 +26,7 @@
<td>支持的状态码</td> <td>支持的状态码</td>
<td> <td>
<http-status-box></http-status-box> <http-status-box></http-status-box>
<p class="comment">只有在设置响应Header时才会起作用</p> <p class="comment">不填表示支持所有的状态码</p>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -27,6 +27,7 @@
<td>支持的状态码</td> <td>支持的状态码</td>
<td> <td>
<http-status-box :v-status-list="statusList"></http-status-box> <http-status-box :v-status-list="statusList"></http-status-box>
<p class="comment">不填表示支持所有的状态码。</p>
</td> </td>
</tr> </tr>
<tr> <tr>