user.vue 911 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <!--简洁用户菜单-->
  3. <div class="right lite">
  4. <span class="name">{{userinfo && userinfo.name || '管理員'}}</span>
  5. <span style="margin: 5px;">|</span>
  6. <el-button type="text" @click="handleLogout">退出</el-button>
  7. </div>
  8. </template>
  9. <script>
  10. import { mapActions, mapGetters } from 'vuex';
  11. export default {
  12. props: {
  13. menuCollapse: Boolean,
  14. },
  15. methods: {
  16. ...mapActions({
  17. logout: 'login/logout',
  18. }),
  19. async handleLogout() {
  20. // console.log(this.userinfo);
  21. // console.log(this);
  22. const res = await this.logout();
  23. // console.log(res);
  24. // if (!res.errcode) {
  25. // this.$router.push(this.$route.query.redirect || '/login');
  26. // }
  27. },
  28. },
  29. computed: {
  30. ...mapGetters(['userinfo']),
  31. },
  32. };
  33. </script>
  34. <style lang="less" scoped>
  35. .right.lite {
  36. font-size: 14px;
  37. }
  38. .el-button--text {
  39. color: white;
  40. }
  41. </style>