1234567891011121314151617181920212223242526272829303132333435 |
- const state = {
- clickedCells: JSON.parse(sessionStorage.getItem('clickedCells')) || []
- }
- const mutations = {
- ADD_CLICKED_CELL(state, cell) {
- state.clickedCells.some(item =>
- Object.keys(item).every(key => {
- item[key] === cell[key]
- })
- ) || (state.clickedCells.push(cell), sessionStorage.setItem('clickedCells', JSON.stringify(state.clickedCells)))
- }
- }
- const actions = {
- addClickedCell({ commit }, cell) {
- commit('ADD_CLICKED_CELL', cell)
- }
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|