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: {
|
2023-04-06 14:20:11 +08:00
|
|
|
historicalSearch: []
|
2023-03-28 18:04:49 +08:00
|
|
|
},
|
|
|
|
getters: {
|
|
|
|
},
|
|
|
|
mutations: {
|
2023-04-06 14:20:11 +08:00
|
|
|
setHistoricalSearch(state, payload) {
|
|
|
|
state.historicalSearch = payload
|
2023-04-06 14:40:10 +08:00
|
|
|
|
|
|
|
localStorage.setItem('historicalSearch', JSON.stringify(payload));
|
|
|
|
|
|
|
|
|
2023-04-06 14:20:11 +08:00
|
|
|
}
|
2023-03-28 18:04:49 +08:00
|
|
|
},
|
|
|
|
actions: {
|
2023-04-06 14:40:10 +08:00
|
|
|
// 获取历史搜索的数据
|
2023-04-06 14:20:11 +08:00
|
|
|
fetchHistoricalSearch({ commit }) {
|
|
|
|
let historicalSearch = JSON.parse(localStorage.getItem('historicalSearch')) || []
|
|
|
|
commit('setHistoricalSearch', historicalSearch)
|
2023-04-06 14:40:10 +08:00
|
|
|
},
|
|
|
|
|
2023-03-28 18:04:49 +08:00
|
|
|
},
|
|
|
|
modules: {
|
|
|
|
}
|
|
|
|
})
|