| | |
| | | import { constantRoutes, Route } from '@/router'; |
| | | import { addAsyncRoutes, ascending } from '@/router/utils'; |
| | | import * as menuServices from '@/services/api/menu'; |
| | | import { myClient } from '@/constants/query'; |
| | | |
| | | export interface PermissonState { |
| | | routes: Route[]; |
| | |
| | | getModuleList() { |
| | | return new Promise<Route[]>(async (resolve, reject) => { |
| | | try { |
| | | const res = await menuServices.getMenus( |
| | | { |
| | | const params: API.APIgetMenusParams = { |
| | | userType: EnumUserType.Operation, |
| | | clientType: EnumClientType.PcWeb, |
| | | }, |
| | | { |
| | | }; |
| | | const res = await myClient.fetchQuery({ |
| | | queryKey: ['menuServices/getMenus', params], |
| | | queryFn: async () => { |
| | | return await menuServices.getMenus(params, { |
| | | showLoading: false, |
| | | } |
| | | ); |
| | | }); |
| | | }, |
| | | staleTime: Infinity, |
| | | }); |
| | | const accessedRoutes = ascending(addAsyncRoutes(formatModuleList(res))); // createAccessedRoutes(userMenuList, userInfo) |
| | | //@ts-ignore |
| | | accessedRoutes.push({ path: '/:pathMatch(.*)*', redirect: '/404', hidden: true }); |