mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-06 21:36:37 +08:00
fix(layout): hide duplicate media nav in mobile drawer (#11)
On narrow screens the media drawer duplicated bottom navigation and user menu links (home, libraries, favourites, playlists, history). Show only management links in the drawer when browsing media. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import clsx from 'clsx'
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
LAYOUT_NAV_ITEMS,
|
LAYOUT_NAV_ITEMS,
|
||||||
MEDIA_NAV_ITEMS,
|
|
||||||
type LayoutNavItem,
|
type LayoutNavItem,
|
||||||
} from './layoutNavigation'
|
} from './layoutNavigation'
|
||||||
import { SidebarLink } from './LayoutSidebarNav'
|
import { SidebarLink } from './LayoutSidebarNav'
|
||||||
@@ -30,7 +29,6 @@ export function LayoutSidebarContent({
|
|||||||
variant = 'admin',
|
variant = 'admin',
|
||||||
}: LayoutSidebarContentProps) {
|
}: LayoutSidebarContentProps) {
|
||||||
const sidebarExpanded = isSidebarOpen || isMobileDrawerOpen
|
const sidebarExpanded = isSidebarOpen || isMobileDrawerOpen
|
||||||
const mediaItems = visibleSidebarItems({ isAdmin, can, items: MEDIA_NAV_ITEMS })
|
|
||||||
const adminItems = visibleSidebarItems({ isAdmin, can, items: LAYOUT_NAV_ITEMS })
|
const adminItems = visibleSidebarItems({ isAdmin, can, items: LAYOUT_NAV_ITEMS })
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -41,19 +39,10 @@ export function LayoutSidebarContent({
|
|||||||
onCloseMobileDrawer={onCloseMobileDrawer}
|
onCloseMobileDrawer={onCloseMobileDrawer}
|
||||||
/>
|
/>
|
||||||
<div className="min-h-0 flex-1 overflow-y-auto scrollbar-hide">
|
<div className="min-h-0 flex-1 overflow-y-auto scrollbar-hide">
|
||||||
{variant === 'media' ? (
|
{/* 窄屏媒体浏览抽屉不展示 MEDIA_NAV_ITEMS:底部导航与用户菜单已覆盖 */}
|
||||||
<>
|
{variant !== 'media' || adminItems.length > 0 ? (
|
||||||
<LayoutSidebarNav items={mediaItems} sidebarExpanded={sidebarExpanded} />
|
|
||||||
{adminItems.length > 0 && (
|
|
||||||
<div className="border-t border-[var(--app-border)]">
|
|
||||||
<LayoutSidebarSectionLabel sidebarExpanded={sidebarExpanded} label="管理" />
|
|
||||||
<LayoutSidebarNav items={adminItems} sidebarExpanded={sidebarExpanded} compactTop />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<LayoutSidebarNav items={adminItems} sidebarExpanded={sidebarExpanded} />
|
<LayoutSidebarNav items={adminItems} sidebarExpanded={sidebarExpanded} />
|
||||||
)}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<LayoutSidebarHomeBack sidebarExpanded={sidebarExpanded} />
|
<LayoutSidebarHomeBack sidebarExpanded={sidebarExpanded} />
|
||||||
</div>
|
</div>
|
||||||
@@ -107,37 +96,15 @@ function LayoutSidebarHeader({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function LayoutSidebarSectionLabel({
|
|
||||||
sidebarExpanded,
|
|
||||||
label,
|
|
||||||
}: {
|
|
||||||
sidebarExpanded: boolean
|
|
||||||
label: string
|
|
||||||
}) {
|
|
||||||
if (!sidebarExpanded) return null
|
|
||||||
return (
|
|
||||||
<p className="px-4 pt-4 pb-1 text-[10px] font-bold uppercase tracking-wider text-[var(--app-muted)]">
|
|
||||||
{label}
|
|
||||||
</p>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function LayoutSidebarNav({
|
function LayoutSidebarNav({
|
||||||
items,
|
items,
|
||||||
sidebarExpanded,
|
sidebarExpanded,
|
||||||
compactTop = false,
|
|
||||||
}: {
|
}: {
|
||||||
items: LayoutNavItem[]
|
items: LayoutNavItem[]
|
||||||
sidebarExpanded: boolean
|
sidebarExpanded: boolean
|
||||||
compactTop?: boolean
|
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav className="px-4 py-5 space-y-1">
|
||||||
className={clsx(
|
|
||||||
'px-4 py-5 space-y-1',
|
|
||||||
compactTop && 'pt-2',
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{items.map((item) => {
|
{items.map((item) => {
|
||||||
const ItemIcon = item.icon
|
const ItemIcon = item.icon
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user