index.js 2.16 KB
import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);
const router = new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/list'
        },
        {
            path: '/',
            component: () => import('@/layout/index.vue'),
            redirect: '/list',
            children: [
                {
                    //禁止修改命名list 其他地方用到
                    path: 'list',
                    component: () => import('@/views/defaultList.vue'),
                    name: 'list',
                    meta: { title: '看板列表' },
                },
                {
                    path: 'upperCloth_PP',
                    component: () => import('@/views/upperCloth_PP'),
                    name: 'upperCloth_PP',
                    meta: { title: '宏仁PP仓看板' },
                },
                {
                    path: 'upperCloth_glass',
                    component: () => import('@/views/upperCloth_glass'),
                    name: 'upperCloth_glass',
                    meta: { title: '宏仁玻璃布仓看板' },
                },
                {
                    path: 'upperCloth_mix',
                    component: () => import('@/views/upperCloth_mix'),
                    name: 'upperCloth_mix',
                    meta: { title: '宏仁混合仓看板' },
                },
                {
                    path: 'upperCloth_substrate',
                    component: () => import('@/views/upperCloth_substrate'),
                    name: 'upperCloth_substrate',
                    meta: { title: '宏仁基板仓看板.' },
                }
            ],

        },
    ]
})

var routerArr = router.options.routes;
var allRouter = null;
if (routerArr.length > 1) {
    allRouter = allRouter = routerArr[1].children;
}
router.afterEach((to, from) => {
    //console.log('后置路由守卫', to, from);
    var path = from.path;
    if (allRouter != null) {
        for (let i = 0; i < allRouter.length; i++) {
            var tempPath = "/" + allRouter[i].path;
            if (path == tempPath) window.location.reload();
        }
    }
})
export default router;