full-routes.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /**
  2. * 1. 前端维护的完整路由表, 用于创建"菜单"
  3. * 2. component 是 string,并不是 组件对象。
  4. * 3. 生成菜单,关注的 path,name,component,icon
  5. */
  6. import { AppRouteRecordRaw } from './types';
  7. import { getTreeItem } from '@/utils';
  8. import { cloneDeep } from 'lodash-es';
  9. const fullRoutes: AppRouteRecordRaw[] = [
  10. /**
  11. * Dashboard
  12. */
  13. {
  14. path: '/dashboard',
  15. name: 'Dashboard',
  16. component: 'LAYOUT',
  17. meta: {
  18. icon: 'DashboardOutlined',
  19. title: 'Dashboard',
  20. },
  21. children: [
  22. {
  23. // 主控台
  24. path: 'console',
  25. name: 'DashboardConsole',
  26. component: '/dashboard/home/Home',
  27. meta: {
  28. icon: '',
  29. title: '主控台',
  30. },
  31. }
  32. ]
  33. },
  34. /**
  35. * 场景管理
  36. */
  37. {
  38. path: '/scene',
  39. name: 'Scene',
  40. component: 'LAYOUT',
  41. meta: {
  42. icon: 'ApartmentOutlined',
  43. title: '场景管理',
  44. },
  45. children: [
  46. {
  47. // 模板管理
  48. path: 'template',
  49. name: 'SceneTemplate',
  50. component: '/templateManage/templateManage',
  51. meta: {
  52. icon: '',
  53. title: '模板管理',
  54. },
  55. },
  56. {
  57. // 车间管理
  58. path: 'workshop',
  59. name: 'SceneWorkshop',
  60. component: '/system-config/scene-manage/SceneManage',
  61. meta: {
  62. icon: '',
  63. title: '车间管理'
  64. },
  65. },
  66. {
  67. // 业务场景管理
  68. path: 'business',
  69. name: 'SceneBusiness',
  70. component: '/system-config/business-scene/PageBusinessScene',
  71. meta: {
  72. icon: '',
  73. title: '业务创建管理',
  74. },
  75. }
  76. ]
  77. },
  78. /**
  79. * 设备管理
  80. */
  81. {
  82. path: '/device',
  83. name: 'Device',
  84. component: 'LAYOUT',
  85. meta: {
  86. icon: 'CameraOutlined',
  87. title: '设备管理'
  88. },
  89. children: [
  90. {
  91. // 相机设备
  92. path: 'camera',
  93. name: 'DeviceCamera',
  94. component: '/cameras/overview/CamerasOverview',
  95. meta: {
  96. icon: '',
  97. title: '相机设备'
  98. },
  99. },
  100. {
  101. // NVR设备
  102. path: 'nvr',
  103. name: 'DeviceNVR',
  104. component: '/cameras/nvrlist/NvrList',
  105. meta: {
  106. icon: '',
  107. title: 'NVR设备'
  108. },
  109. }
  110. ]
  111. },
  112. /**
  113. * 布局管理
  114. */
  115. {
  116. path: '/layout',
  117. name: 'Layout',
  118. component: 'LAYOUT',
  119. meta: {
  120. icon: 'PictureOutlined',
  121. title: '布局管理',
  122. },
  123. children: [
  124. {
  125. // 公司场景布局入口页,选择PC端还是手机端
  126. path: 'scene',
  127. name: 'LayoutScene',
  128. component: '/page-config/PageScene',
  129. meta: {
  130. icon: '',
  131. title: '场景布局',
  132. },
  133. },
  134. {
  135. // 公司场景布局卡片列表。菜单不可见
  136. path: 'scene-list',
  137. name: 'LayoutSceneList',
  138. component: '/page-config/PageSceneList',
  139. meta: {
  140. icon: '',
  141. title: '场景布局列表(菜单不可见)'
  142. }
  143. },
  144. {
  145. // 公司场景配置页面(菜单不可见)
  146. path: 'scene-config',
  147. name: 'LayoutSceneConfig',
  148. component: '/page-config/ConfigEdit',
  149. meta: {
  150. icon: '',
  151. title: '场景布局配置(菜单不可见)'
  152. }
  153. },
  154. {
  155. // 相机布局入口页,选择PC端还是手机端
  156. path: 'camera',
  157. name: 'LayoutCamera',
  158. component: '/page-config/PageCamera',
  159. meta: {
  160. icon: '',
  161. title: '相机布局',
  162. }
  163. },
  164. {
  165. // 相机布局卡片列表。 菜单不可见
  166. path: 'camera-list',
  167. name: 'LayoutCameraList',
  168. component: '/page-config/PageCameraList',
  169. meta: {
  170. icon: '',
  171. title: '相机布局列表(菜单不可见)',
  172. }
  173. },
  174. {
  175. // 相机布局配置
  176. path: 'camera-config',
  177. name: 'LayoutCameraConfig',
  178. component: '/map-config/mini-map/MiniMapConfig',
  179. meta: {
  180. icon: '',
  181. title: '相机布局配置(菜单不可见)',
  182. }
  183. }
  184. ]
  185. },
  186. /**
  187. * 算法管理
  188. */
  189. {
  190. path: '/algorithm',
  191. name: 'Algorithm',
  192. component: 'LAYOUT',
  193. meta: {
  194. icon: 'FunctionOutlined',
  195. title: '算法管理',
  196. },
  197. children: [
  198. {
  199. // 算法预览
  200. path: 'preview',
  201. name: 'AlgorithmPreview',
  202. component: '/cameras/algo-management/algoManagement',
  203. meta: {
  204. icon: '',
  205. title: '算法预览',
  206. },
  207. },
  208. {
  209. // 算法配置
  210. path: 'config',
  211. name: 'AlgorithmConfig',
  212. component: '/cameras/preview/CameraPreview',
  213. meta: {
  214. ico: '',
  215. title: '算法配置',
  216. },
  217. }
  218. ]
  219. },
  220. /**
  221. * 用户管理
  222. */
  223. {
  224. path: '/user',
  225. name: 'User',
  226. component: 'LAYOUT',
  227. meta: {
  228. icon: 'UserOutlined',
  229. title: '用户管理',
  230. },
  231. children: [
  232. {
  233. // 账号管理
  234. path: 'account',
  235. name: 'UserAccount',
  236. component: '/system/user/user',
  237. meta: {
  238. icon: '',
  239. title: '账号管理',
  240. }
  241. },
  242. {
  243. // 角色管理
  244. path: 'role',
  245. name: 'UserRole',
  246. component: '/system/role/role',
  247. meta: {
  248. icon: '',
  249. title: '角色管理',
  250. }
  251. },
  252. {
  253. // 组织管理
  254. path: 'department',
  255. name: 'UserDepartment',
  256. component: '/auth/dept/dept',
  257. meta: {
  258. icon: '',
  259. title: '组织管理',
  260. }
  261. },
  262. {
  263. // 岗位管理 (目前不需要)
  264. path: 'post',
  265. name: 'UserPost',
  266. component: '/auth/post/post',
  267. meta: {
  268. icon: '',
  269. title: '岗位管理'
  270. }
  271. }
  272. ]
  273. },
  274. /**
  275. * 消息管理
  276. */
  277. {
  278. path: '/message',
  279. name: 'Message',
  280. component: 'LAYOUT',
  281. meta: {
  282. icon: 'SendOutlined',
  283. title: '消息管理',
  284. },
  285. children: [
  286. {
  287. // 报表推送
  288. path: 'report',
  289. name: 'MessageReport',
  290. component: '/message/reportmessage/ReportMessage',
  291. meta: {
  292. icon: '',
  293. title: '报表推送',
  294. },
  295. },
  296. {
  297. // 报表推送配置(菜单不可见)
  298. path: 'report-config',
  299. name: 'MessageReportConfig',
  300. component: '/message/reportmessage/ReportOperation',
  301. meta: {
  302. icon: '',
  303. title: '报表推送配置(菜单不可见)'
  304. },
  305. },
  306. {
  307. // 报警推送
  308. path: 'alarm',
  309. name: 'MessageAlarm',
  310. component: '/message/alarmMessages/alarmMessages',
  311. meta: {
  312. icon: '',
  313. title: '报警推送',
  314. },
  315. },
  316. {
  317. // 报警推送配置 (菜单不可见)
  318. path: 'alarm-config',
  319. name: 'MessageAlarmConfig',
  320. component: '/message/alarm-config/AlarmConfig',
  321. meta: {
  322. icon: '',
  323. title: '报警推送配置(菜单不可见)',
  324. },
  325. },
  326. {
  327. // 系统通知
  328. path: 'sys-notification',
  329. name: 'MessageSysNotification',
  330. component: '/message/systemNotifications/systemNotifications',
  331. meta: {
  332. icon: '',
  333. title: '系统通知',
  334. },
  335. },
  336. {
  337. // 系统通知配置(菜单不可见)
  338. path: 'sys-notification-config',
  339. name: 'MessageSysNotificationConfig',
  340. component: '/message/sysnotion-config/SysnotionConfig',
  341. meta: {
  342. icon: '',
  343. title: '系统通知配置(菜单不可见)',
  344. },
  345. },
  346. {
  347. // 人员分组
  348. path: 'personnel-group',
  349. name: 'MessagePersonnelGroup',
  350. component: '/message/persongroup/UserGroup',
  351. meta: {
  352. icon: '',
  353. title: '人员分组',
  354. },
  355. }
  356. ]
  357. },
  358. /**
  359. * 数据管理
  360. */
  361. {
  362. path: '/data',
  363. name: 'Data',
  364. component: 'LAYOUT',
  365. meta: {
  366. icon: 'LineChartOutlined',
  367. title: '数据管理',
  368. },
  369. children: [
  370. {
  371. // 平台统计
  372. path: 'platform',
  373. name: 'DataPlatform',
  374. component: '/datamanager/platformdata/PlatformData',
  375. meta: {
  376. icon: '',
  377. title: '平台统计'
  378. }
  379. },
  380. {
  381. // 历史视频 (视频回看)
  382. path: 'playback',
  383. name: 'DataPlayback',
  384. component: '/datamanager/playback/Playback',
  385. meta: {
  386. icon: '',
  387. title: '历史视频'
  388. }
  389. },
  390. {
  391. // 违规问题
  392. path: 'violation',
  393. name: 'DataViolation',
  394. component: '/datamanager/alertformdata/AlertformData',
  395. meta: {
  396. icon: '',
  397. title: '违规问题'
  398. }
  399. }
  400. ]
  401. },
  402. /**
  403. * 系统管理 (只有超管可见)
  404. */
  405. {
  406. path: '/system',
  407. name: 'System',
  408. component: 'LAYOUT',
  409. meta: {
  410. icon: 'OptionsSharp',
  411. title: '系统管理',
  412. },
  413. children: [
  414. {
  415. // 租户管理
  416. path: 'tenant',
  417. name: 'SystemTenant',
  418. component: '/system/tenant/tenant',
  419. meta: {
  420. icon: '',
  421. title: '租户管理',
  422. }
  423. },
  424. {
  425. // 菜单管理
  426. path: 'menu',
  427. name: 'SystemMenu',
  428. component: '/system/menu/menu',
  429. meta: {
  430. icon: '',
  431. title: '菜单管理',
  432. }
  433. },
  434. {
  435. // 权限管理
  436. path: 'permission',
  437. name: 'SystemPermission',
  438. component: '/system/permssion/PagePermission',
  439. meta: {
  440. icon: '',
  441. title: '权限管理',
  442. }
  443. },
  444. {
  445. // 平台反馈
  446. path: 'feedback',
  447. name: 'SystemFeedback',
  448. component: '/feedback/feedback',
  449. meta: {
  450. icon: '',
  451. title: '平台反馈',
  452. }
  453. },
  454. {
  455. // 反馈处理
  456. path: 'feedback-handle',
  457. name: 'SystemFeedbackHandle',
  458. component: '/feedback/handleFeedback',
  459. meta: {
  460. icon: '',
  461. title: '反馈处理'
  462. }
  463. },
  464. {
  465. // 字典管理
  466. path: 'dictionary',
  467. name: 'SystemDictionary',
  468. component: '/system/dictionary/dictionary',
  469. meta: {
  470. icon: '',
  471. title: '字典管理',
  472. }
  473. },
  474. {
  475. // 日志管理
  476. path: 'logs',
  477. name: 'SytemLogs',
  478. component: 'ParentLayout',
  479. meta: {
  480. icon: '',
  481. title: '日志管理',
  482. },
  483. children: [
  484. {
  485. // 操作日志
  486. path: 'operation',
  487. name: 'SystemLogsOperation',
  488. component: '/system/logs/operlog',
  489. meta: {
  490. icon: '',
  491. title: '操作日志',
  492. },
  493. },
  494. {
  495. // 登录日志
  496. path: 'login',
  497. name: 'SystemLogsLogin',
  498. component: '/system/logs/logininfor',
  499. meta: {
  500. icon: '',
  501. title: '登录日志',
  502. }
  503. }
  504. ]
  505. }
  506. ]
  507. },
  508. /**
  509. * 异常页面
  510. */
  511. {
  512. path: '/exception',
  513. name: 'Exception',
  514. component: 'LAYOUT',
  515. redirect: '/exception/403',
  516. meta: {
  517. icon: 'ExclamationCircleOutlined',
  518. title: '异常页面',
  519. },
  520. children: [
  521. {
  522. // 403,
  523. path: '403',
  524. name: 'Exception403',
  525. component: '/exception/403',
  526. meta: {
  527. icon: '',
  528. title: '403',
  529. },
  530. },
  531. {
  532. path: '404',
  533. name: '/exception/404',
  534. component: '/exception/404',
  535. meta: {
  536. icon: '',
  537. title: '404',
  538. },
  539. },
  540. {
  541. path: '500',
  542. name: 'Exception500',
  543. component: '/exception/500',
  544. meta: {
  545. icon: '',
  546. title: '500',
  547. },
  548. },
  549. ]
  550. },
  551. ] as const;
  552. /**
  553. * 类型定义。避免与已有的定义冲突,避免与 vue-router的类型定义冲突,前面加 _ 前缀
  554. */
  555. export interface _RouteViewItem {
  556. label: string;
  557. value: string;
  558. }
  559. export type _RouteView = _RouteViewItem & { children?: _RouteViewItem[] | null };
  560. export type _RouteViewTree = _RouteView[];
  561. /**
  562. * 获取指定 父路由 下的子路由。
  563. * 若 父级路由 未指定,则返回一级路由
  564. */
  565. export function getChildRoutesView(parentRouteName?: string | null ): _RouteViewItem[] {
  566. // 未指定 parentRouteName, 则返回 level1 的路由
  567. if (parentRouteName == null) {
  568. return fullRoutes.map(route => ({
  569. label: route.meta.title as string,
  570. value: route.name,
  571. }));
  572. }
  573. // 获取指定父路由的子路由
  574. const parentRoute: AppRouteRecordRaw = cloneDeep(getTreeItem(fullRoutes, parentRouteName, 'name'));
  575. if (parentRoute.children && parentRoute.children.length > 0) {
  576. return parentRoute.children.map(route => ({
  577. label: route.meta.title as string,
  578. value: route.name,
  579. }));
  580. } else {
  581. return [];
  582. }
  583. }
  584. /**
  585. * 获取指定的 路由信息
  586. */
  587. export function getRouteByName(routeName: string) {
  588. return cloneDeep(getTreeItem(fullRoutes, routeName, 'name')) as AppRouteRecordRaw;
  589. }
  590. /**
  591. * 转换成 el-tree-select 的数据结构形式
  592. */
  593. export function transformToRouteViewTree(routes?: AppRouteRecordRaw[] | null) {
  594. const tree: _RouteViewTree = [];
  595. if (routes == null) return tree;
  596. for(const route of routes) {
  597. const treeItem: _RouteView = {
  598. value: route.name,
  599. label: route.meta.title as string,
  600. children: null
  601. }
  602. if (route.children && route.children.length > 0) {
  603. treeItem.children = transformToRouteViewTree(route.children);
  604. tree.push(treeItem);
  605. } else {
  606. tree.push(treeItem);
  607. }
  608. }
  609. return tree;
  610. }
  611. export const routeViewTree = transformToRouteViewTree(fullRoutes);