阶段性提交

This commit is contained in:
刘祥超
2020-09-13 20:37:07 +08:00
parent 9093019c73
commit ec3c0cafb3
155 changed files with 1317 additions and 13193 deletions

View 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"
}

View 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()
}

View 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()
})
}

View File

@@ -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
}

View File

@@ -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"
}

View File

@@ -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()
}

View File

@@ -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()
})
}

View File

@@ -10,6 +10,7 @@ type IndexAction struct {
func (this *IndexAction) Init() {
this.Nav("", "component", "index")
this.SecondMenu("global")
}
func (this *IndexAction) RunGet(params struct{}) {

View File

@@ -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()

View File

@@ -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"
}

View 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()
}

View 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()
})
}

View File

@@ -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"
}

View 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()
}

View 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()
})
}

View File

@@ -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"
}

View 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()
}

View 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()
})
}