mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-26 12:16:39 +08:00
阶段性提交
This commit is contained in:
22
internal/web/actions/default/servers/components/cache/helper.go
vendored
Normal file
22
internal/web/actions/default/servers/components/cache/helper.go
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
}
|
||||
|
||||
func NewHelper() *Helper {
|
||||
return &Helper{}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
|
||||
action.Data["mainTab"] = "component"
|
||||
action.Data["secondMenuItem"] = "cache"
|
||||
}
|
||||
18
internal/web/actions/default/servers/components/cache/index.go
vendored
Normal file
18
internal/web/actions/default/servers/components/cache/index.go
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.FirstMenu("index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
this.Show()
|
||||
}
|
||||
19
internal/web/actions/default/servers/components/cache/init.go
vendored
Normal file
19
internal/web/actions/default/servers/components/cache/init.go
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/componentutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(componentutils.NewComponentHelper()).
|
||||
Prefix("/servers/components/cache").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package componentutils
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ComponentHelper struct {
|
||||
}
|
||||
|
||||
func NewComponentHelper() *ComponentHelper {
|
||||
return &ComponentHelper{}
|
||||
}
|
||||
|
||||
func (this *ComponentHelper) BeforeAction(action *actions.ActionObject) {
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
action.Data["teaMenu"] = "server"
|
||||
action.Data["mainTab"] = "component"
|
||||
|
||||
// 顶部标签栏
|
||||
selectedTabbar := action.Data.GetString("mainTab")
|
||||
tabbar := actionutils.NewTabbar()
|
||||
tabbar.Add("服务", "", "/servers", "", selectedTabbar == "server")
|
||||
tabbar.Add("组件", "", "/servers/components", "", selectedTabbar == "component")
|
||||
actionutils.SetTabbar(action, tabbar)
|
||||
|
||||
// 创建左侧菜单
|
||||
secondMenuItem := action.Data.GetString("secondMenuItem")
|
||||
action.Data["leftMenuItems"] = this.createLeftMenus(secondMenuItem)
|
||||
}
|
||||
|
||||
func (this *ComponentHelper) createLeftMenus(secondMenuItem string) (items []maps.Map) {
|
||||
items = append(items, maps.Map{
|
||||
"name": "通用设置",
|
||||
"url": "/servers/components",
|
||||
"isActive": secondMenuItem == "global",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "分组设置",
|
||||
"url": "/servers/components/group",
|
||||
"isActive": secondMenuItem == "group",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "缓存策略",
|
||||
"url": "/servers/components/cache",
|
||||
"isActive": secondMenuItem == "cache",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "WAF策略",
|
||||
"url": "/servers/components/waf",
|
||||
"isActive": secondMenuItem == "waf",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "日志策略",
|
||||
"url": "/servers/components/log",
|
||||
"isActive": secondMenuItem == "log",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "SSL证书管理",
|
||||
"url": "/servers/components/ssl",
|
||||
"isActive": secondMenuItem == "ssl",
|
||||
})
|
||||
/**items = append(items, maps.Map{
|
||||
"name": "Gzip规则",
|
||||
"url": "/servers/components/gzip",
|
||||
"isActive": secondMenuItem == "gzip",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "路径规则",
|
||||
"url": "/servers/components/location",
|
||||
"isActive": secondMenuItem == "location",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "重写规则",
|
||||
"url": "/servers/components/rewrite",
|
||||
"isActive": secondMenuItem == "write",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "源站",
|
||||
"url": "/servers/components/origin",
|
||||
"isActive": secondMenuItem == "origin",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "变量",
|
||||
"url": "/servers/components/variable",
|
||||
"isActive": secondMenuItem == "variable",
|
||||
})**/
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
}
|
||||
|
||||
func NewHelper() *Helper {
|
||||
return &Helper{}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
|
||||
action.Data["mainTab"] = "component"
|
||||
action.Data["secondMenuItem"] = "group"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.FirstMenu("index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
this.Show()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/componentutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(componentutils.NewComponentHelper()).
|
||||
Prefix("/servers/components/group").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -10,6 +10,7 @@ type IndexAction struct {
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "component", "index")
|
||||
this.SecondMenu("global")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/componentutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
@@ -10,6 +11,7 @@ func init() {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(componentutils.NewComponentHelper()).
|
||||
Prefix("/servers/components").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
}
|
||||
|
||||
func NewHelper() *Helper {
|
||||
return &Helper{}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
|
||||
action.Data["mainTab"] = "component"
|
||||
action.Data["secondMenuItem"] = "log"
|
||||
}
|
||||
18
internal/web/actions/default/servers/components/log/index.go
Normal file
18
internal/web/actions/default/servers/components/log/index.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.FirstMenu("index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
this.Show()
|
||||
}
|
||||
19
internal/web/actions/default/servers/components/log/init.go
Normal file
19
internal/web/actions/default/servers/components/log/init.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/componentutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(componentutils.NewComponentHelper()).
|
||||
Prefix("/servers/components/log").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package ssl
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
}
|
||||
|
||||
func NewHelper() *Helper {
|
||||
return &Helper{}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
|
||||
action.Data["mainTab"] = "component"
|
||||
action.Data["secondMenuItem"] = "ssl"
|
||||
}
|
||||
18
internal/web/actions/default/servers/components/ssl/index.go
Normal file
18
internal/web/actions/default/servers/components/ssl/index.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package ssl
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.FirstMenu("index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
this.Show()
|
||||
}
|
||||
19
internal/web/actions/default/servers/components/ssl/init.go
Normal file
19
internal/web/actions/default/servers/components/ssl/init.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package ssl
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/componentutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(componentutils.NewComponentHelper()).
|
||||
Prefix("/servers/components/ssl").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
}
|
||||
|
||||
func NewHelper() *Helper {
|
||||
return &Helper{}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
|
||||
action.Data["mainTab"] = "component"
|
||||
action.Data["secondMenuItem"] = "waf"
|
||||
}
|
||||
18
internal/web/actions/default/servers/components/waf/index.go
Normal file
18
internal/web/actions/default/servers/components/waf/index.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.FirstMenu("index")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
this.Show()
|
||||
}
|
||||
19
internal/web/actions/default/servers/components/waf/init.go
Normal file
19
internal/web/actions/default/servers/components/waf/init.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/componentutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(NewHelper()).
|
||||
Helper(componentutils.NewComponentHelper()).
|
||||
Prefix("/servers/components/waf").
|
||||
Get("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user