From c8df1f5e1f1ba33caad650cbbbd4045e8f5948a3 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 13 Apr 2021 09:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=83=E5=B1=80=E8=AE=BE=E7=BD=AE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BF=9D=E5=AD=98&=E9=87=8D=E7=BD=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 2 +- ruoyi-ui/src/components/TopNav/index.vue | 24 ++++++++--- .../src/layout/components/Settings/index.vue | 43 +++++++++++++++++-- ruoyi-ui/src/settings.js | 2 +- ruoyi-ui/src/store/modules/settings.js | 12 +++--- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 423e75f..1f098e4 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -43,7 +43,7 @@ spring: allow: url-pattern: /druid/* # 控制台管理用户名和密码 - login-username: admin + login-username: ruoyi login-password: 123456 filter: stat: diff --git a/ruoyi-ui/src/components/TopNav/index.vue b/ruoyi-ui/src/components/TopNav/index.vue index fb15c59..2397628 100644 --- a/ruoyi-ui/src/components/TopNav/index.vue +++ b/ruoyi-ui/src/components/TopNav/index.vue @@ -30,6 +30,9 @@ diff --git a/ruoyi-ui/src/layout/components/Settings/index.vue b/ruoyi-ui/src/layout/components/Settings/index.vue index 7e36d48..eba8139 100644 --- a/ruoyi-ui/src/layout/components/Settings/index.vue +++ b/ruoyi-ui/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/ruoyi-ui/src/settings.js b/ruoyi-ui/src/settings.js index d7e774b..0e74c71 100644 --- a/ruoyi-ui/src/settings.js +++ b/ruoyi-ui/src/settings.js @@ -14,7 +14,7 @@ module.exports = { /** * 是否显示顶部导航 */ - topNav: true, + topNav: false, /** * 是否显示 tagsView diff --git a/ruoyi-ui/src/store/modules/settings.js b/ruoyi-ui/src/store/modules/settings.js index f113e9a..7192f1c 100644 --- a/ruoyi-ui/src/store/modules/settings.js +++ b/ruoyi-ui/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)) {