Implemented store to allow torrentSearch to tell our sidebar action buttons how many results we got

This commit is contained in:
2019-10-04 00:20:03 +02:00
parent c8f9cb7e22
commit a6f72c8f6b
3 changed files with 56 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import Vue from 'vue'
import VueRouter from 'vue-router'
import axios from 'axios'
import router from './routes'
import store from './store'
import Toast from './plugins/Toast'
import DataTablee from 'vue-data-tablee'
@@ -19,6 +20,7 @@ Vue.use(VModal, { dialog: true })
new Vue({
el: '#app',
router,
store,
components: { App },
template: '<App />'
})

View File

@@ -0,0 +1,40 @@
export default {
namespaced: true,
state: {
results: [],
resultCount: null
},
getters: {
results: (state) => {
return state.results
},
resultCount: (state) => {
return state.resultCount
}
},
mutations: {
SET_RESULTS: (state, results) => {
state.results = results;
},
SET_RESULT_COUNT: (state, count) => {
state.resultCount = count;
},
RESET: (state) => {
state.results = []
state.resultCount = null
}
},
actions: {
setResults({ commit }, results) {
commit('SET_RESULTS', results)
},
setResultCount({ commit }, count) {
commit('SET_RESULT_COUNT', count)
},
reset({ commit }) {
commit('RESET')
}
}
}

14
src/store.js Normal file
View File

@@ -0,0 +1,14 @@
import Vue from 'vue'
import Vuex from 'vuex'
import torrentModule from './modules/torrentModule.js'
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
torrentModule
}
})
export default store