123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- import Vue from "vue";
- import Router from "vue-router";
- import store from "../store/index";
- Vue.use(Router);
- const router = new Router({
- routes: [
- {
- path: "/",
- redirect: "/login"
- },
- {
- path: "/login",
- component: () => import("@/views/login/index"),
- meta: {
- title: "登陆"
- }
- },
- {
- path: "/expire",
- component: () => import("@/views/expire/index"),
- meta: {
- title: "到期"
- }
- },
- {
- path: "/index",
- component: () => import("@/views/index/index"),
- meta: {
- title: "车间生产管家",
- keepAlive: true
- }
- },
- {
- path: "/todayPlan",
- component: () => import("@/views/planView/todayPlan/todayPlan"),
- meta: {
- title: "今日计划",
- keepAlive: false
- }
- },
- {
- path: "/distribution",
- name: "distribution",
- component: () => import("@/views/planView/todayPlan/distribution"),
- meta: {
- title: "计划详情",
- keepAlive: false
- }
- },
- {
- path: "/tomorrowPlan",
- component: () => import("@/views/planView/tomorrowPlan/tomorrowPlan"),
- meta: {
- title: "明日计划",
- keepAlive: false
- }
- },
- {
- path: "/InsertionPlan",
- component: () => import("@/views/planView/InsertionPlan/InsertionPlan"),
- meta: {
- title: "插单计划",
- keepAlive: false
- }
- },
- {
- path: "/statisticsView",
- component: () => import("@/views/statisticsView/statisticsView"),
- meta: {
- title: "数据统计",
- keepAlive: false
- }
- },
- {
- path: "/groupView",
- component: () => import("@/views/groupView/groupView"),
- meta: {
- title: "班组人员",
- keepAlive: false
- }
- },
- {
- path: "/workView",
- component: () => import("@/views/workView/workView"),
- meta: {
- title: "报工",
- keepAlive: false
- }
- },
- {
- path: "/test",
- meta: {
- title: "测试页面"
- },
- component: () => import("@/views/test/index")
- },
- {
- path: "/tests",
- meta: {
- title: "测试页面2"
- },
- component: () => import("@/views/test/list")
- },
- {
- path: "/clearStorage",
- meta: {
- title: "清空存储"
- },
- component: () => import("@/views/test/clearStorage")
- },
- {
- path: "/my",
- component: () => import("@/views/my/index"),
- redirect: "/my/center",
- children: [
- {
- path: "center",
- meta: {
- title: "个人中心"
- },
- component: () => import("@/views/my/children/center")
- },
- {
- path: "set",
- meta: {
- title: "修改密码"
- },
- component: () => import("@/views/my/children/set")
- }
- ]
- },
- {
- path: "/pdf",
- meta: {
- title: "PDF"
- },
- component: () => import("@/views/pdf/ppd")
- },
- {
- path: "*",
- component: () => import("@/components/NotFound")
- }
- ]
- });
- // 解决编程式路由往同一地址跳转时会报错的情况
- const originalPush = Router.prototype.push;
- const originalReplace = Router.prototype.replace;
- Router.prototype.push = function push(location, onResolve, onReject) {
- if (onResolve || onReject)
- return originalPush.call(this, location, onResolve, onReject);
- return originalPush.call(this, location).catch(err => err);
- };
- Router.prototype.replace = function push(location, onResolve, onReject) {
- if (onResolve || onReject)
- return originalReplace.call(this, location, onResolve, onReject);
- return originalReplace.call(this, location).catch(err => err);
- };
- router.beforeEach((to, from, next) => {
- let { title, needLogin } = to.meta;
- let { isLogin } = store.state;
- document.title = title;
- if (needLogin && !isLogin) {
- next({
- path: "/login"
- });
- } else {
- next();
- }
- });
- export default router;
|