Commit b2f35b9c authored by liangliangyin's avatar liangliangyin

fix: collapsed sidermenu paddingLeft

parent 1b05b728
{ {
"name": "@ant-design-vue/pro-layout", "name": "@ant-design-vue/pro-layout",
"version": "0.2.7", "version": "0.2.8",
"main": "./lib/index.js", "main": "./lib/index.js",
"module": "./es/index.js", "module": "./es/index.js",
"repository": { "repository": {
......
...@@ -63,6 +63,17 @@ const MediaQueryEnum = { ...@@ -63,6 +63,17 @@ const MediaQueryEnum = {
} }
} }
const getPaddingLeft = (
hasLeftPadding,
collapsed = undefined,
siderWidth
) => {
if (hasLeftPadding) {
return collapsed ? 80 : siderWidth
}
return undefined
}
const headerRender = (h, props) => { const headerRender = (h, props) => {
if (props.headerRender === false) { if (props.headerRender === false) {
return null return null
...@@ -97,10 +108,14 @@ const BasicLayout = { ...@@ -97,10 +108,14 @@ const BasicLayout = {
const collapsedButtonRender = getComponentFromProp(content, 'collapsedButtonRender') const collapsedButtonRender = getComponentFromProp(content, 'collapsedButtonRender')
const menuHeaderRender = getComponentFromProp(content, 'menuHeaderRender') const menuHeaderRender = getComponentFromProp(content, 'menuHeaderRender')
const isTopMenu = layout === 'topmenu' const isTopMenu = layout === 'topmenu'
const hasSiderMenu = !isTopMenu
// If it is a fix menu, calculate padding
// don't need padding in phone mode
const hasLeftPadding = fixSiderbar && !isTopMenu && !isMobile
const cdProps = { const cdProps = {
...props, ...props,
hasSiderMenu: !isTopMenu, hasSiderMenu,
footerRender, footerRender,
menuHeaderRender, menuHeaderRender,
rightContentRender, rightContentRender,
...@@ -121,7 +136,9 @@ const BasicLayout = { ...@@ -121,7 +136,9 @@ const BasicLayout = {
onCollapse={handleCollapse} onCollapse={handleCollapse}
/> />
<Layout class={[layout]} style={{ <Layout class={[layout]} style={{
paddingLeft: fixSiderbar ? `${siderWidth}px` : '0', paddingLeft: hasSiderMenu
? `${getPaddingLeft(!!hasLeftPadding, collapsed, siderWidth)}px`
: undefined,
minHeight: '100vh' minHeight: '100vh'
}}> }}>
{headerRender(h, { {headerRender(h, {
......
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