diff --git a/src/layout/components/SearchBar.vue b/src/layout/components/SearchBar.vue index c6b10b4..5e83a3c 100644 --- a/src/layout/components/SearchBar.vue +++ b/src/layout/components/SearchBar.vue @@ -64,11 +64,19 @@ const loadHotSearchKeyword = async () => { watchEffect(() => { const user = localStorage.getItem('user') store.state.user = user ? JSON.parse(user) : null - if(!user){ - userSetOptions.value = USER_SET_OPTIONS.filter(item => item.key !== 'logout') - } }) +watch( + () => store.state.user, + (newVal) => { + if (newVal) { + userSetOptions.value = USER_SET_OPTIONS + }else{ + userSetOptions.value = USER_SET_OPTIONS.filter(item => item.key !== 'logout') + } + } +) + const loadPage = async () => { const token = localStorage.getItem("token") if (!token) return