2019-10-08 01:14:38 +00:00
|
|
|
import variables from '@/assets/styles/element-variables.scss'
|
|
|
|
import defaultSettings from '@/settings'
|
|
|
|
|
2021-04-12 01:54:08 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|