Commit 5ee633cc authored by Rayron Victor's avatar Rayron Victor Committed by 偏右

Layout header height correctly change when `@layout-header-height` change.

parent 51fc7958
...@@ -31,11 +31,9 @@ export default class GlobalHeader extends PureComponent { ...@@ -31,11 +31,9 @@ export default class GlobalHeader extends PureComponent {
<img src={logo} alt="logo" width="32" /> <img src={logo} alt="logo" width="32" />
</Link> </Link>
)} )}
<Icon <span className={styles.trigger} onClick={this.toggle}>
className={styles.trigger} <Icon type={collapsed ? 'menu-unfold' : 'menu-fold'} />
type={collapsed ? 'menu-unfold' : 'menu-fold'} </span>
onClick={this.toggle}
/>
<RightContent {...this.props} /> <RightContent {...this.props} />
</div> </div>
); );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
@pro-header-hover-bg: rgba(0, 0, 0, 0.025); @pro-header-hover-bg: rgba(0, 0, 0, 0.025);
.header { .header {
height: 64px; height: @layout-header-height;
padding: 0; padding: 0;
background: #fff; background: #fff;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
} }
.logo { .logo {
height: 64px; height: @layout-header-height;
line-height: 58px; line-height: @layout-header-height;
vertical-align: top; vertical-align: top;
display: inline-block; display: inline-block;
padding: 0 0 0 24px; padding: 0 0 0 24px;
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
} }
} }
i.trigger { .trigger {
font-size: 20px; font-size: 20px;
height: 64px; height: @layout-header-height;
cursor: pointer; cursor: pointer;
transition: all 0.3s, padding 0s; transition: all 0.3s, padding 0s;
padding: 22px 24px; padding: ~'calc((@{layout-header-height} - 20px) / 2)' 24px;
&:hover { &:hover {
background: @pro-header-hover-bg; background: @pro-header-hover-bg;
} }
...@@ -73,7 +73,8 @@ i.trigger { ...@@ -73,7 +73,8 @@ i.trigger {
} }
.account { .account {
.avatar { .avatar {
margin: 20px 8px 20px 0; margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0;
margin-right: 8px;
color: @primary-color; color: @primary-color;
background: rgba(255, 255, 255, 0.85); background: rgba(255, 255, 255, 0.85);
vertical-align: top; vertical-align: top;
...@@ -82,7 +83,7 @@ i.trigger { ...@@ -82,7 +83,7 @@ i.trigger {
} }
.dark { .dark {
height: 64px; height: @layout-header-height;
.action { .action {
color: rgba(255, 255, 255, 0.85); color: rgba(255, 255, 255, 0.85);
> i { > i {
......
...@@ -42,11 +42,9 @@ export default class SelectLang extends PureComponent { ...@@ -42,11 +42,9 @@ export default class SelectLang extends PureComponent {
); );
return ( return (
<Dropdown overlay={langMenu} placement="bottomRight"> <Dropdown overlay={langMenu} placement="bottomRight">
<Icon <span className={classNames(styles.dropDown, className)}>
type="global" <Icon type="global" title={formatMessage({ id: 'navBar.lang' })} />
className={classNames(styles.dropDown, className)} </span>
title={formatMessage({ id: 'navBar.lang' })}
/>
</Dropdown> </Dropdown>
); );
} }
......
...@@ -11,11 +11,14 @@ ...@@ -11,11 +11,14 @@
.dropDown { .dropDown {
cursor: pointer; cursor: pointer;
font-size: 14px;
vertical-align: top; vertical-align: top;
line-height: 64px; line-height: @layout-header-height;
> svg { > i {
font-size: 14px !important;
transform: none !important;
svg {
position: relative; position: relative;
top: 2px; top: -1px;
}
} }
} }
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import classNames from 'classnames';
import { Menu, Icon } from 'antd'; import { Menu, Icon } from 'antd';
import Link from 'umi/link'; import Link from 'umi/link';
import isEqual from 'lodash/isEqual'; import isEqual from 'lodash/isEqual';
...@@ -130,6 +131,7 @@ export default class BaseMenu extends PureComponent { ...@@ -130,6 +131,7 @@ export default class BaseMenu extends PureComponent {
theme, theme,
mode, mode,
location: { pathname }, location: { pathname },
className,
} = this.props; } = this.props;
// if pathname can't match, use the nearest parent's key // if pathname can't match, use the nearest parent's key
let selectedKeys = this.getSelectedMenuKeys(pathname); let selectedKeys = this.getSelectedMenuKeys(pathname);
...@@ -143,6 +145,10 @@ export default class BaseMenu extends PureComponent { ...@@ -143,6 +145,10 @@ export default class BaseMenu extends PureComponent {
}; };
} }
const { handleOpenChange, style, menuData } = this.props; const { handleOpenChange, style, menuData } = this.props;
const cls = classNames(className, {
'top-nav-menu': mode === 'horizontal',
});
return ( return (
<Menu <Menu
key="Menu" key="Menu"
...@@ -151,7 +157,7 @@ export default class BaseMenu extends PureComponent { ...@@ -151,7 +157,7 @@ export default class BaseMenu extends PureComponent {
onOpenChange={handleOpenChange} onOpenChange={handleOpenChange}
selectedKeys={selectedKeys} selectedKeys={selectedKeys}
style={style} style={style}
className={mode === 'horizontal' ? 'top-nav-menu' : ''} className={cls}
{...props} {...props}
> >
{this.getNavMenuItems(menuData)} {this.getNavMenuItems(menuData)}
......
@import '~antd/lib/style/themes/default.less'; @import '~antd/lib/style/themes/default.less';
@nav-header-height: 64px; @nav-header-height: @layout-header-height;
.logo { .logo {
height: @nav-header-height; height: @nav-header-height;
......
...@@ -40,11 +40,7 @@ export default class TopNavHeader extends PureComponent { ...@@ -40,11 +40,7 @@ export default class TopNavHeader extends PureComponent {
maxWidth, maxWidth,
}} }}
> >
<BaseMenu <BaseMenu {...this.props} flatMenuKeys={flatMenuKeys} className={styles.menu} />
{...this.props}
flatMenuKeys={flatMenuKeys}
style={{ border: 'none', height: 64 }}
/>
</div> </div>
</div> </div>
<RightContent {...this.props} /> <RightContent {...this.props} />
......
@import '~antd/lib/style/themes/default.less';
.head { .head {
width: 100%; width: 100%;
transition: background 0.3s, width 0.2s; transition: background 0.3s, width 0.2s;
height: 64px; height: @layout-header-height;
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
position: relative; position: relative;
:global { :global {
.ant-menu-submenu.ant-menu-submenu-horizontal { .ant-menu-submenu.ant-menu-submenu-horizontal {
line-height: 64px; line-height: @layout-header-height;
height: 100%; height: 100%;
.ant-menu-submenu-title { .ant-menu-submenu-title {
height: 100%; height: 100%;
...@@ -18,7 +20,7 @@ ...@@ -18,7 +20,7 @@
} }
.main { .main {
display: flex; display: flex;
height: 64px; height: @layout-header-height;
padding-left: 24px; padding-left: 24px;
&.wide { &.wide {
max-width: 1200px; max-width: 1200px;
...@@ -37,9 +39,9 @@ ...@@ -37,9 +39,9 @@
.logo { .logo {
width: 165px; width: 165px;
height: 64px; height: @layout-header-height;
position: relative; position: relative;
line-height: 64px; line-height: @layout-header-height;
transition: all 0.3s; transition: all 0.3s;
overflow: hidden; overflow: hidden;
img { img {
...@@ -62,3 +64,9 @@ ...@@ -62,3 +64,9 @@
color: #002140; color: #002140;
} }
} }
.menu {
border: none;
height: @layout-header-height;
line-height: @layout-header-height;
}
...@@ -18,6 +18,8 @@ import Exception403 from '../pages/Exception/403'; ...@@ -18,6 +18,8 @@ import Exception403 from '../pages/Exception/403';
import PageLoading from '@/components/PageLoading'; import PageLoading from '@/components/PageLoading';
import SiderMenu from '@/components/SiderMenu'; import SiderMenu from '@/components/SiderMenu';
import styles from './BasicLayout.less';
// lazy load SettingDrawer // lazy load SettingDrawer
const SettingDrawer = React.lazy(() => import('@/components/SettingDrawer')); const SettingDrawer = React.lazy(() => import('@/components/SettingDrawer'));
...@@ -138,14 +140,6 @@ class BasicLayout extends React.PureComponent { ...@@ -138,14 +140,6 @@ class BasicLayout extends React.PureComponent {
return null; return null;
}; };
getContentStyle = () => {
const { fixedHeader } = this.props;
return {
margin: '24px 24px 0',
paddingTop: fixedHeader ? 64 : 0,
};
};
handleMenuCollapse = collapsed => { handleMenuCollapse = collapsed => {
const { dispatch } = this.props; const { dispatch } = this.props;
dispatch({ dispatch({
...@@ -172,10 +166,12 @@ class BasicLayout extends React.PureComponent { ...@@ -172,10 +166,12 @@ class BasicLayout extends React.PureComponent {
isMobile, isMobile,
menuData, menuData,
breadcrumbNameMap, breadcrumbNameMap,
fixedHeader,
} = this.props; } = this.props;
const isTop = PropsLayout === 'topmenu'; const isTop = PropsLayout === 'topmenu';
const routerConfig = this.matchParamsPath(pathname, breadcrumbNameMap); const routerConfig = this.matchParamsPath(pathname, breadcrumbNameMap);
const contentStyle = !fixedHeader ? { paddingTop: 0 } : {};
const layout = ( const layout = (
<Layout> <Layout>
{isTop && !isMobile ? null : ( {isTop && !isMobile ? null : (
...@@ -201,7 +197,7 @@ class BasicLayout extends React.PureComponent { ...@@ -201,7 +197,7 @@ class BasicLayout extends React.PureComponent {
isMobile={isMobile} isMobile={isMobile}
{...this.props} {...this.props}
/> />
<Content style={this.getContentStyle()}> <Content className={styles.content} style={contentStyle}>
<Authorized <Authorized
authority={routerConfig && routerConfig.authority} authority={routerConfig && routerConfig.authority}
noMatch={<Exception403 />} noMatch={<Exception403 />}
......
@import '~antd/lib/style/themes/default.less';
.content {
margin: 24px;
padding-top: @layout-header-height;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment