lct
Your Name
2022-08-02 33802d74d2720e86c406f5ca9531ac9435b9ddd2
src/router/backEnd.ts
@@ -9,7 +9,7 @@
import { formatTwoStageRoutes, formatFlatteningRoutes, router } from '/@/router/index';
import { useRoutesList } from '/@/stores/routesList';
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
import { useMenuApi } from '/@/api/menu/index';
import { useMenuApi } from '/@/api/systemManage/menu/index';
import { ElMessage } from 'element-plus';
const menuApi = useMenuApi();
@@ -17,14 +17,12 @@
const layouModules: any = import.meta.glob('../layout/routerView/*.{vue,tsx}');
const viewsModules: any = import.meta.glob('../views/**/*.{vue,tsx}');
/**
 * 获取目录下的 .vue、.tsx 全部文件
 * @method import.meta.glob
 * @link 参考:https://cn.vitejs.dev/guide/features.html#json
 */
const dynamicViewsModules: Record<string, Function> = Object.assign({}, { ...layouModules }, { ...viewsModules });
export async function initBackEndControlRoutes() {
   if (window.nextLoading === undefined) NextLoading.start();
@@ -36,19 +34,16 @@
   await setFilterMenuAndCacheTagsViewRoutes();
    }
export function setFilterMenuAndCacheTagsViewRoutes() {
   const storesRoutesList = useRoutesList(pinia);
   storesRoutesList.setRoutesList(dynamicRoutes[0].children as any);
   setCacheTagsViewRoutes();
}
export function setCacheTagsViewRoutes() {
   const storesTagsView = useTagsViewRoutes(pinia);
   storesTagsView.setTagsViewRoutes(formatTwoStageRoutes(formatFlatteningRoutes(dynamicRoutes))[0].children);
}
export function setFilterRouteEnd() {
   let filterRouteEnd: any = formatTwoStageRoutes(formatFlatteningRoutes(dynamicRoutes));
@@ -56,20 +51,17 @@
   return filterRouteEnd;
}
export async function setAddRoute() {
   await setFilterRouteEnd().forEach((route: RouteRecordRaw) => {
      router.addRoute(route);
   });
}
export async function getBackEndControlRoutes(value : string) {
   // const stores = useUserInfo(pinia);
   // const { userInfos } = storeToRefs(stores);
   // const auth = userInfos.value.roles[0];
   return menuApi.getMenuAdmin(value);
}
/**
@@ -81,7 +73,6 @@
   getBackEndControlRoutes(Session.get('projectId'));
}
export function backEndComponent(routes: any) {
   if (!routes) return;
   return routes.map((item: any) => {
@@ -90,7 +81,6 @@
      return item;
   });
}
export function dynamicImport(dynamicViewsModules: Record<string, Function>, component: string) {
   const keys = Object.keys(dynamicViewsModules);