full-routes.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  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/PageTaskExecutionDetail',
  220. id: 1034,
  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-execution-detail',
  234. parentId: 1028,
  235. path: 'task-execution-detail/:id',
  236. redirect: '',
  237. },
  238. {
  239. component: '/disaster/disaster-precaution/PageTaskTemplate',
  240. id: 1031,
  241. meta: {
  242. activeMenu: '/disaster-prevention/disaster-precaution/task-execution',
  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-task-template',
  254. parentId: 1028,
  255. path: 'task-template',
  256. redirect: '',
  257. },
  258. {
  259. component: '/todo/todo',
  260. id: 1032,
  261. meta: {
  262. activeMenu: '/disaster-prevention/disaster-precaution/task-template',
  263. alwaysShow: false,
  264. frameSrc: '',
  265. hidden: false,
  266. icon: '',
  267. isFrame: 0,
  268. isRoot: false,
  269. noCache: false,
  270. query: '',
  271. title: '任务模板详情',
  272. },
  273. name: 'disaster-precaution-template-detail',
  274. parentId: 1028,
  275. path: 'template-detail/:id',
  276. redirect: '',
  277. },
  278. ],
  279. component: '',
  280. id: 1028,
  281. meta: {
  282. activeMenu: null,
  283. alwaysShow: false,
  284. frameSrc: '',
  285. hidden: false,
  286. icon: 'DisasterPrecaution',
  287. isFrame: 0,
  288. isRoot: false,
  289. noCache: false,
  290. query: '',
  291. title: '预防检查',
  292. },
  293. name: 'disaster-precaution',
  294. parentId: 1022,
  295. path: 'disaster-precaution',
  296. redirect: '',
  297. },
  298. {
  299. children: [
  300. {
  301. component: '/disaster/disaster-control/PageDisposalManagement',
  302. id: 1038,
  303. meta: {
  304. activeMenu: '',
  305. alwaysShow: false,
  306. frameSrc: '',
  307. hidden: false,
  308. icon: '',
  309. isFrame: 0,
  310. isRoot: false,
  311. noCache: false,
  312. query: '',
  313. title: '处置管理',
  314. },
  315. name: 'disaster-control-disposal-management',
  316. parentId: 1027,
  317. path: 'disposal-management',
  318. redirect: '',
  319. },
  320. {
  321. component: '/disaster/disaster-control/PageDisposalManagementTaskItem',
  322. id: 1041,
  323. meta: {
  324. activeMenu: '/disaster-prevention/disaster-control/disposal-management',
  325. alwaysShow: false,
  326. frameSrc: '',
  327. hidden: false,
  328. icon: '',
  329. isFrame: 0,
  330. isRoot: false,
  331. noCache: false,
  332. query: '',
  333. title: '处置管理详情(任务项)',
  334. },
  335. name: 'disaster-control-disposal-management-task-item',
  336. parentId: 1027,
  337. path: 'disposal-management-task-item',
  338. redirect: '',
  339. },
  340. {
  341. component: '/disaster/disaster-control/PageDisposalManagementItem',
  342. id: 1042,
  343. meta: {
  344. activeMenu: '/disaster-prevention/disaster-control/disposal-management',
  345. alwaysShow: false,
  346. frameSrc: '',
  347. hidden: false,
  348. icon: '',
  349. isFrame: 0,
  350. isRoot: false,
  351. noCache: false,
  352. query: '',
  353. title: '处置管理详情(列表项)',
  354. },
  355. name: 'disaster-control-disposal-management-item',
  356. parentId: 1027,
  357. path: 'disposal-management-item/:id',
  358. redirect: '',
  359. },
  360. {
  361. component: '/disaster/disaster-control/PageLossReport',
  362. id: 1039,
  363. meta: {
  364. activeMenu: '',
  365. alwaysShow: false,
  366. frameSrc: '',
  367. hidden: false,
  368. icon: '',
  369. isFrame: 0,
  370. isRoot: false,
  371. noCache: false,
  372. query: '',
  373. title: '损失上报',
  374. },
  375. name: 'disaster-control-loss-report',
  376. parentId: 1027,
  377. path: 'loss-report',
  378. redirect: '',
  379. },
  380. {
  381. component: '/disaster/disaster-control/PageLossReportItem',
  382. id: 1043,
  383. meta: {
  384. activeMenu: '/disaster-prevention/disaster-control/loss-report',
  385. alwaysShow: false,
  386. frameSrc: '',
  387. hidden: false,
  388. icon: '',
  389. isFrame: 0,
  390. isRoot: false,
  391. noCache: false,
  392. query: '',
  393. title: '创建损失记录',
  394. },
  395. name: 'disaster-control-loss-report-item',
  396. parentId: 1027,
  397. path: 'loss-report-item/:id',
  398. redirect: '',
  399. },
  400. {
  401. component: '/disaster/disaster-control/PageDisposalRectification',
  402. id: 1040,
  403. meta: {
  404. activeMenu: '',
  405. alwaysShow: false,
  406. frameSrc: '',
  407. hidden: false,
  408. icon: '',
  409. isFrame: 0,
  410. isRoot: false,
  411. noCache: false,
  412. query: '',
  413. title: '处置整改',
  414. },
  415. name: 'disaster-control-disposal-rectification',
  416. parentId: 1027,
  417. path: 'disposal-rectification',
  418. redirect: '',
  419. },
  420. ],
  421. component: '',
  422. id: 1032,
  423. meta: {
  424. activeMenu: null,
  425. alwaysShow: false,
  426. frameSrc: '',
  427. hidden: false,
  428. icon: 'DisasterControlIcon',
  429. isFrame: 0,
  430. isRoot: false,
  431. noCache: false,
  432. query: '',
  433. title: '灾害处置',
  434. },
  435. name: 'disaster-control',
  436. parentId: 1022,
  437. path: 'disaster-control',
  438. redirect: '',
  439. },
  440. ],
  441. component: 'MENU_LAYOUT',
  442. id: 1022,
  443. meta: {
  444. activeMenu: null,
  445. alwaysShow: false,
  446. frameSrc: '',
  447. hidden: false,
  448. icon: 'CameraOutlined',
  449. isFrame: 0,
  450. isRoot: false,
  451. noCache: false,
  452. query: '',
  453. title: '灾害防范',
  454. },
  455. name: 'DisasterPrevention',
  456. parentId: -1,
  457. path: '/disaster-prevention',
  458. redirect: '',
  459. };
  460. /** 平台管理 */
  461. export const platformRoutes = {
  462. path: '/platform',
  463. name: 'Platform',
  464. component: 'MENU_LAYOUT',
  465. meta: {
  466. icon: '',
  467. title: '平台管理',
  468. },
  469. redirect: '',
  470. children: [
  471. {
  472. path: 'user',
  473. name: 'User',
  474. meta: {
  475. icon: 'UserOutlined',
  476. title: '用户管理',
  477. },
  478. children: [
  479. {
  480. // 组织管理
  481. path: 'department',
  482. name: 'UserDepartment',
  483. component: '/auth/dept/dept',
  484. meta: {
  485. icon: '',
  486. title: '组织管理',
  487. },
  488. },
  489. {
  490. // 角色管理
  491. path: 'role',
  492. name: 'UserRole',
  493. component: '/system/role/role',
  494. meta: {
  495. icon: '',
  496. title: '角色管理',
  497. },
  498. },
  499. {
  500. // 账号管理
  501. path: 'account',
  502. name: 'UserAccount',
  503. component: '/system/user/user',
  504. meta: {
  505. icon: '',
  506. title: '账号管理',
  507. },
  508. },
  509. {
  510. // 账号管理
  511. path: 'person',
  512. name: 'Person',
  513. component: '/todo/todo',
  514. meta: {
  515. icon: '',
  516. title: '人员分组',
  517. },
  518. },
  519. ],
  520. },
  521. {
  522. // 菜单管理
  523. path: 'menu',
  524. name: 'SystemMenu',
  525. component: '/system/menu/menu',
  526. meta: {
  527. icon: 'UserOutlined',
  528. title: '菜单管理',
  529. },
  530. },
  531. {
  532. // 权限管理
  533. path: 'permission',
  534. name: 'SystemPermission',
  535. component: '/system/permission/PagePermission',
  536. meta: {
  537. icon: 'UserOutlined',
  538. title: '权限管理',
  539. },
  540. },
  541. {
  542. path: 'dictionary',
  543. name: 'SystemDictionary',
  544. component: '/system/dictionary/dictionary',
  545. meta: {
  546. icon: 'UserOutlined',
  547. title: '字典管理',
  548. },
  549. },
  550. ],
  551. };
  552. export const exceptionRouters =
  553. /**
  554. * 异常页面
  555. */
  556. {
  557. path: '/exception',
  558. name: 'Exception',
  559. component: 'LAYOUT',
  560. redirect: '/exception/403',
  561. meta: {
  562. icon: 'ExclamationCircleOutlined',
  563. title: '异常页面',
  564. ignoreAuth: true,
  565. },
  566. children: [
  567. {
  568. // 403,
  569. path: '403',
  570. name: 'Exception403',
  571. component: '/exception/403',
  572. meta: {
  573. icon: '',
  574. title: '403',
  575. },
  576. },
  577. {
  578. path: '500',
  579. name: 'Exception500',
  580. component: '/exception/500',
  581. meta: {
  582. icon: '',
  583. title: '500',
  584. },
  585. },
  586. ],
  587. };
  588. export const fullRoutes: AppRouteRecordRaw[] = [
  589. disasterPreventionRoute,
  590. // userRoutes,
  591. // systemRoutes,
  592. platformRoutes,
  593. /**
  594. * 消息管理
  595. */
  596. {
  597. path: '/message',
  598. name: 'Message',
  599. component: 'LAYOUT',
  600. meta: {
  601. icon: 'SendOutlined',
  602. title: '消息管理',
  603. },
  604. children: [
  605. {
  606. // 报表推送
  607. path: 'report',
  608. name: 'MessageReport',
  609. component: '/message/reportmessage/ReportMessage',
  610. meta: {
  611. icon: '',
  612. title: '报表推送',
  613. },
  614. },
  615. {
  616. // 报表推送配置。二级页面,菜单不可见!!!
  617. path: 'report-config',
  618. name: 'MessageReportConfig',
  619. component: '/message/reportmessage/ReportOperation',
  620. meta: {
  621. icon: '',
  622. title: '报表推送配置',
  623. activeMenu: 'MessageReport',
  624. },
  625. },
  626. {
  627. // 报警推送
  628. path: 'alarm',
  629. name: 'MessageAlarm',
  630. component: '/message/alarmMessages/alarmMessages',
  631. meta: {
  632. icon: '',
  633. title: '报警推送',
  634. },
  635. },
  636. {
  637. // 报警推送配置 。二级页面,菜单不可见!!!
  638. path: 'alarm-config',
  639. name: 'MessageAlarmConfig',
  640. component: '/message/alarm-config/AlarmConfig',
  641. meta: {
  642. icon: '',
  643. title: '报警推送配置',
  644. activeMenu: 'MessageAlarm',
  645. },
  646. },
  647. {
  648. // 系统通知
  649. path: 'sys-notification',
  650. name: 'MessageSysNotification',
  651. component: '/message/systemNotifications/systemNotifications',
  652. meta: {
  653. icon: '',
  654. title: '系统通知',
  655. },
  656. },
  657. {
  658. // 系统通知配置。二级页面,菜单不可见!!!
  659. path: 'sys-notification-config',
  660. name: 'MessageSysNotificationConfig',
  661. component: '/message/sysnotion-config/SysnotionConfig',
  662. meta: {
  663. icon: '',
  664. title: '系统通知配置',
  665. activeMenu: 'MessageSysNotification',
  666. },
  667. },
  668. {
  669. // 人员分组
  670. path: 'personnel-group',
  671. name: 'MessagePersonnelGroup',
  672. component: '/message/persongroup/UserGroup',
  673. meta: {
  674. icon: '',
  675. title: '人员分组',
  676. },
  677. },
  678. {
  679. // 问题处理通知
  680. path: 'question-notification',
  681. name: 'MessageQuestionNotification',
  682. component: '/message/question-notifications/QuestionNotifications',
  683. meta: {
  684. icon: '',
  685. title: '问题处理通知',
  686. },
  687. },
  688. ],
  689. },
  690. /**
  691. * 数据管理
  692. */
  693. {
  694. path: '/data',
  695. name: 'Data',
  696. component: 'LAYOUT',
  697. meta: {
  698. icon: 'LineChartOutlined',
  699. title: '数据管理',
  700. },
  701. children: [
  702. {
  703. // 平台统计
  704. path: 'platform',
  705. name: 'DataPlatform',
  706. component: '/datamanager/platformdata/PlatformData',
  707. meta: {
  708. icon: '',
  709. title: '平台统计',
  710. },
  711. },
  712. {
  713. // 历史视频 (视频回看)
  714. path: 'playback',
  715. name: 'DataPlayback',
  716. component: '/datamanager/playback/Playback',
  717. meta: {
  718. icon: '',
  719. title: '历史视频',
  720. },
  721. },
  722. {
  723. // 违规问题
  724. path: 'violation',
  725. name: 'DataViolation',
  726. component: '/datamanager/alertformdata/AlertformData',
  727. meta: {
  728. icon: '',
  729. title: '违规问题',
  730. },
  731. },
  732. ],
  733. },
  734. ] as const;
  735. /**
  736. * 类型定义。避免与已有的定义冲突,避免与 vue-router的类型定义冲突,前面加 _ 前缀
  737. */
  738. export interface _RouteViewItem {
  739. label: string;
  740. value: string;
  741. }
  742. export type _RouteView = _RouteViewItem & { children?: _RouteViewItem[] | null };
  743. export type _RouteViewTree = _RouteView[];
  744. /**
  745. * 获取指定 父路由 下的子路由。
  746. * 若 父级路由 未指定,则返回一级路由
  747. */
  748. export function getChildRoutesView(parentRouteName?: string | null): _RouteViewItem[] {
  749. // 未指定 parentRouteName, 则返回 level1 的路由
  750. if (parentRouteName == null) {
  751. return fullRoutes.map((route) => ({
  752. label: route.meta.title as string,
  753. value: route.name,
  754. }));
  755. }
  756. // 获取指定父路由的子路由
  757. const parentRoute: AppRouteRecordRaw = cloneDeep(getTreeItem(fullRoutes, parentRouteName, 'name'));
  758. if (parentRoute.children && parentRoute.children.length > 0) {
  759. return parentRoute.children.map((route) => ({
  760. label: route.meta.title as string,
  761. value: route.name,
  762. }));
  763. } else {
  764. return [];
  765. }
  766. }
  767. /**
  768. * 获取指定的 路由信息
  769. */
  770. export function getRouteByName(routeName: string) {
  771. return cloneDeep(getTreeItem(fullRoutes, routeName, 'name')) as AppRouteRecordRaw;
  772. }
  773. /**
  774. * 转换成 el-tree-select 的数据结构形式
  775. */
  776. export function transformToRouteViewTree(routes?: AppRouteRecordRaw[] | null) {
  777. const tree: _RouteViewTree = [];
  778. if (routes == null) return tree;
  779. for (const route of routes) {
  780. const treeItem: _RouteView = {
  781. value: route.name,
  782. label: route.meta.title as string,
  783. children: null,
  784. };
  785. if (route.children && route.children.length > 0) {
  786. treeItem.children = transformToRouteViewTree(route.children);
  787. tree.push(treeItem);
  788. } else {
  789. tree.push(treeItem);
  790. }
  791. }
  792. return tree;
  793. }
  794. export const routeViewTree = transformToRouteViewTree(fullRoutes);