y595705120 3 سال پیش
والد
کامیت
17ca5f539e
2فایلهای تغییر یافته به همراه26 افزوده شده و 14 حذف شده
  1. 6 7
      src/containers/center/center.vue
  2. 20 7
      src/containers/login/login.vue

+ 6 - 7
src/containers/center/center.vue

@@ -25,13 +25,12 @@ export default {
   	...mapGetters("user", ["userInfo"])
   },
   beforeMount(){
-     this.loadBaseInfo().then(res=>{
-       if( !res.uid ){
-         this.doLogout().then( res=>{
-           this.$router.push('/')
-         } )
-       }
-     })
+    console.log("enter", this.userInfo )
+    if( !this.userInfo || !this.userInfo.token){
+      this.doLogout().then( res=>{
+        this.$router.push('/')
+      })
+    }
   },
   methods: {
     ...mapActions("user", ["loadBaseInfo", "doLogout"]),

+ 20 - 7
src/containers/login/login.vue

@@ -118,15 +118,28 @@ export default {
   computed: {
   	...mapGetters("user", ["typeList", "userInfo"])
   },
-  beforeMount(){
-     if( this.userInfo && this.userInfo.token){
-       this.loginOk = true
-     }else{
-       this.loginOk = false
-     }
-  },
+  // beforeMount(){
+  //    if( this.userInfo && this.userInfo.token){
+  //      this.loginOk = true
+  //    }else{
+  //      this.loginOk = false
+  //    }
+  // },
   created(){
     this.getPostList()
+    this.loginOk = false
+    if( this.userInfo && this.userInfo.token && this.userInfo.uid){
+      this.loadBaseInfo().then(res=>{
+         if( !res || !res.uid ){
+           this.loginOk = false
+           this.doLogout().then( res=>{
+             this.$router.push('/')
+           } )
+         }else{
+           this.loginOk = true
+         }
+      })
+    }
   },
   methods: {
     ...mapActions("user", ["loadBaseInfo", "doLogout", "doLogin"]),