mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-08 16:00:26 +08:00
实现菜单的状态显示
This commit is contained in:
@@ -2,6 +2,7 @@ package locationutils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -28,9 +29,9 @@ func (this *LocationHelper) BeforeAction(actionPtr actions.ActionWrapper) {
|
|||||||
action.Data["mainMenu"] = "server"
|
action.Data["mainMenu"] = "server"
|
||||||
action.Data["mainTab"] = "setting"
|
action.Data["mainTab"] = "setting"
|
||||||
action.Data["secondMenuItem"] = "locations"
|
action.Data["secondMenuItem"] = "locations"
|
||||||
action.Data["tinyLeftMenuItems"] = this.createMenus(serverIdString, locationIdString, action.Data.GetString("tinyMenuItem"))
|
|
||||||
|
|
||||||
// 路径信息
|
// 路径信息
|
||||||
|
var currentLocationConfig *serverconfigs.HTTPLocationConfig = nil
|
||||||
parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
|
parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
|
||||||
if parentActionValue.IsValid() {
|
if parentActionValue.IsValid() {
|
||||||
parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
|
parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
|
||||||
@@ -42,32 +43,41 @@ func (this *LocationHelper) BeforeAction(actionPtr actions.ActionWrapper) {
|
|||||||
}
|
}
|
||||||
action.Data["locationId"] = locationId
|
action.Data["locationId"] = locationId
|
||||||
action.Data["locationConfig"] = locationConfig
|
action.Data["locationConfig"] = locationConfig
|
||||||
|
currentLocationConfig = locationConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 左侧菜单
|
||||||
|
action.Data["tinyLeftMenuItems"] = this.createMenus(serverIdString, locationIdString, action.Data.GetString("tinyMenuItem"), currentLocationConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *LocationHelper) createMenus(serverIdString string, locationIdString string, secondMenuItem string) []maps.Map {
|
func (this *LocationHelper) createMenus(serverIdString string, locationIdString string, secondMenuItem string, locationConfig *serverconfigs.HTTPLocationConfig) []maps.Map {
|
||||||
menuItems := []maps.Map{
|
menuItems := []maps.Map{
|
||||||
{
|
|
||||||
|
}
|
||||||
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "基本信息",
|
"name": "基本信息",
|
||||||
"url": "/servers/server/settings/locations/location?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/location?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "basic",
|
"isActive": secondMenuItem == "basic",
|
||||||
},
|
"isOff": locationConfig != nil && !locationConfig.IsOn,
|
||||||
}
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTP",
|
"name": "HTTP",
|
||||||
"url": "/servers/server/settings/locations/http?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/http?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "http",
|
"isActive": secondMenuItem == "http",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.RedirectToHttps != nil && locationConfig.Web.RedirectToHttps.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Web设置",
|
"name": "Web设置",
|
||||||
"url": "/servers/server/settings/locations/web?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/web?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "web",
|
"isActive": secondMenuItem == "web",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Root != nil && locationConfig.Web.Root.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "反向代理",
|
"name": "反向代理",
|
||||||
"url": "/servers/server/settings/locations/reverseProxy?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/reverseProxy?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "reverseProxy",
|
"isActive": secondMenuItem == "reverseProxy",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.ReverseProxyRef != nil && locationConfig.ReverseProxyRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "重写规则",
|
"name": "重写规则",
|
||||||
@@ -83,11 +93,13 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
|
|||||||
"name": "WAF",
|
"name": "WAF",
|
||||||
"url": "/servers/server/settings/locations/waf?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/waf?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "waf",
|
"isActive": secondMenuItem == "waf",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FirewallRef != nil && locationConfig.Web.FirewallRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "缓存",
|
"name": "缓存",
|
||||||
"url": "/servers/server/settings/locations/cache?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/cache?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "cache",
|
"isActive": secondMenuItem == "cache",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.CacheRef != nil && locationConfig.Web.CacheRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "-",
|
"name": "-",
|
||||||
@@ -98,36 +110,43 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
|
|||||||
"name": "字符编码",
|
"name": "字符编码",
|
||||||
"url": "/servers/server/settings/locations/charset?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/charset?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "charset",
|
"isActive": secondMenuItem == "charset",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.Charset != nil && locationConfig.Web.Charset.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "访问日志",
|
"name": "访问日志",
|
||||||
"url": "/servers/server/settings/locations/accessLog?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/accessLog?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "accessLog",
|
"isActive": secondMenuItem == "accessLog",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.AccessLogRef != nil && locationConfig.Web.AccessLogRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "统计",
|
"name": "统计",
|
||||||
"url": "/servers/server/settings/locations/stat?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/stat?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "stat",
|
"isActive": secondMenuItem == "stat",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.StatRef != nil && locationConfig.Web.StatRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Gzip压缩",
|
"name": "Gzip压缩",
|
||||||
"url": "/servers/server/settings/locations/gzip?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/gzip?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "gzip",
|
"isActive": secondMenuItem == "gzip",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.GzipRef != nil && locationConfig.Web.GzipRef.IsPrior,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "特殊页面",
|
"name": "特殊页面",
|
||||||
"url": "/servers/server/settings/locations/pages?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/pages?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "pages",
|
"isActive": secondMenuItem == "pages",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && (len(locationConfig.Web.Pages) > 0 || (locationConfig.Web.Shutdown != nil && locationConfig.Web.Shutdown.IsPrior)),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTP Header",
|
"name": "HTTP Header",
|
||||||
"url": "/servers/server/settings/locations/headers?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/headers?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "header",
|
"isActive": secondMenuItem == "header",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && ((locationConfig.Web.RequestHeaderPolicyRef != nil && locationConfig.Web.RequestHeaderPolicyRef.IsPrior) || (locationConfig.Web.ResponseHeaderPolicyRef != nil && locationConfig.Web.ResponseHeaderPolicyRef.IsPrior)),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Websocket",
|
"name": "Websocket",
|
||||||
"url": "/servers/server/settings/locations/websocket?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
"url": "/servers/server/settings/locations/websocket?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||||
"isActive": secondMenuItem == "websocket",
|
"isActive": secondMenuItem == "websocket",
|
||||||
|
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.WebsocketRef != nil && locationConfig.Web.WebsocketRef.IsPrior,
|
||||||
})
|
})
|
||||||
|
|
||||||
return menuItems
|
return menuItems
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ func (this *SettingAction) RunPost(params struct {
|
|||||||
RequestHost: reverseProxyConfig.RequestHost,
|
RequestHost: reverseProxyConfig.RequestHost,
|
||||||
RequestURI: reverseProxyConfig.RequestURI,
|
RequestURI: reverseProxyConfig.RequestURI,
|
||||||
StripPrefix: reverseProxyConfig.StripPrefix,
|
StripPrefix: reverseProxyConfig.StripPrefix,
|
||||||
|
AutoFlush: reverseProxyConfig.AutoFlush,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ func (this *SettingAction) RunPost(params struct {
|
|||||||
RequestHost: reverseProxyConfig.RequestHost,
|
RequestHost: reverseProxyConfig.RequestHost,
|
||||||
RequestURI: reverseProxyConfig.RequestURI,
|
RequestURI: reverseProxyConfig.RequestURI,
|
||||||
StripPrefix: reverseProxyConfig.StripPrefix,
|
StripPrefix: reverseProxyConfig.StripPrefix,
|
||||||
|
AutoFlush: reverseProxyConfig.AutoFlush,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
|
|||||||
"name": "基本信息",
|
"name": "基本信息",
|
||||||
"url": "/servers/server/settings?serverId=" + serverIdString,
|
"url": "/servers/server/settings?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "basic",
|
"isActive": secondMenuItem == "basic",
|
||||||
|
"isOff": !serverConfig.IsOn,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,31 +152,37 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
|
|||||||
"name": "域名",
|
"name": "域名",
|
||||||
"url": "/servers/server/settings/serverNames?serverId=" + serverIdString,
|
"url": "/servers/server/settings/serverNames?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "serverName",
|
"isActive": secondMenuItem == "serverName",
|
||||||
|
"isOn": len(serverConfig.ServerNames) > 0,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTP",
|
"name": "HTTP",
|
||||||
"url": "/servers/server/settings/http?serverId=" + serverIdString,
|
"url": "/servers/server/settings/http?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "http",
|
"isActive": secondMenuItem == "http",
|
||||||
|
"isOn": (serverConfig.HTTP != nil && serverConfig.HTTP.IsOn && len(serverConfig.HTTP.Listen) > 0) || (serverConfig.Web != nil && serverConfig.Web.RedirectToHttps != nil && serverConfig.Web.RedirectToHttps.IsOn),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTPS",
|
"name": "HTTPS",
|
||||||
"url": "/servers/server/settings/https?serverId=" + serverIdString,
|
"url": "/servers/server/settings/https?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "https",
|
"isActive": secondMenuItem == "https",
|
||||||
|
"isOn": serverConfig.HTTPS != nil && serverConfig.HTTPS.IsOn && len(serverConfig.HTTPS.Listen) > 0,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Web设置",
|
"name": "Web设置",
|
||||||
"url": "/servers/server/settings/web?serverId=" + serverIdString,
|
"url": "/servers/server/settings/web?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "web",
|
"isActive": secondMenuItem == "web",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.Root != nil && serverConfig.Web.Root.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "反向代理",
|
"name": "反向代理",
|
||||||
"url": "/servers/server/settings/reverseProxy?serverId=" + serverIdString,
|
"url": "/servers/server/settings/reverseProxy?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "reverseProxy",
|
"isActive": secondMenuItem == "reverseProxy",
|
||||||
|
"isOn": serverConfig.ReverseProxyRef != nil && serverConfig.ReverseProxyRef.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "路径规则",
|
"name": "路径规则",
|
||||||
"url": "/servers/server/settings/locations?serverId=" + serverIdString,
|
"url": "/servers/server/settings/locations?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "locations",
|
"isActive": secondMenuItem == "locations",
|
||||||
|
"isOn": serverConfig.Web != nil && len(serverConfig.Web.Locations) > 0,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "重写规则",
|
"name": "重写规则",
|
||||||
@@ -191,11 +198,13 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
|
|||||||
"name": "WAF",
|
"name": "WAF",
|
||||||
"url": "/servers/server/settings/waf?serverId=" + serverIdString,
|
"url": "/servers/server/settings/waf?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "waf",
|
"isActive": secondMenuItem == "waf",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.FirewallRef != nil && serverConfig.Web.FirewallRef.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "缓存",
|
"name": "缓存",
|
||||||
"url": "/servers/server/settings/cache?serverId=" + serverIdString,
|
"url": "/servers/server/settings/cache?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "cache",
|
"isActive": secondMenuItem == "cache",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.CacheRef != nil && serverConfig.Web.CacheRef.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "-",
|
"name": "-",
|
||||||
@@ -206,64 +215,76 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
|
|||||||
"name": "字符编码",
|
"name": "字符编码",
|
||||||
"url": "/servers/server/settings/charset?serverId=" + serverIdString,
|
"url": "/servers/server/settings/charset?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "charset",
|
"isActive": secondMenuItem == "charset",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.Charset != nil && serverConfig.Web.Charset.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "访问日志",
|
"name": "访问日志",
|
||||||
"url": "/servers/server/settings/accessLog?serverId=" + serverIdString,
|
"url": "/servers/server/settings/accessLog?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "accessLog",
|
"isActive": secondMenuItem == "accessLog",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.AccessLogRef != nil && serverConfig.Web.AccessLogRef.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "统计",
|
"name": "统计",
|
||||||
"url": "/servers/server/settings/stat?serverId=" + serverIdString,
|
"url": "/servers/server/settings/stat?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "stat",
|
"isActive": secondMenuItem == "stat",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.StatRef != nil && serverConfig.Web.StatRef.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Gzip压缩",
|
"name": "Gzip压缩",
|
||||||
"url": "/servers/server/settings/gzip?serverId=" + serverIdString,
|
"url": "/servers/server/settings/gzip?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "gzip",
|
"isActive": secondMenuItem == "gzip",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.GzipRef != nil && serverConfig.Web.GzipRef.IsOn,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "特殊页面",
|
"name": "特殊页面",
|
||||||
"url": "/servers/server/settings/pages?serverId=" + serverIdString,
|
"url": "/servers/server/settings/pages?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "pages",
|
"isActive": secondMenuItem == "pages",
|
||||||
|
"isOn": serverConfig.Web != nil && (len(serverConfig.Web.Pages) > 0 || (serverConfig.Web.Shutdown != nil && serverConfig.Web.Shutdown.IsOn)),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "HTTP Header",
|
"name": "HTTP Header",
|
||||||
"url": "/servers/server/settings/headers?serverId=" + serverIdString,
|
"url": "/servers/server/settings/headers?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "header",
|
"isActive": secondMenuItem == "header",
|
||||||
|
"isOn": serverConfig.Web != nil && ((serverConfig.Web.RequestHeaderPolicyRef != nil && serverConfig.Web.RequestHeaderPolicyRef.IsOn) || (serverConfig.Web.ResponseHeaderPolicyRef != nil && serverConfig.Web.ResponseHeaderPolicyRef.IsOn)),
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Websocket",
|
"name": "Websocket",
|
||||||
"url": "/servers/server/settings/websocket?serverId=" + serverIdString,
|
"url": "/servers/server/settings/websocket?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "websocket",
|
"isActive": secondMenuItem == "websocket",
|
||||||
|
"isOn": serverConfig.Web != nil && serverConfig.Web.WebsocketRef != nil && serverConfig.Web.WebsocketRef.IsOn,
|
||||||
})
|
})
|
||||||
} else if serverConfig.IsTCP() {
|
} else if serverConfig.IsTCP() {
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "TCP",
|
"name": "TCP",
|
||||||
"url": "/servers/server/settings/tcp?serverId=" + serverIdString,
|
"url": "/servers/server/settings/tcp?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "tcp",
|
"isActive": secondMenuItem == "tcp",
|
||||||
|
"isOn": serverConfig.TCP != nil && serverConfig.TCP.IsOn && len(serverConfig.TCP.Listen) > 0,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "TLS",
|
"name": "TLS",
|
||||||
"url": "/servers/server/settings/tls?serverId=" + serverIdString,
|
"url": "/servers/server/settings/tls?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "tls",
|
"isActive": secondMenuItem == "tls",
|
||||||
|
"isOn": serverConfig.TLS != nil && serverConfig.TLS.IsOn && len(serverConfig.TLS.Listen) > 0,
|
||||||
})
|
})
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "反向代理",
|
"name": "反向代理",
|
||||||
"url": "/servers/server/settings/reverseProxy?serverId=" + serverIdString,
|
"url": "/servers/server/settings/reverseProxy?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "reverseProxy",
|
"isActive": secondMenuItem == "reverseProxy",
|
||||||
|
"isOn": serverConfig.ReverseProxyRef != nil && serverConfig.ReverseProxyRef.IsOn,
|
||||||
})
|
})
|
||||||
} else if serverConfig.IsUnix() {
|
} else if serverConfig.IsUnix() {
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "Unix",
|
"name": "Unix",
|
||||||
"url": "/servers/server/settings/unix?serverId=" + serverIdString,
|
"url": "/servers/server/settings/unix?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "unix",
|
"isActive": secondMenuItem == "unix",
|
||||||
|
"isOn": serverConfig.Unix != nil && serverConfig.Unix.IsOn && len(serverConfig.Unix.Listen) > 0,
|
||||||
})
|
})
|
||||||
} else if serverConfig.IsUDP() {
|
} else if serverConfig.IsUDP() {
|
||||||
menuItems = append(menuItems, maps.Map{
|
menuItems = append(menuItems, maps.Map{
|
||||||
"name": "UDP",
|
"name": "UDP",
|
||||||
"url": "/servers/server/settings/udp?serverId=" + serverIdString,
|
"url": "/servers/server/settings/udp?serverId=" + serverIdString,
|
||||||
"isActive": secondMenuItem == "udp",
|
"isActive": secondMenuItem == "udp",
|
||||||
|
"isOn": serverConfig.UDP != nil && serverConfig.UDP.IsOn && len(serverConfig.UDP.Listen) > 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,27 @@ Vue.component("http-gzip-box", {
|
|||||||
gzip: gzip,
|
gzip: gzip,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
isOn: function () {
|
||||||
|
return (!this.vIsLocation || this.vGzipRef.isPrior) && this.vGzipRef.isOn
|
||||||
|
}
|
||||||
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
<input type="hidden" name="gzipRefJSON" :value="JSON.stringify(vGzipRef)"/>
|
<input type="hidden" name="gzipRefJSON" :value="JSON.stringify(vGzipRef)"/>
|
||||||
<table class="ui table selectable definition">
|
<table class="ui table selectable definition">
|
||||||
<prior-checkbox :v-config="vGzipRef" v-if="vIsLocation"></prior-checkbox>
|
<prior-checkbox :v-config="vGzipRef" v-if="vIsLocation"></prior-checkbox>
|
||||||
<tbody v-show="!vIsLocation || vGzipRef.isPrior">
|
<tbody v-show="!vIsLocation || vGzipRef.isPrior">
|
||||||
|
<tr>
|
||||||
|
<td class="title">启用压缩</td>
|
||||||
|
<td>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input type="checkbox" v-model="vGzipRef.isOn"/>
|
||||||
|
<label></label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tbody v-show="isOn()">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">压缩级别</td>
|
<td class="title">压缩级别</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
71
web/public/js/components/server/http-location-labels.js
Normal file
71
web/public/js/components/server/http-location-labels.js
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
Vue.component("http-location-labels", {
|
||||||
|
props: ["v-location-config"],
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
location: this.vLocationConfig
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 判断是否已启用某配置
|
||||||
|
configIsOn: function (config) {
|
||||||
|
return config != null && config.isPrior && config.isOn
|
||||||
|
},
|
||||||
|
|
||||||
|
refIsOn: function (ref, config) {
|
||||||
|
return this.configIsOn(ref) && config != null && config.isOn
|
||||||
|
},
|
||||||
|
|
||||||
|
len: function (arr) {
|
||||||
|
return (arr == null) ? 0 : arr.length
|
||||||
|
}
|
||||||
|
},
|
||||||
|
template: ` <div class="labels-box">
|
||||||
|
<!-- TODO 思考是否给各个标签加上链接 -->
|
||||||
|
<!-- redirectToHTTPS -->
|
||||||
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.redirectToHTTPS)">自动跳转HTTPS</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- Web -->
|
||||||
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.root)">文档根目录</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- 反向代理 -->
|
||||||
|
<http-location-labels-label v-if="refIsOn(location.reverseProxyRef, location.reverseProxy)">反向代理</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- WAF -->
|
||||||
|
<!-- TODO -->
|
||||||
|
|
||||||
|
<!-- Cache -->
|
||||||
|
<!-- TODO -->
|
||||||
|
|
||||||
|
<!-- Charset -->
|
||||||
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.charset) && location.web.charset.charset.length > 0">{{location.web.charset.charset}}</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- 访问日志 -->
|
||||||
|
<!-- TODO -->
|
||||||
|
|
||||||
|
<!-- 统计 -->
|
||||||
|
<!-- TODO -->
|
||||||
|
|
||||||
|
<!-- Gzip -->
|
||||||
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.gzipRef, location.web.gzip) && location.web.gzip.level > 0">Gzip:{{location.web.gzip.level}}</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- HTTP Header -->
|
||||||
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.requestHeaderPolicyRef, location.web.requestHeaderPolicy) && (len(location.web.requestHeaderPolicy.addHeaders) > 0 || len(location.web.requestHeaderPolicy.setHeaders) > 0 || len(location.web.requestHeaderPolicy.replaceHeaders) > 0 || len(location.web.requestHeaderPolicy.deleteHeaders) > 0)">请求Header</http-location-labels-label>
|
||||||
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.responseHeaderPolicyRef, location.web.responseHeaderPolicy) && (len(location.web.responseHeaderPolicy.addHeaders) > 0 || len(location.web.responseHeaderPolicy.setHeaders) > 0 || len(location.web.responseHeaderPolicy.replaceHeaders) > 0 || len(location.web.responseHeaderPolicy.deleteHeaders) > 0)">响应Header</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- Websocket -->
|
||||||
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.websocketRef, location.web.websocket)">Websocket</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- 特殊页面 -->
|
||||||
|
<div v-if="location.web != null && location.web.pages != null && location.web.pages.length > 0">
|
||||||
|
<http-location-labels-label v-for="page in location.web.pages">[状态码{{page.status[0]}}] -> {{page.url}}</http-location-labels-label>
|
||||||
|
</div>
|
||||||
|
<div v-if="location.web != null && configIsOn(location.web.shutdown)">
|
||||||
|
<http-location-labels-label :v-class="'red'">临时关闭</http-location-labels-label>
|
||||||
|
</div>
|
||||||
|
</div>`
|
||||||
|
})
|
||||||
|
|
||||||
|
Vue.component("http-location-labels-label", {
|
||||||
|
props: ["v-class"],
|
||||||
|
template: `<span class="ui label tiny" :class="vClass" style="font-size:0.8em;padding:4px;margin-top:0.3em;margin-bottom:0.3em"><slot></slot></span>`
|
||||||
|
})
|
||||||
@@ -58,19 +58,29 @@ Vue.component("reverse-proxy-box", {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>请求URI</td>
|
<td>请求URI<em>(RequestURI)</em></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" placeholder="\${requestURI}" v-model="reverseProxyConfig.requestURI"/>
|
<input type="text" placeholder="\${requestURI}" v-model="reverseProxyConfig.requestURI"/>
|
||||||
<p class="comment">\${requestURI}为完整的请求URI,可以使用类似于"\${requestURI}?arg1=value1&arg2=value2"的形式添加你的参数。</p>
|
<p class="comment">\${requestURI}为完整的请求URI,可以使用类似于"\${requestURI}?arg1=value1&arg2=value2"的形式添加你的参数。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>去除URL前缀</td>
|
<td>去除URL前缀<em>(StripPrefix)</em></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" v-model="reverseProxyConfig.stripPrefix" placeholder="/PREFIX"/>
|
<input type="text" v-model="reverseProxyConfig.stripPrefix" placeholder="/PREFIX"/>
|
||||||
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span>。 </p>
|
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span>。 </p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>是否自动刷新缓存区<em>(AutoFlush)</em></td>
|
||||||
|
<td>
|
||||||
|
<div class="ui checkbox">
|
||||||
|
<input type="checkbox" v-model="reverseProxyConfig.autoFlush"/>
|
||||||
|
<label></label>
|
||||||
|
</div>
|
||||||
|
<p class="comment">开启后将自动刷新缓冲区数据到客户端,在类似于SSE(server-sent events)等场景下很有用。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="margin"></div>
|
<div class="margin"></div>
|
||||||
|
|||||||
@@ -28,6 +28,18 @@
|
|||||||
margin-top: 0 !important;
|
margin-top: 0 !important;
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
.left-box .menu .item.on span {
|
||||||
|
border-bottom: 1px #666 dashed;
|
||||||
|
}
|
||||||
|
.left-box .menu .item.off span var {
|
||||||
|
font-style: normal;
|
||||||
|
background: #db2828;
|
||||||
|
color: white;
|
||||||
|
font-size: 8px;
|
||||||
|
padding: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
.left-box .menu .header {
|
.left-box .menu .header {
|
||||||
border-bottom: 1px #ddd solid;
|
border-bottom: 1px #ddd solid;
|
||||||
padding-left: 0 !important;
|
padding-left: 0 !important;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
<div class="left-box" :class="{disabled:leftMenuItemIsDisabled}">
|
<div class="left-box" :class="{disabled:leftMenuItemIsDisabled}">
|
||||||
<div class="ui menu text blue vertical small">
|
<div class="ui menu text blue vertical small">
|
||||||
<a class="item" v-for="item in leftMenuItems" :href="item.url" :class="{active:item.isActive, separator:item.name == '-'}">
|
<a class="item" v-for="item in leftMenuItems" :href="item.url" :class="{active:item.isActive, separator:item.name == '-', on:item.isOn, off:item.isOff}">
|
||||||
<span v-if="item.name != '-'"><i class="icon play tiny" :style="{'visibility':item.isActive ? 'visible' : 'hidden'}"></i>{{item.name}}</span>
|
<span v-if="item.name != '-'"><i class="icon play tiny" :style="{'visibility':item.isActive ? 'visible' : 'hidden'}"></i>{{item.name}}<var v-if="item.isOff">关</var></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,6 +31,25 @@
|
|||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item.on {
|
||||||
|
span {
|
||||||
|
border-bottom: 1px #666 dashed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.item.off {
|
||||||
|
span {
|
||||||
|
var {
|
||||||
|
font-style: normal;
|
||||||
|
background: #db2828;
|
||||||
|
color: white;
|
||||||
|
font-size: 8px;
|
||||||
|
padding: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
margin-left: 1em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// .header需要在.item下面
|
// .header需要在.item下面
|
||||||
.header {
|
.header {
|
||||||
border-bottom: 1px #ddd solid;
|
border-bottom: 1px #ddd solid;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
<div class="left-box tiny">
|
<div class="left-box tiny">
|
||||||
<div class="ui menu text blue vertical tiny">
|
<div class="ui menu text blue vertical tiny">
|
||||||
<a class="item" v-for="item in tinyLeftMenuItems" :href="item.url" :class="{active:item.isActive, separator:item.name == '-'}">
|
<a class="item" v-for="item in tinyLeftMenuItems" :href="item.url" :class="{active:item.isActive, separator:item.name == '-', on:item.isOn, off:item.isOff}">
|
||||||
<span v-if="item.name != '-'"><i class="icon play tiny" :style="{'visibility':item.isActive ? 'visible' : 'hidden'}"></i>{{item.name}}</span>
|
<i class="icon play tiny" :style="{'visibility':item.isActive ? 'visible' : 'hidden'}"></i><span v-if="item.name != '-'">{{item.name}}<var v-if="item.isOff">关</var></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
undefined
|
||||||
@@ -16,7 +16,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr v-for="location in locations">
|
<tr v-for="location in locations">
|
||||||
<td>{{location.pattern}}</td>
|
<td>
|
||||||
|
{{location.pattern}}
|
||||||
|
<http-location-labels :v-location-config="location"></http-location-labels>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label-on :v-is-on="location.isOn"></label-on>
|
<label-on :v-is-on="location.isOn"></label-on>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
|
// 删除路径规则
|
||||||
this.deleteLocation = function (locationId) {
|
this.deleteLocation = function (locationId) {
|
||||||
teaweb.confirm("确定要删除此路径规则吗?", function () {
|
teaweb.confirm("确定要删除此路径规则吗?", function () {
|
||||||
this.$post(".delete")
|
this.$post(".delete")
|
||||||
|
|||||||
Reference in New Issue
Block a user