Skip to content

Commit

Permalink
feat(admin): add flat mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Aysnine committed Feb 11, 2020
1 parent a7a4aac commit 7f83464
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/locales/main/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"admin.roll-tools-api.qrcode.placeholder.content": "Please input content",
"admin.roll-tools-api.qrcode.generate": "Generate",
"admin.roll-tools-api.qrcode.logo_type_limit": "Logo file type must be {0}",
"admin.roll-tools-api.qrcode.logo_size_limit": "Logo file size cannot exceed {0}"
"admin.roll-tools-api.qrcode.logo_size_limit": "Logo file size cannot exceed {0}",
"admin.preferences.flat": "Flat mode"
}
3 changes: 2 additions & 1 deletion src/locales/main/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
"admin.roll-tools-api.qrcode.placeholder.content": "请输入内容",
"admin.roll-tools-api.qrcode.generate": "立即生成",
"admin.roll-tools-api.qrcode.logo_type_limit": "Logo 图片只能是 {0} 格式",
"admin.roll-tools-api.qrcode.logo_size_limit": "Logo 文件大小不能超过 {0}"
"admin.roll-tools-api.qrcode.logo_size_limit": "Logo 文件大小不能超过 {0}",
"admin.preferences.flat": "小屏模式"
}
1 change: 1 addition & 0 deletions src/store/modules/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const init = app => {
asideTransition: true,
pageTransition: true,
showSourceLink: true,
flat: false,

token: null
})
Expand Down
6 changes: 6 additions & 0 deletions src/store/modules/admin/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,9 @@ export const token = {
...mapFields(namespace, ['token'])
}
}

export const flat = {
computed: {
...mapFields(namespace, ['flat'])
}
}
5 changes: 5 additions & 0 deletions src/views/admin/$index/components/AsideNavMenu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export default {
router: true,
'default-active': this.$route.path,
collapse: this.collapse
},
on: {
select: (index, deepIndex, targetComponent) => {
this.$emit('select', index, deepIndex, targetComponent)
}
}
},
map(this.menu, it)
Expand Down
11 changes: 11 additions & 0 deletions src/views/admin/$index/components/PageContainer/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@
border-top none
border-top-left-radius 0
border-top-right-radius 0

// for flat mode
&.flat
border-radius 0
border-right 0
border-left 0
>
.header, .footer
border-radius 0
border-right 0
border-left 0
29 changes: 25 additions & 4 deletions src/views/admin/$index/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<el-container class="admin-container">
<el-container
class="admin-container"
:class="{ collapse: asideCollapse, tabs: showTabs, flat }"
>
<el-header class="header">
<smart-logo :has-transition="asideTransition" :collapse="asideCollapse" />
<aside-nav-menu-toggle v-model="asideCollapse" />
Expand Down Expand Up @@ -35,6 +38,7 @@
:has-transition="asideTransition"
:menu="menu"
:collapse="asideCollapse"
@select="handleAsideMenuItemSelected"
/>
</div>
</el-aside>
Expand All @@ -52,7 +56,7 @@
<keep-alive>
<router-view
class="page-wrapper"
:class="{ 'sharp-top': showTabs }"
:class="{ 'sharp-top': showTabs, flat }"
/>
</keep-alive>
</transition>
Expand All @@ -75,7 +79,8 @@ import {
asideTransition,
menu,
sourceLink,
token
token,
flat
} from '@/store/modules/admin/mixins'
import { loginPath } from '@/routes/admin'
Expand All @@ -88,7 +93,8 @@ export default {
menu,
sourceLink,
asideBscroll,
token
token,
flat
],
provide: {
'@adminContainer'(v) {
Expand All @@ -98,6 +104,16 @@ export default {
assign(v.$options.components, internalComponents)
}
},
watch: {
flat(value) {
if (value) {
this.asideCollapse = true
this.asideTransition = false
this.pageTransition = false
this.showTabs = false
}
}
},
methods: {
handleSwitchTabs({ index }) {
this.$router.push(index)
Expand All @@ -107,6 +123,11 @@ export default {
this.token = null
this.$router.push(loginPath)
}
},
handleAsideMenuItemSelected(...args) {
if (this.flat) {
this.asideCollapse = true
}
}
},
components: internalComponents
Expand Down
26 changes: 26 additions & 0 deletions src/views/admin/$index/style.styl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '../../../style/variable.styl'

$aside-width = 200px
$aside-collapse-width = 65px
$header-height = 60px
$right-margin = 20px

Expand All @@ -19,6 +20,7 @@ $right-margin = 20px
> .action-bar
flex 1
.body
position relative
overflow hidden
>
.aside
Expand All @@ -38,6 +40,30 @@ $right-margin = 20px
left 0
right $right-margin
overflow-x hidden
&.flat >
.body >
.aside
position absolute
z-index 2000
top 0
bottom 0
background #ecf1f6
border-right 1px solid #cfd7e5
border-top 1px solid #cfd7e5
border-top-right-radius 4px
.center-wrapper >
.tabs-wrapper
margin-right 0
.main > .page-wrapper
right 0
&.flat.collapse >
.body >
.aside
margin-left - $aside-collapse-width
&.flat:not(.tabs)
.body >
.aside
border-top-right-radius 0

.fade-transverse
&-leave-active
Expand Down
13 changes: 11 additions & 2 deletions src/views/admin/preferences/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

<el-divider />

<p>
<b>{{ $t('admin.preferences.flat') }}:</b
><el-switch v-model="flat"></el-switch>
</p>

<el-divider />

<h2>{{ $t('admin.preferences.language') }}</h2>
<el-radio-group v-model="$i18n.locale">
<el-radio v-for="item in langs" :key="item.value" :label="item.value">{{
Expand All @@ -43,7 +50,8 @@ import {
sourceLink,
asideCollapse,
pageTransition,
asideTransition
asideTransition,
flat
} from '@/store/modules/admin/mixins'
import { langs } from '@/locales'
Expand All @@ -54,7 +62,8 @@ export default {
sourceLink,
asideCollapse,
pageTransition,
asideTransition
asideTransition,
flat
],
data() {
Expand Down

0 comments on commit 7f83464

Please sign in to comment.