@@ -39,6 +39,21 @@ const navLinks = links.map((link) => {
39
39
... link
40
40
}
41
41
})
42
+ const ready = ref (false )
43
+ const authenticated = ref (false )
44
+ onMounted (async () => {
45
+ const endpoint = import .meta .dev ? ' http://localhost:3000/api/authenticated' : ' https://admin.hub.nuxt.com/api/authenticated'
46
+ await $fetch (endpoint , {
47
+ credentials: ' include'
48
+ }).then ((state : { authenticated: boolean }) => {
49
+ authenticated .value = state .authenticated
50
+ }).catch (() => {
51
+ authenticated .value = false
52
+ })
53
+ nextTick (() => {
54
+ ready .value = true
55
+ })
56
+ })
42
57
</script >
43
58
44
59
<template >
@@ -51,19 +66,24 @@ const navLinks = links.map((link) => {
51
66
</template >
52
67
53
68
<template #right >
54
- <UTooltip text =" Search" :shortcuts =" [metaSymbol, 'K']" :popper =" { strategy: 'absolute' }" >
55
- <UContentSearchButton :label =" null" />
56
- </UTooltip >
57
- <UButton variant =" ghost" label =" Log in" to =" https://admin.hub.nuxt.com/" color =" black" class =" hidden sm:block" external />
58
- <UButton variant =" solid" label =" Sign up" to =" https://admin.hub.nuxt.com/" class =" hidden sm:block" external />
69
+ <div class =" flex items-center gap-1.5 transition-opacity duration-300" :class =" [ready ? 'opacity-100' : 'opacity-0']" >
70
+ <UTooltip text =" Search" :shortcuts =" [metaSymbol, 'K']" :popper =" { strategy: 'absolute' }" >
71
+ <UContentSearchButton :label =" null" />
72
+ </UTooltip >
73
+ <UButton v-if =" ready && !authenticated" size =" sm" variant =" ghost" label =" Log in" to =" https://admin.hub.nuxt.com/" color =" black" class =" hidden sm:inline-flex" external />
74
+ <UButton v-if =" ready && !authenticated" size =" sm" variant =" solid" label =" Sign up" to =" https://admin.hub.nuxt.com/" class =" hidden sm:inline-flex" external />
75
+ <UButton v-if =" ready && authenticated" size =" sm" icon =" i-ph-app-window-duotone" label =" Dashboard" to =" https://admin.hub.nuxt.com/" color =" black" class =" hidden sm:inline-flex" external />
76
+ </div >
59
77
</template >
60
78
61
79
<template #panel >
62
- <UNavigationTree :links =" navLinks" : default-open= " 1 " :multiple =" false" :ui =" { accordion: { button: { label: 'font-normal' } } }" />
80
+ <UNavigationTree :links =" navLinks" default-open :multiple =" false" :ui =" { accordion: { button: { label: 'font-normal' } } }" />
63
81
64
82
<div class =" flex flex-col gap-y-2 mt-4" >
65
- <UButton variant =" solid" label =" Log in" to =" https://admin.hub.nuxt.com/" color =" white" class =" flex justify-center sm:hidden" external />
66
- <UButton variant =" solid" label =" Sign up" to =" https://admin.hub.nuxt.com/" class =" flex justify-center text-gray-900 bg-primary sm:hidden" external />
83
+ <UDivider class =" mb-4" />
84
+ <UButton v-if =" ready && !authenticated" variant =" solid" label =" Log in" to =" https://admin.hub.nuxt.com/" color =" white" class =" flex justify-center sm:hidden" external />
85
+ <UButton v-if =" ready && !authenticated" variant =" solid" label =" Sign up" to =" https://admin.hub.nuxt.com/" class =" flex justify-center text-gray-900 bg-primary sm:hidden" external />
86
+ <UButton v-if =" ready && authenticated" variant =" solid" color =" black" icon =" i-ph-app-window-duotone" label =" Dashboard" to =" https://admin.hub.nuxt.com/" class =" flex justify-center text-gray-900 bg-primary sm:hidden" external />
67
87
</div >
68
88
</template >
69
89
</UHeader >
0 commit comments