index.js 3.12 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: 'inventoryInformation',
                    component: () => import('@/views/inventoryInformation'),
                    name: 'inventoryInformation',
                    meta: { title: '料箱库信息' },
                },
                {
                    path: 'inventoryInformation2',
                    component: () => import('@/views/inventoryInformation2'),
                    name: 'inventoryInformation2',
                    meta: { title: '电池包库信息' },
                },
                // {
                //     path: 'workstationMaterialBox_one',
                //     component: () => import('@/views/workstationMaterialBox_one'),
                //     name: 'workstationMaterialBox_one',
                //     meta: { title: '工位料箱1' },
                // },
                // {
                //     path: 'workstationMaterialBox_two',
                //     component: () => import('@/views/workstationMaterialBox_two'),
                //     name: 'workstationMaterialBox_two',
                //     meta: { title: '工位料箱2' },
                // },
                // {
                //     path: 'workstationMaterialBox_there',
                //     component: () => import('@/views/workstationMaterialBox_there'),
                //     name: 'workstationMaterialBox_there',
                //     meta: { title: '工位料箱3' },
                // },
                // {
                //     path: 'overviewOfLibraryInformation',
                //     component: () => import('@/views/overviewOfLibraryInformation'),
                //     name: 'overviewOfLibraryInformation',
                //     meta: { title: '立库信息总览' },
                // },
                // {
                //     path: 'AgvLine',
                //     component: () => import('@/views/AgvLine'),
                //     name: 'AgvLine',
                //     meta: { title: 'Agv路线图' },
                // },

            ],

        },
    ]
})

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;