From 0f1c5ec4121d0025f08db24f362f8c20aadeab1d Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sun, 19 Apr 2026 00:15:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(public-layout):=20hide=20header=20=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B0=20when=20viewing=20another=20user's=20profil?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Made-with: Cursor --- app/layouts/public.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/layouts/public.vue b/app/layouts/public.vue index b068c25..e2f6c27 100644 --- a/app/layouts/public.vue +++ b/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(() => {