yangfeng
2023-11-07 eb5c123294366bdf405d15b07af1509e1dbf532d
增加用户名显示问题
1个文件已修改
43 ■■■■■ 已修改文件
src/components/layout/components/appHeader/index.vue 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/layout/components/appHeader/index.vue
@@ -4,7 +4,7 @@
   <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>
        <div class="el-dropdown-link">{{ username }}<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>
@@ -21,31 +21,38 @@
    headerTitle: String
  },
  data() {
    return {}
    return {
      username: ""
    }
  },
  mounted() {
    this.username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
  },
  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'; //本地的智慧工厂-登录页
        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(() => {
              type: "success",
              message: "注销成功!"
            })
          })
          .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消注销'
          });
        });
              type: "info",
              message: "已取消注销"
            })
          })
      }
    }
  }