Skip to content

Commit e2f8273

Browse files
committed
react: hack router push callback
1 parent 677a9b8 commit e2f8273

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/config/router.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ export const constantRouterMap = [
355355
path: 'register-result',
356356
name: 'registerResult',
357357
component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
358+
},
359+
{
360+
path: 'recover',
361+
name: 'recover',
362+
component: undefined
358363
}
359364
]
360365
},

src/router/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import Vue from 'vue'
22
import Router from 'vue-router'
33
import { constantRouterMap } from '@/config/router.config'
44

5+
// hack router push callback
6+
const originalPush = Router.prototype.push
7+
Router.prototype.push = function push (location, onResolve, onReject) {
8+
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
9+
return originalPush.call(this, location).catch(err => err)
10+
}
11+
512
Vue.use(Router)
613

714
export default new Router({

src/views/user/Login.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export default {
261261
})
262262
})
263263
*/
264-
this.$router.push({ name: 'Analysis' })
264+
this.$router.push({ path: '/' })
265265
// 延迟 1 秒显示欢迎信息
266266
setTimeout(() => {
267267
this.$notification.success({

0 commit comments

Comments
 (0)