32 lines
603 B
JavaScript
Raw Normal View History

2023-03-28 18:04:49 +08:00
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
historicalSearch: []
2023-03-28 18:04:49 +08:00
},
getters: {
},
mutations: {
setHistoricalSearch(state, payload) {
state.historicalSearch = payload
localStorage.setItem('historicalSearch', JSON.stringify(payload));
}
2023-03-28 18:04:49 +08:00
},
actions: {
// 获取历史搜索的数据
fetchHistoricalSearch({ commit }) {
let historicalSearch = JSON.parse(localStorage.getItem('historicalSearch')) || []
commit('setHistoricalSearch', historicalSearch)
},
2023-03-28 18:04:49 +08:00
},
modules: {
}
})