| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
- /* Layout */
- import Layout from '@/layout/index.vue';
- /**
- * Note: 路由配置项
- *
- * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
- * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
- * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
- * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
- * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
- * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
- * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
- * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
- * roles: ['admin', 'common'] // 访问路由的角色权限
- * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
- * meta : {
- noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
- title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
- icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
- breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
- activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
- }
- */
- // 公共路由
- export const constantRoutes: RouteRecordRaw[] = [
- {
- path: '/redirect',
- component: Layout,
- hidden: true,
- children: [
- {
- path: '/redirect/:path(.*)',
- component: () => import('@/views/redirect/index.vue')
- }
- ]
- },
- {
- path: '/social-callback',
- hidden: true,
- component: () => import('@/layout/components/SocialCallback/index.vue')
- },
- {
- path: '/login',
- component: () => import('@/views/login.vue'),
- hidden: true
- },
- {
- path: '/register',
- component: () => import('@/views/register.vue'),
- hidden: true
- },
- {
- path: '/:pathMatch(.*)*',
- component: () => import('@/views/error/404.vue'),
- hidden: true
- },
- {
- path: '/401',
- component: () => import('@/views/error/401.vue'),
- hidden: true
- },
- {
- path: '',
- component: Layout,
- redirect: '/index',
- children: [
- {
- path: '/index',
- component: () => import('@/views/index.vue'),
- name: 'Index',
- meta: { title: '首页', icon: 'dashboard', affix: true }
- }
- ]
- },
- {
- path: '/user',
- component: Layout,
- hidden: true,
- redirect: 'noredirect',
- children: [
- {
- path: 'profile',
- component: () => import('@/views/system/user/profile/index.vue'),
- name: 'Profile',
- meta: { title: '个人中心', icon: 'user' }
- }
- ]
- }
- ];
- // 动态路由,基于用户权限动态去加载
- export const dynamicRoutes: RouteRecordRaw[] = [
- {
- path: '/system',
- component: Layout,
- hidden: true,
- redirect: 'noredirect',
- name: 'System',
- meta: { title: '系统管理', icon: 'system' },
- children: [
- {
- path: 'user',
- component: () => import('@/views/system/user/index.vue'),
- name: 'SystemUser',
- meta: { title: '用户管理', icon: 'user', permissions: ['system:user:list'] }
- },
- {
- path: 'role',
- component: () => import('@/views/system/role/index.vue'),
- name: 'SystemRole',
- meta: { title: '角色管理', icon: 'peoples', permissions: ['system:role:list'] }
- },
- {
- path: 'menu',
- component: () => import('@/views/system/menu/index.vue'),
- name: 'SystemMenu',
- meta: { title: '菜单管理', icon: 'tree-table', permissions: ['system:menu:list'] }
- },
- {
- path: 'dept',
- component: () => import('@/views/system/dept/index.vue'),
- name: 'SystemDept',
- meta: { title: '部门管理', icon: 'tree', permissions: ['system:dept:list'] }
- },
- {
- path: 'post',
- component: () => import('@/views/system/post/index.vue'),
- name: 'SystemPost',
- meta: { title: '岗位管理', icon: 'post', permissions: ['system:post:list'] }
- },
- {
- path: 'dict',
- component: () => import('@/views/system/dict/index.vue'),
- name: 'SystemDict',
- meta: { title: '字典管理', icon: 'dict', permissions: ['system:dict:list'] }
- },
- {
- path: 'config',
- component: () => import('@/views/system/config/index.vue'),
- name: 'SystemConfig',
- meta: { title: '参数设置', icon: 'edit', permissions: ['system:config:list'] }
- },
- {
- path: 'notice',
- component: () => import('@/views/system/notice/index.vue'),
- name: 'SystemNotice',
- meta: { title: '通知公告', icon: 'message', permissions: ['system:notice:list'] }
- },
- {
- path: 'client',
- component: () => import('@/views/system/client/index.vue'),
- name: 'SystemClient',
- meta: { title: '客户端管理', icon: 'tab', permissions: ['system:client:list'] }
- },
- {
- path: 'oss',
- component: () => import('@/views/system/oss/index.vue'),
- name: 'SystemOss',
- meta: { title: '对象存储', icon: 'upload', permissions: ['system:oss:list'] }
- },
- {
- path: 'tenant',
- component: () => import('@/views/system/tenant/index.vue'),
- name: 'SystemTenant',
- meta: { title: '租户管理', icon: 'chart', permissions: ['system:tenant:list'] }
- }
- ]
- },
- {
- path: '/monitor',
- component: Layout,
- hidden: true,
- redirect: 'noredirect',
- name: 'Monitor',
- meta: { title: '系统监控', icon: 'monitor' },
- children: [
- {
- path: 'online',
- component: () => import('@/views/monitor/online/index.vue'),
- name: 'MonitorOnline',
- meta: { title: '在线用户', icon: 'online', permissions: ['monitor:online:list'] }
- },
- {
- path: 'operlog',
- component: () => import('@/views/monitor/operlog/index.vue'),
- name: 'MonitorOperlog',
- meta: { title: '操作日志', icon: 'form', permissions: ['monitor:operlog:list'] }
- },
- {
- path: 'logininfor',
- component: () => import('@/views/monitor/logininfor/index.vue'),
- name: 'MonitorLogininfor',
- meta: { title: '登录日志', icon: 'logininfor', permissions: ['monitor:logininfor:list'] }
- },
- {
- path: 'cache',
- component: () => import('@/views/monitor/cache/index.vue'),
- name: 'MonitorCache',
- meta: { title: '缓存监控', icon: 'redis', permissions: ['monitor:cache:list'] }
- },
- {
- path: 'snailjob',
- component: () => import('@/views/monitor/snailjob/index.vue'),
- name: 'MonitorSnailjob',
- meta: { title: '任务调度', icon: 'job', permissions: ['monitor:snailjob:list'] }
- },
- {
- path: 'admin',
- component: () => import('@/views/monitor/admin/index.vue'),
- name: 'MonitorAdmin',
- meta: { title: '服务监控', icon: 'server', permissions: ['monitor:admin:list'] }
- }
- ]
- },
- {
- path: 'tool',
- component: Layout,
- hidden: true,
- redirect: 'noredirect',
- name: 'Tool',
- meta: { title: '系统工具', icon: 'tool' },
- children: [
- {
- path: 'gen',
- component: () => import('@/views/tool/gen/index.vue'),
- name: 'ToolGen',
- meta: { title: '代码生成', icon: 'code', permissions: ['tool:gen:list'] }
- }
- ]
- },
- {
- path: 'demo',
- component: Layout,
- hidden: true,
- redirect: 'noredirect',
- name: 'Demo',
- meta: { title: '演示菜单', icon: 'star' },
- children: [
- {
- path: 'demo',
- component: () => import('@/views/demo/demo/index.vue'),
- name: 'DemoDemo',
- meta: { title: '演示单表', icon: 'build', permissions: ['demo:demo:list'] }
- },
- {
- path: 'tree',
- component: () => import('@/views/demo/tree/index.vue'),
- name: 'DemoTree',
- meta: { title: '演示树表', icon: 'tree-table', permissions: ['demo:tree:list'] }
- }
- ]
- },
- {
- path: '/risk',
- component: Layout,
- redirect: 'noredirect',
- name: 'Risk',
- meta: { title: '风控平台', icon: 'warning' },
- children: [
- {
- path: 'hiddenDanger',
- component: () => import('@/views/risk/hiddenDanger/index.vue'),
- name: 'RiskHiddenDanger',
- meta: { title: '安全隐患', icon: 'warning', permissions: ['risk:hiddenDanger:list'] }
- },
- {
- path: 'dangerSource',
- component: () => import('@/views/risk/dangerSource/index.vue'),
- name: 'RiskDangerSource',
- meta: { title: '危险源上报', icon: 'guide', permissions: ['risk:dangerSource:list'] }
- },
- {
- path: 'workReport',
- component: () => import('@/views/risk/workReport/index.vue'),
- name: 'RiskWorkReport',
- meta: { title: '作业上报', icon: 'documentation', permissions: ['risk:workReport:list'] }
- },
- {
- path: 'personnel',
- component: () => import('@/views/risk/personnel/index.vue'),
- name: 'RiskPersonnel',
- meta: { title: '人员信息', icon: 'peoples', permissions: ['risk:personnel:list'] }
- },
- {
- path: 'personnelChange',
- component: () => import('@/views/risk/personnelChange/index.vue'),
- name: 'RiskPersonnelChange',
- meta: { title: '审计工作', icon: 'log', permissions: ['risk:personnelChange:list'] }
- },
- {
- path: 'warning',
- component: () => import('@/views/risk/warning/index.vue'),
- name: 'RiskWarning',
- meta: { title: '风险警示', icon: 'message', permissions: ['risk:warning:list'] }
- },
- {
- path: 'specialEquipment',
- component: () => import('@/views/risk/specialEquipment/index.vue'),
- name: 'RiskSpecialEquipment',
- meta: { title: '特种设备', icon: 'tree', permissions: ['risk:specialEquipment:list'] }
- },
- {
- path: 'publicOpinion',
- component: () => import('@/views/risk/publicOpinion/index.vue'),
- name: 'RiskPublicOpinion',
- meta: { title: '舆情推送', icon: 'email', permissions: ['risk:publicOpinion:list'] }
- },
- {
- path: 'accident',
- component: () => import('@/views/risk/accident/index.vue'),
- name: 'RiskAccident',
- meta: { title: '事故上报', icon: 'bug', permissions: ['risk:accident:list'] }
- },
- {
- path: 'inspectionTask',
- component: () => import('@/views/risk/inspectionTask/index.vue'),
- name: 'RiskInspectionTask',
- meta: { title: '巡检任务', icon: 'list', permissions: ['risk:inspectionTask:list'] }
- },
- {
- path: 'qualityInspectionTask',
- component: () => import('@/views/risk/qualityInspectionTask/index.vue'),
- name: 'RiskQualityInspectionTask',
- meta: { title: '品控巡检', icon: 'list', permissions: ['risk:qualityInspectionTask:list'] }
- },
- {
- path: 'factoryVisit',
- component: () => import('@/views/risk/factoryVisit/index.vue'),
- name: 'RiskFactoryVisit',
- meta: { title: '品控访厂', icon: 'guide', permissions: ['risk:factoryVisit:list'] }
- },
- {
- path: 'bigScreen',
- component: () => import('@/views/risk/bigScreen/index.vue'),
- name: 'RiskBigScreen',
- meta: { title: '风控大屏', icon: 'data-board', permissions: ['risk:bigScreen:view'] }
- }
- ]
- }
- ];
- /**
- * 创建路由
- */
- const router = createRouter({
- history: createWebHistory(import.meta.env.VITE_APP_CONTEXT_PATH),
- routes: constantRoutes,
- // 刷新时,滚动条位置还原
- scrollBehavior(to, from, savedPosition) {
- if (savedPosition) {
- return savedPosition;
- }
- return { top: 0 };
- }
- });
- export default router;import { createWebHistory, createRouter, RouteRecordRaw } from 'vue-router';
- /* Layout */
- import Layout from '@/layout/index.vue';
- /**
- * Note: 路由配置项
- *
- * hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
- * alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
- * // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
- * // 若你想不管路由下面的 children 声明的个数都显示你的根路由
- * // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
- * redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
- * name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
- * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
- * roles: ['admin', 'common'] // 访问路由的角色权限
- * permissions: ['a:a:a', 'b:b:b'] // 访问路由的菜单权限
- * meta : {
- noCache: true // 如果设置为true,则不会被 <keep-alive> 缓存(默认 false)
- title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
- icon: 'svg-name' // 设置该路由的图标,对应路径src/assets/icons/svg
- breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
- activeMenu: '/system/user' // 当路由设置了该属性,则会高亮相对应的侧边栏。
- }
- */
- // 公共路由
|