Blame view

src/store/modules/settings.js 632 Bytes
d7d9c38c2   Adam   auto commit the c...
1
  import variables from '@/styles/element-variables.scss'
80a28914e   吉鹏   init
2
  import defaultSettings from '@/settings'
d7d9c38c2   Adam   auto commit the c...
3
  const { showSettings, tagsView, fixedHeader, sidebarLogo, supportPinyinSearch } = defaultSettings
80a28914e   吉鹏   init
4
5
  
  const state = {
d7d9c38c2   Adam   auto commit the c...
6
7
8
9
10
11
    theme: variables.theme,
    showSettings,
    tagsView,
    fixedHeader,
    sidebarLogo,
    supportPinyinSearch
80a28914e   吉鹏   init
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  }
  
  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
  }