diff --git a/frontend/src/components/RightPanel.tsx b/frontend/src/components/RightPanel.tsx index 2cdc1eb..f3797ff 100644 --- a/frontend/src/components/RightPanel.tsx +++ b/frontend/src/components/RightPanel.tsx @@ -232,11 +232,13 @@ export default function RightPanel({
{isPostDetail && ( <> - + {postDetail.author?.id ? ( + + ) : null}
diff --git a/frontend/src/layouts/MainLayout.tsx b/frontend/src/layouts/MainLayout.tsx index 90f1de1..a00862b 100644 --- a/frontend/src/layouts/MainLayout.tsx +++ b/frontend/src/layouts/MainLayout.tsx @@ -148,7 +148,10 @@ export default function MainLayout() { setSidebarOpen(false); }, [loc.pathname, loc.search]); useEffect(() => { - if (!/^\/post\/\d+/.test(loc.pathname)) setPostOutline(null); + const isArticleAside = + (/^\/post\/\d+/.test(loc.pathname) && !/\/edit$/.test(loc.pathname)) + || /^\/page\//.test(loc.pathname); + if (!isArticleAside) setPostOutline(null); }, [loc.pathname]); useEffect(() => { if (!hideAside) setAsideOpen(false); @@ -477,6 +480,10 @@ export default function MainLayout() { const activeChipIndex = Math.max(0, boardChipIds.indexOf(mobileActiveBoard === -1 ? 0 : mobileActiveBoard)); const isPostDetail = /^\/post\/\d+/.test(loc.pathname) && !/\/edit$/.test(loc.pathname); + const isSitePage = /^\/page\//.test(loc.pathname); + const isArticleAside = isPostDetail || isSitePage; + // 帖子有作者 →「作者与目录」;单页仅目录 + const articleAsideLabel = isPostDetail ? '作者与目录' : '文章目录'; const setPostOutlineSafe = useCallback((outline: { headings: PostHeading[]; scrollRoot: HTMLElement | null; @@ -632,10 +639,10 @@ export default function MainLayout() { type="button" className="header-icon-btn" onClick={openAside} - aria-label={isPostDetail ? '打开作者与目录' : '打开社区动态'} + aria-label={isArticleAside ? `打开${articleAsideLabel}` : '打开社区动态'} aria-expanded={asideOpen} aria-controls="aside-drawer" - title={isPostDetail ? '作者与目录' : '社区动态'} + title={isArticleAside ? articleAsideLabel : '社区动态'} > @@ -815,7 +822,7 @@ export default function MainLayout() { asideWidgets={asideWidgets} onPostClick={openPost} - postDetail={isPostDetail ? { + postDetail={isArticleAside ? { author: postOutline?.author ?? null, publishedAt: postOutline?.publishedAt, viewCount: postOutline?.viewCount, @@ -879,7 +886,7 @@ export default function MainLayout() { onClick={() => { closeSidebar(); openAside(); }} > - {isPostDetail ? '作者与目录' : '社区动态'} + {isArticleAside ? articleAsideLabel : '社区动态'}