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') } }