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() {