Skip to content

Commit

Permalink
react: hack router push callback
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Sep 24, 2019
1 parent 677a9b8 commit e2f8273
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/config/router.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ export const constantRouterMap = [
path: 'register-result',
name: 'registerResult',
component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
},
{
path: 'recover',
name: 'recover',
component: undefined
}
]
},
Expand Down
7 changes: 7 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import Vue from 'vue'
import Router from 'vue-router'
import { constantRouterMap } from '@/config/router.config'

// hack router push callback
const originalPush = Router.prototype.push
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)
}

Vue.use(Router)

export default new Router({
Expand Down
2 changes: 1 addition & 1 deletion src/views/user/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export default {
})
})
*/
this.$router.push({ name: 'Analysis' })
this.$router.push({ path: '/' })
// 延迟 1 秒显示欢迎信息
setTimeout(() => {
this.$notification.success({
Expand Down

0 comments on commit e2f8273

Please sign in to comment.