123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- 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: "/audit",
- meta: {
- title: "导入日报审核"
- },
- component: () => import("@/views/audit/audit")
- },
- {
- path: "/login",
- component: () => import("@/views/login/index"),
- meta: {
- title: "登陆"
- }
- },
- {
- path: "/register",
- component: () => import("@/views/register/index"),
- meta: {
- title: "注册"
- }
- },
- {
- path: "/index",
- component: () => import("@/views/index/index"),
- meta: {
- title: "工时管家",
- keepAlive: true
- }
- },
- {
- path: "/view",
- meta: {
- title: "查看日报"
- },
- component: () => import("@/views/view/index")
- },
- {
- path: "/calendar",
- meta: {
- title: "查看日报"
- },
- component: () => import("@/views/view/calendar")
- },
- {
- path: "/edit",
- meta: {
- title: "填写日报"
- },
- component: () => import("@/views/edit/index")
- },
- {
- path: "/weekedit",
- meta: {
- title: "按周填报"
- },
- component: () => import("@/views/edit/weekEdit")
- },
- {
- path: "/search",
- meta: {
- title: "选择项目"
- },
- component: () => import("@/views/edit/search")
- },
- {
- path: "/review",
- meta: {
- title: "审核日报"
- },
- component: () => import("@/views/review/index")
- },
- {
- path: "/profession_review",
- meta: {
- title: "专业审核"
- },
- component: () => import("@/views/review/profession_list")
- },
- {
- path: "/department_review",
- meta: {
- title: "部门审核"
- },
- component: () => import("@/views/review/department_list")
- },
- {
- path: "/msg",
- meta: {
- title: "消息记录"
- },
- component: () => import("@/views/msg/index")
- },
- {
- path: "/project",
- meta: {
- title: "项目管理"
- },
- component: () => import("@/views/project/index")
- },
- {
- path: "/error",
- meta: {
- title: "错误提示"
- },
- component: () => import("@/views/error/index")
- },
- {
- path: "/test",
- meta: {
- title: "测试页面"
- },
- component: () => import("@/views/test/index")
- },
- {
- path: "/tests",
- meta: {
- title: "测试页面2"
- },
- component: () => import("@/views/test/list")
- },
- // {
- // path: "/timetool",
- // meta: {
- // title: "自动计时"
- // },
- // component: () => import("@/views/timetool/timetool")
- // },
- {
- path: "/exaLeave",
- meta: {
- title: "请假审批"
- },
- component: () => import("@/views/exaLeave/exaLeave")
- },
- {
- 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: "*",
- 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;
|