修改侧边配置栏

This commit is contained in:
季圣华
2021-06-28 00:24:51 +08:00
parent 5df8c12e43
commit 72998dde4b

View File

@@ -1,330 +1,330 @@
<template> <template>
<div class="setting-drawer"> <div class="setting-drawer">
<a-drawer <a-drawer
width="300" width="300"
placement="right" placement="right"
:closable="false" :closable="false"
@close="onClose" @close="onClose"
:visible="visible" :visible="visible"
:style="{}" :style="{}"
> >
<div class="setting-drawer-index-content"> <div class="setting-drawer-index-content">
<div :style="{ marginBottom: '24px' }"> <div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">整体风格设置</h3> <h3 class="setting-drawer-index-title">整体风格设置</h3>
<div class="setting-drawer-index-blockChecbox"> <div class="setting-drawer-index-blockChecbox">
<a-tooltip> <a-tooltip>
<template slot="title"> <template slot="title">
暗色菜单风格 暗色菜单风格
</template> </template>
<div class="setting-drawer-index-item" @click="handleMenuTheme('dark')"> <div class="setting-drawer-index-item" @click="handleMenuTheme('dark')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/LCkqqYNmvBEbokSDscrm.svg" alt="dark"> <img src="https://gw.alipayobjects.com/zos/rmsportal/LCkqqYNmvBEbokSDscrm.svg" alt="dark">
<div class="setting-drawer-index-selectIcon" v-if="navTheme === 'dark'"> <div class="setting-drawer-index-selectIcon" v-if="navTheme === 'dark'">
<a-icon type="check"/> <a-icon type="check"/>
</div> </div>
</div> </div>
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template slot="title"> <template slot="title">
亮色菜单风格 亮色菜单风格
</template> </template>
<div class="setting-drawer-index-item" @click="handleMenuTheme('light')"> <div class="setting-drawer-index-item" @click="handleMenuTheme('light')">
<img src="https://gw.alipayobjects.com/zos/rmsportal/jpRkZQMyYRryryPNtyIC.svg" alt="light"> <img src="https://gw.alipayobjects.com/zos/rmsportal/jpRkZQMyYRryryPNtyIC.svg" alt="light">
<div class="setting-drawer-index-selectIcon" v-if="navTheme !== 'dark'"> <div class="setting-drawer-index-selectIcon" v-if="navTheme !== 'dark'">
<a-icon type="check"/> <a-icon type="check"/>
</div> </div>
</div> </div>
</a-tooltip> </a-tooltip>
</div> </div>
</div> </div>
<div :style="{ marginBottom: '24px' }"> <div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">主题色</h3> <h3 class="setting-drawer-index-title">主题色</h3>
<div style="height: 20px"> <div style="height: 20px">
<a-tooltip class="setting-drawer-theme-color-colorBlock" v-for="(item, index) in colorList" :key="index"> <a-tooltip class="setting-drawer-theme-color-colorBlock" v-for="(item, index) in colorList" :key="index">
<template slot="title"> <template slot="title">
{{ item.key }} {{ item.key }}
</template> </template>
<a-tag :color="item.color" @click="changeColor(item.color)"> <a-tag :color="item.color" @click="changeColor(item.color)">
<a-icon type="check" v-if="item.color === primaryColor"></a-icon> <a-icon type="check" v-if="item.color === primaryColor"></a-icon>
</a-tag> </a-tag>
</a-tooltip> </a-tooltip>
</div> </div>
</div> </div>
<a-divider /> <a-divider />
<div :style="{ marginBottom: '24px' }"> <div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">导航模式</h3> <!-- <h3 class="setting-drawer-index-title">导航模式</h3>-->
<div class="setting-drawer-index-blockChecbox"> <!-- <div class="setting-drawer-index-blockChecbox">-->
<a-tooltip> <!-- <a-tooltip>-->
<template slot="title"> <!-- <template slot="title">-->
侧边栏导航 <!-- 侧边栏导航-->
</template> <!-- </template>-->
<div class="setting-drawer-index-item" @click="handleLayout('sidemenu')"> <!-- <div class="setting-drawer-index-item" @click="handleLayout('sidemenu')">-->
<img src="https://gw.alipayobjects.com/zos/rmsportal/JopDzEhOqwOjeNTXkoje.svg" alt="sidemenu"> <!-- <img src="https://gw.alipayobjects.com/zos/rmsportal/JopDzEhOqwOjeNTXkoje.svg" alt="sidemenu">-->
<div class="setting-drawer-index-selectIcon" v-if="layoutMode === 'sidemenu'"> <!-- <div class="setting-drawer-index-selectIcon" v-if="layoutMode === 'sidemenu'">-->
<a-icon type="check"/> <!-- <a-icon type="check"/>-->
</div> <!-- </div>-->
</div> <!-- </div>-->
</a-tooltip> <!-- </a-tooltip>-->
<a-tooltip> <!-- <a-tooltip>-->
<template slot="title"> <!-- <template slot="title">-->
顶部栏导航 <!-- 顶部栏导航-->
</template> <!-- </template>-->
<div class="setting-drawer-index-item" @click="handleLayout('topmenu')"> <!-- <div class="setting-drawer-index-item" @click="handleLayout('topmenu')">-->
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDNDBbriJhLwuqMoxcAr.svg" alt="topmenu"> <!-- <img src="https://gw.alipayobjects.com/zos/rmsportal/KDNDBbriJhLwuqMoxcAr.svg" alt="topmenu">-->
<div class="setting-drawer-index-selectIcon" v-if="layoutMode !== 'sidemenu'"> <!-- <div class="setting-drawer-index-selectIcon" v-if="layoutMode !== 'sidemenu'">-->
<a-icon type="check"/> <!-- <a-icon type="check"/>-->
</div> <!-- </div>-->
</div> <!-- </div>-->
</a-tooltip> <!-- </a-tooltip>-->
</div> <!-- </div>-->
<div :style="{ marginTop: '24px' }"> <div :style="{ marginTop: '24px' }">
<a-list :split="false"> <a-list :split="false">
<a-list-item> <!-- <a-list-item>-->
<a-tooltip slot="actions"> <!-- <a-tooltip slot="actions">-->
<template slot="title"> <!-- <template slot="title">-->
该设定仅 [顶部栏导航] 时有效 <!-- 该设定仅 [顶部栏导航] 时有效-->
</template> <!-- </template>-->
<a-select size="small" style="width: 80px;" :defaultValue="contentWidth" @change="handleContentWidthChange"> <!-- <a-select size="small" style="width: 80px;" :defaultValue="contentWidth" @change="handleContentWidthChange">-->
<a-select-option value="Fixed">固定</a-select-option> <!-- <a-select-option value="Fixed">固定</a-select-option>-->
<a-select-option value="Fluid" v-if="layoutMode !== 'sidemenu'">流式</a-select-option> <!-- <a-select-option value="Fluid" v-if="layoutMode !== 'sidemenu'">流式</a-select-option>-->
</a-select> <!-- </a-select>-->
</a-tooltip> <!-- </a-tooltip>-->
<a-list-item-meta> <!-- <a-list-item-meta>-->
<div slot="title">内容区域宽度</div> <!-- <div slot="title">内容区域宽度</div>-->
</a-list-item-meta> <!-- </a-list-item-meta>-->
</a-list-item> <!-- </a-list-item>-->
<a-list-item> <a-list-item>
<a-switch slot="actions" size="small" :defaultChecked="fixedHeader" @change="handleFixedHeader" /> <a-switch slot="actions" size="small" :defaultChecked="fixedHeader" @change="handleFixedHeader" />
<a-list-item-meta> <a-list-item-meta>
<div slot="title">固定 Header</div> <div slot="title">固定 Header</div>
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
<a-list-item> <a-list-item>
<a-switch slot="actions" size="small" :disabled="!fixedHeader" :defaultChecked="autoHideHeader" @change="handleFixedHeaderHidden" /> <a-switch slot="actions" size="small" :disabled="!fixedHeader" :defaultChecked="autoHideHeader" @change="handleFixedHeaderHidden" />
<a-list-item-meta> <a-list-item-meta>
<div slot="title" :style="{ textDecoration: !fixedHeader ? 'line-through' : 'unset' }">下滑时隐藏 Header</div> <div slot="title" :style="{ textDecoration: !fixedHeader ? 'line-through' : 'unset' }">下滑时隐藏 Header</div>
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
<a-list-item > <a-list-item >
<a-switch slot="actions" size="small" :disabled="(layoutMode === 'topmenu')" :checked="dataFixSiderbar" @change="handleFixSiderbar" /> <a-switch slot="actions" size="small" :disabled="(layoutMode === 'topmenu')" :checked="dataFixSiderbar" @change="handleFixSiderbar" />
<a-list-item-meta> <a-list-item-meta>
<div slot="title" :style="{ textDecoration: layoutMode === 'topmenu' ? 'line-through' : 'unset' }">固定侧边菜单</div> <div slot="title" :style="{ textDecoration: layoutMode === 'topmenu' ? 'line-through' : 'unset' }">固定侧边菜单</div>
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
</a-list> </a-list>
</div> </div>
</div> </div>
<a-divider /> <a-divider />
<div :style="{ marginBottom: '24px' }"> <div :style="{ marginBottom: '24px' }">
<h3 class="setting-drawer-index-title">其他设置</h3> <h3 class="setting-drawer-index-title">其他设置</h3>
<div> <div>
<a-list :split="false"> <a-list :split="false">
<a-list-item> <a-list-item>
<a-switch slot="actions" size="small" :defaultChecked="colorWeak" @change="onColorWeak" /> <a-switch slot="actions" size="small" :defaultChecked="colorWeak" @change="onColorWeak" />
<a-list-item-meta> <a-list-item-meta>
<div slot="title">色弱模式</div> <div slot="title">色弱模式</div>
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
<a-list-item> <a-list-item>
<a-switch slot="actions" size="small" :defaultChecked="multipage" @change="onMultipageWeak" /> <a-switch slot="actions" size="small" :defaultChecked="multipage" @change="onMultipageWeak" />
<a-list-item-meta> <a-list-item-meta>
<div slot="title">多页签模式</div> <div slot="title">多页签模式</div>
</a-list-item-meta> </a-list-item-meta>
</a-list-item> </a-list-item>
</a-list> </a-list>
</div> </div>
</div> </div>
<a-divider /> <!-- <a-divider />-->
<div :style="{ marginBottom: '24px' }"> <!-- <div :style="{ marginBottom: '24px' }">-->
<a-alert type="warning"> <!-- <a-alert type="warning">-->
<span slot="message"> <!-- <span slot="message">-->
配置栏只在开发环境用于预览,生产环境不会展现,请手动修改配置文件 <!-- 生产环境如需修改默认配置,请手动修改配置文件-->
<a href="https://github.com/sendya/ant-design-pro-vue/blob/master/src/defaultSettings.js" target="_blank">src/defaultSettings.js</a> <!-- src/defaultSettings.js-->
</span> <!-- </span>-->
</a-alert> <!-- </a-alert>-->
</div> <!-- </div>-->
</div> </div>
<div class="setting-drawer-index-handle" @click="toggle" v-if="visible"> <div class="setting-drawer-index-handle" @click="toggle" v-if="visible">
<!-- <a-icon type="setting" v-if="!visible"/>--> <!-- <a-icon type="setting" v-if="!visible"/>-->
<!-- <a-icon type="close" v-else/>--> <!-- <a-icon type="close" v-else/>-->
<a-icon type="close" /> <a-icon type="close" />
</div> </div>
</a-drawer> </a-drawer>
</div> </div>
</template> </template>
<script> <script>
import DetailList from '@/components/tools/DetailList' import DetailList from '@/components/tools/DetailList'
import SettingItem from '@/components/setting/SettingItem' import SettingItem from '@/components/setting/SettingItem'
import config from '@/defaultSettings' import config from '@/defaultSettings'
import { updateTheme, updateColorWeak, colorList } from '@/components/tools/setting' import { updateTheme, updateColorWeak, colorList } from '@/components/tools/setting'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import { triggerWindowResizeEvent } from '@/utils/util' import { triggerWindowResizeEvent } from '@/utils/util'
export default { export default {
components: { components: {
DetailList, DetailList,
SettingItem SettingItem
}, },
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
data() { data() {
return { return {
visible: true, visible: true,
colorList, colorList,
dataFixSiderbar: false dataFixSiderbar: false
} }
}, },
watch: { watch: {
}, },
mounted () { mounted () {
const vm = this const vm = this
setTimeout(() => { setTimeout(() => {
vm.visible = false vm.visible = false
}, 16) }, 16)
// 当主题色不是默认色时,才进行主题编译 // 当主题色不是默认色时,才进行主题编译
if (this.primaryColor !== config.primaryColor) { if (this.primaryColor !== config.primaryColor) {
updateTheme(this.primaryColor) updateTheme(this.primaryColor)
} }
if (this.colorWeak !== config.colorWeak) { if (this.colorWeak !== config.colorWeak) {
updateColorWeak(this.colorWeak) updateColorWeak(this.colorWeak)
} }
if (this.multipage !== config.multipage) { if (this.multipage !== config.multipage) {
this.$store.dispatch('ToggleMultipage', this.multipage) this.$store.dispatch('ToggleMultipage', this.multipage)
} }
}, },
methods: { methods: {
showDrawer() { showDrawer() {
this.visible = true this.visible = true
}, },
onClose() { onClose() {
this.visible = false this.visible = false
}, },
toggle() { toggle() {
this.visible = !this.visible this.visible = !this.visible
}, },
onColorWeak (checked) { onColorWeak (checked) {
this.$store.dispatch('ToggleWeak', checked) this.$store.dispatch('ToggleWeak', checked)
updateColorWeak(checked) updateColorWeak(checked)
}, },
onMultipageWeak (checked) { onMultipageWeak (checked) {
this.$store.dispatch('ToggleMultipage', checked) this.$store.dispatch('ToggleMultipage', checked)
}, },
handleMenuTheme (theme) { handleMenuTheme (theme) {
this.$store.dispatch('ToggleTheme', theme) this.$store.dispatch('ToggleTheme', theme)
}, },
handleLayout (mode) { handleLayout (mode) {
this.$store.dispatch('ToggleLayoutMode', mode) this.$store.dispatch('ToggleLayoutMode', mode)
// 因为顶部菜单不能固定左侧菜单栏,所以强制关闭 // 因为顶部菜单不能固定左侧菜单栏,所以强制关闭
this.handleFixSiderbar(false) this.handleFixSiderbar(false)
// 触发窗口resize事件 // 触发窗口resize事件
triggerWindowResizeEvent() triggerWindowResizeEvent()
}, },
handleContentWidthChange (type) { handleContentWidthChange (type) {
this.$store.dispatch('ToggleContentWidth', type) this.$store.dispatch('ToggleContentWidth', type)
}, },
changeColor (color) { changeColor (color) {
if (this.primaryColor !== color) { if (this.primaryColor !== color) {
this.$store.dispatch('ToggleColor', color) this.$store.dispatch('ToggleColor', color)
updateTheme(color) updateTheme(color)
} }
}, },
handleFixedHeader (fixed) { handleFixedHeader (fixed) {
this.$store.dispatch('ToggleFixedHeader', fixed) this.$store.dispatch('ToggleFixedHeader', fixed)
}, },
handleFixedHeaderHidden (autoHidden) { handleFixedHeaderHidden (autoHidden) {
this.$store.dispatch('ToggleFixedHeaderHidden', autoHidden) this.$store.dispatch('ToggleFixedHeaderHidden', autoHidden)
}, },
handleFixSiderbar (fixed) { handleFixSiderbar (fixed) {
if (this.layoutMode === 'topmenu') { if (this.layoutMode === 'topmenu') {
fixed = false fixed = false
} }
this.dataFixSiderbar = fixed this.dataFixSiderbar = fixed
this.$store.dispatch('ToggleFixSiderbar', fixed) this.$store.dispatch('ToggleFixSiderbar', fixed)
} }
}, },
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.setting-drawer-index-content { .setting-drawer-index-content {
.setting-drawer-index-blockChecbox { .setting-drawer-index-blockChecbox {
display: flex; display: flex;
.setting-drawer-index-item { .setting-drawer-index-item {
margin-right: 16px; margin-right: 16px;
position: relative; position: relative;
border-radius: 4px; border-radius: 4px;
cursor: pointer; cursor: pointer;
img { img {
width: 48px; width: 48px;
} }
.setting-drawer-index-selectIcon { .setting-drawer-index-selectIcon {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
width: 100%; width: 100%;
padding-top: 15px; padding-top: 15px;
padding-left: 24px; padding-left: 24px;
height: 100%; height: 100%;
color: #1890ff; color: #1890ff;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
} }
} }
} }
.setting-drawer-theme-color-colorBlock { .setting-drawer-theme-color-colorBlock {
width: 20px; width: 20px;
height: 20px; height: 20px;
border-radius: 2px; border-radius: 2px;
float: left; float: left;
cursor: pointer; cursor: pointer;
margin-right: 8px; margin-right: 8px;
padding-left: 0px; padding-left: 0px;
padding-right: 0px; padding-right: 0px;
text-align: center; text-align: center;
color: #fff; color: #fff;
font-weight: 700; font-weight: 700;
i { i {
font-size: 14px; font-size: 14px;
} }
} }
} }
.setting-drawer-index-handle { .setting-drawer-index-handle {
position: absolute; position: absolute;
top: 240px; top: 240px;
background: #1890ff; background: #1890ff;
width: 48px; width: 48px;
height: 48px; height: 48px;
right: 300px; right: 300px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
pointer-events: auto; pointer-events: auto;
z-index: 1001; z-index: 1001;
text-align: center; text-align: center;
font-size: 16px; font-size: 16px;
border-radius: 4px 0 0 4px; border-radius: 4px 0 0 4px;
i { i {
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
font-size: 20px; font-size: 20px;
} }
} }
</style> </style>