yangfeng
2023-11-06 ecd31158cb08c8e50cbb4e31e04b8368bf4db823
src/components/layout/components/appHeader/index.vue
@@ -1,14 +1,53 @@
<template>
  <div class="sales-lead">
    <div class="header-title">{{ headerTitle }}</div>
   <div class="header-user-info">
     <div class="avatar"><el-avatar icon="el-icon-user-solid"></el-avatar></div>
     <el-dropdown @command="handleCommand">
       <div class="el-dropdown-link">用户名<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></div>
       <el-dropdown-menu slot="dropdown">
         <el-dropdown-item command="logout">退出</el-dropdown-item>
       </el-dropdown-menu>
     </el-dropdown>
   </div>
  </div>
</template>
<script>
import Cookies from "js-cookie"
export default {
  name: "SalesLead",
  props: {
    headerTitle: String
  },
  data() {
    return {}
  },
  methods: {
    handleCommand(command) {
      console.log(command)
      if (command === "logout") {
        // this.$router.push({ path: "/login" })
        document.cookie = "cookieName=; path=/;";
        this.$confirm('确定要注销当前用户吗?', '注销用户', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          Cookies.remove('token')
          window.location.href = 'http://localhost:8080/login'; //本地的智慧工厂-登录页
          this.$message({
            type: 'success',
            message: '注销成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消注销'
          });
        });
      }
    }
  }
}
</script>
@@ -16,14 +55,26 @@
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.sales-lead {
  height: 55px;
  line-height: 55px;
  background-color: #fff;
  margin-bottom: 10px;
  display: flex;
  height: 50px;
  box-sizing: border-box;
  line-height: 50px;
  background-color: $color-bg;
  border: 1px solid #ccc;
  .header-title {
    margin-left: 16px;
    font-size: 16px;
    color: #475059;
    padding-left: 16px;
    font-size: 18px;
    font-weight: bold;
    color: #171718;
  }
  .header-user-info {
    margin-left: auto;
    margin-right: 20px;
    display: flex;
    .avatar {
      margin-top: 4px;
      margin-right: 10px;
    }
  }
}
</style>