anchor.js 423 B

12345678910111213141516171819202122
  1. export default {
  2. namespaced: true,
  3. state: {
  4. shown: false,
  5. hash: ''
  6. },
  7. getters: {},
  8. mutations: {
  9. anchorChange: (state, opts) => {
  10. state.shown = (opts.shown === true)
  11. state.hash = opts.hash || ''
  12. }
  13. },
  14. actions: {
  15. open({ commit }, hash) {
  16. commit('anchorChange', { shown: true, hash })
  17. },
  18. close({ commit }) {
  19. commit('anchorChange', { shown: false })
  20. }
  21. }
  22. }