87 lines
2.0 KiB
JavaScript
87 lines
2.0 KiB
JavaScript
import Vue from 'vue'
|
||
import Router from 'vue-router'
|
||
|
||
Vue.use(Router)
|
||
|
||
// 公共路由
|
||
export const constantRoutes = [
|
||
{
|
||
path: '/login',
|
||
component: () => import('@/views/login'),
|
||
hidden: true
|
||
},
|
||
{
|
||
path: '/register',
|
||
component: () => import('@/views/register'),
|
||
hidden: true
|
||
},
|
||
{
|
||
path: '/404',
|
||
component: () => import('@/views/error/404'),
|
||
hidden: true
|
||
},
|
||
{
|
||
path: '/401',
|
||
component: () => import('@/views/error/401'),
|
||
hidden: true
|
||
},
|
||
// 直接配置产品中心路由,不使用Layout
|
||
{
|
||
path: '/product-center',
|
||
name: 'ProductCenter',
|
||
component: () => import('@/views/psp/productCenter/index'),
|
||
meta: { title: '产品中心首页' }
|
||
},
|
||
|
||
// 直接配置产品中心路由,不使用Layout
|
||
{
|
||
path: '/product-case',
|
||
name: 'ProductCase',
|
||
component: () => import('@/views/psp/productCenter/product-case'),
|
||
meta: { title: '产品中心-案例' }
|
||
},
|
||
|
||
// 直接配置产品中心路由,不使用Layout
|
||
{
|
||
path: '/product-detail',
|
||
name: 'ProductDetail',
|
||
component: () => import('@/views/psp/productCenter/product-detail'),
|
||
meta: { title: '产品中心-详情' }
|
||
},
|
||
|
||
{
|
||
path: '/common/index',
|
||
name: 'common',
|
||
component: () => import('@/views/psp/common/index'),
|
||
meta: { title: '产品中心' }
|
||
},
|
||
|
||
|
||
// 配置根路径重定向到产品中心
|
||
{
|
||
path: '/',
|
||
redirect: '/product-center',
|
||
hidden: true
|
||
}
|
||
]
|
||
|
||
// 可以移除dynamicRoutes动态路由部分
|
||
|
||
// 防止连续点击多次路由报错
|
||
let routerPush = Router.prototype.push
|
||
let routerReplace = Router.prototype.replace
|
||
// push
|
||
Router.prototype.push = function push(location) {
|
||
return routerPush.call(this, location).catch(err => err)
|
||
}
|
||
// replace
|
||
Router.prototype.replace = function push(location) {
|
||
return routerReplace.call(this, location).catch(err => err)
|
||
}
|
||
|
||
export default new Router({
|
||
mode: 'history', // 去掉url中的#
|
||
scrollBehavior: () => ({ y: 0 }),
|
||
routes: constantRoutes
|
||
})
|