history.js 920 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // import { REST } from 'api/rest-axios'
  2. import router from '../../router'
  3. export default {
  4. namespaced: true,
  5. router,
  6. // initial state
  7. state: {
  8. items: [],
  9. opened: false
  10. },
  11. // getters
  12. getters: {},
  13. // mutations
  14. mutations: {
  15. addItem (state, item) {
  16. state.items.push(item)
  17. },
  18. setOpened (state, opened) {
  19. state.opened = opened
  20. }
  21. },
  22. // actions
  23. actions: {
  24. addItem ({ dispatch, commit, state }, item) {
  25. console.log('history add item', item, router)
  26. commit('addItem', item)
  27. commit('setOpened', true)
  28. router.push({
  29. name: `item`,
  30. params: { uuid: item.uuid }
  31. })
  32. },
  33. navigateToItem ({ dispatch, commit, state }, item) {
  34. console.log('history navigate to item', item, router)
  35. // commit('addItem', item)
  36. router.push({
  37. name: `item`,
  38. params: { uuid: item.uuid }
  39. })
  40. }
  41. }
  42. }