index.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // 静态路由
  2. import homeRouter from "./home";
  3. import errorRouter from "./error";
  4. import guideRouter from "./guide";
  5. import editorRouter from "./editor";
  6. import nestedRouter from "./nested";
  7. import menuTreeRouter from "./menuTree";
  8. import externalLink from "./externalLink";
  9. import flowChartRouter from "./flowchart";
  10. import remainingRouter from "./remaining";
  11. import componentsRouter from "./components";
  12. import { RouteRecordRaw, RouteComponent } from "vue-router";
  13. import {
  14. ascending,
  15. formatTwoStageRoutes,
  16. formatFlatteningRoutes
  17. } from "../utils";
  18. // 原始静态路由(未做任何处理)
  19. const routes = [
  20. homeRouter,
  21. errorRouter,
  22. guideRouter,
  23. nestedRouter,
  24. externalLink,
  25. editorRouter,
  26. menuTreeRouter,
  27. flowChartRouter,
  28. componentsRouter
  29. ];
  30. // 导出处理后的静态路由(三级及以上的路由全部拍成二级)
  31. export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
  32. formatFlatteningRoutes(ascending(routes))
  33. );
  34. // 用于渲染菜单,保持原始层级
  35. export const constantMenus: Array<RouteComponent> = ascending(routes).concat(
  36. ...remainingRouter
  37. );