web/client/store/index.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 33
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 22
mnd 0
bc 0
fnc 5
dl 0
loc 33
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
export const state = () => ({
2
  site: {},
3
  config: {}
4
})
5
6
export const mutations = {
7
  setData (state, { key, value }) {
8
    state[key] = value
9
  }
10
}
11
12
export const actions = {
13
  async nuxtServerInit ({ dispatch }) {
14
    await dispatch('initSite')
15
    await dispatch('initConfig')
16
    await dispatch('news/initCategory')
17
  },
18
  async initSite ({ commit }) {
19
    const data = await this.$wp.site()
20
    commit('setData', {
21
      key: 'site',
22
      value: data
23
    })
24
  },
25
  async initConfig ({ commit }) {
26
    const data = await this.$wp.options()
27
      .id('rsl-fe-config')
28
    commit('setData', {
29
      key: 'config',
30
      value: data.acf
31
    })
32
  }
33
}
34