From 3c0491662dc8979602b1f9e14270bc83489491b4 Mon Sep 17 00:00:00 2001 From: jiutianzhiyu Date: Thu, 25 Mar 2021 23:39:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Navbar.vue | 5 ++++- src/store/modules/user.js | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index b1cb5d6..168560a 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -51,9 +51,12 @@ export default { toggleSideBar() { this.$store.dispatch('app/toggleSideBar') }, + // 退出登录 async logout() { + // 在vuex中删除token, userinfo await this.$store.dispatch('user/logout') - this.$router.push(`/login?redirect=${this.$route.fullPath}`) + // 调整登录页 + this.$router.push('/login') } } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index e63530b..e8380ac 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -150,6 +150,11 @@ const actions = { } commit('setUserInfo', totalInfo) return totalInfo + }, + // 退出登录 + logout(contex) { + contex.commit('removeToken') + contex.commit('removeUserInfo') } }