Skip to content
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

feat(param-menu): feature: menu with params #845

Merged
merged 1 commit into from
Jul 3, 2021

Conversation

noahlann
Copy link

@noahlann noahlann commented Jul 1, 2021

有些时候需要左侧菜单携带动态参数(params)

  1. 能够携带参数正常使用菜单。
  2. 切换菜单时能够使用上次的参数。
  3. 手动更换参数能够正常识别,且切换时能够正常携带已更换的参数。

实现方案:

  1. 新增一个guard(paramMenuGuard.ts),放置于createPermissionGuard之后(即需要先生成菜单,再进行修改)
  2. 根据不同的模式读取菜单(FrontMenuListBackMenuList)(BackMode/RouteMappingMode
  3. 使用正则获取类似所有 :paramKey 的参数组,与 to.params 进行一一匹配替换
  4. 将替换后的path填装到menu中,同时需要保留原path,故于 types (interface Menu)新增了属性 paramPath?: string
  5. 将原path保留至paramPath中,完成操作。

示例如图

自己项目示例:

vben-admin示例:

说明

经测试,自己项目的面包屑无法正常导航,但vben-admin中可以,还没查原因。

已添加示例页面 feat -> TestParam -> TestParam_1/TestParam_2

建议:

permissionStore可新增一个方法,getMenuList,内部判断模式,最终输出当前使用的菜单。

@noahlann
Copy link
Author

noahlann commented Jul 1, 2021

另外提一下,更新了 RouteMap 功能后,原带参tab演示功能出现bug。

原方案是menu填具体参数值,route填:id,这样tab可以携带具体参数值。
现有逻辑无法支撑(但tab带参功能还是可用的,只是演示页面的bug)

@mynetfan
Copy link
Collaborator

mynetfan commented Jul 1, 2021

另外提一下,更新了 RouteMap 功能后,原带参tab演示功能出现bug。

原方案是menu填具体参数值,route填:id,这样tab可以携带具体参数值。
现有逻辑无法支撑(但tab带参功能还是可用的,只是演示页面的bug)

https://github.com/anncwb/vue-vben-admin/commit/72ac240f2858cd74cb62b7647ca89d63bb71d247 解决ROUTE_MAPPING模式下的tab带参菜单问题

@noahlann
Copy link
Author

noahlann commented Jul 1, 2021

另外提一下,更新了 RouteMap 功能后,原带参tab演示功能出现bug。
原方案是menu填具体参数值,route填:id,这样tab可以携带具体参数值。
现有逻辑无法支撑(但tab带参功能还是可用的,只是演示页面的bug)

72ac240 解决ROUTE_MAPPING模式下的tab带参菜单问题

nice,我这个主要解决动态参数的问题。 目前看到的路由示例中,参数都是给固定的。

@anncwb anncwb merged commit 48fcd76 into vbenjs:main Jul 3, 2021
@noahlann noahlann deleted the feat-dynamic-param-menu branch July 3, 2021 13:09
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants