Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ant-design-pro-vue
Overview
Overview
Details
Activity
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
tianzhuanghu
ant-design-pro-vue
Commits
268afeef
Commit
268afeef
authored
Sep 08, 2018
by
Sendya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed sider auto close
parent
c7a3d904
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
11 deletions
+35
-11
App.vue
src/App.vue
+15
-5
LayoutMain.vue
src/components/layout/LayoutMain.vue
+7
-2
device.js
src/utils/device.js
+13
-4
No files found.
src/App.vue
View file @
268afeef
...
...
@@ -17,11 +17,21 @@
},
created
()
{
let
that
=
this
enquireScreen
(
isMobile
=>
{
if
(
isMobile
)
{
that
.
$store
.
commit
(
'app/TOGGLE_DEVICE'
,
true
)
}
else
{
that
.
$store
.
commit
(
'app/TOGGLE_SIDEBAR'
,
true
)
enquireScreen
(
deviceType
=>
{
console
.
log
(
'deviceType'
,
deviceType
)
// tablet
if
(
deviceType
===
0
)
{
that
.
$store
.
commit
(
'TOGGLE_DEVICE'
,
'tablet'
)
that
.
$store
.
commit
(
'CLOSE_SIDEBAR'
,
false
)
}
// mobile
else
if
(
deviceType
===
1
)
{
that
.
$store
.
commit
(
'TOGGLE_DEVICE'
,
'mobile'
)
that
.
$store
.
commit
(
'CLOSE_SIDEBAR'
,
false
)
}
else
{
that
.
$store
.
commit
(
'TOGGLE_DEVICE'
,
'desktop'
)
that
.
$store
.
commit
(
'TOGGLE_SIDEBAR'
,
true
)
}
})
...
...
src/components/layout/LayoutMain.vue
View file @
268afeef
<
template
>
<a-layout
class=
"layout"
>
<sider-menu
:menus=
"menus"
theme=
"light"
:collapsed=
"collapsed"
:collapsible=
"true"
></sider-menu>
<sider-menu
:menus=
"menus"
theme=
"light"
:collapsed=
"
!siderOpen ||
collapsed"
:collapsible=
"true"
></sider-menu>
<a-layout>
<!-- layout header -->
...
...
@@ -24,6 +24,7 @@
import
LayoutHeader
from
'./LayoutHeader'
import
LayoutFooter
from
'./LayoutFooter'
import
{
asyncRouterMap
}
from
'@/router/index'
import
{
mapState
}
from
'vuex'
export
default
{
name
:
"LayoutView"
,
...
...
@@ -41,11 +42,15 @@
created
()
{
this
.
menus
=
asyncRouterMap
},
computed
:
{
...
mapState
({
siderOpen
:
state
=>
state
.
app
.
sidebar
.
opened
})
},
methods
:
{
toggle
()
{
this
.
collapsed
=
!
this
.
collapsed
;
},
}
}
</
script
>
...
...
src/utils/device.js
View file @
268afeef
import
enquireJs
from
'enquire.js'
const
enquireScreen
=
function
(
call
)
{
const
hanlder
=
{
// tablet
const
handler
=
{
match
:
function
()
{
call
&&
call
(
true
)
call
&&
call
(
0
)
},
unmatch
:
function
()
{
call
&&
call
(
false
)
call
&&
call
(
-
1
)
}
}
enquireJs
.
register
(
'only screen and (max-width: 767.99px)'
,
hanlder
)
// mobile
const
handler2
=
{
match
:
()
=>
{
call
&&
call
(
1
)
}
}
enquireJs
.
register
(
'screen and (max-width: 980.99px)'
,
handler
)
enquireJs
.
register
(
'screen and (max-width: 767.99px)'
,
handler2
)
}
export
default
enquireScreen
\ No newline at end of file
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