diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index 156f1b7d07dc41a094c24220d0d067c0e05c52da..fe96cdea6d003485c78bd404cee957f7d0a345b1 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -31,11 +31,9 @@ export default class GlobalHeader extends PureComponent { logo )} - + + + ); diff --git a/src/components/GlobalHeader/index.less b/src/components/GlobalHeader/index.less index 10758fe9cd156b14b14f78d6ed2d9bac5937fcc3..db11b7830e7ee98a4ce333f76739b51592ff464a 100644 --- a/src/components/GlobalHeader/index.less +++ b/src/components/GlobalHeader/index.less @@ -3,7 +3,7 @@ @pro-header-hover-bg: rgba(0, 0, 0, 0.025); .header { - height: 64px; + height: @layout-header-height; padding: 0; background: #fff; box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); @@ -11,8 +11,8 @@ } .logo { - height: 64px; - line-height: 58px; + height: @layout-header-height; + line-height: @layout-header-height; vertical-align: top; display: inline-block; padding: 0 0 0 24px; @@ -33,12 +33,12 @@ } } -i.trigger { +.trigger { font-size: 20px; - height: 64px; + height: @layout-header-height; cursor: pointer; transition: all 0.3s, padding 0s; - padding: 22px 24px; + padding: ~'calc((@{layout-header-height} - 20px) / 2)' 24px; &:hover { background: @pro-header-hover-bg; } @@ -73,7 +73,8 @@ i.trigger { } .account { .avatar { - margin: 20px 8px 20px 0; + margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0; + margin-right: 8px; color: @primary-color; background: rgba(255, 255, 255, 0.85); vertical-align: top; @@ -82,7 +83,7 @@ i.trigger { } .dark { - height: 64px; + height: @layout-header-height; .action { color: rgba(255, 255, 255, 0.85); > i { diff --git a/src/components/SelectLang/index.js b/src/components/SelectLang/index.js index ee91cd64d09e613af36e955aa45a88820324b52e..ab006bf9a498b2d7c0ea8b0b458e57fb1b99014f 100644 --- a/src/components/SelectLang/index.js +++ b/src/components/SelectLang/index.js @@ -42,11 +42,9 @@ export default class SelectLang extends PureComponent { ); return ( - + + + ); } diff --git a/src/components/SelectLang/index.less b/src/components/SelectLang/index.less index 819c0f8c282d87302c09b02bcfa5c4e9c3e95c52..e7f12ab3c72aea38ef2c27cf486a1045ff110770 100644 --- a/src/components/SelectLang/index.less +++ b/src/components/SelectLang/index.less @@ -11,11 +11,14 @@ .dropDown { cursor: pointer; - font-size: 14px; vertical-align: top; - line-height: 64px; - > svg { - position: relative; - top: 2px; + line-height: @layout-header-height; + > i { + font-size: 14px !important; + transform: none !important; + svg { + position: relative; + top: -1px; + } } } diff --git a/src/components/SiderMenu/BaseMenu.js b/src/components/SiderMenu/BaseMenu.js index e819cda3f043184ab3b220e2b04758d16700dec8..83e8837e1ddf04165cd75ae9125104620a869dad 100644 --- a/src/components/SiderMenu/BaseMenu.js +++ b/src/components/SiderMenu/BaseMenu.js @@ -1,4 +1,5 @@ import React, { PureComponent } from 'react'; +import classNames from 'classnames'; import { Menu, Icon } from 'antd'; import Link from 'umi/link'; import isEqual from 'lodash/isEqual'; @@ -130,6 +131,7 @@ export default class BaseMenu extends PureComponent { theme, mode, location: { pathname }, + className, } = this.props; // if pathname can't match, use the nearest parent's key let selectedKeys = this.getSelectedMenuKeys(pathname); @@ -143,6 +145,10 @@ export default class BaseMenu extends PureComponent { }; } const { handleOpenChange, style, menuData } = this.props; + const cls = classNames(className, { + 'top-nav-menu': mode === 'horizontal', + }); + return ( {this.getNavMenuItems(menuData)} diff --git a/src/components/SiderMenu/index.less b/src/components/SiderMenu/index.less index 7ffba1b1f6479cf29f6f2b4c9312c2a0950c4109..b098bd2cabea937bee997004083c3de17cd164b2 100644 --- a/src/components/SiderMenu/index.less +++ b/src/components/SiderMenu/index.less @@ -1,6 +1,6 @@ @import '~antd/lib/style/themes/default.less'; -@nav-header-height: 64px; +@nav-header-height: @layout-header-height; .logo { height: @nav-header-height; diff --git a/src/components/TopNavHeader/index.js b/src/components/TopNavHeader/index.js index ee302f6625ad8a4325cb1fa5c4c852e85fec7644..eca4dbe4b993b21de576c903c4fafe1fda856a9d 100644 --- a/src/components/TopNavHeader/index.js +++ b/src/components/TopNavHeader/index.js @@ -40,11 +40,7 @@ export default class TopNavHeader extends PureComponent { maxWidth, }} > - + diff --git a/src/components/TopNavHeader/index.less b/src/components/TopNavHeader/index.less index 9883019eac2f20b1cd7ce7c35835a0ad202bec23..b299fa96a6c5bc0fef98a024ad77ddd163209f36 100644 --- a/src/components/TopNavHeader/index.less +++ b/src/components/TopNavHeader/index.less @@ -1,64 +1,72 @@ -.head { - width: 100%; - transition: background 0.3s, width 0.2s; - height: 64px; - box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); - position: relative; - :global { - .ant-menu-submenu.ant-menu-submenu-horizontal { - line-height: 64px; - height: 100%; - .ant-menu-submenu-title { - height: 100%; - } - } - } - &.light { - background-color: #fff; - } - .main { - display: flex; - height: 64px; - padding-left: 24px; - &.wide { - max-width: 1200px; - margin: auto; - padding-left: 0; - } - .left { - flex: 1; - display: flex; - } - .right { - width: 324px; - } - } -} - -.logo { - width: 165px; - height: 64px; - position: relative; - line-height: 64px; - transition: all 0.3s; - overflow: hidden; - img { - display: inline-block; - vertical-align: middle; - height: 32px; - } - h1 { - color: #fff; - display: inline-block; - vertical-align: top; - font-size: 16px; - margin: 0 0 0 12px; - font-weight: 400; - } -} - -.light { - h1 { - color: #002140; - } -} +@import '~antd/lib/style/themes/default.less'; + +.head { + width: 100%; + transition: background 0.3s, width 0.2s; + height: @layout-header-height; + box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); + position: relative; + :global { + .ant-menu-submenu.ant-menu-submenu-horizontal { + line-height: @layout-header-height; + height: 100%; + .ant-menu-submenu-title { + height: 100%; + } + } + } + &.light { + background-color: #fff; + } + .main { + display: flex; + height: @layout-header-height; + padding-left: 24px; + &.wide { + max-width: 1200px; + margin: auto; + padding-left: 0; + } + .left { + flex: 1; + display: flex; + } + .right { + width: 324px; + } + } +} + +.logo { + width: 165px; + height: @layout-header-height; + position: relative; + line-height: @layout-header-height; + transition: all 0.3s; + overflow: hidden; + img { + display: inline-block; + vertical-align: middle; + height: 32px; + } + h1 { + color: #fff; + display: inline-block; + vertical-align: top; + font-size: 16px; + margin: 0 0 0 12px; + font-weight: 400; + } +} + +.light { + h1 { + color: #002140; + } +} + +.menu { + border: none; + height: @layout-header-height; + line-height: @layout-header-height; +} diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index 3998735597a71dd6e3719b6a209969e6cc0f28cb..00e3429dec0cb0995418e092d03f5a87c5bb027d 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -18,6 +18,8 @@ import Exception403 from '../pages/Exception/403'; import PageLoading from '@/components/PageLoading'; import SiderMenu from '@/components/SiderMenu'; +import styles from './BasicLayout.less'; + // lazy load SettingDrawer const SettingDrawer = React.lazy(() => import('@/components/SettingDrawer')); @@ -138,14 +140,6 @@ class BasicLayout extends React.PureComponent { return null; }; - getContentStyle = () => { - const { fixedHeader } = this.props; - return { - margin: '24px 24px 0', - paddingTop: fixedHeader ? 64 : 0, - }; - }; - handleMenuCollapse = collapsed => { const { dispatch } = this.props; dispatch({ @@ -172,10 +166,12 @@ class BasicLayout extends React.PureComponent { isMobile, menuData, breadcrumbNameMap, + fixedHeader, } = this.props; const isTop = PropsLayout === 'topmenu'; const routerConfig = this.matchParamsPath(pathname, breadcrumbNameMap); + const contentStyle = !fixedHeader ? { paddingTop: 0 } : {}; const layout = ( {isTop && !isMobile ? null : ( @@ -201,7 +197,7 @@ class BasicLayout extends React.PureComponent { isMobile={isMobile} {...this.props} /> - + } diff --git a/src/layouts/BasicLayout.less b/src/layouts/BasicLayout.less new file mode 100644 index 0000000000000000000000000000000000000000..60beb60923741967a5e5940d2152778a57243c06 --- /dev/null +++ b/src/layouts/BasicLayout.less @@ -0,0 +1,6 @@ +@import '~antd/lib/style/themes/default.less'; + +.content { + margin: 24px; + padding-top: @layout-header-height; +}