Blame view

src/store/modules/settings.js 657 Bytes
d7d9c38c2   Adam   auto commit the c...
1
  import variables from '@/styles/element-variables.scss'
80a28914e   吉鹏   init
2
  import defaultSettings from '@/settings'
a86b16bba   Adam   auto commit the c...
3
4
5
6
7
8
9
  const {
    showSettings,
    tagsView,
    fixedHeader,
    sidebarLogo,
    supportPinyinSearch
  } = defaultSettings
80a28914e   吉鹏   init
10
11
  
  const state = {
d7d9c38c2   Adam   auto commit the c...
12
13
14
15
16
17
    theme: variables.theme,
    showSettings,
    tagsView,
    fixedHeader,
    sidebarLogo,
    supportPinyinSearch
80a28914e   吉鹏   init
18
19
20
  }
  
  const mutations = {
a86b16bba   Adam   auto commit the c...
21
22
23
24
    CHANGE_SETTING: (state, {
      key,
      value
    }) => {
80a28914e   吉鹏   init
25
26
27
28
29
30
31
      if (state.hasOwnProperty(key)) {
        state[key] = value
      }
    }
  }
  
  const actions = {
a86b16bba   Adam   auto commit the c...
32
33
34
    changeSetting({
      commit
    }, data) {
80a28914e   吉鹏   init
35
36
37
38
39
40
41
42
43
44
      commit('CHANGE_SETTING', data)
    }
  }
  
  export default {
    namespaced: true,
    state,
    mutations,
    actions
  }