登录页面增加登出接口

This commit is contained in:
aixianling
2022-06-10 16:24:29 +08:00
parent 1218536e64
commit 2c9f3179c1
2 changed files with 9 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ export default {
}, },
methods: { methods: {
...mapActions(['getToken']), ...mapActions(['getToken']),
...mapMutations(['login']), ...mapMutations(['login', 'logout']),
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(v => { this.$refs.loginForm.validate(v => {
if (v) { if (v) {
@@ -65,6 +65,13 @@ export default {
} }
}) })
}, },
handleLogout() {
this.logout()
this.$http.delete("/auth/token/logout")
}
},
onShow() {
this.handleLogout()
}, },
mounted() { mounted() {
this.$refs.loginForm.setRules(this.rules) this.$refs.loginForm.setRules(this.rules)

View File

@@ -24,6 +24,7 @@ const store = new Vuex.Store({
logout(state) { logout(state) {
state.token = "" state.token = ""
state.openUser = {} state.openUser = {}
state.user = {}
}, },
setOpenUser(state, user) { setOpenUser(state, user) {
state.openUser = user state.openUser = user