diff --git a/src/store/index.ts b/src/store/index.ts index 3972484..21f7793 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -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 } } } diff --git a/src/views/Login.vue b/src/views/Login.vue index cae727e..4bcc957 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -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() + } /** * 登录 */