@@ -14,7 +14,7 @@ import Flex from '@pages/components/Flex'
1414import { ElBreadcrumb , ElBreadcrumbItem , ElIcon , ElMenu , ElMenuItem , useNamespace } from "element-plus"
1515import { defineComponent , h , onBeforeMount , ref , watch } from "vue"
1616import { useRouter } from "vue-router"
17- import { type MenuItem , NAV_MENUS } from "./item"
17+ import { type MenuItem , navMenus } from "./item"
1818import { handleClick , initTitle } from "./route"
1919import { colorMenu } from './style'
2020
@@ -42,12 +42,13 @@ const useStyle = () => {
4242 return { containerCls, menuWrapperCls }
4343}
4444
45- const findTitle = ( routePath : string ) : string => {
46- const title = NAV_MENUS . find ( v => routePath === v . route ) ?. title
45+ const findTitle = ( routePath : string , menus : MenuItem [ ] ) : string => {
46+ const title = menus . find ( v => routePath === v . route ) ?. title
4747 return title ? t ( title ) : ''
4848}
4949
5050const _default = defineComponent < { } > ( ( ) => {
51+ const menus = navMenus ( )
5152 const router = useRouter ( )
5253 const title = ref ( '' )
5354 const [ showMenu , , closeMenu , toggleMenu ] = useSwitch ( false )
@@ -58,7 +59,7 @@ const _default = defineComponent<{}>(() => {
5859
5960 const syncRouter = ( ) => {
6061 const route = router . currentRoute . value
61- route && ( title . value = findTitle ( route . path ) )
62+ route && ( title . value = findTitle ( route . path , menus ) )
6263 }
6364
6465 watch ( router . currentRoute , syncRouter )
@@ -86,7 +87,7 @@ const _default = defineComponent<{}>(() => {
8687 </ Flex >
8788 < div class = { menuWrapperCls } v-show = { showMenu . value } >
8889 < ElMenu >
89- { NAV_MENUS . map ( item => (
90+ { menus . map ( item => (
9091 < ElMenuItem
9192 index = { item . index ?? item . route ?? item . href }
9293 onClick = { ( ) => handleItemClick ( item ) }
0 commit comments