| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637 |
- /**
- * 1. 前端维护的完整路由表, 用于创建"菜单"
- * 2. component 是 string,并不是 组件对象。
- * 3. 生成菜单,关注的 path,name,component,icon
- */
- import { AppRouteRecordRaw } from './types';
- import { getTreeItem } from '@/utils';
- import { cloneDeep } from 'lodash-es';
- const fullRoutes: AppRouteRecordRaw[] = [
- /**
- * Dashboard
- */
- {
- path: '/dashboard',
- name: 'Dashboard',
- component: 'LAYOUT',
- meta: {
- icon: 'DashboardOutlined',
- title: 'Dashboard',
- },
- children: [
- {
- // 主控台
- path: 'console',
- name: 'DashboardConsole',
- component: '/dashboard/home/Home',
- meta: {
- icon: '',
- title: '主控台',
- },
- }
- ]
- },
- /**
- * 场景管理
- */
- {
- path: '/scene',
- name: 'Scene',
- component: 'LAYOUT',
- meta: {
- icon: 'ApartmentOutlined',
- title: '场景管理',
- },
- children: [
- {
- // 模板管理
- path: 'template',
- name: 'SceneTemplate',
- component: '/templateManage/templateManage',
- meta: {
- icon: '',
- title: '模板管理',
- },
- },
- {
- // 车间管理
- path: 'workshop',
- name: 'SceneWorkshop',
- component: '/system-config/scene-manage/SceneManage',
- meta: {
- icon: '',
- title: '车间管理'
- },
- },
- {
- // 业务场景管理
- path: 'business',
- name: 'SceneBusiness',
- component: '/system-config/business-scene/PageBusinessScene',
- meta: {
- icon: '',
- title: '业务创建管理',
- },
- }
- ]
- },
- /**
- * 设备管理
- */
- {
- path: '/device',
- name: 'Device',
- component: 'LAYOUT',
- meta: {
- icon: 'CameraOutlined',
- title: '设备管理'
- },
- children: [
- {
- // 相机设备
- path: 'camera',
- name: 'DeviceCamera',
- component: '/cameras/overview/CamerasOverview',
- meta: {
- icon: '',
- title: '相机设备'
- },
- },
- {
- // NVR设备
- path: 'nvr',
- name: 'DeviceNVR',
- component: '/cameras/nvrlist/NvrList',
- meta: {
- icon: '',
- title: 'NVR设备'
- },
- }
- ]
- },
- /**
- * 布局管理
- */
- {
- path: '/layout',
- name: 'Layout',
- component: 'LAYOUT',
- meta: {
- icon: 'PictureOutlined',
- title: '布局管理',
- },
- children: [
- {
- // 公司场景布局入口页,选择PC端还是手机端
- path: 'scene',
- name: 'LayoutScene',
- component: '/page-config/PageScene',
- meta: {
- icon: '',
- title: '场景布局',
- },
- },
- {
- // 公司场景布局卡片列表。菜单不可见
- path: 'scene-list',
- name: 'LayoutSceneList',
- component: '/page-config/PageSceneList',
- meta: {
- icon: '',
- title: '场景布局列表(菜单不可见)'
- }
- },
- {
- // 公司场景配置页面(菜单不可见)
- path: 'scene-config',
- name: 'LayoutSceneConfig',
- component: '/page-config/ConfigEdit',
- meta: {
- icon: '',
- title: '场景布局配置(菜单不可见)'
- }
- },
- {
- // 相机布局入口页,选择PC端还是手机端
- path: 'camera',
- name: 'LayoutCamera',
- component: '/page-config/PageCamera',
- meta: {
- icon: '',
- title: '相机布局',
- }
- },
- {
- // 相机布局卡片列表。 菜单不可见
- path: 'camera-list',
- name: 'LayoutCameraList',
- component: '/page-config/PageCameraList',
- meta: {
- icon: '',
- title: '相机布局列表(菜单不可见)',
- }
- },
- {
- // 相机布局配置
- path: 'camera-config',
- name: 'LayoutCameraConfig',
- component: '/map-config/mini-map/MiniMapConfig',
- meta: {
- icon: '',
- title: '相机布局配置(菜单不可见)',
- }
- }
- ]
- },
- /**
- * 算法管理
- */
- {
- path: '/algorithm',
- name: 'Algorithm',
- component: 'LAYOUT',
- meta: {
- icon: 'FunctionOutlined',
- title: '算法管理',
- },
- children: [
- {
- // 算法预览
- path: 'preview',
- name: 'AlgorithmPreview',
- component: '/cameras/algo-management/algoManagement',
- meta: {
- icon: '',
- title: '算法预览',
- },
- },
- {
- // 算法配置
- path: 'config',
- name: 'AlgorithmConfig',
- component: '/cameras/preview/CameraPreview',
- meta: {
- ico: '',
- title: '算法配置',
- },
- }
- ]
- },
- /**
- * 用户管理
- */
- {
- path: '/user',
- name: 'User',
- component: 'LAYOUT',
- meta: {
- icon: 'UserOutlined',
- title: '用户管理',
- },
- children: [
- {
- // 账号管理
- path: 'account',
- name: 'UserAccount',
- component: '/system/user/user',
- meta: {
- icon: '',
- title: '账号管理',
- }
- },
- {
- // 角色管理
- path: 'role',
- name: 'UserRole',
- component: '/system/role/role',
- meta: {
- icon: '',
- title: '角色管理',
- }
- },
- {
- // 组织管理
- path: 'department',
- name: 'UserDepartment',
- component: '/auth/dept/dept',
- meta: {
- icon: '',
- title: '组织管理',
- }
- },
- {
- // 岗位管理 (目前不需要)
- path: 'post',
- name: 'UserPost',
- component: '/auth/post/post',
- meta: {
- icon: '',
- title: '岗位管理'
- }
- }
- ]
- },
- /**
- * 消息管理
- */
- {
- path: '/message',
- name: 'Message',
- component: 'LAYOUT',
- meta: {
- icon: 'SendOutlined',
- title: '消息管理',
- },
- children: [
- {
- // 报表推送
- path: 'report',
- name: 'MessageReport',
- component: '/message/reportmessage/ReportMessage',
- meta: {
- icon: '',
- title: '报表推送',
- },
- },
- {
- // 报表推送配置(菜单不可见)
- path: 'report-config',
- name: 'MessageReportConfig',
- component: '/message/reportmessage/ReportOperation',
- meta: {
- icon: '',
- title: '报表推送配置(菜单不可见)'
- },
- },
- {
- // 报警推送
- path: 'alarm',
- name: 'MessageAlarm',
- component: '/message/alarmMessages/alarmMessages',
- meta: {
- icon: '',
- title: '报警推送',
- },
- },
- {
- // 报警推送配置 (菜单不可见)
- path: 'alarm-config',
- name: 'MessageAlarmConfig',
- component: '/message/alarm-config/AlarmConfig',
- meta: {
- icon: '',
- title: '报警推送配置(菜单不可见)',
- },
- },
- {
- // 系统通知
- path: 'sys-notification',
- name: 'MessageSysNotification',
- component: '/message/systemNotifications/systemNotifications',
- meta: {
- icon: '',
- title: '系统通知',
- },
- },
- {
- // 系统通知配置(菜单不可见)
- path: 'sys-notification-config',
- name: 'MessageSysNotificationConfig',
- component: '/message/sysnotion-config/SysnotionConfig',
- meta: {
- icon: '',
- title: '系统通知配置(菜单不可见)',
- },
- },
- {
- // 人员分组
- path: 'personnel-group',
- name: 'MessagePersonnelGroup',
- component: '/message/persongroup/UserGroup',
- meta: {
- icon: '',
- title: '人员分组',
- },
- }
- ]
- },
- /**
- * 数据管理
- */
- {
- path: '/data',
- name: 'Data',
- component: 'LAYOUT',
- meta: {
- icon: 'LineChartOutlined',
- title: '数据管理',
- },
- children: [
- {
- // 平台统计
- path: 'platform',
- name: 'DataPlatform',
- component: '/datamanager/platformdata/PlatformData',
- meta: {
- icon: '',
- title: '平台统计'
- }
- },
- {
- // 历史视频 (视频回看)
- path: 'playback',
- name: 'DataPlayback',
- component: '/datamanager/playback/Playback',
- meta: {
- icon: '',
- title: '历史视频'
- }
- },
- {
- // 违规问题
- path: 'violation',
- name: 'DataViolation',
- component: '/datamanager/alertformdata/AlertformData',
- meta: {
- icon: '',
- title: '违规问题'
- }
- }
- ]
- },
- /**
- * 系统管理 (只有超管可见)
- */
- {
- path: '/system',
- name: 'System',
- component: 'LAYOUT',
- meta: {
- icon: 'OptionsSharp',
- title: '系统管理',
- },
- children: [
- {
- // 租户管理
- path: 'tenant',
- name: 'SystemTenant',
- component: '/system/tenant/tenant',
- meta: {
- icon: '',
- title: '租户管理',
- }
- },
- {
- // 菜单管理
- path: 'menu',
- name: 'SystemMenu',
- component: '/system/menu/menu',
- meta: {
- icon: '',
- title: '菜单管理',
- }
- },
- {
- // 权限管理
- path: 'permission',
- name: 'SystemPermission',
- component: '/system/permssion/PagePermission',
- meta: {
- icon: '',
- title: '权限管理',
- }
- },
- {
- // 平台反馈
- path: 'feedback',
- name: 'SystemFeedback',
- component: '/feedback/feedback',
- meta: {
- icon: '',
- title: '平台反馈',
- }
- },
- {
- // 反馈处理
- path: 'feedback-handle',
- name: 'SystemFeedbackHandle',
- component: '/feedback/handleFeedback',
- meta: {
- icon: '',
- title: '反馈处理'
- }
- },
- {
- // 字典管理
- path: 'dictionary',
- name: 'SystemDictionary',
- component: '/system/dictionary/dictionary',
- meta: {
- icon: '',
- title: '字典管理',
- }
- },
- {
- // 日志管理
- path: 'logs',
- name: 'SytemLogs',
- component: 'ParentLayout',
- meta: {
- icon: '',
- title: '日志管理',
- },
- children: [
- {
- // 操作日志
- path: 'operation',
- name: 'SystemLogsOperation',
- component: '/system/logs/operlog',
- meta: {
- icon: '',
- title: '操作日志',
- },
- },
- {
- // 登录日志
- path: 'login',
- name: 'SystemLogsLogin',
- component: '/system/logs/logininfor',
- meta: {
- icon: '',
- title: '登录日志',
- }
- }
- ]
- }
- ]
- },
- /**
- * 异常页面
- */
- {
- path: '/exception',
- name: 'Exception',
- component: 'LAYOUT',
- redirect: '/exception/403',
- meta: {
- icon: 'ExclamationCircleOutlined',
- title: '异常页面',
- },
- children: [
- {
- // 403,
- path: '403',
- name: 'Exception403',
- component: '/exception/403',
- meta: {
- icon: '',
- title: '403',
- },
- },
- {
- path: '404',
- name: '/exception/404',
- component: '/exception/404',
- meta: {
- icon: '',
- title: '404',
- },
- },
- {
- path: '500',
- name: 'Exception500',
- component: '/exception/500',
- meta: {
- icon: '',
- title: '500',
- },
-
- },
- ]
- },
- ] as const;
- /**
- * 类型定义。避免与已有的定义冲突,避免与 vue-router的类型定义冲突,前面加 _ 前缀
- */
- export interface _RouteViewItem {
- label: string;
- value: string;
- }
- export type _RouteView = _RouteViewItem & { children?: _RouteViewItem[] | null };
- export type _RouteViewTree = _RouteView[];
- /**
- * 获取指定 父路由 下的子路由。
- * 若 父级路由 未指定,则返回一级路由
- */
- export function getChildRoutesView(parentRouteName?: string | null ): _RouteViewItem[] {
- // 未指定 parentRouteName, 则返回 level1 的路由
- if (parentRouteName == null) {
- return fullRoutes.map(route => ({
- label: route.meta.title as string,
- value: route.name,
- }));
- }
- // 获取指定父路由的子路由
- const parentRoute: AppRouteRecordRaw = cloneDeep(getTreeItem(fullRoutes, parentRouteName, 'name'));
- if (parentRoute.children && parentRoute.children.length > 0) {
- return parentRoute.children.map(route => ({
- label: route.meta.title as string,
- value: route.name,
- }));
- } else {
- return [];
- }
- }
- /**
- * 获取指定的 路由信息
- */
- export function getRouteByName(routeName: string) {
- return cloneDeep(getTreeItem(fullRoutes, routeName, 'name')) as AppRouteRecordRaw;
- }
- /**
- * 转换成 el-tree-select 的数据结构形式
- */
- export function transformToRouteViewTree(routes?: AppRouteRecordRaw[] | null) {
- const tree: _RouteViewTree = [];
- if (routes == null) return tree;
- for(const route of routes) {
- const treeItem: _RouteView = {
- value: route.name,
- label: route.meta.title as string,
- children: null
- }
- if (route.children && route.children.length > 0) {
- treeItem.children = transformToRouteViewTree(route.children);
- tree.push(treeItem);
- } else {
- tree.push(treeItem);
- }
- }
-
- return tree;
- }
- export const routeViewTree = transformToRouteViewTree(fullRoutes);
|