From ea1af4b253047d2dbacfb2551c9c4b7008ff7b41 Mon Sep 17 00:00:00 2001 From: yxh Date: Tue, 15 Mar 2022 18:26:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/app/system/model/sys_auth_rule.go | 14 ++++--- internal/app/system/service/sys_user.go | 45 +++++++++++++++------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/internal/app/system/model/sys_auth_rule.go b/internal/app/system/model/sys_auth_rule.go index 1e635c1..d1f231a 100644 --- a/internal/app/system/model/sys_auth_rule.go +++ b/internal/app/system/model/sys_auth_rule.go @@ -28,18 +28,22 @@ type SysAuthRuleInfoRes struct { } type UserMenu struct { - *SysAuthRuleInfoRes + Id uint `json:"id"` + Pid uint `json:"pid"` Index string `json:"index"` Name string `json:"name"` MenuName string `json:"menuName"` Component string `json:"component"` Path string `json:"path"` Meta struct { - Icon string `json:"icon"` - Title string `json:"title"` + Icon string `json:"icon"` + Title string `json:"title"` + IsLink string `json:"isLink"` + IsHide bool `json:"isHide"` + IsKeepAlive bool `json:"isKeepAlive"` + IsAffix bool `json:"isAffix"` + IsIframe bool `json:"isIframe"` } `json:"meta"` - Hidden bool `json:"hidden"` - AlwaysShow bool `json:"alwaysShow"` } type UserMenus struct { diff --git a/internal/app/system/service/sys_user.go b/internal/app/system/service/sys_user.go index 0686ba0..a7950c3 100644 --- a/internal/app/system/service/sys_user.go +++ b/internal/app/system/service/sys_user.go @@ -253,17 +253,36 @@ func (s *userImpl) GetMenusTree(menus []*model.UserMenus, pid uint) []*model.Use func (s *userImpl) setMenuData(menu *model.UserMenu, entity *model.SysAuthRuleInfoRes) *model.UserMenu { menu = &model.UserMenu{ - SysAuthRuleInfoRes: entity, - Index: entity.Name, - Name: gstr.UcFirst(entity.Path), - MenuName: entity.Title, + Id: entity.Id, + Pid: entity.Pid, + Index: entity.Name, + Name: gstr.UcFirst(entity.Path), + MenuName: entity.Title, Meta: struct { - Icon string `json:"icon"` - Title string `json:"title"` + Icon string `json:"icon"` + Title string `json:"title"` + IsLink string `json:"isLink"` + IsHide bool `json:"isHide"` + IsKeepAlive bool `json:"isKeepAlive"` + IsAffix bool `json:"isAffix"` + IsIframe bool `json:"isIframe"` }(struct { - Icon string - Title string - }{Icon: entity.Icon, Title: entity.Title}), + Icon string + Title string + IsLink string + IsHide bool + IsKeepAlive bool + IsAffix bool + IsIframe bool + }{ + Icon: entity.Icon, + Title: entity.Title, + IsLink: "", + IsHide: false, + IsKeepAlive: false, + IsAffix: false, + IsIframe: false, + }), } if entity.MenuType != 0 { menu.Component = entity.Component @@ -273,14 +292,14 @@ func (s *userImpl) setMenuData(menu *model.UserMenu, entity *model.SysAuthRuleIn menu.Path = "/" + entity.Path } if entity.AlwaysShow == 1 { - menu.Hidden = false + menu.Meta.IsHide = false } else { - menu.Hidden = true + menu.Meta.IsHide = true } if entity.AlwaysShow == 1 && entity.MenuType == 0 { - menu.AlwaysShow = true + menu.Meta.IsHide = true } else { - menu.AlwaysShow = false + menu.Meta.IsHide = false } return menu }