登录状态等待拉取

This commit is contained in:
satori 2024-08-27 20:04:31 +08:00
parent 15834c5daf
commit 97ff48aef9

17
app.vue
View File

@ -10,7 +10,7 @@
:class="{ 'text-black': item.active }",
:to="item.path"
) {{ item.title }}
NuxtLink.px-4.py-6.ml-auto(to="/account") {{ account.online ? account.name : '登录' }}
NuxtLink.px-4.py-6.ml-auto(to="/account" v-if="!account.padding") {{ account.online ? account.name : '登录' }}
NuxtPage
</template>
@ -24,7 +24,8 @@ const account = useState("account", () => ({
sid: '',
name: '',
avatars: [],
online: false
online: false,
padding: true,
}))
const navbar = computed(() => {
@ -59,11 +60,13 @@ const navbar = computed(() => {
onMounted(() => {
$fetch("/api/user/self").then((data) => {
if (data) {
account.value = data;
}
});
});
account.value.sid = data.sid
account.value.id = data.id
account.value.name = data.name
account.value.online = data.online
account.value.padding = false
})
})
</script>