import Vue from 'vue' import VueRouter from 'vue-router' Vue.use(VueRouter) const routes = [ { path: '/', name: 'login', component: function () { return import('../views/login.vue') }, meta: { keepAlive: false, title: '登录' } }, { path: '/home', name: 'home', component: function () { return import('../views/home.vue') }, meta: { keepAlive: false, title: '首页' } }, { path: '/system/role', name: 'role', component: function () { return import('../views/system/role.vue') }, meta: { keepAlive: true, title: '角色管理' } }, { path: '/system/user', name: 'user', component: function () { return import('../views/system/user.vue') }, meta: { keepAlive: true, title: '用户管理' } }, { path: '/system/log', name: 'log', component: function () { return import('../views/system/log.vue') }, meta: { keepAlive: true, title: '系统日志' } }, { path: '/platform/workstation', name: 'workstation', component: function () { return import('../views/platform/workstation.vue') }, meta: { keepAlive: true, title: '工站管理' } }, { path: '/platform/productionLine', name: 'productionLine', component: function () { return import('../views/platform/productionLine.vue') }, meta: { keepAlive: true, title: '生产线管理' } }, { path: '/platform/product', name: 'product', component: function () { return import('../views/platform/product.vue') }, meta: { keepAlive: true, title: '产品管理' } }, { path: '/platform/nonconformity', name: 'nonconformity', component: function () { return import('../views/platform/nonconformity.vue') }, meta: { keepAlive: true, title: '生产不合格原因' } }, { path: '/platform/scrap', name: 'scrap', component: function () { return import('../views/platform/scrap.vue') }, meta: { keepAlive: true, title: '设备报废原因' } }, { path: '/platform/qualityInspection', name: 'qualityInspection', component: function () { return import('../views/platform/qualityInspection.vue') }, meta: { keepAlive: true, title: '品质检查项目' } }, { path: '/platform/TestCheck', name: 'TestCheck', component: function () { return import('../views/platform/TestCheck.vue') }, meta: { keepAlive: true, title: '测试检查项目' } }, { path: '/platform/encoding', name: 'encoding', component: function () { return import('../views/platform/encoding.vue') }, meta: { keepAlive: true, title: '编码管理' } }, { path: '/production/process', name: 'process', component: function () { return import('../views/production/process.vue') }, meta: { keepAlive: true, title: '生产流程管理' } }, { path: '/production/assembly', name: 'assembly', component: function () { return import('../views/production/assembly.vue') }, meta: { keepAlive: true, title: '组装任务计划管理' } }, { path: '/production/installation', name: 'installation', component: function () { return import('../views/production/installation.vue') }, meta: { keepAlive: true, title: '安装运维任务计划管理' } }, { path: '/production/order', name: 'order', component: function () { return import('../views/production/order.vue') }, meta: { keepAlive: true, title: '订单管理' } }, { path: '/production/schedule', name: 'schedule', component: function () { return import('../views/production/schedule.vue') }, meta: { keepAlive: true, title: '排班管理' } }, { path: '/autoTest', name: 'autoTest', component: function () { return import('../views/autoTest.vue') }, meta: { keepAlive: true, title: '自动化测试' } }, ] const router = new VueRouter({ routes }) router.beforeEach((to, from, next) => { if ( (to.name !== 'login') && !localStorage.token) { next({ name: 'login' }) } else { next() } }) export default router