history is functionnal and with state transition
This commit is contained in:
+3
-1
@@ -3,11 +3,13 @@ import Vuex from 'vuex'
|
||||
|
||||
import Corpus from './modules/corpus'
|
||||
import Search from './modules/search'
|
||||
import History from './modules/history'
|
||||
|
||||
Vue.use(Vuex)
|
||||
export default new Vuex.Store({
|
||||
modules: {
|
||||
Corpus,
|
||||
Search
|
||||
Search,
|
||||
History
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// import { REST } from 'api/rest-axios'
|
||||
import router from '../../router'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
router,
|
||||
// initial state
|
||||
state: {
|
||||
items: [],
|
||||
opened: false
|
||||
},
|
||||
|
||||
// getters
|
||||
getters: {},
|
||||
|
||||
// mutations
|
||||
mutations: {
|
||||
addItem (state, item) {
|
||||
state.items.push(item)
|
||||
},
|
||||
setOpened (state, opened) {
|
||||
state.opened = opened
|
||||
}
|
||||
},
|
||||
|
||||
// actions
|
||||
actions: {
|
||||
addItem ({ dispatch, commit, state }, item) {
|
||||
console.log('history add item', item, router)
|
||||
commit('addItem', item)
|
||||
commit('setOpened', true)
|
||||
router.push({
|
||||
name: `item`,
|
||||
params: { uuid: item.uuid }
|
||||
})
|
||||
},
|
||||
navigateToItem ({ dispatch, commit, state }, item) {
|
||||
console.log('history navigate to item', item, router)
|
||||
// commit('addItem', item)
|
||||
router.push({
|
||||
name: `item`,
|
||||
params: { uuid: item.uuid }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user