Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
兵
兵役_吉林工业
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
麦嘉得
兵役_吉林工业
提交
c3ee0047
提交
c3ee0047
编写于
5月 02, 2018
作者:
Pan
提交者:
花裤衩
5月 02, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat[sidebar]: add resonsive sidebar
上级
b97702d6
变更
5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
113 行增加
和
14 行删除
+113
-14
getters.js
src/store/getters.js
+1
-0
app.js
src/store/modules/app.js
+18
-2
sidebar.scss
src/styles/sidebar.scss
+32
-3
Layout.vue
src/views/layout/Layout.vue
+21
-9
ResizeHandler.js
src/views/layout/mixin/ResizeHandler.js
+41
-0
未找到文件。
src/store/getters.js
浏览文件 @
c3ee0047
const
getters
=
{
sidebar
:
state
=>
state
.
app
.
sidebar
,
device
:
state
=>
state
.
app
.
device
,
token
:
state
=>
state
.
user
.
token
,
avatar
:
state
=>
state
.
user
.
avatar
,
name
:
state
=>
state
.
user
.
name
,
...
...
src/store/modules/app.js
浏览文件 @
c3ee0047
...
...
@@ -3,8 +3,10 @@ import Cookies from 'js-cookie'
const
app
=
{
state
:
{
sidebar
:
{
opened
:
!+
Cookies
.
get
(
'
sidebarStatus
'
)
}
opened
:
!+
Cookies
.
get
(
'
sidebarStatus
'
),
withoutAnimation
:
false
},
device
:
'
desktop
'
},
mutations
:
{
TOGGLE_SIDEBAR
:
state
=>
{
...
...
@@ -14,11 +16,25 @@ const app = {
Cookies
.
set
(
'
sidebarStatus
'
,
0
)
}
state
.
sidebar
.
opened
=
!
state
.
sidebar
.
opened
},
CLOSE_SIDEBAR
:
(
state
,
withoutAnimation
)
=>
{
Cookies
.
set
(
'
sidebarStatus
'
,
1
)
state
.
sidebar
.
opened
=
false
state
.
sidebar
.
withoutAnimation
=
withoutAnimation
},
TOGGLE_DEVICE
:
(
state
,
device
)
=>
{
state
.
device
=
device
}
},
actions
:
{
ToggleSideBar
:
({
commit
})
=>
{
commit
(
'
TOGGLE_SIDEBAR
'
)
},
CloseSideBar
({
commit
},
{
withoutAnimation
})
{
commit
(
'
CLOSE_SIDEBAR
'
,
withoutAnimation
)
},
ToggleDevice
({
commit
},
device
)
{
commit
(
'
TOGGLE_DEVICE
'
,
device
)
}
}
}
...
...
src/styles/sidebar.scss
浏览文件 @
c3ee0047
#app
{
// 主体区域
.main-container
{
min-height
:
100%
;
transition
:
margin-left
.28s
;
margin-left
:
180px
;
}
// 侧边栏
// 侧边栏
.sidebar-container
{
.horizontal-collapse-transition
{
transition
:
0s
width
ease-in-out
,
0s
padding-left
ease-in-out
,
0s
padding-right
ease-in-out
;
...
...
@@ -32,6 +34,7 @@
width
:
100%
!
important
;
}
}
.hideSidebar
{
.sidebar-container
{
width
:
36px
!
important
;
...
...
@@ -62,8 +65,9 @@
}
}
}
.nest-menu
.el-submenu
>
.el-submenu__title
,
.el-submenu
.el-menu-item
{
.sidebar-container
.nest-menu
.el-submenu
>
.el-submenu__title
,
.sidebar-container
.el-submenu
.el-menu-item
{
min-width
:
180px
!
important
;
background-color
:
$subMenuBg
!
important
;
&
:hover
{
...
...
@@ -73,4 +77,29 @@
.el-menu--collapse
.el-menu
.el-submenu
{
min-width
:
180px
!
important
;
}
//适配移动端
.mobile
{
.main-container
{
margin-left
:
0px
;
}
.sidebar-container
{
top
:
50px
;
transition
:
transform
.28s
;
width
:
180px
!
important
;
}
&
.hideSidebar
{
.sidebar-container
{
transition-duration
:
0
.3s
;
transform
:
translate3d
(
-180px
,
0
,
0
);
}
}
}
.withoutAnimation
{
.main-container
,
.sidebar-container
{
transition
:
none
;
}
}
}
src/views/layout/Layout.vue
浏览文件 @
c3ee0047
<
template
>
<div
class=
"app-wrapper"
:class=
"
{hideSidebar:!sidebar.opened}
">
<div
class=
"app-wrapper"
:class=
"
classObj
"
>
<sidebar
class=
"sidebar-container"
></sidebar>
<div
class=
"main-container"
>
<navbar></navbar>
...
...
@@ -9,7 +9,8 @@
</
template
>
<
script
>
import
{
Navbar
,
Sidebar
,
AppMain
}
from
'
@/views/layout/components
'
import
{
Navbar
,
Sidebar
,
AppMain
}
from
'
./components
'
import
ResizeMixin
from
'
./mixin/ResizeHandler
'
export
default
{
name
:
'
layout
'
,
...
...
@@ -18,20 +19,31 @@ export default {
Sidebar
,
AppMain
},
mixins
:
[
ResizeMixin
],
computed
:
{
sidebar
()
{
return
this
.
$store
.
state
.
app
.
sidebar
},
device
()
{
return
this
.
$store
.
state
.
app
.
device
},
classObj
()
{
return
{
hideSidebar
:
!
this
.
sidebar
.
opened
,
withoutAnimation
:
this
.
sidebar
.
withoutAnimation
,
mobile
:
this
.
device
===
'
mobile
'
}
}
}
}
</
script
>
<
style
rel=
"stylesheet/scss"
lang=
"scss"
scoped
>
@import
"src/styles/mixin.scss"
;
.app-wrapper
{
@include
clearfix
;
position
:
relative
;
height
:
100%
;
width
:
100%
;
}
@import
"src/styles/mixin.scss"
;
.app-wrapper
{
@include
clearfix
;
position
:
relative
;
height
:
100%
;
width
:
100%
;
}
</
style
>
src/views/layout/mixin/ResizeHandler.js
0 → 100644
浏览文件 @
c3ee0047
import
store
from
'
@/store
'
const
{
body
}
=
document
const
WIDTH
=
1024
const
RATIO
=
3
export
default
{
watch
:
{
$route
(
route
)
{
if
(
this
.
device
===
'
mobile
'
&&
this
.
sidebar
.
opened
)
{
store
.
dispatch
(
'
CloseSideBar
'
,
{
withoutAnimation
:
false
})
}
}
},
beforeMount
()
{
window
.
addEventListener
(
'
resize
'
,
this
.
resizeHandler
)
},
mounted
()
{
const
isMobile
=
this
.
isMobile
()
if
(
isMobile
)
{
store
.
dispatch
(
'
ToggleDevice
'
,
'
mobile
'
)
store
.
dispatch
(
'
CloseSideBar
'
,
{
withoutAnimation
:
true
})
}
},
methods
:
{
isMobile
()
{
const
rect
=
body
.
getBoundingClientRect
()
return
rect
.
width
-
RATIO
<
WIDTH
},
resizeHandler
()
{
if
(
!
document
.
hidden
)
{
const
isMobile
=
this
.
isMobile
()
store
.
dispatch
(
'
ToggleDevice
'
,
isMobile
?
'
mobile
'
:
'
desktop
'
)
if
(
isMobile
)
{
store
.
dispatch
(
'
CloseSideBar
'
,
{
withoutAnimation
:
true
})
}
}
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录