Browse Source

fix(public-layout): hide header 控制台 when viewing another user's profile

Made-with: Cursor
main
npmrun 7 hours ago
parent
commit
0f1c5ec412
  1. 17
      app/layouts/public.vue

17
app/layouts/public.vue

@ -7,7 +7,7 @@ import {
import { unwrapApiBody, type ApiResponse } from '../utils/http/factory'
const route = useRoute()
const { loggedIn, refresh, initialized } = useAuthSession()
const { loggedIn, user, refresh, initialized } = useAuthSession()
const { siteName } = useGlobalConfig()
const showPublicLayoutToggle = computed(() => /^\/@[^/]+$/.test(route.path))
@ -16,6 +16,19 @@ const profileSlug = computed(() => {
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 }
const { data: publicHomeHeader } = await useAsyncData(
@ -152,7 +165,7 @@ onMounted(() => {
<USkeleton class="h-5 w-12 rounded" />
</template>
<NuxtLink
v-else-if="loggedIn"
v-else-if="showPublicConsoleLink"
to="/me"
class="text-muted hover:text-default whitespace-nowrap"
>

Loading…
Cancel
Save