From 1663b455974c1633a930e2aaeb11acab21708a0a Mon Sep 17 00:00:00 2001 From: Hakadao Date: Wed, 12 Apr 2023 17:51:31 +0800 Subject: [PATCH] fix: #4 thank god, i finally fixed this bug from 1 year ago --- src/components/Topbar/Topbar.vue | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/Topbar/Topbar.vue b/src/components/Topbar/Topbar.vue index 7dd687b2..4f9505ea 100644 --- a/src/components/Topbar/Topbar.vue +++ b/src/components/Topbar/Topbar.vue @@ -26,7 +26,7 @@ const showUploadPop = ref(false) const showHistoryPop = ref(false) const showMorePop = ref(false) -const isLogin = ref(!!getUserID()) +const isLogin = ref(false) const unReadMessage = reactive( {}, ) as UnwrapNestedRefs @@ -62,8 +62,8 @@ onMounted(() => { }) }) -function initUserPanel() { - getUserInfo() +async function initUserPanel() { + await getUserInfo() getUnreadMessageCount() getNewMomentsCount() @@ -96,18 +96,18 @@ function closeUserPanel() { avatarShadow.value.classList.remove('hover') } -function getUserInfo() { - browser.runtime +async function getUserInfo() { + const res = await browser.runtime .sendMessage({ contentScriptQuery: 'getUserInfo', }) - .then((res) => { - if (res.code === 0) - Object.assign(userInfo, res.data) - // Account not logged in - else if (res.code === -101) - isLogin.value = false - }) + + if (res.code === 0) { + isLogin.value = true + Object.assign(userInfo, res.data) + } + // Account not logged in + else if (res.code === -101) { isLogin.value = false } } async function getUnreadMessageCount() {