继续完善页面布局

This commit is contained in:
2026-01-27 20:02:57 +08:00
parent f1ee5b340c
commit 289d371630
27 changed files with 1761 additions and 3688 deletions

View File

@@ -0,0 +1,34 @@
import type { MenuItem } from '../types.uts'
export function findActiveByCurrentPage(menuList: MenuItem[], currentPage: string) {
// currentPage 既可能是顶级菜单 id也可能是子页面 id如 user-list
// 返回activeMenuId / activeSubId / activeGroupTitle
for (const m of menuList) {
if (m.id === currentPage) {
return { activeMenuId: m.id, activeSubId: '', activeGroupTitle: '' }
}
const groups = m.groups || []
for (const g of groups) {
for (const c of g.children) {
if (c.id === currentPage) {
return { activeMenuId: m.id, activeSubId: c.id, activeGroupTitle: g.title }
}
}
}
}
return { activeMenuId: menuList[0]?.id || 'home', activeSubId: '', activeGroupTitle: '' }
}
export function getCurrentRoutePath(): string {
// 使用页面栈获取当前路由uni-app标准能力
// getCurrentPages 用于获取当前页面栈实例 :contentReference[oaicite:2]{index=2}
const pages = getCurrentPages()
const last: any = pages[pages.length - 1]
// #ifdef H5
return last?.route ? `/${last.route}` : ''
// #endif
// #ifndef H5
// 小程序/App 可能是 route / $page?.fullPath 形式,按你项目实际字段微调
return last?.route ? `/${last.route}` : (last?.$page?.fullPath || '')
// #endif
}