Browse Source

logout

master
chutingting 1 year ago
parent
commit
ad3df75f03
2 changed files with 8 additions and 4 deletions
  1. +2
    -2
      src/api/user.js
  2. +6
    -2
      src/layout/components/Navbar.vue

+ 2
- 2
src/api/user.js View File

@@ -18,7 +18,7 @@ export function getInfo(token) {

export function logout() {
return request({
url: '/vue-admin-template/user/logout',
method: 'post'
url: '/logout',
method: 'get'
})
}

+ 6
- 2
src/layout/components/Navbar.vue View File

@@ -36,6 +36,9 @@ import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'

import {
logoutApi
} from '@/api/login'
export default {
components: {
Breadcrumb,
@@ -52,8 +55,9 @@ export default {
this.$store.dispatch('app/toggleSideBar')
},
async logout() {
// await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
logoutApi().then(res => {
this.$router.push(`/login`)
})
}
}
}


Loading…
Cancel
Save