-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(projects): refactor the menu section code
- Loading branch information
Showing
10 changed files
with
87 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 10 additions & 37 deletions
47
src/layouts/modules/global-menu/modules/HorizontalMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,15 @@ | ||
import type { Route } from '@sa/simple-router'; | ||
import type { MenuInfo } from 'rc-menu/lib/interface'; | ||
import { useRouterPush } from '@/hooks/common/routerPush'; | ||
import { headerContainer } from './shared'; | ||
import { createPortal } from 'react-dom'; | ||
import { GLOBAL_HEADER_MENU_ID } from '@/constants/app'; | ||
import HorizontalMenu from '../components/HorizontalMenu'; | ||
import type { Props } from '../components/HorizontalMenu'; | ||
import { useGetElementById } from './hook'; | ||
|
||
function getSelectKey(route: Route) { | ||
const { hideInMenu, activeMenu } = route.meta; | ||
const Horizontal = ({ menus }: Props) => { | ||
const container = useGetElementById(GLOBAL_HEADER_MENU_ID); | ||
|
||
const name = route.name as string; | ||
if (!container) return null; | ||
|
||
const routeName = (hideInMenu ? activeMenu : name) || name; | ||
|
||
return [routeName]; | ||
} | ||
|
||
const HorizontalMenu = () => { | ||
const route = useRoute(); | ||
|
||
const menus = useMenu(); | ||
|
||
const router = useRouterPush(); | ||
|
||
const selectKey = getSelectKey(route); | ||
|
||
function handleClickMenu(menuInfo: MenuInfo) { | ||
router.menuPush(menuInfo.key); | ||
} | ||
|
||
if (!headerContainer) return null; | ||
|
||
return ( | ||
<AMenu | ||
mode="horizontal" | ||
items={menus} | ||
inlineIndent={18} | ||
onSelect={handleClickMenu} | ||
selectedKeys={selectKey} | ||
/> | ||
); | ||
return createPortal(<HorizontalMenu menus={menus} />, container); | ||
}; | ||
|
||
export default HorizontalMenu; | ||
export default Horizontal; |
60 changes: 0 additions & 60 deletions
60
src/layouts/modules/global-menu/modules/HorizontalMixMenu.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.