From 820597e9038047dc49184d0a3b1c409a4212d44c Mon Sep 17 00:00:00 2001 From: alger Date: Thu, 4 Jan 2024 10:02:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/SearchBar.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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