方式一
import store from '@/store'
import router from '@/router'
async function logout() {
await store.dispatch('user/logout')
let autoLogin = false
if (localStorage.loginInfo) {
autoLogin = JSON.parse(localStorage.loginInfo).autoLogin
}
router.push({
path: `/login?redirect=${this.$route.fullPath}`,
query: {
autoLogin: autoLogin ? 1 : 0
}
})
sessionStorage.clear()
}
export default logout
方式一
import store from '@/store'
import router from '@/router'
export const logout = async() => {
await store.dispatch('user/logout')
let autoLogin = false
if (localStorage.loginInfo) {
autoLogin = JSON.parse(localStorage.loginInfo).autoLogin
}
router.push({
path: `/login?redirect=${this.$route.fullPath}`,
query: {
autoLogin: autoLogin ? 1 : 0
}
})
sessionStorage.clear()
}