优化界面

This commit is contained in:
GoEdgeLab
2023-05-27 17:05:17 +08:00
parent 7d424c9a9c
commit 4730d79469
4 changed files with 58 additions and 25 deletions

View File

@@ -2,38 +2,49 @@ package actionutils
import ( import (
"github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
) )
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定义 // Tabbar Tabbar定义
type Tabbar struct { type Tabbar struct {
items []maps.Map items []*TabItem
} }
// NewTabbar 获取新对象 // NewTabbar 获取新对象
func NewTabbar() *Tabbar { func NewTabbar() *Tabbar {
return &Tabbar{ return &Tabbar{
items: []maps.Map{}, items: []*TabItem{},
} }
} }
// Add 添加菜单项 // Add 添加菜单项
func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) maps.Map { func (this *Tabbar) Add(name string, subName string, url string, icon string, active bool) *TabItem {
m := maps.Map{ var m = &TabItem{
"name": name, Name: name,
"subName": subName, SubName: subName,
"url": url, URL: url,
"icon": icon, Icon: icon,
"active": active, IsActive: active,
"right": false, IsRight: false,
"isTitle": false, IsTitle: false,
IsDisabled: false,
} }
this.items = append(this.items, m) this.items = append(this.items, m)
return m return m
} }
// Items 取得所有的Items // Items 取得所有的Items
func (this *Tabbar) Items() []maps.Map { func (this *Tabbar) Items() []*TabItem {
return this.items return this.items
} }

View File

@@ -29,9 +29,9 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
action.Data["teaMenu"] = "clusters" action.Data["teaMenu"] = "clusters"
selectedTabbar := action.Data.GetString("mainTab") var selectedTabbar = action.Data.GetString("mainTab")
clusterId := action.ParamInt64("clusterId") var clusterId = action.ParamInt64("clusterId")
clusterIdString := strconv.FormatInt(clusterId, 10) var clusterIdString = strconv.FormatInt(clusterId, 10)
action.Data["clusterId"] = clusterId action.Data["clusterId"] = clusterId
if clusterId > 0 { if clusterId > 0 {
@@ -57,18 +57,39 @@ func (this *ClusterHelper) BeforeAction(actionPtr actions.ActionWrapper) (goNext
return return
} }
var nodeId = action.ParamInt64("nodeId")
var isInCluster = nodeId <= 0
var tabbar = actionutils.NewTabbar() var tabbar = actionutils.NewTabbar()
tabbar.Add("", "", "/clusters", "arrow left", false) tabbar.Add("", "", "/clusters", "arrow left", false)
{ {
var item = tabbar.Add(cluster.Name, "", "/clusters/cluster?clusterId="+clusterIdString, "angle right", true) var url = "/clusters/cluster?clusterId=" + clusterIdString
item["isTitle"] = true if !isInCluster {
url = "/clusters/cluster/nodes?clusterId=" + clusterIdString
}
var item = tabbar.Add(cluster.Name, "", url, "angle right", true)
item.IsTitle = true
} }
if teaconst.IsPlus { if teaconst.IsPlus {
tabbar.Add("看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board") {
var item = tabbar.Add("集群看板", "", "/clusters/cluster/boards?clusterId="+clusterIdString, "chart line area", selectedTabbar == "board")
item.IsDisabled = !isInCluster
}
}
{
var item = tabbar.Add("节点列表", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node")
item.IsDisabled = !isInCluster
}
{
var item = tabbar.Add("集群设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting")
item.IsDisabled = !isInCluster
}
{
var item = tabbar.Add("删除集群", "", "/clusters/cluster/delete?clusterId="+clusterIdString, "trash", selectedTabbar == "delete")
item.IsDisabled = !isInCluster
} }
tabbar.Add("节点", "", "/clusters/cluster/nodes?clusterId="+clusterIdString, "server", selectedTabbar == "node")
tabbar.Add("设置", "", "/clusters/cluster/settings?clusterId="+clusterIdString, "setting", selectedTabbar == "setting")
tabbar.Add("删除", "", "/clusters/cluster/delete?clusterId="+clusterIdString, "trash", selectedTabbar == "delete")
actionutils.SetTabbar(action, tabbar) actionutils.SetTabbar(action, tabbar)
// 左侧菜单 // 左侧菜单

View File

@@ -110,7 +110,7 @@ func (this *ServerHelper) createLeftMenu(action *actions.ActionObject) {
tabbar.Add("", "", "/servers", "left arrow", false) tabbar.Add("", "", "/servers", "left arrow", false)
if len(serverConfig.Name) > 0 { if len(serverConfig.Name) > 0 {
var item = tabbar.Add(serverConfig.Name, "", "/servers/server?serverId="+serverIdString, "angle right", true) var item = tabbar.Add(serverConfig.Name, "", "/servers/server?serverId="+serverIdString, "angle right", true)
item["isTitle"] = true item.IsTitle = true
} }
if teaconst.IsPlus { if teaconst.IsPlus {

View File

@@ -107,9 +107,10 @@
<div class="main" :class="{'without-menu':teaSubMenus.menus == null || teaSubMenus.menus.length == 0 || (teaSubMenus.menus.length == 1 && teaSubMenus.menus[0].alwaysActive), 'without-secondary-menu':teaSubMenus.alwaysMenu == null || teaSubMenus.alwaysMenu.items.length <= 1, 'without-footer':!teaShowOpenSourceInfo}" v-cloak=""> <div class="main" :class="{'without-menu':teaSubMenus.menus == null || teaSubMenus.menus.length == 0 || (teaSubMenus.menus.length == 1 && teaSubMenus.menus[0].alwaysActive), 'without-secondary-menu':teaSubMenus.alwaysMenu == null || teaSubMenus.alwaysMenu.items.length <= 1, 'without-footer':!teaShowOpenSourceInfo}" v-cloak="">
<!-- 操作菜单 --> <!-- 操作菜单 -->
<div class="ui top menu tabular tab-menu small" v-if="teaTabbar.length > 1"> <div class="ui top menu tabular tab-menu small" v-if="teaTabbar.length > 1">
<a class="item" v-for="item in teaTabbar" :class="{'active':item.active, right:item.right, title: item.isTitle, icon: item.icon != null && item.icon.length > 0}" :href="item.url"> <a class="item" v-for="item in teaTabbar" :class="{'active':item.isActive && !item.isDisabled, right:item.isRight, title: item.isTitle, icon: item.icon != null && item.icon.length > 0, disabled: item.isDisabled}" :href="item.url">
<var>{{item.name}}<span v-if="item.subName.length > 0">({{item.subName}})</span><i class="icon small" :class="item.icon" v-if="item.icon != null && item.icon.length > 0"></i> </var> <var>{{item.name}}<span v-if="item.subName.length > 0">({{item.subName}})</span><i class="icon small" :class="item.icon" v-if="item.icon != null && item.icon.length > 0"></i> </var>
<div class="bottom-indicator" v-if="item.active && !item.isTitle"></div> <var v-if="item.isTitle && typeof _data.node == 'object'">{{node.name}}</var>
<div class="bottom-indicator" v-if="item.isActive && !item.isTitle"></div>
</a> </a>
</div> </div>