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

55 lines
1.1 KiB
Go
Raw Normal View History

2020-07-22 22:19:39 +08:00
package actionutils
import (
"github.com/iwind/TeaGo/actions"
)
2023-05-27 17:05:17 +08:00
type TabItem struct {
Name string `json:"name"`
SubName string `json:"subName"`
URL string `json:"url"`
Icon string `json:"icon"`
IsActive bool `json:"isActive"`
IsRight bool `json:"isRight"`
IsTitle bool `json:"isTitle"`
IsDisabled bool `json:"isDisabled"`
}
// Tabbar Tabbar定义
2020-07-22 22:19:39 +08:00
type Tabbar struct {
2023-05-27 17:05:17 +08:00
items []*TabItem
2020-07-22 22:19:39 +08:00
}
// NewTabbar 获取新对象
2020-07-22 22:19:39 +08:00
func NewTabbar() *Tabbar {
return &Tabbar{
2023-05-27 17:05:17 +08:00
items: []*TabItem{},
2020-07-22 22:19:39 +08:00
}
}
// Add 添加菜单项
2023-05-27 17:05:17 +08:00
func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) *TabItem {
var m = &TabItem{
Name: name,
SubName: subName,
URL: url,
Icon: icon,
IsActive: active,
IsRight: false,
IsTitle: false,
IsDisabled: false,
2020-07-22 22:19:39 +08:00
}
this.items = append(this.items, m)
return m
}
// Items 取得所有的Items
2023-05-27 17:05:17 +08:00
func (this *Tabbar) Items() []*TabItem {
2020-07-22 22:19:39 +08:00
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()
}