From eb5c123294366bdf405d15b07af1509e1dbf532d Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期二, 07 十一月 2023 19:15:50 +0800 Subject: [PATCH] 增加用户名显示问题 --- src/components/layout/components/appHeader/index.vue | 65 ++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/components/layout/components/appHeader/index.vue b/src/components/layout/components/appHeader/index.vue index e4f2f31..3eaf269 100644 --- a/src/components/layout/components/appHeader/index.vue +++ b/src/components/layout/components/appHeader/index.vue @@ -1,51 +1,58 @@ <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--right"></i></div> - <el-dropdown-menu slot="dropdown"> - <el-dropdown-item command="logout">閫�鍑�</el-dropdown-item> - </el-dropdown-menu> - </el-dropdown> - </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">{{ username }}<i class="el-icon-arrow-down el-icon--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" +import Cookies from "js-cookie" export default { name: "SalesLead", props: { 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'; //鏈湴鐨勬櫤鎱у伐鍘�-鐧诲綍椤� - this.$message({ - type: 'success', - message: '娉ㄩ攢鎴愬姛!' - }); - }).catch(() => { - this.$message({ - type: 'info', - message: '宸插彇娑堟敞閿�' - }); - }); + 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: "宸插彇娑堟敞閿�" + }) + }) } } } -- Gitblit v1.8.0