-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
动态参数菜单功能建议。 #824
Comments
我也在尝试实现这个功能, 因为层级参数对我们的项目是必须的: |
@thinkershare 我这个已经可以正常工作,支持多个参数的情况,上面的gif是实录。 比如 /device/:deviceId
/device/:deviceId/detail
/device/:deviceId/sub-device/:subDiviceId
/device/:deviceId/sub-device/:subDiviceId/detail
# 诸如此类 就是不知道实现方式是否影响性能。没经过测试。 也存在一个问题,就是 首次进入页面时,参数得存在(不过这应该也不是什么大问题) 另外,面包屑经过测试不能工作(具体我得去看看作者如何使用面包屑的) 我稍后会提一个pr上去,看看接不接受。 |
@thinkershare |
其实并不存在首次进入参数必须要存在的问题, 因为id?是可选的, 而且UI的路由匹配模式决定了id必须符合指定正则, 还有默认界面是没有通过导航栏进入的入口, 都是link进去的, 就不允许用户直接进入这个链接, 如果id不存在, 则页面会按照逻辑选择一个默认的id, 也就是说这里的路由参数需要检测3个模式: 一个是路由参数, 正则约束, 可选条件, 要这三都正常工作, 但没有id时候, 左侧如果需要导航菜单, 则直接使用/devices/parameter就好了, 这时候:id是缺省的, 路由一样可以正常匹配 |
已经融合至主分支,关闭。 |
有些时候需要左侧菜单携带动态参数(params)
实现方案:
guard
(paramMenuGuard.ts),放置于createPermissionGuard
之后(即需要先生成菜单,再进行修改)FrontMenuList
与BackMenuList
)(BackMode
/RouteMappingMode
):paramKey
的参数组,与to.params
进行一一匹配替换path
填装到menu
中,同时需要保留原path
,故于types (interface Menu)
新增了属性paramPath?: string
path
保留至paramPath
中,完成操作。示例如图
建议:
permissionStore
可新增一个方法,getMenuList
,内部判断模式,最终输出当前使用的菜单。The text was updated successfully, but these errors were encountered: