登录页面加载时清空用户信息&导航页签信息
This commit is contained in:
parent
ac3388f35d
commit
1ffd56efc2
@ -31,13 +31,12 @@ class Store {
|
|||||||
* @param {Object} state
|
* @param {Object} state
|
||||||
*/
|
*/
|
||||||
logout(state: StateType): void {
|
logout(state: StateType): void {
|
||||||
localStorage.removeItem('login_token')
|
|
||||||
state.loginInfo.token = null
|
state.loginInfo.token = null
|
||||||
state.loginInfo.userInfo = null
|
state.loginInfo.userInfo = null
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 添加导航页签
|
* 添加导航页签
|
||||||
* @param {Object} state
|
* @param {StateType} state
|
||||||
* @param {TabItem} tab 新加入的页签
|
* @param {TabItem} tab 新加入的页签
|
||||||
*/
|
*/
|
||||||
addTab(state: StateType, tab: TabItem): void {
|
addTab(state: StateType, tab: TabItem): void {
|
||||||
@ -48,8 +47,8 @@ class Store {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 移除导航页签
|
* 移除导航页签
|
||||||
* @param {Object} state
|
* @param {StateType} state
|
||||||
* @param {TabItem} name 页签标识名称
|
* @param {string} path 页签路径
|
||||||
*/
|
*/
|
||||||
removeTab(state: StateType, path: string): void {
|
removeTab(state: StateType, path: string): void {
|
||||||
const removeIndex = state.tabs.findIndex(item => item.path === path)
|
const removeIndex = state.tabs.findIndex(item => item.path === path)
|
||||||
@ -57,6 +56,14 @@ class Store {
|
|||||||
state.tabs.splice(removeIndex, 1)
|
state.tabs.splice(removeIndex, 1)
|
||||||
localStorage.setItem('tabs', JSON.stringify(state.tabs))
|
localStorage.setItem('tabs', JSON.stringify(state.tabs))
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 清空导航标签页
|
||||||
|
* @param {StateType} state
|
||||||
|
*/
|
||||||
|
clearTabs(state: StateType): void {
|
||||||
|
state.tabs.splice(0, state.tabs.length)
|
||||||
|
state.activeTab = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,11 @@ export default class Login extends Vue {
|
|||||||
{ required: true, message: '请输入密码', trigger: 'blur' }
|
{ required: true, message: '请输入密码', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
created(): void {
|
||||||
|
this.$store.commit('logout')
|
||||||
|
this.$store.commit('clearTabs')
|
||||||
|
localStorage.clear()
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user