mirror of
https://github.com/kihashi/stardew_community_checklist.git
synced 2025-10-19 08:03:17 +00:00
Add vuex store.
This commit is contained in:
parent
cc89b4d4fa
commit
cb1fd8ede6
@ -3,6 +3,7 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
|
||||
require('./assets/sass/main.scss')
|
||||
|
||||
@ -12,6 +13,7 @@ Vue.config.productionTip = false
|
||||
new Vue({
|
||||
el: '#app',
|
||||
router,
|
||||
store,
|
||||
components: { App },
|
||||
template: '<App/>'
|
||||
})
|
||||
|
||||
28
src/store/index.js
Normal file
28
src/store/index.js
Normal file
@ -0,0 +1,28 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
StoredItems: {}
|
||||
},
|
||||
getters: {
|
||||
IsBundleItemRedeemed: (state) => (BundleItem) => {
|
||||
return state.StoredItems[BundleItem.bundle.id].hasOwnProperty(BundleItem.item.id)
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
RedeemItem (state, BundleItem) {
|
||||
state.StoredItems[BundleItem.bundle.id][BundleItem.item.id] = 1
|
||||
},
|
||||
UndoRedeemItem (state, BundleItem) {
|
||||
delete state.StoredItems[BundleItem.bundle.id][BundleItem.item.id]
|
||||
},
|
||||
AddBundles (state, Bundles) {
|
||||
for (let bundle of Bundles) {
|
||||
state.StoredItems.set(bundle.id, {})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user