From 9704b00cc29ddbdb2ee2225826a79bc9754f8106 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 18 Feb 2022 15:43:12 +0800 Subject: [PATCH] refactor: admin layout settings (#441) Signed-off-by: Ryan Wang --- .../SettingDrawer/SettingDrawer.vue | 141 ++++++++++-------- src/config/defaultSettings.js | 4 +- src/store/modules/app.js | 3 - 3 files changed, 81 insertions(+), 67 deletions(-) diff --git a/src/components/SettingDrawer/SettingDrawer.vue b/src/components/SettingDrawer/SettingDrawer.vue index e3e28d50..255db097 100644 --- a/src/components/SettingDrawer/SettingDrawer.vue +++ b/src/components/SettingDrawer/SettingDrawer.vue @@ -6,8 +6,8 @@

整体风格设置

- -
+ +
dark
@@ -16,8 +16,8 @@ - -
+ +
light
@@ -31,8 +31,8 @@

主题色

- - + + @@ -43,14 +43,14 @@

导航模式

-
+
sidemenu
-
+
topmenu
@@ -62,53 +62,68 @@
- - - - 固定 - 流式 - - - -
内容区域宽度
-
-
- - - -
固定 Header
-
-
- - - - - -
下滑时隐藏 Header
+ + +
- + -
固定侧边菜单
+ +
+
+ + + + + + + + + +
@@ -148,43 +163,45 @@ export default { onClose() { this.ToggleLayoutSetting(false) }, - handleMenuTheme(theme) { + handleSetMenuTheme(theme) { this.baseConfig.navTheme = theme this.$store.dispatch('ToggleTheme', theme) }, - handleLayout(mode) { + handleSetLayout(mode) { this.baseConfig.layout = mode this.$store.dispatch('ToggleLayoutMode', mode) - this.handleFixedSidebar(false) if (mode === 'sidemenu') { this.handleContentWidthChange('Fixed') + this.handleSetFixedSidebar(true) + } else { + this.handleSetFixedHeader(true) + this.handleSetFixedSidebar(false) } }, handleContentWidthChange(type) { this.baseConfig.contentWidth = type this.$store.dispatch('ToggleContentWidth', type) }, - changeColor(color) { + handleChangeColor(color) { this.baseConfig.primaryColor = color if (this.primaryColor !== color) { this.$store.dispatch('ToggleColor', color) updateTheme(color) } }, - handleFixedHeader(fixed) { + handleSetFixedHeader(fixed) { this.baseConfig.fixedHeader = fixed this.$store.dispatch('ToggleFixedHeader', fixed) + + if (!fixed) { + this.handleSetAutoHideHeader(false) + } }, - handleFixedHeaderHidden(autoHidden) { + handleSetAutoHideHeader(autoHidden) { this.baseConfig.autoHideHeader = autoHidden this.$store.dispatch('ToggleFixedHeaderHidden', autoHidden) }, - handleFixedSidebar(fixed) { - if (this.layoutMode === 'topmenu') { - this.baseConfig.fixedSidebar = false - this.$store.dispatch('ToggleFixedSidebar', false) - return - } + handleSetFixedSidebar(fixed) { this.baseConfig.fixedSidebar = fixed this.$store.dispatch('ToggleFixedSidebar', fixed) } diff --git a/src/config/defaultSettings.js b/src/config/defaultSettings.js index dba7fcd5..3bc45274 100644 --- a/src/config/defaultSettings.js +++ b/src/config/defaultSettings.js @@ -1,10 +1,10 @@ export default { primaryColor: '#1890FF', navTheme: 'dark', - layout: 'topmenu', + layout: 'sidemenu', contentWidth: 'Fixed', fixedHeader: false, - fixedSidebar: false, + fixedSidebar: true, autoHideHeader: false, storageOptions: { namespace: 'halo__', diff --git a/src/store/modules/app.js b/src/store/modules/app.js index c2f200c9..8142981d 100644 --- a/src/store/modules/app.js +++ b/src/store/modules/app.js @@ -84,9 +84,6 @@ const app = { commit('TOGGLE_LAYOUT_MODE', mode) }, ToggleFixedHeader({ commit }, fixedHeader) { - if (!fixedHeader) { - commit('TOGGLE_FIXED_HEADER_HIDDEN', false) - } commit('TOGGLE_FIXED_HEADER', fixedHeader) }, ToggleFixedSidebar({ commit }, fixedSidebar) {