Fixiaobai
2023-08-28 6cc81f9de0c87c40a9f1181ab35e8dff792a1884
src/layout/components/Navbar.vue
@@ -64,6 +64,10 @@
        newPwd: '',
        confirmPwd: ''
      },
      user: {
            id: null,
            name: 'value'
         },
      dialogFormVisible: false,
      formLabelWidth: '120px'
    }
@@ -78,14 +82,6 @@
      'avatar'
    ])
  },
   data() {
      return {
         user: {
            id: null,
            name: 'value'
         }
      }
   },
   mounted() {
      this.getUser()
   },
@@ -107,11 +103,15 @@
    },
    async logout() {
      // await this.$store.dispatch('user/logout')
      this.$router.push(`/login?redirect=${this.$route.fullPath}`)
      localStorage.removeItem("user")
      this.$router.push(`/login?redirect=${this.$route.fullPath}`)
      this.$router.replace({path: '/login'});
      location.reload();
    },
      getUser(){
         get(this.$url.info).then(res=>{
            this.user = res.data
        localStorage.setItem("user",JSON.stringify(res.data))
         })
      }
  }