Files
EdgeAdmin/internal/web/actions/actionutils/tabbar.go

43 lines
816 B
Go
Raw Normal View History

2020-07-22 22:19:39 +08:00
package actionutils
import (
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
// Tabbar Tabbar定义
2020-07-22 22:19:39 +08:00
type Tabbar struct {
items []maps.Map
}
// NewTabbar 获取新对象
2020-07-22 22:19:39 +08:00
func NewTabbar() *Tabbar {
return &Tabbar{
items: []maps.Map{},
}
}
// Add 添加菜单项
2020-07-22 22:19:39 +08:00
func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) maps.Map {
m := maps.Map{
"name": name,
"subName": subName,
"url": url,
"icon": icon,
"active": active,
2020-08-21 12:32:16 +08:00
"right": false,
2020-07-22 22:19:39 +08:00
}
this.items = append(this.items, m)
return m
}
// Items 取得所有的Items
2020-07-22 22:19:39 +08:00
func (this *Tabbar) Items() []maps.Map {
return this.items
}
// SetTabbar 设置子菜单
2020-07-22 22:19:39 +08:00
func SetTabbar(action actions.ActionWrapper, tabbar *Tabbar) {
action.Object().Data["teaTabbar"] = tabbar.Items()
}