feat: add configuration for width of page content;

新增:增加页面内容宽度配置;
This commit is contained in:
chenghongxing 2020-09-06 12:16:51 +08:00
parent 09aae4d921
commit 4a7bee7506
9 changed files with 32 additions and 22 deletions

View File

@ -1,6 +1,6 @@
<template>
<div class="page-header">
<div :class="['page-header-wide', layout]">
<div :class="['page-header', layout, pageWidth]">
<div class="page-header-wide">
<div class="breadcrumb">
<a-breadcrumb>
<a-breadcrumb-item :key="index" v-for="(item, index) in breadcrumb">
@ -50,7 +50,7 @@ export default {
},
},
computed: {
...mapState('setting', ['layout', 'showPageTitle'])
...mapState('setting', ['layout', 'showPageTitle', 'pageWidth'])
}
}
</script>

View File

@ -1,13 +1,11 @@
.page-header{
background: @base-bg-color;
padding: 16px 24px;
&.head.fixed{
margin: auto;
max-width: 1400px;
}
.page-header-wide{
&.head{
margin: auto;
max-width: 1400px;
}
&.side{
}
.breadcrumb{
margin-bottom: 20px;
}

View File

@ -33,9 +33,9 @@
<a-list :split="false">
<a-list-item>
{{$t('navigate.content.title')}}
<a-select :getPopupContainer="getPopupContainer" :dropdown-style="{zIndex: 2001}" size="small" defaultValue="1" slot="actions" style="width: 80px">
<a-select-option value="1">{{$t('navigate.content.fluid')}}</a-select-option>
<a-select-option value="2">{{$t('navigate.content.fixed')}}</a-select-option>
<a-select :getPopupContainer="getPopupContainer" :dropdown-style="{zIndex: 2001}" size="small" :defaultValue="pageWidth" @change="setPageWidth" slot="actions" style="width: 80px">
<a-select-option value="fluid">{{$t('navigate.content.fluid')}}</a-select-option>
<a-select-option value="fixed">{{$t('navigate.content.fixed')}}</a-select-option>
</a-select>
</a-list-item>
<a-list-item>
@ -132,7 +132,7 @@ export default {
directions() {
return this.animates.find(item => item.name == this.animate.name).directions
},
...mapState('setting', ['theme', 'layout', 'animate', 'animates', 'palettes', 'multiPage', 'weekMode', 'fixedHeader', 'fixedSideBar', 'hideSetting'])
...mapState('setting', ['theme', 'layout', 'animate', 'animates', 'palettes', 'multiPage', 'weekMode', 'fixedHeader', 'fixedSideBar', 'hideSetting', 'pageWidth'])
},
watch: {
'animate.name': function(val) {
@ -166,7 +166,7 @@ export default {
})
},
...mapMutations('setting', ['setTheme', 'setLayout', 'setMultiPage', 'setWeekMode',
'setFixedSideBar', 'setFixedHeader', 'setAnimate', 'setHideSetting'])
'setFixedSideBar', 'setFixedHeader', 'setAnimate', 'setHideSetting', 'setPageWidth'])
}
}
</script>

View File

@ -11,6 +11,7 @@ module.exports = {
layout: 'side', //导航布局,可选 side 和 head分别为侧边导航和顶部导航
fixedHeader: false, //固定头部状态栏true:固定false:不固定
fixedSideBar: true, //固定侧边栏true:固定false:不固定
pageWidth: 'fixed', //内容区域宽度fixed:固定宽度fluid:流式宽度
weekMode: false, //色弱模式true:开启false:不开启
multiPage: false, //多页签模式true:开启false:不开启
hideSetting: false, //隐藏设置抽屉true:隐藏false:不隐藏

View File

@ -13,7 +13,7 @@
</div>
<slot v-if="this.$slots.extra" slot="extra" name="extra"></slot>
</page-header>
<div ref="page" :class="['page-content', layout]" >
<div ref="page" :class="['page-content', layout, pageWidth]" >
<slot></slot>
</div>
</div>
@ -60,7 +60,7 @@ export default {
this.updatePageHeight(0)
},
computed: {
...mapState('setting', ['layout', 'multiPage', 'pageMinHeight']),
...mapState('setting', ['layout', 'multiPage', 'pageMinHeight', 'pageWidth']),
pageTitle() {
let pageTitle = this.page && this.page.title
return pageTitle === undefined ? (this.title || this.routeName) : this.$t(pageTitle)
@ -130,7 +130,7 @@ export default {
padding: 24px 0 0;
&.side{
}
&.head{
&.head.fixed{
margin: 0 auto;
max-width: 1400px;
}

View File

@ -1,6 +1,6 @@
<template>
<a-layout-header :class="[headerTheme, 'admin-header']">
<div :class="['admin-header-wide', layout]">
<div :class="['admin-header-wide', layout, pageWidth]">
<router-link v-if="isMobile || layout === 'head'" to="/" :class="['logo', isMobile ? null : 'pc', headerTheme]">
<img width="32" src="@/assets/img/logo.png" />
<h1 v-if="!isMobile">{{systemName}}</h1>
@ -54,7 +54,7 @@ export default {
}
},
computed: {
...mapState('setting', ['theme', 'isMobile', 'layout', 'systemName', 'lang']),
...mapState('setting', ['theme', 'isMobile', 'layout', 'systemName', 'lang', 'pageWidth']),
headerTheme () {
if (this.layout == 'side' && this.theme.mode == 'dark' && !this.isMobile) {
return 'light'

View File

@ -20,9 +20,11 @@
}
}
.admin-header-wide{
&.head{
padding-left: 24px;
&.head.fixed{
max-width: 1400px;
margin: auto;
padding-left: 0;
}
&.side{
padding-right: 12px;

View File

@ -5,7 +5,7 @@
v-if="multiPage"
type="editable-card"
:active-key="activePage"
:style="`margin: -16px auto 8px; ${layout == 'head' ? 'max-width: 1400px;' : ''}`"
:class="['tabs-view', layout, pageWidth]"
:hide-add="true"
@change="changePage"
@edit="editPage"
@ -48,7 +48,7 @@ export default {
}
},
computed: {
...mapState('setting', ['multiPage', 'animate', 'layout']),
...mapState('setting', ['multiPage', 'animate', 'layout', 'pageWidth']),
menuItemList() {
return [
{ key: '1', icon: 'vertical-right', text: this.$t('closeLeft') },
@ -206,6 +206,12 @@ function getPageKey (target, depth = 0) {
</script>
<style scoped lang="less">
.tabs-view{
margin: -16px auto 8px;
&.head.fixed{
max-width: 1400px;
}
}
.tabs-view-content{
position: relative;
}

View File

@ -82,6 +82,9 @@ export default {
setAsyncRoutes(state, asyncRoutes) {
state.asyncRoutes = asyncRoutes
},
setPageWidth(state, pageWidth) {
state.pageWidth = pageWidth
},
setActivatedFirst(state, activatedFirst) {
state.activatedFirst = activatedFirst
}