diff --git a/server/desc/api/manage/menu.api b/server/desc/api/manage/menu.api index f09a968..cdedf2b 100644 --- a/server/desc/api/manage/menu.api +++ b/server/desc/api/manage/menu.api @@ -55,26 +55,29 @@ type ListRequest { } type SystemMenu { - id uint64 `json:"id"` - parentId uint64 `json:"parentId"` - menuType string `json:"menuType"` - menuName string `json:"menuName"` - routeName string `json:"routeName"` - routePath string `json:"routePath"` - component string `json:"component"` - icon string `json:"icon"` - iconType string `json:"iconType"` - buttonCode string `json:"buttonCode"` - permissions []Permission `json:"permissions"` - order uint64 `json:"order"` - i18nKey string `json:"i18nKey"` - status string `json:"status"` - keepAlive bool `json:"keepAlive"` - constant bool `json:"constant"` - hideInMenu bool `json:"hideInMenu"` - multiTab bool `json:"mutiTab"` - activeMenu string `json:"activeMenu"` - children []SystemMenu `json:"children"` + id uint64 `json:"id"` + activeMenu string `json:"activeMenu,optional"` + menuType string `json:"menuType"` + menuName string `json:"menuName"` + routeName string `json:"routeName"` + routePath string `json:"routePath"` + component string `json:"component"` + icon string `json:"icon"` + iconType string `json:"iconType"` + parentId uint64 `json:"parentId"` + status string `json:"status"` + keepAlive bool `json:"keepAlive"` + constant bool `json:"constant"` + order uint64 `json:"order"` + hideInMenu bool `json:"hideInMenu"` + href string `json:"href,optional"` + multiTab bool `json:"multiTab,optional"` + fixedIndexInTab bool `json:"fixedIndexInTab,optional"` + query []Query `json:"query,optional"` + buttonCode string `json:"buttonCode,optional"` + permissions []Permission `json:"permissions,optional"` + i18nKey string `json:"i18nKey,optional"` + children []SystemMenu `json:"children"` } type ListResponse { diff --git a/server/desc/api/route/route.api b/server/desc/api/route/route.api index d7f32ae..29c161f 100644 --- a/server/desc/api/route/route.api +++ b/server/desc/api/route/route.api @@ -17,15 +17,23 @@ type Route { } type RouteMeta { - title string `json:"title"` - i18nKey string `json:"i18nKey"` - icon string `json:"icon"` - order int `json:"order"` - hideInMenu bool `json:"hideInMenu"` - activeMenu string `json:"activeMenu"` - multiTab bool `json:"multiTab"` - keepAlive bool `json:"keepAlive"` - constant bool `json:"constant"` + title string `json:"title"` + i18nKey string `json:"i18nKey"` + icon string `json:"icon"` + order int `json:"order"` + hideInMenu bool `json:"hideInMenu"` + activeMenu string `json:"activeMenu"` + multiTab bool `json:"multiTab"` + fixedIndexInTab int `json:"fixedIndexInTab"` + keepAlive bool `json:"keepAlive"` + constant bool `json:"constant"` + href string `json:"href"` + query []Query `json:"query"` +} + +type Query { + key string `json:"key"` + value string `json:"value"` } type GetConstantRoutesRequest {} diff --git a/server/desc/swagger/manage-menu.swagger.json b/server/desc/swagger/manage-menu.swagger.json index 69f6b50..d888149 100644 --- a/server/desc/swagger/manage-menu.swagger.json +++ b/server/desc/swagger/manage-menu.swagger.json @@ -571,9 +571,8 @@ "type": "integer", "format": "int64" }, - "parentId": { - "type": "integer", - "format": "int64" + "activeMenu": { + "type": "string" }, "menuType": { "type": "string" @@ -596,22 +595,10 @@ "iconType": { "type": "string" }, - "buttonCode": { - "type": "string" - }, - "permissions": { - "type": "array", - "items": { - "$ref": "#/definitions/Permission" - } - }, - "order": { + "parentId": { "type": "integer", "format": "int64" }, - "i18nKey": { - "type": "string" - }, "status": { "type": "string" }, @@ -623,15 +610,41 @@ "type": "boolean", "format": "boolean" }, + "order": { + "type": "integer", + "format": "int64" + }, "hideInMenu": { "type": "boolean", "format": "boolean" }, - "mutiTab": { + "href": { + "type": "string" + }, + "multiTab": { "type": "boolean", "format": "boolean" }, - "activeMenu": { + "fixedIndexInTab": { + "type": "boolean", + "format": "boolean" + }, + "query": { + "type": "array", + "items": { + "$ref": "#/definitions/Query" + } + }, + "buttonCode": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + }, + "i18nKey": { "type": "string" }, "children": { @@ -644,7 +657,6 @@ "title": "SystemMenu", "required": [ "id", - "parentId", "menuType", "menuName", "routeName", @@ -652,16 +664,12 @@ "component", "icon", "iconType", - "buttonCode", - "permissions", - "order", - "i18nKey", + "parentId", "status", "keepAlive", "constant", + "order", "hideInMenu", - "mutiTab", - "activeMenu", "children" ] }, diff --git a/server/desc/swagger/route.swagger.json b/server/desc/swagger/route.swagger.json index 02da79c..845567a 100644 --- a/server/desc/swagger/route.swagger.json +++ b/server/desc/swagger/route.swagger.json @@ -137,6 +137,22 @@ "type": "object", "title": "IsRouteExistRequest" }, + "Query": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "title": "Query", + "required": [ + "key", + "value" + ] + }, "Route": { "type": "object", "properties": { @@ -213,6 +229,10 @@ "type": "boolean", "format": "boolean" }, + "fixedIndexInTab": { + "type": "integer", + "format": "int32" + }, "keepAlive": { "type": "boolean", "format": "boolean" @@ -220,6 +240,15 @@ "constant": { "type": "boolean", "format": "boolean" + }, + "href": { + "type": "string" + }, + "query": { + "type": "array", + "items": { + "$ref": "#/definitions/Query" + } } }, "title": "RouteMeta", @@ -231,8 +260,11 @@ "hideInMenu", "activeMenu", "multiTab", + "fixedIndexInTab", "keepAlive", - "constant" + "constant", + "href", + "query" ] }, "boolean": { diff --git a/server/internal/logic/manage/menu/list.go b/server/internal/logic/manage/menu/list.go index e3465c0..f36eac9 100644 --- a/server/internal/logic/manage/menu/list.go +++ b/server/internal/logic/manage/menu/list.go @@ -5,6 +5,7 @@ import ( "encoding/json" "sort" + "github.com/jzero-io/jzero-contrib/condition" "github.com/spf13/cast" "github.com/zeromicro/go-zero/core/logx" @@ -30,7 +31,9 @@ func NewList(ctx context.Context, svcCtx *svc.ServiceContext) *List { func (l *List) List(req *types.ListRequest) (resp *types.ListResponse, err error) { resp = &types.ListResponse{} - list, err := l.svcCtx.Model.ManageMenu.FindByCondition(l.ctx, nil) + list, err := l.svcCtx.Model.ManageMenu.FindByCondition(l.ctx, nil, condition.NewChain(). + Equal("constant", false). + Build()...) if err != nil { return nil, err } @@ -62,28 +65,33 @@ func convert(list []*manage_menu.ManageMenu) []*types.SystemMenu { for _, item := range list { var menu types.SystemMenu var permissions []types.Permission + var query []types.Query Unmarshal(item.Permissions.String, &permissions) + Unmarshal(item.Query.String, &query) menu = types.SystemMenu{ - Id: item.Id, - ParentId: uint64(item.ParentId), - MenuType: item.MenuType, - MenuName: item.MenuName, - RouteName: item.RouteName, - RoutePath: item.RoutePath, - Component: item.Component, - Icon: item.Icon, - IconType: item.IconType, - Order: uint64(item.Order), - I18nKey: item.I18nKey, - Status: item.Status, - Constant: cast.ToBool(item.Constant), - HideInMenu: cast.ToBool(item.HideInMenu), - MultiTab: cast.ToBool(item.MultiTab), - KeepAlive: cast.ToBool(item.KeepAlive), - ActiveMenu: item.ActiveMenu.String, - ButtonCode: item.ButtonCode.String, - Permissions: permissions, - Children: nil, + Id: item.Id, + ActiveMenu: item.ActiveMenu.String, + MenuType: item.MenuType, + MenuName: item.MenuName, + RouteName: item.RouteName, + RoutePath: item.RoutePath, + Component: item.Component, + Icon: item.Icon, + IconType: item.IconType, + ParentId: uint64(item.ParentId), + Status: item.Status, + KeepAlive: cast.ToBool(item.KeepAlive), + Constant: cast.ToBool(item.Constant), + Order: uint64(item.Order), + HideInMenu: cast.ToBool(item.HideInMenu), + Href: item.Href.String, + MultiTab: cast.ToBool(item.MultiTab), + FixedIndexInTab: cast.ToBool(item.FixedIndexInTab), + Query: query, + ButtonCode: item.ButtonCode.String, + Permissions: permissions, + I18nKey: item.I18nKey, + Children: nil, } records = append(records, &menu) } diff --git a/server/internal/logic/manage/menu/tree.go b/server/internal/logic/manage/menu/tree.go index 1a8dfda..15bad79 100644 --- a/server/internal/logic/manage/menu/tree.go +++ b/server/internal/logic/manage/menu/tree.go @@ -30,7 +30,6 @@ func (l *Tree) Tree(req *types.TreeRequest) (resp []types.TreeResponse, err erro list, err := l.svcCtx.Model.ManageMenu.FindByCondition(l.ctx, nil, condition.NewChain(). NotEqual("constant", true). - NotEqual("hide_in_menu", true). Build()...) if err != nil { return nil, err diff --git a/server/internal/logic/route/get_user_routes.go b/server/internal/logic/route/get_user_routes.go index 5a40df9..c931d3c 100644 --- a/server/internal/logic/route/get_user_routes.go +++ b/server/internal/logic/route/get_user_routes.go @@ -10,6 +10,7 @@ import ( "github.com/zeromicro/go-zero/core/logx" "server/internal/auth" + "server/internal/logic/manage/menu" "server/internal/model/manage_menu" "server/internal/svc" types "server/internal/types/route" @@ -77,21 +78,28 @@ func convert(list []*manage_menu.ManageMenu) []*types.Route { var records []*types.Route for _, item := range list { var route types.Route + var query []types.Query + + menu.Unmarshal(item.Query.String, &query) + route = types.Route{ Id: int64(item.Id), ParentId: item.ParentId, Name: item.RouteName, Path: item.RoutePath, Meta: types.RouteMeta{ - Title: item.RouteName, - I18nKey: item.I18nKey, - Icon: item.Icon, - Order: int(item.Order), - HideInMenu: cast.ToBool(item.HideInMenu), - ActiveMenu: item.ActiveMenu.String, - MultiTab: cast.ToBool(item.MultiTab), - KeepAlive: cast.ToBool(item.KeepAlive), - Constant: cast.ToBool(item.Constant), + Title: item.RouteName, + I18nKey: item.I18nKey, + Icon: item.Icon, + Order: int(item.Order), + HideInMenu: cast.ToBool(item.HideInMenu), + ActiveMenu: item.ActiveMenu.String, + MultiTab: cast.ToBool(item.MultiTab), + FixedIndexInTab: int(item.FixedIndexInTab), + KeepAlive: cast.ToBool(item.KeepAlive), + Constant: cast.ToBool(item.Constant), + Href: item.Href.String, + Query: query, }, Component: item.Component, Props: strings.Contains(item.RoutePath, ":"), diff --git a/server/internal/types/manage/menu/types.go b/server/internal/types/manage/menu/types.go index 6906387..64816c2 100644 --- a/server/internal/types/manage/menu/types.go +++ b/server/internal/types/manage/menu/types.go @@ -113,26 +113,29 @@ type Query struct { } type SystemMenu struct { - Id uint64 `json:"id"` - ParentId uint64 `json:"parentId"` - MenuType string `json:"menuType"` - MenuName string `json:"menuName"` - RouteName string `json:"routeName"` - RoutePath string `json:"routePath"` - Component string `json:"component"` - Icon string `json:"icon"` - IconType string `json:"iconType"` - ButtonCode string `json:"buttonCode"` - Permissions []Permission `json:"permissions"` - Order uint64 `json:"order"` - I18nKey string `json:"i18nKey"` - Status string `json:"status"` - KeepAlive bool `json:"keepAlive"` - Constant bool `json:"constant"` - HideInMenu bool `json:"hideInMenu"` - MultiTab bool `json:"mutiTab"` - ActiveMenu string `json:"activeMenu"` - Children []SystemMenu `json:"children"` + Id uint64 `json:"id"` + ActiveMenu string `json:"activeMenu,optional"` + MenuType string `json:"menuType"` + MenuName string `json:"menuName"` + RouteName string `json:"routeName"` + RoutePath string `json:"routePath"` + Component string `json:"component"` + Icon string `json:"icon"` + IconType string `json:"iconType"` + ParentId uint64 `json:"parentId"` + Status string `json:"status"` + KeepAlive bool `json:"keepAlive"` + Constant bool `json:"constant"` + Order uint64 `json:"order"` + HideInMenu bool `json:"hideInMenu"` + Href string `json:"href,optional"` + MultiTab bool `json:"multiTab,optional"` + FixedIndexInTab bool `json:"fixedIndexInTab,optional"` + Query []Query `json:"query,optional"` + ButtonCode string `json:"buttonCode,optional"` + Permissions []Permission `json:"permissions,optional"` + I18nKey string `json:"i18nKey,optional"` + Children []SystemMenu `json:"children"` } type TreeRequest struct { diff --git a/server/internal/types/route/types.go b/server/internal/types/route/types.go index 5a5a13c..d8785de 100644 --- a/server/internal/types/route/types.go +++ b/server/internal/types/route/types.go @@ -31,6 +31,11 @@ type GetUserRoutesResponse struct { type IsRouteExistRequest struct { } +type Query struct { + Key string `json:"key"` + Value string `json:"value"` +} + type Route struct { Id int64 `json:"-"` ParentId int64 `json:"-"` @@ -44,13 +49,16 @@ type Route struct { } type RouteMeta struct { - Title string `json:"title"` - I18nKey string `json:"i18nKey"` - Icon string `json:"icon"` - Order int `json:"order"` - HideInMenu bool `json:"hideInMenu"` - ActiveMenu string `json:"activeMenu"` - MultiTab bool `json:"multiTab"` - KeepAlive bool `json:"keepAlive"` - Constant bool `json:"constant"` + Title string `json:"title"` + I18nKey string `json:"i18nKey"` + Icon string `json:"icon"` + Order int `json:"order"` + HideInMenu bool `json:"hideInMenu"` + ActiveMenu string `json:"activeMenu"` + MultiTab bool `json:"multiTab"` + FixedIndexInTab int `json:"fixedIndexInTab"` + KeepAlive bool `json:"keepAlive"` + Constant bool `json:"constant"` + Href string `json:"href"` + Query []Query `json:"query"` } diff --git a/web/src/views/manage/menu/index.vue b/web/src/views/manage/menu/index.vue index b1e2069..1498e46 100644 --- a/web/src/views/manage/menu/index.vue +++ b/web/src/views/manage/menu/index.vue @@ -248,6 +248,7 @@ init(); v-model:columns="columnChecks" :disabled-delete="checkedRowKeys.length === 0" :loading="loading" + add-auth="manage:menu:add" @add="handleAdd" @delete="handleBatchDelete" @refresh="getData" diff --git a/web/src/views/manage/menu/modules/menu-operate-modal.vue b/web/src/views/manage/menu/modules/menu-operate-modal.vue index 047a3e8..4447de5 100644 --- a/web/src/views/manage/menu/modules/menu-operate-modal.vue +++ b/web/src/views/manage/menu/modules/menu-operate-modal.vue @@ -185,7 +185,6 @@ async function getRoleOptions() { } function handleInitModel() { - console.log('operateType', props.operateType); Object.assign(model, createDefaultModel()); if (!props.rowData) return;