登录状态等待拉取
This commit is contained in:
parent
15834c5daf
commit
97ff48aef9
17
app.vue
17
app.vue
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user