|
|
@ -7,7 +7,7 @@ import { |
|
|
import { unwrapApiBody, type ApiResponse } from '../utils/http/factory' |
|
|
import { unwrapApiBody, type ApiResponse } from '../utils/http/factory' |
|
|
|
|
|
|
|
|
const route = useRoute() |
|
|
const route = useRoute() |
|
|
const { loggedIn, refresh, initialized } = useAuthSession() |
|
|
const { loggedIn, user, refresh, initialized } = useAuthSession() |
|
|
const { siteName } = useGlobalConfig() |
|
|
const { siteName } = useGlobalConfig() |
|
|
|
|
|
|
|
|
const showPublicLayoutToggle = computed(() => /^\/@[^/]+$/.test(route.path)) |
|
|
const showPublicLayoutToggle = computed(() => /^\/@[^/]+$/.test(route.path)) |
|
|
@ -16,6 +16,19 @@ const profileSlug = computed(() => { |
|
|
return typeof s === 'string' && s.length ? s : '' |
|
|
return typeof s === 'string' && s.length ? s : '' |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
/** 顶栏「控制台」仅在看自己的 /@slug 时显示;浏览他人主页时隐藏 */ |
|
|
|
|
|
const showPublicConsoleLink = computed(() => { |
|
|
|
|
|
if (!loggedIn.value || !user.value) { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
const slug = profileSlug.value.trim().toLowerCase() |
|
|
|
|
|
if (!slug) { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
const mine = user.value.publicSlug?.trim().toLowerCase() ?? '' |
|
|
|
|
|
return mine !== '' && mine === slug |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
type PublicHomeHeaderPayload = { title: string; iconUrl: string | null } |
|
|
type PublicHomeHeaderPayload = { title: string; iconUrl: string | null } |
|
|
|
|
|
|
|
|
const { data: publicHomeHeader } = await useAsyncData( |
|
|
const { data: publicHomeHeader } = await useAsyncData( |
|
|
@ -152,7 +165,7 @@ onMounted(() => { |
|
|
<USkeleton class="h-5 w-12 rounded" /> |
|
|
<USkeleton class="h-5 w-12 rounded" /> |
|
|
</template> |
|
|
</template> |
|
|
<NuxtLink |
|
|
<NuxtLink |
|
|
v-else-if="loggedIn" |
|
|
v-else-if="showPublicConsoleLink" |
|
|
to="/me" |
|
|
to="/me" |
|
|
class="text-muted hover:text-default whitespace-nowrap" |
|
|
class="text-muted hover:text-default whitespace-nowrap" |
|
|
> |
|
|
> |
|
|
|