{logoRender}
diff --git a/packages/basic-layouts/src/Sider/index.tsx b/packages/basic-layouts/src/Sider/index.tsx
index 6cf10e4f4..afe2f3ae0 100644
--- a/packages/basic-layouts/src/Sider/index.tsx
+++ b/packages/basic-layouts/src/Sider/index.tsx
@@ -3,7 +3,7 @@ import { Layout, Menu, MenuProps } from 'antd';
import React, { useMemo } from 'react';
import { useLocation } from 'react-router-dom';
import { useLayouts } from '../hooks';
-import { RouterMenu } from '../interface';
+import { LayoutModel, RouterMenu } from '../interface';
import { getSiderMenus } from '../utils';
import Logo from './../Logo';
@@ -20,6 +20,7 @@ const Sider = (props: SiderProps) => {
collapsed,
siderWidth = 260,
setCollapsed,
+ layout
} = useLayouts();
const collapsedView = useMemo(
@@ -34,11 +35,13 @@ const Sider = (props: SiderProps) => {
const menus = HandleMenu.getSiderMenus(location.pathname);
const items = useMemo(() => {
- return getSiderMenus(menus, !!ANTD_MENU_TOP_LEFT);
- }, [menus]);
+ return getSiderMenus(menus, layout === LayoutModel.TOPLEFT);
+ }, [menus, layout]);
+
if (!items.length) {
return
;
}
+
return (
{
{collapsedView}
}
>
- {!!ANTD_MENU_SLIDER && (
+ {layout === LayoutModel.SLIDER && (
diff --git a/packages/basic-layouts/src/hooks.ts b/packages/basic-layouts/src/hooks.ts
index f3844af64..4068a46ee 100644
--- a/packages/basic-layouts/src/hooks.ts
+++ b/packages/basic-layouts/src/hooks.ts
@@ -9,7 +9,7 @@ import DocumentTitleDom, { DocumentTitle } from '@antdp/document-title';
import { useLocation } from 'react-router-dom';
// @ts-ignore
import { useAppData } from '@umijs/max';
-import { UseLayoutsProps, RouterMenu } from './interface';
+import { UseLayoutsProps, RouterMenu, LayoutModel } from './interface';
import { HandleMenu } from './utils';
export interface LayoutsContextType extends UseLayoutsProps {
@@ -22,6 +22,7 @@ export const LayoutsContext = createContext({
HandleMenu: new HandleMenu({ routers: [] }),
collapsed: false,
setCollapsed: () => null,
+ layout: LayoutModel.MIX
});
export const useLayouts = () => useContext(LayoutsContext);
@@ -31,6 +32,7 @@ export const LayoutsProvider = (props: UseLayoutsProps) => {
const [collapsed, setCollapsed] = useState(false);
const location = useLocation();
const { clientRoutes } = useAppData();
+ const layout = props.layout
const routes = useMemo(() => {
const routes = (clientRoutes as RouterMenu[]).find(
@@ -44,9 +46,9 @@ export const LayoutsProvider = (props: UseLayoutsProps) => {
routers: routes || [],
intlLanguage: intlLanguage,
isCheckAuth: !!ANTD_AUTH_CONF,
- isTOPLEFT: !!ANTD_MENU_TOP_LEFT,
+ isTOPLEFT: layout === LayoutModel.TOPLEFT,
});
- }, [routes, intlLanguage]);
+ }, [routes, intlLanguage, layout]);
const title = useMemo(() => {
const item = Menus.getPathItem(location.pathname);
@@ -67,8 +69,12 @@ export const LayoutsProvider = (props: UseLayoutsProps) => {
return createElement(DocumentTitleDom, {
title: renderTitle,
children: createElement(LayoutsContext.Provider, {
- value: { HandleMenu: Menus, collapsed, setCollapsed, ...rest },
+ value: {
+ HandleMenu: Menus, collapsed, setCollapsed, layout: LayoutModel.MIX,
+ ...rest
+ },
children,
}),
});
};
+
diff --git a/packages/basic-layouts/src/index.tsx b/packages/basic-layouts/src/index.tsx
index 259740202..cfba96f3f 100644
--- a/packages/basic-layouts/src/index.tsx
+++ b/packages/basic-layouts/src/index.tsx
@@ -5,7 +5,7 @@ import WarpContent from './Content';
import Header from './Header';
import { LayoutsProvider } from './hooks';
import './index.css';
-import { BasicLayoutsProps } from './interface';
+import { BasicLayoutsProps, LayoutModel } from './interface';
import SiderMenus from './Sider';
export * from './Breadcrumb';
export { default as Breadcrumb } from './Breadcrumb';
@@ -25,8 +25,11 @@ export * from './utils';
const BasicLayouts = (props: BasicLayoutsProps) => {
const { theme = 'light' } = props;
+ const layout = props.layout
+
+
const render = useMemo(() => {
- if (!!ANTD_MENU_TOP_LEFT) {
+ if (layout === LayoutModel.TOPLEFT) {
return (
{ANTD_HEAD_IS_SHOW && (
@@ -44,7 +47,7 @@ const BasicLayouts = (props: BasicLayoutsProps) => {
);
- } else if (!!ANTD_MENU_SLIDER) {
+ } else if (layout === LayoutModel.SLIDER) {
return (
{ANTD_MENU_IS_SHOW && }
@@ -83,7 +86,8 @@ const BasicLayouts = (props: BasicLayoutsProps) => {
);
}
- }, [theme]);
+ }, [theme, layout]);
+
const newData = useMemo(() => {
if (typeof ANTD_AUTH_CONF === 'boolean') {
return {
@@ -104,6 +108,7 @@ const BasicLayouts = (props: BasicLayoutsProps) => {
}
return { isCheckAuth: false };
}, [ANTD_AUTH_CONF]);
+
return (
diff --git a/packages/basic-layouts/src/interface.ts b/packages/basic-layouts/src/interface.ts
index 29144dfa4..6e9cd7aa1 100644
--- a/packages/basic-layouts/src/interface.ts
+++ b/packages/basic-layouts/src/interface.ts
@@ -35,7 +35,18 @@ export interface RouterMenu {
parentId?: string;
}
+export enum LayoutModel {
+ SLIDER = 'slider',
+ TOPLEFT = 'topleft',
+ MIX = 'mix',
+}
+
export interface BasicLayoutsProps {
+ /**
+ * layout 的菜单模式
+ * @default MIX
+ * */
+ layout?: LayoutModel;
/**
* 项目logo
*/
diff --git a/packages/basic-layouts/src/react-app-env.d.ts b/packages/basic-layouts/src/react-app-env.d.ts
index 5effa8976..1f42c7eb3 100644
--- a/packages/basic-layouts/src/react-app-env.d.ts
+++ b/packages/basic-layouts/src/react-app-env.d.ts
@@ -1,5 +1,3 @@
-declare var ANTD_MENU_TOP_LEFT: boolean | undefined;
-declare var ANTD_MENU_SLIDER: boolean | undefined;
declare var ANTD_AUTH_CONF: boolean | undefined;
declare var ANTD_HEAD_IS_SHOW: boolean | undefined;
declare var ANTD_MENU_IS_SHOW: boolean | undefined;
diff --git a/packages/config/README.md b/packages/config/README.md
index cb9a9ceac..d8939b260 100644
--- a/packages/config/README.md
+++ b/packages/config/README.md
@@ -150,22 +150,6 @@ export default config(router, {
);
```
-### ANTD_MENU_TOP_LEFT
-
-父级菜单展示顶部 ,子集菜单展示侧边,默认值`false`不显示
-
-```diff
-import config from '@antdp/config';
-import proxy from './proxy';
-import router from './router.json';
-export default config(router, {
- proxy,
- define: {
-+ ANTD_MENU_TOP_LEFT: true
- },
-);
-```
-
### ANTD_MENU_SEARCH_IS_SHOW
是否开启菜单栏搜索,默认值`false`
diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts
index 0c78d01f8..03d18bfc9 100644
--- a/packages/config/src/index.ts
+++ b/packages/config/src/index.ts
@@ -82,10 +82,6 @@ export default (routes: IRoute[] = [], options: OptionsProps = {}) => {
ANTD_MENU_IS_SHOW: true,
/** 是否显示 head头部 */
ANTD_HEAD_IS_SHOW: true,
- /** 父级菜单展示顶部 ,子集菜单展示侧边 */
- ANTD_MENU_TOP_LEFT: false,
- /** 菜单侧边展示 */
- ANTD_MENU_SLIDER: false,
/** 是否开启菜单栏搜索 */
ANTD_MENU_SEARCH_IS_SHOW: false,
...(options.define || {}),