修复bug
This commit is contained in:
262
layouts/admin/AdminLayout.uvue
Normal file
262
layouts/admin/AdminLayout.uvue
Normal file
@@ -0,0 +1,262 @@
|
||||
<template>
|
||||
<view class="layout-root">
|
||||
<!-- 主侧边栏 -->
|
||||
<AdminAside
|
||||
:collapsed="isCollapsed"
|
||||
:menuList="menuList"
|
||||
:activeMenuId="activeMenuId"
|
||||
@toggle="toggleCollapse"
|
||||
@menu-click="onMenuClick"
|
||||
:asideWidth='ASIDE_W'
|
||||
/>
|
||||
|
||||
<!-- 二级侧边栏:固定在内容区左侧(独立层级) -->
|
||||
<AdminSubSider
|
||||
v-if="activeGroups.length > 0"
|
||||
:activeMenuTitle="activeMenuTitle"
|
||||
:groups="activeGroups"
|
||||
:activeSubId="activeSubId"
|
||||
:activeMenuId="activeMenuId || 'home'"
|
||||
:asideWidth="ASIDE_W"
|
||||
:siderWidth="SUB_W"
|
||||
@sub-click="onSubClick"
|
||||
/>
|
||||
|
||||
<!-- 右侧内容区(Header + Tags + 内容展示区 + Footer) -->
|
||||
<view
|
||||
class="main"
|
||||
:style="{ marginLeft: mainLeft }"
|
||||
>
|
||||
<AdminHeader
|
||||
:breadcrumb="breadcrumb"
|
||||
:hasNotification="hasNotification"
|
||||
@search="onSearch"
|
||||
@refresh="onRefresh"
|
||||
@notify="onNotify"
|
||||
/>
|
||||
|
||||
<AdminTagsView
|
||||
:tabs="tabs"
|
||||
:activeTabId="activeTabId"
|
||||
@tab-click="onTabClick"
|
||||
@tab-close="onTabClose"
|
||||
/>
|
||||
|
||||
<!-- 展示区:只渲染 slot 内容(你的页面内容都在这里展示) -->
|
||||
<scroll-view class="content" scroll-y="true">
|
||||
<view class="content-inner">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<AdminFooter />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import AdminAside from './components/AdminAside.uvue'
|
||||
import AdminSubSider from './components/AdminSubSider.uvue'
|
||||
import AdminHeader from './components/AdminHeader.uvue'
|
||||
import AdminTagsView from './components/AdminTagsView.uvue'
|
||||
import AdminFooter from './components/AdminFooter.uvue'
|
||||
|
||||
import { menuList as menuConst } from './utils/menu.uts'
|
||||
import { findActiveByCurrentPage, getCurrentRoutePath } from './utils/nav.uts'
|
||||
import { makeTabFromPath, upsertTab, removeTab } from './utils/tabs.uts'
|
||||
import type { MenuItem, TabItem , MenuChild } from './types.uts'
|
||||
|
||||
import { tabs, activeTabId, isCollapsed, hasNotification } from './state.uts'
|
||||
|
||||
|
||||
|
||||
// 你页面传进来的 currentPage:可能是顶级 id,也可能是子页面 id(user-list)
|
||||
const props = defineProps<{ currentPage: string }>()
|
||||
|
||||
const menuList = ref<MenuItem[]>(menuConst)
|
||||
|
||||
|
||||
// active states
|
||||
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'
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 每次 layout 渲染时,同步高亮(靠 currentPage)
|
||||
const syncActiveByCurrentPage = () => {
|
||||
const r = findActiveByCurrentPage(menuList.value, props.currentPage)
|
||||
activeMenuId.value = r.activeMenuId
|
||||
activeSubId.value = r.activeSubId
|
||||
}
|
||||
|
||||
// 同步 tabs(靠当前 route)
|
||||
const syncTabsByRoute = () => {
|
||||
const path = getCurrentRoutePath()
|
||||
if (!path) return
|
||||
|
||||
const tab = makeTabFromPath(menuList.value, path)
|
||||
tabs.value = upsertTab(tabs.value, tab)
|
||||
activeTabId.value = tab.id
|
||||
}
|
||||
|
||||
// 初始化同步(setup 执行一次)
|
||||
syncActiveByCurrentPage()
|
||||
syncTabsByRoute()
|
||||
|
||||
// computed
|
||||
const activeMenu = computed(() => menuList.value.find(m => m.id === activeMenuId.value))
|
||||
const activeMenuTitle = computed(() => activeMenu.value?.title || '商城后台')
|
||||
const activeGroups = computed(() => {
|
||||
const m = menuList.value.find(it => it.id === activeMenuId.value)
|
||||
return m?.groups ?? [] // ✅ 永远是数组
|
||||
})
|
||||
|
||||
|
||||
const breadcrumb = computed(() => {
|
||||
let subTitle = ''
|
||||
const groups = activeGroups.value
|
||||
for (const g of groups) {
|
||||
const cs = g.children ?? []
|
||||
const hit = cs.find(c => c.id === activeSubId.value)
|
||||
if (hit) { subTitle = hit.title; break }
|
||||
}
|
||||
return subTitle ? `${activeMenuTitle.value} / ${subTitle}` : `${activeMenuTitle.value}`
|
||||
})
|
||||
|
||||
|
||||
// handlers
|
||||
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]
|
||||
}
|
||||
|
||||
let navigating = false
|
||||
|
||||
// ✅ 改:使用 redirectTo(防止页面栈越堆越深)
|
||||
// 此方法用于主导航:菜单点击、二级菜单点击、tabs 点击
|
||||
const go = async (url?: string | null) => {
|
||||
if (!url || url.length === 0) return
|
||||
if (navigating) return
|
||||
navigating = true
|
||||
try {
|
||||
await uni.redirectTo({ url })
|
||||
} catch (e) {
|
||||
} finally {
|
||||
setTimeout(() => { navigating = false }, 80)
|
||||
}
|
||||
}
|
||||
|
||||
// // ✅ 新增:navigateTo 用于详情页等非主导航场景(允许用户返回)
|
||||
// const navigateToDetail = async (url?: string | null) => {
|
||||
// if (!url || url.length === 0) return
|
||||
// try {
|
||||
// await uni.navigateTo({ url })
|
||||
// } catch (e) {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
const onMenuClick = (menuId: string) => {
|
||||
const m = menuList.value.find(x => x.id === menuId)
|
||||
if (!m) return
|
||||
|
||||
activeMenuId.value = m.id
|
||||
|
||||
const leaf = firstLeafOfMenu(m)
|
||||
activeSubId.value = leaf ? leaf.id : ''
|
||||
|
||||
// ✅ 优先 leaf.path,其次才考虑 m.path
|
||||
go(leaf?.path ?? m.path ?? '')
|
||||
}
|
||||
|
||||
const firstLeafInChildren = (list?: MenuChild[] | null): MenuChild | null => {
|
||||
const arr = list ?? []
|
||||
if (arr.length === 0) return null
|
||||
const n = arr[0]
|
||||
const deep = n.children ?? []
|
||||
return deep.length > 0 ? firstLeafInChildren(deep) : n
|
||||
}
|
||||
|
||||
const onSubClick = (c: MenuChild) => {
|
||||
activeSubId.value = c.id
|
||||
if (c.path && c.path.length > 0) {
|
||||
go(c.path)
|
||||
} else {
|
||||
const leaf = firstLeafInChildren(c.children)
|
||||
go(leaf?.path ?? '')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const onTabClick = (tab: TabItem) => {
|
||||
activeTabId.value = tab.id
|
||||
go(tab.path)
|
||||
}
|
||||
|
||||
const onTabClose = (tabId: string) => {
|
||||
// 关闭当前 tab:删除后回到最后一个 tab
|
||||
const wasActive = activeTabId.value === tabId
|
||||
tabs.value = removeTab(tabs.value, tabId)
|
||||
if (wasActive) {
|
||||
const last = tabs.value[tabs.value.length - 1]
|
||||
if (last) {
|
||||
activeTabId.value = last.id
|
||||
go(last.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onSearch = () => uni.showToast({ title: '搜索', icon: 'none' })
|
||||
const onRefresh = () => uni.showToast({ title: '刷新', icon: 'none' })
|
||||
const onNotify = () => uni.showToast({ title: '通知', icon: 'none' })
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.layout-root{
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
background:#f3f4f6;
|
||||
}
|
||||
|
||||
/* 右侧主区域:左边距由 template 动态控制(96 或 336) */
|
||||
.main{
|
||||
min-height: 100vh;
|
||||
display:flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 展示区 */
|
||||
.content{
|
||||
height: calc(100vh - 56px - 44px);
|
||||
}
|
||||
.content-inner{
|
||||
padding:5px;
|
||||
}
|
||||
</style>
|
||||
@@ -45,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, computed, watch, withDefaults } from 'vue'
|
||||
import { ref, computed, watch, withDefaults, onMounted } from 'vue'
|
||||
import type { MenuGroup, MenuChild } from '../types.uts'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -269,34 +269,44 @@ const handleClick = (c: MenuChild) => {
|
||||
emit('sub-click', c)
|
||||
}
|
||||
|
||||
/** 自动:groups 变更/activeSubId 无效时,默认跳第一个 leaf 并展开对应 group */
|
||||
/** 自动:groups 变更/activeSubId 无效时,只做状态同步(展开对应 group),不触发导航 */
|
||||
const ensureDefault = () => {
|
||||
if (!props.groups || props.groups.length === 0) return
|
||||
|
||||
const hit = findChildById(props.activeSubId)
|
||||
if (hit) {
|
||||
openGroupKey.value = findGroupKeyByChildId(hit.id)
|
||||
return
|
||||
}
|
||||
if (hit) { openGroupKey.value = findGroupKeyByChildId(hit.id); return }
|
||||
|
||||
// ✅ 再按当前 route 找一次
|
||||
try {
|
||||
const pages = getCurrentPages()
|
||||
// @ts-ignore
|
||||
const cur: any = pages[pages.length - 1]
|
||||
const route: string = cur?.route ?? ''
|
||||
const byRoute = findChildByPath(route)
|
||||
if (byRoute) { openGroupKey.value = findGroupKeyByChildId(byRoute.id); return }
|
||||
} catch(e) {}
|
||||
|
||||
const first = firstLeaf()
|
||||
if (first) {
|
||||
openGroupKey.value = findGroupKeyByChildId(first.id)
|
||||
emit('sub-click', first)
|
||||
}
|
||||
if (first) openGroupKey.value = findGroupKeyByChildId(first.id)
|
||||
}
|
||||
|
||||
// ✅ 移除 watch(immediate: true) 中的自动 emit,仅在 groups/activeSubId 变更时同步状态
|
||||
watch(
|
||||
() => props.groups,
|
||||
() => { ensureDefault() },
|
||||
{ immediate: true, deep: true }
|
||||
{ immediate: false, deep: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.activeSubId,
|
||||
() => { ensureDefault() },
|
||||
{ immediate: true }
|
||||
{ immediate: false }
|
||||
)
|
||||
|
||||
// ✅ 初始化时只做一次状态同步(不通过 watch immediate)
|
||||
onMounted(() => {
|
||||
ensureDefault()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
0
layouts/admin/components/AdminTopBar.uvue
Normal file
0
layouts/admin/components/AdminTopBar.uvue
Normal file
@@ -1,254 +1,5 @@
|
||||
<template>
|
||||
<view class="layout-root">
|
||||
<!-- 主侧边栏 -->
|
||||
<AdminAside
|
||||
:collapsed="isCollapsed"
|
||||
:menuList="menuList"
|
||||
:activeMenuId="activeMenuId"
|
||||
@toggle="toggleCollapse"
|
||||
@menu-click="onMenuClick"
|
||||
:asideWidth='ASIDE_W'
|
||||
/>
|
||||
|
||||
<!-- 二级侧边栏:固定在内容区左侧(独立层级) -->
|
||||
<AdminSubSider
|
||||
v-if="activeGroups.length > 0"
|
||||
:activeMenuTitle="activeMenuTitle"
|
||||
:groups="activeGroups"
|
||||
:activeSubId="activeSubId"
|
||||
:activeMenuId="activeMenuId || 'home'"
|
||||
:asideWidth="ASIDE_W"
|
||||
:siderWidth="SUB_W"
|
||||
@sub-click="onSubClick"
|
||||
/>
|
||||
|
||||
<!-- 右侧内容区(Header + Tags + 内容展示区 + Footer) -->
|
||||
<view
|
||||
class="main"
|
||||
:style="{ marginLeft: mainLeft }"
|
||||
>
|
||||
<AdminHeader
|
||||
:breadcrumb="breadcrumb"
|
||||
:hasNotification="hasNotification"
|
||||
@search="onSearch"
|
||||
@refresh="onRefresh"
|
||||
@notify="onNotify"
|
||||
/>
|
||||
|
||||
<AdminTagsView
|
||||
:tabs="tabs"
|
||||
:activeTabId="activeTabId"
|
||||
@tab-click="onTabClick"
|
||||
@tab-close="onTabClose"
|
||||
/>
|
||||
|
||||
<!-- 展示区:只渲染 slot 内容(你的页面内容都在这里展示) -->
|
||||
<scroll-view class="content" scroll-y="true">
|
||||
<view class="content-inner">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<AdminFooter />
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template><view /></template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref, computed } from 'vue'
|
||||
import AdminAside from './components/AdminAside.uvue'
|
||||
import AdminSubSider from './components/AdminSubSider.uvue'
|
||||
import AdminHeader from './components/AdminHeader.uvue'
|
||||
import AdminTagsView from './components/AdminTagsView.uvue'
|
||||
import AdminFooter from './components/AdminFooter.uvue'
|
||||
|
||||
import { menuList as menuConst } from './utils/menu.uts'
|
||||
import { findActiveByCurrentPage, getCurrentRoutePath } from './utils/nav.uts'
|
||||
import { makeTabFromPath, upsertTab, removeTab } from './utils/tabs.uts'
|
||||
import type { MenuItem, TabItem , MenuChild } from './types.uts'
|
||||
|
||||
// 你页面传进来的 currentPage:可能是顶级 id,也可能是子页面 id(user-list)
|
||||
const props = defineProps<{ currentPage: string }>()
|
||||
|
||||
const menuList = ref<MenuItem[]>(menuConst)
|
||||
|
||||
const isCollapsed = ref(false)
|
||||
const hasNotification = ref(true)
|
||||
|
||||
// active states
|
||||
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' }
|
||||
])
|
||||
const activeTabId = ref('home')
|
||||
|
||||
// 每次 layout 渲染时,同步高亮(靠 currentPage)
|
||||
const syncActiveByCurrentPage = () => {
|
||||
const r = findActiveByCurrentPage(menuList.value, props.currentPage)
|
||||
activeMenuId.value = r.activeMenuId
|
||||
activeSubId.value = r.activeSubId
|
||||
}
|
||||
|
||||
// 同步 tabs(靠当前 route)
|
||||
const syncTabsByRoute = () => {
|
||||
const path = getCurrentRoutePath()
|
||||
if (!path) return
|
||||
|
||||
const tab = makeTabFromPath(menuList.value, path)
|
||||
tabs.value = upsertTab(tabs.value, tab)
|
||||
activeTabId.value = tab.id
|
||||
}
|
||||
|
||||
// 初始化同步(setup 执行一次)
|
||||
syncActiveByCurrentPage()
|
||||
syncTabsByRoute()
|
||||
|
||||
// computed
|
||||
const activeMenu = computed(() => menuList.value.find(m => m.id === activeMenuId.value))
|
||||
const activeMenuTitle = computed(() => activeMenu.value?.title || '商城后台')
|
||||
const activeGroups = computed(() => {
|
||||
const m = menuList.value.find(it => it.id === activeMenuId.value)
|
||||
return m?.groups ?? [] // ✅ 永远是数组
|
||||
})
|
||||
|
||||
|
||||
const breadcrumb = computed(() => {
|
||||
let subTitle = ''
|
||||
const groups = activeGroups.value
|
||||
for (const g of groups) {
|
||||
const cs = g.children ?? []
|
||||
const hit = cs.find(c => c.id === activeSubId.value)
|
||||
if (hit) { subTitle = hit.title; break }
|
||||
}
|
||||
return subTitle ? `${activeMenuTitle.value} / ${subTitle}` : `${activeMenuTitle.value}`
|
||||
})
|
||||
|
||||
|
||||
// handlers
|
||||
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]
|
||||
}
|
||||
|
||||
let navigating = false
|
||||
|
||||
const go = async (url?: string | null) => {
|
||||
if (!url || url.length === 0) return
|
||||
if (navigating) return
|
||||
navigating = true
|
||||
try {
|
||||
await uni.navigateTo({ url })
|
||||
} catch (e) {
|
||||
// 可选:忽略取消类报错,避免控制台刷屏
|
||||
} finally {
|
||||
setTimeout(() => { navigating = false }, 80)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const onMenuClick = (menuId: string) => {
|
||||
const m = menuList.value.find(x => x.id === menuId)
|
||||
if (!m) return
|
||||
|
||||
activeMenuId.value = m.id
|
||||
|
||||
const leaf = firstLeafOfMenu(m)
|
||||
activeSubId.value = leaf ? leaf.id : ''
|
||||
|
||||
// ✅ 优先 leaf.path,其次才考虑 m.path
|
||||
go(leaf?.path ?? m.path ?? '')
|
||||
}
|
||||
|
||||
const firstLeafInChildren = (list?: MenuChild[] | null): MenuChild | null => {
|
||||
const arr = list ?? []
|
||||
if (arr.length === 0) return null
|
||||
const n = arr[0]
|
||||
const deep = n.children ?? []
|
||||
return deep.length > 0 ? firstLeafInChildren(deep) : n
|
||||
}
|
||||
|
||||
const onSubClick = (c: MenuChild) => {
|
||||
activeSubId.value = c.id
|
||||
if (c.path && c.path.length > 0) {
|
||||
go(c.path)
|
||||
} else {
|
||||
const leaf = firstLeafInChildren(c.children)
|
||||
go(leaf?.path ?? '')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const onTabClick = (tab: TabItem) => {
|
||||
activeTabId.value = tab.id
|
||||
go(tab.path)
|
||||
}
|
||||
|
||||
const onTabClose = (tabId: string) => {
|
||||
// 关闭当前 tab:删除后回到最后一个 tab
|
||||
const wasActive = activeTabId.value === tabId
|
||||
tabs.value = removeTab(tabs.value, tabId)
|
||||
if (wasActive) {
|
||||
const last = tabs.value[tabs.value.length - 1]
|
||||
if (last) {
|
||||
activeTabId.value = last.id
|
||||
go(last.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onSearch = () => uni.showToast({ title: '搜索', icon: 'none' })
|
||||
const onRefresh = () => uni.showToast({ title: '刷新', icon: 'none' })
|
||||
const onNotify = () => uni.showToast({ title: '通知', icon: 'none' })
|
||||
uni.redirectTo({ url: '/pages/mall/admin/homePage/index' })
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.layout-root{
|
||||
width: 100%;
|
||||
min-height: 100vh;
|
||||
background:#f3f4f6;
|
||||
}
|
||||
|
||||
/* 右侧主区域:左边距由 template 动态控制(96 或 336) */
|
||||
.main{
|
||||
min-height: 100vh;
|
||||
display:flex;
|
||||
flex-direction: rowe;
|
||||
}
|
||||
|
||||
/* 展示区 */
|
||||
.content{
|
||||
height: calc(100vh - 56px - 44px);
|
||||
}
|
||||
.content-inner{
|
||||
padding:5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
10
layouts/admin/state.uts
Normal file
10
layouts/admin/state.uts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { ref } from 'vue'
|
||||
import type { TabItem } from './types.uts'
|
||||
|
||||
export const tabs = ref<TabItem[]>([
|
||||
{ id: 'home', title: '首页', path: '/pages/mall/admin/homePage/index' }
|
||||
])
|
||||
|
||||
export const activeTabId = ref<string>('home')
|
||||
export const isCollapsed = ref<boolean>(false)
|
||||
export const hasNotification = ref<boolean>(true)
|
||||
@@ -14,22 +14,19 @@ export type TagItem = {
|
||||
export type MenuChild = {
|
||||
id: string
|
||||
title: string
|
||||
path: string
|
||||
|
||||
// ✅ 目录节点可以没有 path
|
||||
path?: string | null
|
||||
|
||||
// ✅ 允许四级
|
||||
// ✅ 允许四级:MenuChild 下还能继续 children
|
||||
children?: MenuChild[] | null
|
||||
}
|
||||
|
||||
export type MenuGroup = {
|
||||
id?: string | null
|
||||
title: string
|
||||
|
||||
// ✅ 允许 group 自己也能当叶子直接跳转(可选)
|
||||
// ✅ 允许“叶子二级菜单”:group 自己也可以有 path(可选)
|
||||
path?: string | null
|
||||
|
||||
// ✅ children 允许缺省/为空
|
||||
// ✅ 关键:children 改成可选(否则你现在这种叶子 group 会直接报错)
|
||||
children?: MenuChild[] | null
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,12 @@ export const menuList: MenuItem[] = [
|
||||
id: 'user',
|
||||
title: '用户',
|
||||
icon: '/static/user.svg',
|
||||
path: '/pages/mall/admin/user-management',
|
||||
path: '/pages/mall/admin/user-statistics',
|
||||
groups: [
|
||||
{
|
||||
id: 'user-management',
|
||||
title: '用户管理',
|
||||
children: [
|
||||
{
|
||||
id: 'user-statistics',
|
||||
title: '用户统计',
|
||||
path: '/pages/mall/admin/user-statistics'
|
||||
},
|
||||
{
|
||||
id: 'user-list',
|
||||
title: '用户管理',
|
||||
|
||||
Reference in New Issue
Block a user