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