Total Complexity | 4 |
Complexity/F | 1 |
Lines of Code | 32 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import Cookies from 'js-cookie' |
||
2 | import * as types from '../mutation-types' |
||
3 | |||
4 | const { locale, locales } = window.config |
||
5 | |||
6 | // state |
||
7 | export const state = { |
||
8 | locale: Cookies.get('locale') || locale, |
||
9 | locales: locales |
||
10 | } |
||
11 | |||
12 | // getters |
||
13 | export const getters = { |
||
14 | locale: state => state.locale, |
||
15 | locales: state => state.locales |
||
16 | } |
||
17 | |||
18 | // mutations |
||
19 | export const mutations = { |
||
20 | [types.SET_LOCALE] (state, { locale }) { |
||
21 | state.locale = locale |
||
22 | } |
||
23 | } |
||
24 | |||
25 | // actions |
||
26 | export const actions = { |
||
27 | setLocale ({ commit }, { locale }) { |
||
28 | commit(types.SET_LOCALE, { locale }) |
||
29 | |||
30 | Cookies.set('locale', locale, { expires: 365 }) |
||
31 | } |
||
32 | } |
||
33 |