登录页面加载时清空用户信息&导航页签信息

This commit is contained in:
灌糖包子 2023-10-22 11:38:57 +08:00
parent ac3388f35d
commit 1ffd56efc2
Signed by: sookie
GPG Key ID: 0599BECB75C1E68D
2 changed files with 16 additions and 4 deletions

View File

@ -31,13 +31,12 @@ class Store {
* @param {Object} state
*/
logout(state: StateType): void {
localStorage.removeItem('login_token')
state.loginInfo.token = null
state.loginInfo.userInfo = null
},
/**
*
* @param {Object} state
* @param {StateType} state
* @param {TabItem} tab
*/
addTab(state: StateType, tab: TabItem): void {
@ -48,8 +47,8 @@ class Store {
},
/**
*
* @param {Object} state
* @param {TabItem} name
* @param {StateType} state
* @param {string} path
*/
removeTab(state: StateType, path: string): void {
const removeIndex = state.tabs.findIndex(item => item.path === path)
@ -57,6 +56,14 @@ class Store {
state.tabs.splice(removeIndex, 1)
localStorage.setItem('tabs', JSON.stringify(state.tabs))
}
},
/**
*
* @param {StateType} state
*/
clearTabs(state: StateType): void {
state.tabs.splice(0, state.tabs.length)
state.activeTab = null
}
}
}

View File

@ -35,6 +35,11 @@ export default class Login extends Vue {
{ required: true, message: '请输入密码', trigger: 'blur' }
],
}
created(): void {
this.$store.commit('logout')
this.$store.commit('clearTabs')
localStorage.clear()
}
/**
* 登录
*/