import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' /** * 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 = [ { path: '/redirect', component: Layout, hidden: true, children: [ { path: '/redirect/:path(.*)', component: () => import('@/views/redirect') } ] }, { path: '/login', component: () => import('@/views/login'), hidden: true }, { path: '/register', component: () => import('@/views/register'), hidden: true }, { path: '/404', component: () => import('@/views/error/404'), hidden: true }, { path: '/401', component: () => import('@/views/error/401'), hidden: true }, { path: '', component: Layout, redirect: 'index', children: [ { path: 'index', component: () => import('@/views/index'), 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'), name: 'Profile', meta: { title: '个人ä¸å¿ƒ', icon: 'user' } } ] } ] // 动æ€è·¯ç”±ï¼ŒåŸºäºŽç”¨æˆ·æƒé™åŠ¨æ€åŽ»åŠ è½½ export const dynamicRoutes = [ { path: '/system/user-auth', component: Layout, hidden: true, permissions: ['system:user:edit'], children: [ { path: 'role/:userId(\\d+)', component: () => import('@/views/system/user/authRole'), name: 'AuthRole', meta: { title: '分é…角色', activeMenu: '/system/user' } } ] }, { path: '/system/role-auth', component: Layout, hidden: true, permissions: ['system:role:edit'], children: [ { path: 'user/:roleId(\\d+)', component: () => import('@/views/system/role/authUser'), name: 'AuthUser', meta: { title: '分é…用户', activeMenu: '/system/role' } } ] }, { path: '/system/dict-data', component: Layout, hidden: true, permissions: ['system:dict:list'], children: [ { path: 'index/:dictId(\\d+)', component: () => import('@/views/system/dict/data'), name: 'Data', meta: { title: 'å—典数æ®', activeMenu: '/system/dict' } } ] }, { path: '/monitor/job-log', component: Layout, hidden: true, permissions: ['monitor:job:list'], children: [ { path: 'index/:jobId(\\d+)', component: () => import('@/views/monitor/job/log'), name: 'JobLog', meta: { title: '调度日志', activeMenu: '/monitor/job' } } ] }, { path: '/tool/gen-edit', component: Layout, hidden: true, permissions: ['tool:gen:edit'], children: [ { path: 'index/:tableId(\\d+)', component: () => import('@/views/tool/gen/editTable'), name: 'GenEdit', meta: { title: '修改生æˆé…ç½®', activeMenu: '/tool/gen' } } ] } ] // 防æ¢è¿žç»ç‚¹å‡»å¤šæ¬¡è·¯ç”±æŠ¥é”™ let routerPush = Router.prototype.push; let routerReplace = Router.prototype.replace; // push Router.prototype.push = function push(location) { return routerPush.call(this, location).catch(err => err) } // replace Router.prototype.replace = function push(location) { return routerReplace.call(this, location).catch(err => err) } export default new Router({ mode: 'history', // 去掉urlä¸çš„# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes })