From 0a2e08f24e9aa5c12727e5e079988aaae405a6b1 Mon Sep 17 00:00:00 2001 From: invalid w Date: Mon, 16 Oct 2023 11:15:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8F=9C=E5=8D=95=E5=92=8C?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E8=B7=AF=E7=94=B1=E8=B0=83=E6=95=B4=E5=B8=B8?= =?UTF-8?q?=E8=A7=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- other/faq.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/other/faq.md b/other/faq.md index b103effe..fa43ac03 100644 --- a/other/faq.md +++ b/other/faq.md @@ -269,3 +269,29 @@ proxy 代理不成功,没有代理到实际地址? ## 组件库问题 跟组件库相关的问题可以查看[常见问题](https://2x.antdv.com/docs/vue/faq-cn/) + +## 动态调整菜单问题 + +菜单数据的值被存放在 `store/modules/permission` store 中, 你可以在这里进行修改 + +## 更灵活的菜单路由权限控制 + +你可以在 `store/modules/permission`下, 修改 `routeFilter` 方法来进行更灵活的菜单路由权限控制 + +``` + const routeFilter = (route: AppRouteRecordRaw) => { + const { meta } = route; + // 抽出角色 + const { roles } = meta || {}; + + // 添加你的自定义逻辑来过滤路由和菜单 + if (xxx) { + return false; + } + + if (!roles) return true; + // 进行角色权限判断 + return roleList.some((role) => roles.includes(role)); + }; + +```