Fixiaobai
2023-08-28 6cc81f9de0c87c40a9f1181ab35e8dff792a1884
src/layout/components/Navbar.vue
@@ -13,7 +13,7 @@
      </div>
      <el-dropdown class="avatar-container" trigger="click">
        <div class="avatar-wrapper">
          <a class="user-avatar">{{ '中天'.slice(0,1) }}</a>
          <a class="user-avatar">{{ user.name.slice(0,1) }}</a>
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown">
            <el-dropdown-item >
@@ -49,6 +49,12 @@
import { mapGetters } from 'vuex'
// import Breadcrumb from '@/components/Breadcrumb'
// import Hamburger from '@/components/Hamburger'
   import {
      get,
      post,
      wpost,
      postFile
   } from "@/api/util/requestUtil.js"
export default {
  data(){
@@ -58,6 +64,10 @@
        newPwd: '',
        confirmPwd: ''
      },
      user: {
            id: null,
            name: 'value'
         },
      dialogFormVisible: false,
      formLabelWidth: '120px'
    }
@@ -72,6 +82,9 @@
      'avatar'
    ])
  },
   mounted() {
      this.getUser()
   },
  methods: {
    reset(){
      this.dialogFormVisible = false;
@@ -90,8 +103,17 @@
    },
    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))
         })
      }
  }
}
</script>