Browse Source

react: Login success not enter $router onComplete

Sendya 5 years ago
parent
commit
66919b3e5c
1 changed files with 14 additions and 1 deletions
  1. 14 1
      src/views/user/Login.vue

+ 14 - 1
src/views/user/Login.vue

@@ -250,12 +250,25 @@ export default {
     },
     loginSuccess (res) {
       console.log(res)
-      this.$router.push({ name: 'dashboard' }, () => {
+      // check res.homePage define, set $router.push name res.homePage
+      // Why not enter onComplete
+      /*
+      this.$router.push({ name: 'analysis' }, () => {
+        console.log('onComplete')
         this.$notification.success({
           message: '欢迎',
           description: `${timeFix()},欢迎回来`
         })
       })
+      */
+      this.$router.push({ name: 'analysis' })
+      // 延迟 1 秒显示欢迎信息
+      setTimeout(() => {
+        this.$notification.success({
+          message: '欢迎',
+          description: `${timeFix()},欢迎回来`
+        })
+      }, 1000)
       this.isLoginError = false
     },
     requestFailed (err) {