(dev) can rename dev

This commit is contained in:
2020-07-14 00:21:09 +02:00
parent d9385bc457
commit 8385762262
3 changed files with 68 additions and 6 deletions

View File

@@ -7,11 +7,15 @@ Vue.use(Vuex)
export interface State {
interval: number
withMusic: boolean
dev1: string | null
dev2: string | null
}
export interface RootActions extends ActionTree<State, State> {
setInterval: (ctx: ActionContext<State, State>, payload: number) => void
setWithMusic: (ctx: ActionContext<State, State>, payload: boolean) => void
setDev1: (ctx: ActionContext<State, State>, payload: string) => void
setDev2: (ctx: ActionContext<State, State>, payload: string) => void
}
const vuexLocal = new VuexPersistence<State>({
@@ -21,15 +25,21 @@ const vuexLocal = new VuexPersistence<State>({
const SET_INTERVAL = 'SET_INTERVAL'
const WITH_MUSIC = 'WITH_MUSIC'
const SET_DEV_1 = 'SET_DEV_1'
const SET_DEV_2 = 'SET_DEV_2'
const store = new Vuex.Store<State>({
state: {
interval: 5,
withMusic: true
withMusic: true,
dev1: null,
dev2: null
},
getters: {
interval: ({ interval }) => interval,
withMusic: ({ withMusic }) => withMusic
withMusic: ({ withMusic }) => withMusic,
dev1: ({ dev1 }) => dev1,
dev2: ({ dev2 }) => dev2
},
mutations: {
[SET_INTERVAL](state, interval: number) {
@@ -37,6 +47,12 @@ const store = new Vuex.Store<State>({
},
[WITH_MUSIC](state, withMusic: boolean) {
state.withMusic = withMusic
},
[SET_DEV_1](state, dev1: string) {
state.dev1 = dev1
},
[SET_DEV_2](state, dev2: string) {
state.dev2 = dev2
}
},
actions: {
@@ -45,8 +61,14 @@ const store = new Vuex.Store<State>({
commit(SET_INTERVAL, interval)
}
},
setWithMusic({ commit }, withMusic: number) {
setWithMusic({ commit }, withMusic: boolean) {
commit(WITH_MUSIC, withMusic)
},
setDev1({ commit }, dev1: string) {
commit(SET_DEV_1, dev1)
},
setDev2({ commit }, dev2: string) {
commit(SET_DEV_2, dev2)
}
},
plugins: [vuexLocal.plugin]