index.js 2.39 KB
Newer Older
1 2
import Vue from "vue";
import VueRouter from "vue-router";
fukai committed
3

4 5 6 7
import Display from "../views/Display";
import Login from "../views/Login";
import Layout from "../views/Layout";
import BusRouter from "../views/Business/BusRouter";
潘际乾 committed
8
import ReviewRouter from "../views/Review/ReviewRouter";
9
import DocRouter from "../views/Docpan/DocRouter";
fukai committed
10

11
Vue.use(VueRouter);
fukai committed
12

13 14 15 16
const DisplayRouter = BusRouter.map(route => {
    const newRoute = Object.assign({}, route)
    newRoute.name = newRoute.name + 'Display'
    return newRoute;
fukai committed
17 18
})

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/**
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 * 
 * name:'router-name'             name 必填 <keep-alive>使用这个
 * meta : {
 *   title: 'title'               title
 *   icon: 'svg-name'/'el-icon-x' 图标
 *   noCache: true                无需缓存起来的页面
 *   affix: true                  固定的页面视图
 *   activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
 * }
 */
export const routes = [
    // 刷新时使用
    {
        path: '/redirect',
        component: Layout,
        hidden: true,
        children: [
            {
                path: '/redirect/:path(.*)',
                component: () => import('~/views/Redirect/index')
            }
        ]
    },
    {
        path: "/",
        component: Layout,
        redirect: "/home",
        children: [
潘际乾 committed
49 50
            { path: 'home', component: () => import('~/views/Home'), name: 'Home', meta: { title: '首页', icon: 'el-icon-s-home', affix: true } },
            { path: 'taskList', component: () => import('~/views/TaskList'), name: 'TaskList', meta: { title: '任务列表', icon: 'el-icon-s-claim', affix: true } },
51 52
        ],
    },
潘际乾 committed
53
    { path: "/review", component: Layout, children: ReviewRouter },
54
    { path: "/business", component: Layout, children: BusRouter },
潘际乾 committed
55 56
    { path: "/display", component: Display, children: DisplayRouter },
    { path: "/login", component: Login, name: "Login" },
57 58 59 60 61 62 63 64 65 66 67 68 69
    { path: "/docpan", component: () => import("../views/Docpan"), children: DocRouter },
];

const rootRouter = new VueRouter({
    routes,
});


// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
fukai committed
70

71
export default rootRouter;