We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
简而言之:想要获取这个菜单的路由数据
这个是服务器下发的菜单格式
{ "id": "20", "menuNames": { "en": "test json" }, "parentId": "0", "orderNum": 0, "path": "/json", "svrPath": "", "menuType": "C", "disabled": 0, "perms": "", "hideChildrenInMenu": 0, "hideInMenu": 0, "icon": "", "menuKey": "", "parentKeys": "", "flatMenu": 0, "pageSchema": "", "pageType": "J", "component": "", "customizeConfig": "", "createBy": "108", "updateBy": "1", "createdAt": "1727661405", "updatedAt": "1727664346", "remark": "", "children": [], "name": "test json" }
使用umi的getRouteData和getRouteProps拿到的是
{ "path": "/json", "title": "json页面", "parentId": "ant-design-pro-layout", "id": "8", "locale": "json页面" }
umi获取到的并不是想要的,getMenuData又好像不是用来获取这信息的,理想的是获取到上面的格式(在app.ts -> layout -> menu -> request请求获取到的),请问有什么方法吗
export const layout = ({ initialState, }: { initialState: { permissions: string[]; user: TYPE.User; roles: TYPE.Role[] }; }) => { return { logo: '/favicon.png', menu: { locale: false, request: async (_: any, defaultMenuData: MenuDataItem[]) => { const { roles } = initialState; let menu = []; const baseRoutes = defaultMenuData.filter((route) => route.resident); const adminRoutes = defaultMenuData.filter((route) => route.needAdmin); try { const { data } = await getUserMenu(); menu = toCamelCase(data); if (roles.find((role) => role.role_key === 'admin')) { menu = [...baseRoutes, ...adminRoutes, ...menu]; } else { menu = [...baseRoutes, ...menu]; } menu = fmtMenuName(menu); } catch (err) { console.log('err', err); menu = []; } console.log('当前账号的菜单权限列表:', menu); return menu; }, }, };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
🧐 问题描述
简而言之:想要获取这个菜单的路由数据
这个是服务器下发的菜单格式
使用umi的getRouteData和getRouteProps拿到的是
umi获取到的并不是想要的,getMenuData又好像不是用来获取这信息的,理想的是获取到上面的格式(在app.ts -> layout -> menu -> request请求获取到的),请问有什么方法吗
💻 代码示例
The text was updated successfully, but these errors were encountered: