full-routes.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /**
  2. * 1. 前端维护的完整路由表, 用于创建"菜单"
  3. * 2. component 是 string,并不是 组件对象。
  4. * 3. 生成菜单,关注的 path,name,component,icon。
  5. * 4. 部分路由组件是菜单不可见的,当访问该路由时,左侧菜单的menu item会失去active状态。需要设置 meta.activeMenu 保持选中状态。
  6. */
  7. import { AppRouteRecordRaw } from './types';
  8. import { getTreeItem } from '@/utils';
  9. import { cloneDeep } from 'lodash-es';
  10. import { RouteRecordRaw } from 'vue-router';
  11. import { PageEnum } from '@/enums/pageEnum';
  12. type RouteRecordString = Omit<AppRouteRecordRaw, 'component'> & { component?: string };
  13. export const RootRoute: RouteRecordString = {
  14. path: '/',
  15. name: 'Root',
  16. redirect: PageEnum.BASE_HOME,
  17. meta: {
  18. title: 'Root',
  19. },
  20. };
  21. export const HOME_PAGE: RouteRecordString = {
  22. // 模板管理
  23. path: '/home',
  24. name: 'HomePage',
  25. component: '/home/PageHome',
  26. meta: {
  27. icon: '',
  28. title: '公司主页',
  29. },
  30. };
  31. /** 灾害防范的路由 */
  32. export const disasterPreventionRoute = {
  33. children: [
  34. {
  35. component: '/disaster/overview/PageOverview',
  36. id: 1025,
  37. meta: {
  38. activeMenu: null,
  39. alwaysShow: false,
  40. frameSrc: '',
  41. hidden: false,
  42. icon: 'OverviewIcon',
  43. isFrame: 0,
  44. isRoot: false,
  45. noCache: false,
  46. query: '',
  47. title: '总览',
  48. },
  49. name: 'disaster-prevention-overview',
  50. parentId: 1022,
  51. path: 'overview',
  52. redirect: '',
  53. },
  54. {
  55. component: '/disaster/monitor/PageMonitor',
  56. id: 1026,
  57. meta: {
  58. activeMenu: null,
  59. alwaysShow: false,
  60. frameSrc: '',
  61. hidden: false,
  62. icon: 'RiskPointMonitoringIcon',
  63. isFrame: 0,
  64. isRoot: false,
  65. noCache: false,
  66. query: '',
  67. title: '重点区域监测',
  68. },
  69. name: 'risk-point-monitoring',
  70. parentId: 1022,
  71. path: 'risk-point-monitoring',
  72. redirect: '',
  73. },
  74. {
  75. children: [
  76. {
  77. component: '/disaster/disaster-warning/PageWarningInfo',
  78. id: 1035,
  79. meta: {
  80. activeMenu: '/disaster-prevention/disaster-warning',
  81. alwaysShow: false,
  82. frameSrc: '',
  83. hidden: false,
  84. icon: '',
  85. isFrame: 0,
  86. isRoot: false,
  87. noCache: false,
  88. query: '',
  89. title: '预警信息',
  90. },
  91. name: 'disaster-warning/warning-info',
  92. parentId: 1027,
  93. path: 'warning-info',
  94. redirect: '',
  95. },
  96. {
  97. component: '/disaster/disaster-warning/PageDefenseNotice',
  98. id: 1037,
  99. meta: {
  100. activeMenu: null,
  101. alwaysShow: false,
  102. frameSrc: '',
  103. hidden: false,
  104. icon: '',
  105. isFrame: 0,
  106. isRoot: false,
  107. noCache: false,
  108. query: '',
  109. title: '防御通知',
  110. },
  111. name: 'disaster-warning/defense-notice',
  112. parentId: 1027,
  113. path: 'defense-notice',
  114. redirect: '',
  115. },
  116. {
  117. component: '/disaster/disaster-warning/PageDefenseNoticeItem',
  118. id: 1038,
  119. meta: {
  120. activeMenu: null,
  121. alwaysShow: false,
  122. frameSrc: '',
  123. hidden: false,
  124. icon: '',
  125. isFrame: 0,
  126. isRoot: false,
  127. noCache: false,
  128. query: '',
  129. title: '防御通知详情',
  130. },
  131. name: 'defense-notice-item',
  132. parentId: 1027,
  133. path: 'defense-notice-item',
  134. redirect: '',
  135. },
  136. ],
  137. component: '',
  138. id: 1027,
  139. meta: {
  140. activeMenu: null,
  141. alwaysShow: false,
  142. frameSrc: '',
  143. hidden: false,
  144. icon: 'DisasterWarningIcon',
  145. isFrame: 0,
  146. isRoot: false,
  147. noCache: false,
  148. query: '',
  149. title: '灾害预警',
  150. },
  151. name: 'disaster-warning',
  152. parentId: 1022,
  153. path: 'disaster-warning',
  154. redirect: '',
  155. },
  156. {
  157. children: [
  158. {
  159. component: '/disaster/disaster-precaution/PageTaskManagement',
  160. id: 1029,
  161. meta: {
  162. activeMenu: null,
  163. alwaysShow: false,
  164. frameSrc: '',
  165. hidden: false,
  166. icon: '',
  167. isFrame: 0,
  168. isRoot: false,
  169. noCache: false,
  170. query: '',
  171. title: '任务管理',
  172. },
  173. name: 'disaster-precaution-task-management',
  174. parentId: 1028,
  175. path: 'task-management',
  176. redirect: '',
  177. },
  178. {
  179. component: '/disaster/disaster-precaution/PageTaskItem',
  180. id: 1033,
  181. meta: {
  182. activeMenu: null,
  183. alwaysShow: false,
  184. frameSrc: '',
  185. hidden: true,
  186. icon: '',
  187. isFrame: 0,
  188. isRoot: false,
  189. noCache: false,
  190. query: '',
  191. title: '任务列表详情',
  192. },
  193. name: 'disaster-precaution-task-item',
  194. parentId: 1028,
  195. path: 'task-item',
  196. redirect: '',
  197. },
  198. {
  199. component: '/disaster/disaster-precaution/PageTaskExecution',
  200. id: 1030,
  201. meta: {
  202. activeMenu: null,
  203. alwaysShow: false,
  204. frameSrc: '',
  205. hidden: false,
  206. icon: '',
  207. isFrame: 0,
  208. isRoot: false,
  209. noCache: false,
  210. query: '',
  211. title: '任务执行',
  212. },
  213. name: 'disaster-precaution-task-execution',
  214. parentId: 1028,
  215. path: 'task-execution',
  216. redirect: '',
  217. },
  218. {
  219. component: '/disaster/disaster-precaution/PageTaskTemplate',
  220. id: 1031,
  221. meta: {
  222. activeMenu: '/disaster-prevention/disaster-precaution/task-execution',
  223. alwaysShow: false,
  224. frameSrc: '',
  225. hidden: false,
  226. icon: '',
  227. isFrame: 0,
  228. isRoot: false,
  229. noCache: false,
  230. query: '',
  231. title: '任务模板',
  232. },
  233. name: 'disaster-precaution-task-template',
  234. parentId: 1028,
  235. path: 'task-template',
  236. redirect: '',
  237. },
  238. {
  239. component: '/todo/todo',
  240. id: 1032,
  241. meta: {
  242. activeMenu: '/disaster-prevention/disaster-precaution/task-template',
  243. alwaysShow: false,
  244. frameSrc: '',
  245. hidden: false,
  246. icon: '',
  247. isFrame: 0,
  248. isRoot: false,
  249. noCache: false,
  250. query: '',
  251. title: '任务模板详情',
  252. },
  253. name: 'disaster-precaution-template-detail',
  254. parentId: 1028,
  255. path: 'template-detail/:id',
  256. redirect: '',
  257. },
  258. ],
  259. component: '',
  260. id: 1028,
  261. meta: {
  262. activeMenu: null,
  263. alwaysShow: false,
  264. frameSrc: '',
  265. hidden: false,
  266. icon: 'DisasterPrecaution',
  267. isFrame: 0,
  268. isRoot: false,
  269. noCache: false,
  270. query: '',
  271. title: '预防检查',
  272. // OverviewIcon: renderSvg('overview'),
  273. // DisasterWarningIcon: renderSvg('disaster-warning'),
  274. // DisasterControlIcon: renderSvg('disaster-control'),
  275. },
  276. name: 'disaster-precaution',
  277. parentId: 1022,
  278. path: 'disaster-precaution',
  279. redirect: '',
  280. },
  281. {
  282. component: '/disaster/disaster-control/PageDisasterControl',
  283. id: 1032,
  284. meta: {
  285. activeMenu: null,
  286. alwaysShow: false,
  287. frameSrc: '',
  288. hidden: false,
  289. icon: 'DisasterControlIcon',
  290. isFrame: 0,
  291. isRoot: false,
  292. noCache: false,
  293. query: '',
  294. title: '灾害处置',
  295. },
  296. name: 'disaster-control',
  297. parentId: 1022,
  298. path: 'disaster-control',
  299. redirect: '',
  300. },
  301. ],
  302. component: 'MENU_LAYOUT',
  303. id: 1022,
  304. meta: {
  305. activeMenu: null,
  306. alwaysShow: false,
  307. frameSrc: '',
  308. hidden: false,
  309. icon: 'CameraOutlined',
  310. isFrame: 0,
  311. isRoot: false,
  312. noCache: false,
  313. query: '',
  314. title: '灾害防范',
  315. },
  316. name: 'DisasterPrevention',
  317. parentId: -1,
  318. path: '/disaster-prevention',
  319. redirect: '',
  320. };
  321. // export const userRoutesOld: AppRouteRecordRaw =
  322. // /**
  323. // * 用户管理
  324. // */
  325. // {
  326. // path: '/user',
  327. // name: 'User',
  328. // component: 'LAYOUT',
  329. // meta: {
  330. // icon: 'UserOutlined',
  331. // title: '用户管理',
  332. // },
  333. // children: [
  334. // {
  335. // // 账号管理
  336. // path: 'account',
  337. // name: 'UserAccount',
  338. // component: '/system/user/user',
  339. // meta: {
  340. // icon: '',
  341. // title: '账号管理',
  342. // },
  343. // },
  344. // {
  345. // // 角色管理
  346. // path: 'role',
  347. // name: 'UserRole',
  348. // component: '/system/role/role',
  349. // meta: {
  350. // icon: '',
  351. // title: '角色管理',
  352. // },
  353. // },
  354. // {
  355. // // 组织管理
  356. // path: 'department',
  357. // name: 'UserDepartment',
  358. // component: '/auth/dept/dept',
  359. // meta: {
  360. // icon: '',
  361. // title: '组织管理',
  362. // },
  363. // },
  364. // {
  365. // // 岗位管理 (目前不需要)
  366. // path: 'post',
  367. // name: 'UserPost',
  368. // component: '/auth/post/post',
  369. // meta: {
  370. // icon: '',
  371. // title: '岗位管理',
  372. // },
  373. // },
  374. // ],
  375. // };
  376. // export const systemRoutesOld =
  377. // /**
  378. // * 系统管理 (只有超管可见)
  379. // */
  380. // {
  381. // path: '/system',
  382. // name: 'System',
  383. // component: 'MENU_LAYOUT',
  384. // meta: {
  385. // icon: 'OptionsSharp',
  386. // title: '系统管理',
  387. // },
  388. // redirect: 'SystemMenu',
  389. // children: [
  390. // {
  391. // // 租户管理
  392. // path: 'tenant',
  393. // name: 'SystemTenant',
  394. // component: '/system/tenant/tenant',
  395. // meta: {
  396. // icon: '',
  397. // title: '租户管理',
  398. // },
  399. // },
  400. // {
  401. // // 菜单管理
  402. // path: 'menu',
  403. // name: 'SystemMenu',
  404. // component: '/system/menu/menu',
  405. // meta: {
  406. // icon: '',
  407. // title: '菜单管理',
  408. // },
  409. // },
  410. // {
  411. // // 权限管理
  412. // path: 'permission',
  413. // name: 'SystemPermission',
  414. // component: '/system/permssion/PagePermission',
  415. // meta: {
  416. // icon: '',
  417. // title: '权限管理',
  418. // },
  419. // },
  420. // {
  421. // // 权限管理
  422. // path: 'comments',
  423. // name: 'SystemComments',
  424. // component: '/system/comments/PageCommentsManage',
  425. // meta: {
  426. // icon: '',
  427. // title: '评论管理',
  428. // },
  429. // },
  430. // {
  431. // // 意见反馈
  432. // path: 'feedback',
  433. // name: 'SystemFeedback',
  434. // component: '/feedback/feedback',
  435. // meta: {
  436. // icon: '',
  437. // title: '意见反馈',
  438. // },
  439. // },
  440. // {
  441. // // 反馈处理 。意见反馈的二级页面。菜单不可见!!!
  442. // path: 'feedback-handle',
  443. // name: 'SystemFeedbackHandle',
  444. // component: '/feedback/handleFeedback',
  445. // meta: {
  446. // icon: '',
  447. // title: '反馈处理',
  448. // activeMenu: 'SystemFeedback',
  449. // },
  450. // },
  451. // // {
  452. // // // 字典管理 (暂时用不到)
  453. // // path: 'dictionary',
  454. // // name: 'SystemDictionary',
  455. // // component: '/system/dictionary/dictionary',
  456. // // meta: {
  457. // // icon: '',
  458. // // title: '字典管理',
  459. // // },
  460. // // },
  461. // {
  462. // // 日志管理
  463. // path: 'log',
  464. // name: 'SystemLog',
  465. // component: '/system/log/log',
  466. // meta: {
  467. // icon: '',
  468. // title: '日志管理',
  469. // },
  470. // },
  471. // ],
  472. // };
  473. /** 平台管理 */
  474. export const platformRoutes = {
  475. path: '/platform',
  476. name: 'Platform',
  477. component: 'MENU_LAYOUT',
  478. meta: {
  479. icon: '',
  480. title: '平台管理',
  481. },
  482. redirect: '',
  483. children: [
  484. {
  485. path: 'user',
  486. name: 'User',
  487. meta: {
  488. icon: 'UserOutlined',
  489. title: '用户管理',
  490. },
  491. children: [
  492. {
  493. // 组织管理
  494. path: 'department',
  495. name: 'UserDepartment',
  496. component: '/auth/dept/dept',
  497. meta: {
  498. icon: '',
  499. title: '组织管理',
  500. },
  501. },
  502. {
  503. // 角色管理
  504. path: 'role',
  505. name: 'UserRole',
  506. component: '/system/role/role',
  507. meta: {
  508. icon: '',
  509. title: '角色管理',
  510. },
  511. },
  512. {
  513. // 账号管理
  514. path: 'account',
  515. name: 'UserAccount',
  516. component: '/system/user/user',
  517. meta: {
  518. icon: '',
  519. title: '账号管理',
  520. },
  521. },
  522. ],
  523. },
  524. {
  525. // 菜单管理
  526. path: 'menu',
  527. name: 'SystemMenu',
  528. component: '/system/menu/menu',
  529. meta: {
  530. icon: 'UserOutlined',
  531. title: '菜单管理',
  532. },
  533. },
  534. {
  535. // 权限管理
  536. path: 'permission',
  537. name: 'SystemPermission',
  538. component: '/system/permission/PagePermission',
  539. meta: {
  540. icon: 'UserOutlined',
  541. title: '权限管理',
  542. },
  543. },
  544. {
  545. path: 'dictionary',
  546. name: 'SystemDictionary',
  547. component: '/system/dictionary/dictionary',
  548. meta: {
  549. icon: 'UserOutlined',
  550. title: '字典管理',
  551. },
  552. },
  553. ],
  554. };
  555. export const exceptionRouters =
  556. /**
  557. * 异常页面
  558. */
  559. {
  560. path: '/exception',
  561. name: 'Exception',
  562. component: 'LAYOUT',
  563. redirect: '/exception/403',
  564. meta: {
  565. icon: 'ExclamationCircleOutlined',
  566. title: '异常页面',
  567. ignoreAuth: true,
  568. },
  569. children: [
  570. {
  571. // 403,
  572. path: '403',
  573. name: 'Exception403',
  574. component: '/exception/403',
  575. meta: {
  576. icon: '',
  577. title: '403',
  578. },
  579. },
  580. {
  581. path: '500',
  582. name: 'Exception500',
  583. component: '/exception/500',
  584. meta: {
  585. icon: '',
  586. title: '500',
  587. },
  588. },
  589. ],
  590. };
  591. export const fullRoutes: AppRouteRecordRaw[] = [
  592. disasterPreventionRoute,
  593. // userRoutes,
  594. // systemRoutes,
  595. platformRoutes,
  596. /**
  597. * 消息管理
  598. */
  599. {
  600. path: '/message',
  601. name: 'Message',
  602. component: 'LAYOUT',
  603. meta: {
  604. icon: 'SendOutlined',
  605. title: '消息管理',
  606. },
  607. children: [
  608. {
  609. // 报表推送
  610. path: 'report',
  611. name: 'MessageReport',
  612. component: '/message/reportmessage/ReportMessage',
  613. meta: {
  614. icon: '',
  615. title: '报表推送',
  616. },
  617. },
  618. {
  619. // 报表推送配置。二级页面,菜单不可见!!!
  620. path: 'report-config',
  621. name: 'MessageReportConfig',
  622. component: '/message/reportmessage/ReportOperation',
  623. meta: {
  624. icon: '',
  625. title: '报表推送配置',
  626. activeMenu: 'MessageReport',
  627. },
  628. },
  629. {
  630. // 报警推送
  631. path: 'alarm',
  632. name: 'MessageAlarm',
  633. component: '/message/alarmMessages/alarmMessages',
  634. meta: {
  635. icon: '',
  636. title: '报警推送',
  637. },
  638. },
  639. {
  640. // 报警推送配置 。二级页面,菜单不可见!!!
  641. path: 'alarm-config',
  642. name: 'MessageAlarmConfig',
  643. component: '/message/alarm-config/AlarmConfig',
  644. meta: {
  645. icon: '',
  646. title: '报警推送配置',
  647. activeMenu: 'MessageAlarm',
  648. },
  649. },
  650. {
  651. // 系统通知
  652. path: 'sys-notification',
  653. name: 'MessageSysNotification',
  654. component: '/message/systemNotifications/systemNotifications',
  655. meta: {
  656. icon: '',
  657. title: '系统通知',
  658. },
  659. },
  660. {
  661. // 系统通知配置。二级页面,菜单不可见!!!
  662. path: 'sys-notification-config',
  663. name: 'MessageSysNotificationConfig',
  664. component: '/message/sysnotion-config/SysnotionConfig',
  665. meta: {
  666. icon: '',
  667. title: '系统通知配置',
  668. activeMenu: 'MessageSysNotification',
  669. },
  670. },
  671. {
  672. // 人员分组
  673. path: 'personnel-group',
  674. name: 'MessagePersonnelGroup',
  675. component: '/message/persongroup/UserGroup',
  676. meta: {
  677. icon: '',
  678. title: '人员分组',
  679. },
  680. },
  681. {
  682. // 问题处理通知
  683. path: 'question-notification',
  684. name: 'MessageQuestionNotification',
  685. component: '/message/question-notifications/QuestionNotifications',
  686. meta: {
  687. icon: '',
  688. title: '问题处理通知',
  689. },
  690. },
  691. ],
  692. },
  693. /**
  694. * 数据管理
  695. */
  696. {
  697. path: '/data',
  698. name: 'Data',
  699. component: 'LAYOUT',
  700. meta: {
  701. icon: 'LineChartOutlined',
  702. title: '数据管理',
  703. },
  704. children: [
  705. {
  706. // 平台统计
  707. path: 'platform',
  708. name: 'DataPlatform',
  709. component: '/datamanager/platformdata/PlatformData',
  710. meta: {
  711. icon: '',
  712. title: '平台统计',
  713. },
  714. },
  715. {
  716. // 历史视频 (视频回看)
  717. path: 'playback',
  718. name: 'DataPlayback',
  719. component: '/datamanager/playback/Playback',
  720. meta: {
  721. icon: '',
  722. title: '历史视频',
  723. },
  724. },
  725. {
  726. // 违规问题
  727. path: 'violation',
  728. name: 'DataViolation',
  729. component: '/datamanager/alertformdata/AlertformData',
  730. meta: {
  731. icon: '',
  732. title: '违规问题',
  733. },
  734. },
  735. ],
  736. },
  737. ] as const;
  738. /**
  739. * 类型定义。避免与已有的定义冲突,避免与 vue-router的类型定义冲突,前面加 _ 前缀
  740. */
  741. export interface _RouteViewItem {
  742. label: string;
  743. value: string;
  744. }
  745. export type _RouteView = _RouteViewItem & { children?: _RouteViewItem[] | null };
  746. export type _RouteViewTree = _RouteView[];
  747. /**
  748. * 获取指定 父路由 下的子路由。
  749. * 若 父级路由 未指定,则返回一级路由
  750. */
  751. export function getChildRoutesView(parentRouteName?: string | null): _RouteViewItem[] {
  752. // 未指定 parentRouteName, 则返回 level1 的路由
  753. if (parentRouteName == null) {
  754. return fullRoutes.map((route) => ({
  755. label: route.meta.title as string,
  756. value: route.name,
  757. }));
  758. }
  759. // 获取指定父路由的子路由
  760. const parentRoute: AppRouteRecordRaw = cloneDeep(getTreeItem(fullRoutes, parentRouteName, 'name'));
  761. if (parentRoute.children && parentRoute.children.length > 0) {
  762. return parentRoute.children.map((route) => ({
  763. label: route.meta.title as string,
  764. value: route.name,
  765. }));
  766. } else {
  767. return [];
  768. }
  769. }
  770. /**
  771. * 获取指定的 路由信息
  772. */
  773. export function getRouteByName(routeName: string) {
  774. return cloneDeep(getTreeItem(fullRoutes, routeName, 'name')) as AppRouteRecordRaw;
  775. }
  776. /**
  777. * 转换成 el-tree-select 的数据结构形式
  778. */
  779. export function transformToRouteViewTree(routes?: AppRouteRecordRaw[] | null) {
  780. const tree: _RouteViewTree = [];
  781. if (routes == null) return tree;
  782. for (const route of routes) {
  783. const treeItem: _RouteView = {
  784. value: route.name,
  785. label: route.meta.title as string,
  786. children: null,
  787. };
  788. if (route.children && route.children.length > 0) {
  789. treeItem.children = transformToRouteViewTree(route.children);
  790. tree.push(treeItem);
  791. } else {
  792. tree.push(treeItem);
  793. }
  794. }
  795. return tree;
  796. }
  797. export const routeViewTree = transformToRouteViewTree(fullRoutes);