登录状态等待拉取
This commit is contained in:
parent
15834c5daf
commit
97ff48aef9
17
app.vue
17
app.vue
@ -10,7 +10,7 @@
|
|||||||
:class="{ 'text-black': item.active }",
|
:class="{ 'text-black': item.active }",
|
||||||
:to="item.path"
|
:to="item.path"
|
||||||
) {{ item.title }}
|
) {{ 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
|
NuxtPage
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -24,7 +24,8 @@ const account = useState("account", () => ({
|
|||||||
sid: '',
|
sid: '',
|
||||||
name: '',
|
name: '',
|
||||||
avatars: [],
|
avatars: [],
|
||||||
online: false
|
online: false,
|
||||||
|
padding: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const navbar = computed(() => {
|
const navbar = computed(() => {
|
||||||
@ -59,11 +60,13 @@ const navbar = computed(() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
$fetch("/api/user/self").then((data) => {
|
$fetch("/api/user/self").then((data) => {
|
||||||
if (data) {
|
account.value.sid = data.sid
|
||||||
account.value = data;
|
account.value.id = data.id
|
||||||
}
|
account.value.name = data.name
|
||||||
});
|
account.value.online = data.online
|
||||||
});
|
account.value.padding = false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user