/* * @Author: Badguy * @Date: 2022-03-08 17:31:03 * @LastEditTime: 2022-05-17 20:14:20 * @LastEditors: your name * @Description: 页面缓存 * have a nice day! */ 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 }