fxfast-code/ruoyi-ui/src/store/modules/settings.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-10-08 01:14:38 +00:00
import variables from '@/assets/styles/element-variables.scss'
import defaultSettings from '@/settings'
const { sideTheme, showSettings, topNav, tagsView, fixedHeader, sidebarLogo } = defaultSettings
2019-10-08 01:14:38 +00:00
2021-04-13 01:47:28 +00:00
const storageSetting = JSON.parse(localStorage.getItem('layout-setting')) || ''
2019-10-08 01:14:38 +00:00
const state = {
theme: variables.theme,
2021-04-13 01:47:28 +00:00
sideTheme: storageSetting.sideTheme || sideTheme,
2019-10-08 01:14:38 +00:00
showSettings: showSettings,
2021-04-13 01:47:28 +00:00
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
2019-10-08 01:14:38 +00:00
}
const mutations = {
CHANGE_SETTING: (state, { key, value }) => {
if (state.hasOwnProperty(key)) {
state[key] = value
}
}
}
const actions = {
changeSetting({ commit }, data) {
commit('CHANGE_SETTING', data)
}
}
export default {
namespaced: true,
state,
mutations,
actions
}