mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-12-17 07:30:47 +00:00
outils de création de sorts/monstres/objets
This commit is contained in:
parent
6237f0e6a2
commit
a6986c42c6
48 changed files with 2743 additions and 259 deletions
63
docs/.vuepress/store/modules/mySpells.js
Normal file
63
docs/.vuepress/store/modules/mySpells.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import {sortByString} from '@theme/util/filterHelpers'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: {
|
||||
spells: [],
|
||||
},
|
||||
|
||||
getters: {
|
||||
spells: state => state.spells,
|
||||
},
|
||||
|
||||
actions: {
|
||||
reset: ({ commit }) => {
|
||||
commit('resetSpells')
|
||||
},
|
||||
updateSpells: ({ commit }, payload) => {
|
||||
commit('setSpells', payload)
|
||||
},
|
||||
addSpell: ({ commit }, payload) => {
|
||||
commit('addSpell', payload)
|
||||
},
|
||||
removeSpell: ({ commit }, payload) => {
|
||||
commit('removeSpell', payload)
|
||||
},
|
||||
},
|
||||
|
||||
mutations: {
|
||||
initialiseStore (state) {
|
||||
// Récupération des données utilisateurs depuis le navigateur
|
||||
if(localStorage.getItem('mySpells') && localStorage.getItem('mySpells') !== undefined) {
|
||||
let localStorageData = JSON.parse(localStorage.getItem('mySpells'))
|
||||
state.spells = localStorageData.spells
|
||||
}
|
||||
},
|
||||
setSpells: (state, payload) => {
|
||||
state.spells = payload
|
||||
},
|
||||
resetSpells: (state) => {
|
||||
state.spells = []
|
||||
},
|
||||
addSpell: (state, payload) => {
|
||||
state.spells.push(payload)
|
||||
state.spells.sort((a, b) => { return sortByString(a.title, b.title) })
|
||||
},
|
||||
updateSpell: (state, payload) => {
|
||||
state.spells.forEach((spell, idx) => {
|
||||
if (spell.key == payload.key) {
|
||||
state.spells[idx] = payload
|
||||
}
|
||||
})
|
||||
},
|
||||
removeSpell: (state, payload) => {
|
||||
state.spells.forEach((spell, idx) => {
|
||||
if (spell.key == payload.key) {
|
||||
state.spells.splice(idx, 1)
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue