From 65a074b885b9c33dd1da0a9662b91b4cbb0bb67c Mon Sep 17 00:00:00 2001 From: miaojiale <1123971748@qq.com> Date: Wed, 30 Nov 2022 14:54:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/index.vue | 37 ++++++++++++++++++++++++--------- src/store/modules/user.js | 1 + 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/components/layout/index.vue b/src/components/layout/index.vue index 2d26bd7..8e084f4 100644 --- a/src/components/layout/index.vue +++ b/src/components/layout/index.vue @@ -45,7 +45,7 @@
-
欢迎,LIXid胡
+
欢迎,{{ userInfo.name }}
退出
@@ -126,6 +126,7 @@ export default { }, allianceToken: getAccessToken(), currentRoute: this.$route.path, + userInfo: {}, } }, watch: { @@ -140,6 +141,7 @@ export default { // if (localStorage.getItem('allianceToken')) { // this.$router.push('/datacenter/home') // } + this.userInfo = JSON.parse(localStorage.getItem("userInfo")) }, methods: { handleSubmit(name) { @@ -166,17 +168,31 @@ export default { }) }, logout() { - this.$Modal.confirm({ + const h = this.$createElement + this.$msgbox({ title: "提示", - content: - '

是否确认退出?

', - onOk: () => { - setTimeout(() => { - localStorage.removeItem("agcs") - this.allianceToken = "" - }, 500) + message: h("p", null, [h("span", null, "是否确认退出登录?")]), + showCancelButton: true, + confirmButtonText: "确定", + cancelButtonText: "取消", + beforeClose: (action, instance, done) => { + if (action === "confirm") { + instance.confirmButtonLoading = true + instance.confirmButtonText = "执行中..." + this.$store.dispatch("user/logout").then(() => { + this.allianceToken = "" + done() + instance.confirmButtonLoading = false + }) + } else { + done() + } }, - onCancel: () => {}, + }).then((action) => { + // this.$message({ + // type: "info", + // message: "action: " + action, + // }) }) }, }, @@ -247,6 +263,7 @@ export default { font-size: 20px; font-family: AlibabaPuHuiTiM; color: #ffffff; + margin: 10px 0; } .exit { font-size: 16px; diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 73d36c1..8c2481d 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -35,6 +35,7 @@ const mutations = { setAccessToken(accessToken) }, setUserInfo(state, userInfo) { + localStorage.setItem("userInfo", JSON.stringify(userInfo)) state.userInfo = userInfo }, setGroup(state, group) { -- 2.22.0