Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-layout
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
packages
pro-layout
Commits
8db595b2
Unverified
Commit
8db595b2
authored
Dec 04, 2019
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: mobile sider menu
parent
d900f29d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
121 additions
and
108 deletions
+121
-108
BasicLayout.jsx
examples/src/layouts/BasicLayout.jsx
+13
-2
TestPage.vue
examples/src/views/TestPage.vue
+2
-1
TestPage2.vue
examples/src/views/TestPage2.vue
+2
-1
BasicLayout.jsx
src/BasicLayout.jsx
+9
-11
Header.jsx
src/Header.jsx
+1
-2
Header.less
src/Header.less
+0
-84
index.jsx
src/components/GlobalHeader/index.jsx
+2
-3
index.less
src/components/GlobalHeader/index.less
+88
-2
SiderMenuWrapper.jsx
src/components/SiderMenu/SiderMenuWrapper.jsx
+4
-2
No files found.
examples/src/layouts/BasicLayout.jsx
View file @
8db595b2
...
@@ -68,11 +68,13 @@ export default {
...
@@ -68,11 +68,13 @@ export default {
// 媒体查询
// 媒体查询
query
:
{},
query
:
{},
// 布局类型
// 布局类型
layout
:
'
side
menu'
,
// 'sidemenu', 'topmenu'
layout
:
'
top
menu'
,
// 'sidemenu', 'topmenu'
// 定宽: true / 流式: false
// 定宽: true / 流式: false
contentWidth
:
true
,
contentWidth
:
true
,
// 主题 'dark' | 'light'
// 主题 'dark' | 'light'
theme
:
'dark'
theme
:
'light'
,
// 是否手机模式
isMobile
:
false
}
}
},
},
render
(
h
)
{
render
(
h
)
{
...
@@ -86,6 +88,14 @@ export default {
...
@@ -86,6 +88,14 @@ export default {
const
handleMediaQuery
=
(
val
)
=>
{
const
handleMediaQuery
=
(
val
)
=>
{
this
.
query
=
val
this
.
query
=
val
if
(
this
.
isMobile
&&
!
val
[
'screen-xs'
])
{
this
.
isMobile
=
false
return
}
if
(
!
this
.
isMobile
&&
val
[
'screen-xs'
])
{
this
.
isMobile
=
true
this
.
collapsed
=
false
}
}
}
const
handleCollapse
=
(
val
)
=>
{
const
handleCollapse
=
(
val
)
=>
{
this
.
collapsed
=
val
this
.
collapsed
=
val
...
@@ -103,6 +113,7 @@ export default {
...
@@ -103,6 +113,7 @@ export default {
layout
,
layout
,
contentWidth
,
contentWidth
,
theme
,
theme
,
isMobile
:
this
.
isMobile
,
rightContentRender
,
rightContentRender
,
footerRender
,
footerRender
,
i18nRender
,
i18nRender
,
...
...
examples/src/views/TestPage.vue
View file @
8db595b2
...
@@ -45,7 +45,8 @@ export default {
...
@@ -45,7 +45,8 @@ export default {
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
.page-test-wrapper {
.page-test-wrapper {
width: 400px;
width: 100%;
max-width: 400px;
margin: 0 auto;
margin: 0 auto;
}
}
</
style
>
</
style
>
examples/src/views/TestPage2.vue
View file @
8db595b2
...
@@ -31,7 +31,8 @@ export default {
...
@@ -31,7 +31,8 @@ export default {
<
style
lang=
"less"
scoped
>
<
style
lang=
"less"
scoped
>
.page-test-wrapper {
.page-test-wrapper {
width: 400px;
width: 100%;
max-width: 400px;
margin: 0 auto;
margin: 0 auto;
}
}
</
style
>
</
style
>
src/BasicLayout.jsx
View file @
8db595b2
...
@@ -97,17 +97,15 @@ const BasicLayout = {
...
@@ -97,17 +97,15 @@ const BasicLayout = {
<
div
>
<
div
>
<
ContainerQuery
query=
{
MediaQueryEnum
}
onChange=
{
handleMediaQuery
}
>
<
ContainerQuery
query=
{
MediaQueryEnum
}
onChange=
{
handleMediaQuery
}
>
<
Layout
class=
{
{
'basicLayout'
:
true
,
...
mediaQuery
}
}
>
<
Layout
class=
{
{
'basicLayout'
:
true
,
...
mediaQuery
}
}
>
{
layout
!==
'topmenu'
&&
(
<
SiderMenuWrapper
<
SiderMenuWrapper
{
...
{
props
:
props
}
}
{
...
{
props
:
props
}
}
menus=
{
menus
}
menus=
{
menus
}
mode=
{
'inline'
}
mode=
{
'inline'
}
logo=
{
logo
}
logo=
{
logo
}
collapsed=
{
collapsed
}
collapsed=
{
collapsed
}
onCollapse=
{
handleCollapse
}
onCollapse=
{
handleCollapse
}
handleCollapse=
{
handleCollapse
}
handleCollapse=
{
handleCollapse
}
/>
/>
)
}
<
Layout
class=
{
[
layout
]
}
style=
{
{
paddingLeft
:
'0'
,
minHeight
:
'100vh'
}
}
>
<
Layout
class=
{
[
layout
]
}
style=
{
{
paddingLeft
:
'0'
,
minHeight
:
'100vh'
}
}
>
{
headerRender
(
h
,
{
{
headerRender
(
h
,
{
...
props
,
...
props
,
...
...
src/Header.jsx
View file @
8db595b2
...
@@ -47,11 +47,10 @@ export const HeaderViewProps = {
...
@@ -47,11 +47,10 @@ export const HeaderViewProps = {
const
renderContent
=
(
h
,
props
)
=>
{
const
renderContent
=
(
h
,
props
)
=>
{
const
isTop
=
props
.
layout
===
'topmenu'
const
isTop
=
props
.
layout
===
'topmenu'
const
isMobile
=
false
const
maxWidth
=
1200
-
280
-
120
const
maxWidth
=
1200
-
280
-
120
const
contentWidth
=
props
.
contentWidth
const
contentWidth
=
props
.
contentWidth
const
baseCls
=
'ant-pro-top-nav-header'
const
baseCls
=
'ant-pro-top-nav-header'
const
{
logo
,
title
,
theme
,
headerRender
,
rightContentRender
}
=
props
const
{
logo
,
title
,
theme
,
isMobile
,
headerRender
,
rightContentRender
}
=
props
const
rightContentProps
=
{
theme
}
const
rightContentProps
=
{
theme
}
let
defaultDom
=
<
GlobalHeader
{
...
{
props
:
props
}}
/>
let
defaultDom
=
<
GlobalHeader
{
...
{
props
:
props
}}
/>
if
(
isTop
&&
!
isMobile
)
{
if
(
isTop
&&
!
isMobile
)
{
...
...
src/Header.less
View file @
8db595b2
@import "~ant-design-vue/es/style/themes/default";
@import "~ant-design-vue/es/style/themes/default";
@global-header-prefix-cls: ~'@{ant-prefix}-pro-global-header';
@top-nav-header-prefix-cls: ~'@{ant-prefix}-pro-top-nav-header';
@top-nav-header-prefix-cls: ~'@{ant-prefix}-pro-top-nav-header';
@pro-header-bg: @component-background;
@pro-header-hover-bg: @component-background;
@pro-header-box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
.@{top-nav-header-prefix-cls} {
.@{top-nav-header-prefix-cls} {
position: relative;
position: relative;
width: 100%;
width: 100%;
...
@@ -77,85 +72,6 @@
...
@@ -77,85 +72,6 @@
}
}
}
}
.@{global-header-prefix-cls} {
position: relative;
height: @layout-header-height;
padding: 0;
background: @pro-header-bg;
box-shadow: @pro-header-box-shadow;
&-index-right {
float: right;
height: 100%;
margin-left: auto;
overflow: hidden;
.@{global-header-prefix-cls}-index-action {
display: inline-block;
height: 100%;
padding: 0 12px;
cursor: pointer;
transition: all .3s;
&:hover {
background: rgba(0,0,0,.025);
}
}
}
&-logo {
display: inline-block;
height: @layout-header-height;
padding: 0 0 0 24px;
font-size: 20px;
line-height: @layout-header-height;
vertical-align: top;
cursor: pointer;
img {
display: inline-block;
width: 32px;
vertical-align: middle;
}
}
&-menu {
.anticon {
margin-right: 8px;
}
.ant-dropdown-menu-item {
min-width: 160px;
}
}
&-trigger {
height: @layout-header-height;
padding: ~'calc((@{layout-header-height} - 26px) / 2)' 24px;
font-size: 20px;
cursor: pointer;
transition: all 0.3s, padding 0s;
&:hover {
background: @pro-header-hover-bg;
}
}
.dark {
height: @layout-header-height;
.action {
color: rgba(255, 255, 255, 0.85);
> i {
color: rgba(255, 255, 255, 0.85);
}
&:hover,
&.opened {
background: @primary-color;
}
.ant-badge {
color: rgba(255, 255, 255, 0.85);
}
}
}
}
.drop-down {
.drop-down {
&.menu {
&.menu {
.anticon {
.anticon {
...
...
src/components/GlobalHeader/index.jsx
View file @
8db595b2
/* eslint-disable */
import
'./index.less'
import
'./index.less'
import
debounce
from
'lodash/debounce'
import
debounce
from
'lodash/debounce'
...
@@ -74,7 +73,7 @@ const GlobalHeader = {
...
@@ -74,7 +73,7 @@ const GlobalHeader = {
return
(
return
(
<
div
class=
{
headerCls
}
>
<
div
class=
{
headerCls
}
>
{
isMobile
&&
(
{
isMobile
&&
(
<
a
class=
{
`${headerCls}-logo`
}
key=
"logo"
>
<
a
class=
{
`${headerCls}-logo`
}
key=
"logo"
href=
{
'/'
}
>
{
defaultRenderLogo
(
h
,
logo
)
}
{
defaultRenderLogo
(
h
,
logo
)
}
</
a
>
</
a
>
)
}
)
}
...
@@ -89,7 +88,7 @@ const GlobalHeader = {
...
@@ -89,7 +88,7 @@ const GlobalHeader = {
})
})
},
},
beforeDestroy
()
{
beforeDestroy
()
{
this
.
triggerResizeEvent
.
cancel
()
this
.
triggerResizeEvent
.
cancel
&&
this
.
triggerResizeEvent
.
cancel
()
}
}
}
}
...
...
src/components/GlobalHeader/index.less
View file @
8db595b2
@import "~ant-design-vue/es/style/themes/default";
@global-header-prefix-cls: ~'@{ant-prefix}-pro-global-header';
@pro-header-bg: @component-background;
@pro-header-hover-bg: @component-background;
@pro-header-box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
@pro-header-hover-trigger-action-bg: rgba(0,0,0,.025);
.@{global-header-prefix-cls} {
position: relative;
height: @layout-header-height;
padding: 0;
background: @pro-header-bg;
box-shadow: @pro-header-box-shadow;
&-index-right {
float: right;
height: 100%;
margin-left: auto;
overflow: hidden;
.@{global-header-prefix-cls}-index-action {
display: inline-block;
height: 100%;
padding: 0 12px;
cursor: pointer;
transition: all .3s;
&:hover {
background: @pro-header-hover-trigger-action-bg;
}
}
}
&-logo {
display: inline-block;
height: @layout-header-height;
padding: 0 0 0 24px;
font-size: 20px;
line-height: @layout-header-height;
vertical-align: top;
cursor: pointer;
img, svg {
display: inline-block;
width: 32px;
height: 32px;
vertical-align: middle;
}
}
&-menu {
.anticon {
margin-right: 8px;
}
.ant-dropdown-menu-item {
min-width: 160px;
}
}
&-trigger {
height: @layout-header-height;
padding: ~'calc((@{layout-header-height} - 26px) / 2)' 24px;
font-size: 20px;
cursor: pointer;
transition: all 0.3s, padding 0s;
&:hover {
background: @pro-header-hover-trigger-action-bg;
}
}
.dark {
height: @layout-header-height;
.action {
color: rgba(255, 255, 255, 0.85);
> i {
color: rgba(255, 255, 255, 0.85);
}
&:hover,
&.opened {
background: @primary-color;
}
.ant-badge {
color: rgba(255, 255, 255, 0.85);
}
}
}
.ant-pro-global-header {
.ant-pro-global-header-index-action {
.ant-pro-global-header-index-action {
i {
i {
color: rgba(0,0,0,.65);
color: rgba(0,0,0,.65);
vertical-align: middle;
vertical-align: middle;
}
}
}
}
}
}
src/components/SiderMenu/SiderMenuWrapper.jsx
View file @
8db595b2
...
@@ -10,10 +10,12 @@ const SiderMenuWrapper = {
...
@@ -10,10 +10,12 @@ const SiderMenuWrapper = {
props
:
SiderMenuProps
,
props
:
SiderMenuProps
,
render
()
{
render
()
{
const
{
const
{
layout
,
isMobile
,
isMobile
,
collapsed
,
collapsed
,
handleCollapse
:
onCollapse
handleCollapse
:
onCollapse
}
=
this
}
=
this
const
isTopMenu
=
layout
===
'topmenu'
return
isMobile
?
(
return
isMobile
?
(
<
Drawer
<
Drawer
class=
"ant-pro-sider-menu"
class=
"ant-pro-sider-menu"
...
@@ -26,9 +28,9 @@ const SiderMenuWrapper = {
...
@@ -26,9 +28,9 @@ const SiderMenuWrapper = {
height
:
'100vh'
height
:
'100vh'
}
}
}
}
>
>
<
SiderMenu
{
...
{
props
:
this
.
$props
}}
collapsed=
{
isMobile
?
false
:
collapsed
}
/>
<
SiderMenu
{
...
{
props
:
{
...
this
.
$props
,
collapsed
:
isMobile
?
false
:
collapsed
}
}
}
/>
</
Drawer
>
</
Drawer
>
)
:
(
)
:
!
isTopMenu
&&
(
<
SiderMenu
class=
"ant-pro-sider-menu"
{
...
{
props
:
this
.
$props
}}
/>
<
SiderMenu
class=
"ant-pro-sider-menu"
{
...
{
props
:
this
.
$props
}}
/>
)
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment