mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
add a module store to deal with api data and calls and maybe save data to avoid api recalls
This commit is contained in:
parent
55fe70ab33
commit
ea51885361
2 changed files with 25 additions and 1 deletions
22
app/src/helpers/dataStore.js
Normal file
22
app/src/helpers/dataStore.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import api from './api'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
state: () => ({
|
||||||
|
domains: undefined
|
||||||
|
}),
|
||||||
|
mutations: {
|
||||||
|
'SET_DATA' (state, { key, data }) {
|
||||||
|
state[key] = data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
async 'FETCH' ({ commit }, uri) {
|
||||||
|
return api.get('/' + uri).then(data => {
|
||||||
|
commit('SET_DATA', { data: data[uri], key: uri })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
|
|
||||||
|
import dataStore from '@/helpers/dataStore'
|
||||||
|
|
||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
|
@ -18,7 +20,6 @@ export default new Vuex.Store({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'YUNOHOST_INFOS' (state, data) {
|
'YUNOHOST_INFOS' (state, data) {
|
||||||
console.log('version changed', data)
|
|
||||||
state.yunohostInfos = data
|
state.yunohostInfos = data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -26,5 +27,6 @@ export default new Vuex.Store({
|
||||||
actions: {
|
actions: {
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {
|
||||||
|
data: dataStore
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue