解决登录重定向404问题
This commit is contained in:
parent
3b9763cd03
commit
9b1acdd46e
@ -1,9 +1,9 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import Vue from "vue";
|
||||
import Router from "vue-router";
|
||||
/* Layout */
|
||||
import Layout from '@/layout'
|
||||
import Layout from "@/layout";
|
||||
|
||||
Vue.use(Router)
|
||||
Vue.use(Router);
|
||||
|
||||
/**
|
||||
* Note: 路由配置项
|
||||
@ -29,253 +29,324 @@ Vue.use(Router)
|
||||
// 公共路由
|
||||
export const constantRoutes = [
|
||||
{
|
||||
path: '/redirect',
|
||||
path: "/redirect",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: '/redirect/:path(.*)',
|
||||
component: (resolve) => require(['@/views/redirect'], resolve)
|
||||
}
|
||||
]
|
||||
path: "/redirect/:path(.*)",
|
||||
component: (resolve) => require(["@/views/redirect"], resolve),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: (resolve) => require(['@/views/login'], resolve),
|
||||
hidden: true
|
||||
path: "/login",
|
||||
component: (resolve) => require(["@/views/login"], resolve),
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/sso',
|
||||
component: (resolve) => require(['@/views/sso'], resolve),
|
||||
hidden: true
|
||||
path: "/sso",
|
||||
component: (resolve) => require(["@/views/sso"], resolve),
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/social-login',
|
||||
component: (resolve) => require(['@/views/socialLogin'], resolve),
|
||||
hidden: true
|
||||
path: "/social-login",
|
||||
component: (resolve) => require(["@/views/socialLogin"], resolve),
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: (resolve) => require(['@/views/error/404'], resolve),
|
||||
hidden: true
|
||||
path: "/404",
|
||||
component: (resolve) => require(["@/views/error/404"], resolve),
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '/401',
|
||||
component: (resolve) => require(['@/views/error/401'], resolve),
|
||||
hidden: true
|
||||
path: "/401",
|
||||
component: (resolve) => require(["@/views/error/401"], resolve),
|
||||
hidden: true,
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
path: "",
|
||||
component: Layout,
|
||||
redirect: 'imtIndex',
|
||||
children: [{
|
||||
path: 'imtIndex',
|
||||
component: (resolve) => require(['@/views/imtIndex'], resolve),
|
||||
name: '首页',
|
||||
meta: {title: '首页', icon: 'dashboard', affix: true}
|
||||
}
|
||||
]
|
||||
redirect: "imtIndex",
|
||||
children: [
|
||||
{
|
||||
path: "imtIndex",
|
||||
component: (resolve) => require(["@/views/imtIndex"], resolve),
|
||||
name: "首页",
|
||||
meta: { title: "首页", icon: "dashboard", affix: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
path: "/index",
|
||||
component: Layout,
|
||||
redirect: "/imtIndex",
|
||||
hidden: true,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
path: "/user",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
children: [{
|
||||
path: 'profile',
|
||||
component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
|
||||
name: 'Profile',
|
||||
meta: {title: '个人中心', icon: 'user'}
|
||||
}, {
|
||||
path: 'notify-message',
|
||||
component: (resolve) => require(['@/views/system/notify/my/index'], resolve),
|
||||
name: 'MyNotifyMessage',
|
||||
meta: { title: '我的站内信', icon: 'message' },
|
||||
}]
|
||||
redirect: "noredirect",
|
||||
children: [
|
||||
{
|
||||
path: "profile",
|
||||
component: (resolve) =>
|
||||
require(["@/views/system/user/profile/index"], resolve),
|
||||
name: "Profile",
|
||||
meta: { title: "个人中心", icon: "user" },
|
||||
},
|
||||
{
|
||||
path: '/dict',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'type/data/:dictId(\\d+)',
|
||||
component: (resolve) => require(['@/views/system/dict/data'], resolve),
|
||||
name: 'SystemDictData',
|
||||
meta: {title: '字典数据', icon: '', activeMenu: '/system/dict'}
|
||||
}
|
||||
]
|
||||
path: "notify-message",
|
||||
component: (resolve) =>
|
||||
require(["@/views/system/notify/my/index"], resolve),
|
||||
name: "MyNotifyMessage",
|
||||
meta: { title: "我的站内信", icon: "message" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/job',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'log',
|
||||
component: (resolve) => require(['@/views/infra/job/log'], resolve),
|
||||
name: 'InfraJobLog',
|
||||
meta: {title: '调度日志', activeMenu: '/infra/job'}
|
||||
}
|
||||
]
|
||||
}, {
|
||||
path: '/codegen',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'edit/:tableId(\\d+)',
|
||||
component: (resolve) => require(['@/views/infra/codegen/editTable'], resolve),
|
||||
name: 'InfraCodegenEditTable',
|
||||
meta: {title: '修改生成配置', activeMenu: '/infra/codegen'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/system/maintenance/maintenanceInfo/create',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: '/',
|
||||
component: (resolve) => require(['@/views/system/maintenance/maintenanceInfo/create.vue'], resolve),
|
||||
name: 'BpmMaintenanceInfoCreate',
|
||||
meta: {title: '发起维修审批', icon: 'form', activeMenu: '/maintenance'}
|
||||
}]
|
||||
},
|
||||
{
|
||||
path: '/system/maintenance/maintenanceInfo/detail',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: '/',
|
||||
component: (resolve) => require(['@/views/system/maintenance/maintenanceInfo/details.vue'], resolve),
|
||||
name: 'BpmMaintenanceInfoDetail',
|
||||
meta: {title: '查看维修审批', icon: 'view', activeMenu: '/maintenance'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/bpm',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
children: [{
|
||||
path: 'oa/leave/create',
|
||||
component: (resolve) => require(['@/views/bpm/oa/leave/create'], resolve),
|
||||
name: 'BpmOALeaveCreate',
|
||||
meta: {title: '发起 OA 请假', icon: 'form', activeMenu: '/bpm/oa/leave'}
|
||||
}, {
|
||||
path: 'oa/leave/detail',
|
||||
component: (resolve) => require(['@/views/bpm/oa/leave/detail'], resolve),
|
||||
name: 'BpmOALeaveDetail',
|
||||
meta: {title: '查看 OA 请假', icon: 'view', activeMenu: '/bpm/oa/leave'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/bpm',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'manager/form/edit',
|
||||
component: (resolve) => require(['@/views/bpm/form/formEditor'], resolve),
|
||||
name: 'BpmFormEditor',
|
||||
meta: {title: '流程表单-编辑', activeMenu: '/bpm/manager/form'}
|
||||
}, {
|
||||
path: 'manager/definition',
|
||||
component: (resolve) => require(['@/views/bpm/definition/index'], resolve),
|
||||
name: 'BpmProcessDefinition',
|
||||
meta: {title: '流程定义', activeMenu: '/bpm/manager/model'}
|
||||
}, {
|
||||
path: 'manager/model/design',
|
||||
component: (resolve) => require(['@/views/bpm/model/modelEditor'], resolve),
|
||||
name: 'BpmModelEditor',
|
||||
meta: {title: '设计流程', activeMenu: '/bpm/manager/model'}
|
||||
}, {
|
||||
path: 'process-instance/create',
|
||||
component: (resolve) => require(['@/views/bpm/processInstance/create/index'], resolve),
|
||||
name: 'BpmProcessInstanceCreate',
|
||||
meta: {title: '发起流程', activeMenu: '/bpm/task/my'}
|
||||
}, {
|
||||
path: 'process-instance/detail',
|
||||
component: (resolve) => require(['@/views/bpm/processInstance/detail'], resolve),
|
||||
name: 'BpmProcessInstanceDetail',
|
||||
meta: {title: '流程详情', activeMenu: '/bpm/task/my'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/property',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'value/:propertyId(\\d+)',
|
||||
component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
|
||||
name: 'ProductPropertyValue',
|
||||
meta: {title: '商品属性值', icon: '', activeMenu: '/product/property'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/spu',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'edit/:spuId(\\d+)',
|
||||
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
|
||||
name: 'ProductSpuUpdate',
|
||||
meta: {title: '修改商品', activeMenu: '/product/spu'}
|
||||
},
|
||||
{
|
||||
path: 'add',
|
||||
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
|
||||
name: 'ProductSpuCreate',
|
||||
meta: {title: '添加商品', activeMenu: '/product/spu'}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/trade/order',
|
||||
path: "/dict",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'detail',
|
||||
name: 'TradeOrderDetail',
|
||||
hidden: true,
|
||||
meta: { title: '订单详情' },
|
||||
component: (resolve) => require(['@/views/mall/trade/order/detail'], resolve)
|
||||
}
|
||||
]
|
||||
path: "type/data/:dictId(\\d+)",
|
||||
component: (resolve) => require(["@/views/system/dict/data"], resolve),
|
||||
name: "SystemDictData",
|
||||
meta: { title: "字典数据", icon: "", activeMenu: "/system/dict" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/pay',
|
||||
path: "/job",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [{
|
||||
path: 'cashier',
|
||||
name: 'PayCashier',
|
||||
children: [
|
||||
{
|
||||
path: "log",
|
||||
component: (resolve) => require(["@/views/infra/job/log"], resolve),
|
||||
name: "InfraJobLog",
|
||||
meta: { title: "调度日志", activeMenu: "/infra/job" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/codegen",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "edit/:tableId(\\d+)",
|
||||
component: (resolve) =>
|
||||
require(["@/views/infra/codegen/editTable"], resolve),
|
||||
name: "InfraCodegenEditTable",
|
||||
meta: { title: "修改生成配置", activeMenu: "/infra/codegen" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/system/maintenance/maintenanceInfo/create",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "/",
|
||||
component: (resolve) =>
|
||||
require([
|
||||
"@/views/system/maintenance/maintenanceInfo/create.vue",
|
||||
], resolve),
|
||||
name: "BpmMaintenanceInfoCreate",
|
||||
meta: {
|
||||
title: "发起维修审批",
|
||||
icon: "form",
|
||||
activeMenu: "/maintenance",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/system/maintenance/maintenanceInfo/detail",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "/",
|
||||
component: (resolve) =>
|
||||
require([
|
||||
"@/views/system/maintenance/maintenanceInfo/details.vue",
|
||||
], resolve),
|
||||
name: "BpmMaintenanceInfoDetail",
|
||||
meta: {
|
||||
title: "查看维修审批",
|
||||
icon: "view",
|
||||
activeMenu: "/maintenance",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/bpm",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: "noredirect",
|
||||
children: [
|
||||
{
|
||||
path: "oa/leave/create",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/oa/leave/create"], resolve),
|
||||
name: "BpmOALeaveCreate",
|
||||
meta: {
|
||||
title: "发起 OA 请假",
|
||||
icon: "form",
|
||||
activeMenu: "/bpm/oa/leave",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "oa/leave/detail",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/oa/leave/detail"], resolve),
|
||||
name: "BpmOALeaveDetail",
|
||||
meta: {
|
||||
title: "查看 OA 请假",
|
||||
icon: "view",
|
||||
activeMenu: "/bpm/oa/leave",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/bpm",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "manager/form/edit",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/form/formEditor"], resolve),
|
||||
name: "BpmFormEditor",
|
||||
meta: { title: "流程表单-编辑", activeMenu: "/bpm/manager/form" },
|
||||
},
|
||||
{
|
||||
path: "manager/definition",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/definition/index"], resolve),
|
||||
name: "BpmProcessDefinition",
|
||||
meta: { title: "流程定义", activeMenu: "/bpm/manager/model" },
|
||||
},
|
||||
{
|
||||
path: "manager/model/design",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/model/modelEditor"], resolve),
|
||||
name: "BpmModelEditor",
|
||||
meta: { title: "设计流程", activeMenu: "/bpm/manager/model" },
|
||||
},
|
||||
{
|
||||
path: "process-instance/create",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/processInstance/create/index"], resolve),
|
||||
name: "BpmProcessInstanceCreate",
|
||||
meta: { title: "发起流程", activeMenu: "/bpm/task/my" },
|
||||
},
|
||||
{
|
||||
path: "process-instance/detail",
|
||||
component: (resolve) =>
|
||||
require(["@/views/bpm/processInstance/detail"], resolve),
|
||||
name: "BpmProcessInstanceDetail",
|
||||
meta: { title: "流程详情", activeMenu: "/bpm/task/my" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/property",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "value/:propertyId(\\d+)",
|
||||
component: (resolve) =>
|
||||
require(["@/views/mall/product/property/value"], resolve),
|
||||
name: "ProductPropertyValue",
|
||||
meta: {
|
||||
title: "商品属性值",
|
||||
icon: "",
|
||||
activeMenu: "/product/property",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/spu",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "edit/:spuId(\\d+)",
|
||||
component: (resolve) =>
|
||||
require(["@/views/mall/product/spu/save"], resolve),
|
||||
name: "ProductSpuUpdate",
|
||||
meta: { title: "修改商品", activeMenu: "/product/spu" },
|
||||
},
|
||||
{
|
||||
path: "add",
|
||||
component: (resolve) =>
|
||||
require(["@/views/mall/product/spu/save"], resolve),
|
||||
name: "ProductSpuCreate",
|
||||
meta: { title: "添加商品", activeMenu: "/product/spu" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/trade/order",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "detail",
|
||||
name: "TradeOrderDetail",
|
||||
hidden: true,
|
||||
meta: { title: "订单详情" },
|
||||
component: (resolve) =>
|
||||
require(["@/views/mall/trade/order/detail"], resolve),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/pay",
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: "cashier",
|
||||
name: "PayCashier",
|
||||
hidden: true,
|
||||
meta: {
|
||||
title: '收银台',
|
||||
noCache: true
|
||||
title: "收银台",
|
||||
noCache: true,
|
||||
},
|
||||
component: (resolve) => require(['@/views/pay/cashier'], resolve)
|
||||
}]
|
||||
},{
|
||||
path: '/largeScreen',
|
||||
meta: { title: '大屏展示',affix: false},
|
||||
component: (resolve) => require(['@/views/system/bigscreen/index'], resolve),
|
||||
hidden: true
|
||||
}
|
||||
]
|
||||
component: (resolve) => require(["@/views/pay/cashier"], resolve),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/largeScreen",
|
||||
meta: { title: "大屏展示", affix: false },
|
||||
component: (resolve) =>
|
||||
require(["@/views/system/bigscreen/index"], resolve),
|
||||
hidden: true,
|
||||
},
|
||||
];
|
||||
|
||||
// 防止连续点击多次路由报错
|
||||
let routerPush = Router.prototype.push;
|
||||
Router.prototype.push = function push(location) {
|
||||
return routerPush.call(this, location).catch(err => err)
|
||||
}
|
||||
return routerPush.call(this, location).catch((err) => err);
|
||||
};
|
||||
|
||||
export default new Router({
|
||||
base: process.env.VUE_APP_APP_NAME ? process.env.VUE_APP_APP_NAME : "/",
|
||||
mode: 'history', // 去掉url中的#
|
||||
mode: "history", // 去掉url中的#
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
routes: constantRoutes
|
||||
})
|
||||
routes: constantRoutes,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user