Skip to content

Commit ca733a2

Browse files
committed
退出用户主页时清除用户信息
1 parent 1846f5c commit ca733a2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/router/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,16 @@ router.beforeResolve((to, from, next) => {
263263
}
264264
})
265265

266-
router.afterEach((to, _) => {
266+
router.afterEach((to, from) => {
267267
if (to.name === 'Home') {
268268
// 清除浏览器地址栏中的参数
269269
history.replaceState({}, '', '/')
270270
}
271+
// 退出用户主页时清除用户信息
272+
const allowList = ['Works', 'Liked', 'Following', 'Followers', 'CycleBin', 'User']
273+
if (allowList.includes(from.name) && !allowList.includes(to.name)) {
274+
store.commit('clearCurUserDetail')
275+
}
271276
window.scrollTo(0, 0)
272277
})
273278

0 commit comments

Comments
 (0)