完善页面布局

This commit is contained in:
2026-01-28 17:54:30 +08:00
parent 8c5024a943
commit 9f3c2803e3
25 changed files with 4333 additions and 2064 deletions

View File

@@ -7,6 +7,7 @@
:activeMenuId="activeMenuId"
@toggle="toggleCollapse"
@menu-click="onMenuClick"
:asideWidth='ASIDE_W'
/>
<!-- 二级侧边栏:固定在内容区左侧(独立层级) -->
@@ -15,13 +16,15 @@
:activeMenuTitle="activeMenuTitle"
:groups="activeGroups"
:activeSubId="activeSubId"
:asideWidth="ASIDE_W"
:siderWidth="SUB_W"
@sub-click="onSubClick"
/>
<!-- 右侧内容区Header + Tags + 内容展示区 + Footer -->
<view
class="main"
:style="{ marginLeft: activeGroups.length > 0 ? '336px' : '96px' }"
:style="{ marginLeft: mainLeft }"
>
<AdminHeader
:breadcrumb="breadcrumb"
@@ -74,6 +77,14 @@ const hasNotification = ref(true)
const activeMenuId = ref('home')
const activeSubId = ref('')
// 二级侧边栏
const ASIDE_W = 96
const SUB_W = 200 // 你想更像 CRMEB就把这改小160~180 都行
const mainLeft = computed(() => {
return (activeGroups.value.length > 0 ? (ASIDE_W + SUB_W) : ASIDE_W) + 'px'
})
// tabs
const tabs = ref<TabItem[]>([
{ id: 'home', title: '首页', path: '/pages/mall/admin/homePage/index' }
@@ -122,6 +133,26 @@ const toggleCollapse = () => {
isCollapsed.value = !isCollapsed.value
}
// 递归取第一个 leaf你要求的“递归默认打开第一个页面”
const firstLeafOfMenu = (m: MenuItem): MenuChild | null => {
if (!m.groups || m.groups.length === 0) return null
const g0 = m.groups[0]
if (!g0.children || g0.children.length === 0) return null
const c0: any = g0.children[0] as any
// 兼容未来 children 还能再嵌套
if (c0.children && (c0.children as MenuChild[]).length > 0) {
const walk = (list: MenuChild[]): MenuChild | null => {
if (!list || list.length === 0) return null
const n: any = list[0] as any
if (n.children && (n.children as MenuChild[]).length > 0) return walk(n.children as MenuChild[])
return list[0]
}
return walk(c0.children as MenuChild[])
}
return g0.children[0]
}
const go = (url: string) => {
// 你明确要用 navigateTo页面栈会增长这是正常行为:contentReference[oaicite:4]{index=4}
uni.navigateTo({ url })
@@ -138,9 +169,9 @@ const onMenuClick = (menuId: string) => {
go(m.path)
}
const onSubClick = (child: any) => {
activeSubId.value = child.id
go(child.path)
const onSubClick = (c: MenuChild) => {
activeSubId.value = c.id
go(c.path)
}
const onTabClick = (tab: TabItem) => {
@@ -177,7 +208,7 @@ const onNotify = () => uni.showToast({ title: '通知', icon: 'none' })
.main{
min-height: 100vh;
display:flex;
flex-direction: column;
flex-direction: rowe;
}
/* 展示区 */