diff --git a/yudao-ui-admin/src/components/TopNav/index.vue b/yudao-ui-admin/src/components/TopNav/index.vue index 393b9e114..babfeaed0 100644 --- a/yudao-ui-admin/src/components/TopNav/index.vue +++ b/yudao-ui-admin/src/components/TopNav/index.vue @@ -30,6 +30,9 @@ diff --git a/yudao-ui-admin/src/layout/components/Settings/index.vue b/yudao-ui-admin/src/layout/components/Settings/index.vue index 994b16864..ca12e0b0d 100644 --- a/yudao-ui-admin/src/layout/components/Settings/index.vue +++ b/yudao-ui-admin/src/layout/components/Settings/index.vue @@ -62,6 +62,10 @@ + + + 保存配置 + 重置配置 @@ -72,15 +76,14 @@ import ThemePicker from '@/components/ThemePicker' export default { components: { ThemePicker }, data() { - return {} + return { + sideTheme: this.$store.state.settings.sideTheme + }; }, computed: { theme() { return this.$store.state.settings.theme }, - sideTheme() { - return this.$store.state.settings.sideTheme - }, fixedHeader: { get() { return this.$store.state.settings.fixedHeader @@ -141,6 +144,38 @@ export default { key: 'sideTheme', value: val }) + this.sideTheme = val; + }, + saveSetting() { + const loading = this.$loading({ + lock: true, + fullscreen: false, + text: "正在保存到本地,请稍后...", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)" + }); + localStorage.setItem( + "layout-setting", + `{ + "topNav":${this.topNav}, + "tagsView":${this.tagsView}, + "fixedHeader":${this.fixedHeader}, + "sidebarLogo":${this.sidebarLogo}, + "sideTheme":"${this.sideTheme}" + }` + ); + setTimeout(loading.close(), 1000) + }, + resetSetting() { + this.$loading({ + lock: true, + fullscreen: false, + text: "正在清除设置缓存并刷新,请稍后...", + spinner: "el-icon-loading", + background: "rgba(0, 0, 0, 0.7)" + }); + localStorage.removeItem("layout-setting") + setTimeout("window.location.reload()", 1000) } } } diff --git a/yudao-ui-admin/src/settings.js b/yudao-ui-admin/src/settings.js index 2dc34822b..ba5cbd03c 100644 --- a/yudao-ui-admin/src/settings.js +++ b/yudao-ui-admin/src/settings.js @@ -14,7 +14,7 @@ module.exports = { /** * 是否显示顶部导航 */ - topNav: true, + topNav: false, /** * 是否显示 tagsView diff --git a/yudao-ui-admin/src/store/modules/settings.js b/yudao-ui-admin/src/store/modules/settings.js index 79d6fa579..bb8062f13 100644 --- a/yudao-ui-admin/src/store/modules/settings.js +++ b/yudao-ui-admin/src/store/modules/settings.js @@ -3,16 +3,16 @@ import defaultSettings from '@/settings' const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo } = defaultSettings +const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || '' const state = { theme: variables.theme, - sideTheme: sideTheme, + sideTheme: storageSetting.sideTheme || sideTheme, showSettings: showSettings, - topNav: topNav, - tagsView: tagsView, - fixedHeader: fixedHeader, - sidebarLogo: sidebarLogo + topNav: storageSetting.topNav === undefined ? topNav : storageSetting.topNav, + tagsView: storageSetting.tagsView === undefined ? tagsView : storageSetting.tagsView, + fixedHeader: storageSetting.fixedHeader === undefined ? fixedHeader : storageSetting.fixedHeader, + sidebarLogo: storageSetting.sidebarLogo === undefined ? sidebarLogo : storageSetting.sidebarLogo } - const mutations = { CHANGE_SETTING: (state, { key, value }) => { if (state.hasOwnProperty(key)) {