123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import Vue from 'vue'
- import Router from 'vue-router'
- import LevelRouter from './levelRouter'
- import ApplyRouter from './applyRouter'
- import AdapayRouter from './adapayRouter'
- import AppRouter from './appRouter'
- Vue.use(Router)
- let defaultRouter = [{
- path: '/',
- redirect: {
- name: 'signUp'
- }
- }, {
- path: "/levelMusic",
- name: "levelMusic",
- component: () =>
- import( /* webpackChunkName: "LevelMusic" */ "@/views/LevelMusic"),
- meta: {
- description: "音乐考级",
- weight: 1 // 页面权重
- }
- }, {
- path: "/paymentResult",
- name: "paymentResult",
- component: () =>
- import( /* webpackChunkName: "PaymentResult" */ "@/views/PaymentResult"),
- meta: {
- description: "支付结果",
- weight: 2 // 页面权重
- }
- }, {
- path: "/downLoad",
- name: "downLoad",
- component: () =>
- import( /* webpackChunkName: "DownLoad" */ "@/views/DownLoad"),
- meta: {
- description: "支付结果",
- weight: 2 // 页面权重
- }
- }]
- defaultRouter = defaultRouter.concat(LevelRouter)
- .concat(ApplyRouter)
- .concat(AdapayRouter)
- .concat(AppRouter)
- const router = new Router({
- // mode: 'history',
- // base: process.env.BASE_URL,
- routes: defaultRouter,
- scrollBehavior() {
- return {
- x: 0,
- y: 0
- }
- }
- })
- router.onError((error) => {
- const pattern = /Loading chunk (\d)+ failed/g;
- const isChunkLoadFailed = error.message.match(pattern);
- const targetPath = router.history.pending.fullPath;
- if (isChunkLoadFailed) {
- router.replace(targetPath);
- }
- })
- const originalPush = Router.prototype.push
- Router.prototype.push = function(location) {
- return originalPush.call(this, location).catch(err => err)
- }
- export default router
|