| | |
| | | const viewer = { |
| | | state: { |
| | | viewer: null |
| | | viewer: null, |
| | | visitedViews: [], |
| | | cachedViews: [] |
| | | }, |
| | | mutations: { |
| | | SET_VIEWER (state, viewer) { |
| | | // console.log(viewer, 456) |
| | | state.viewer = viewer |
| | | }, |
| | | DEL_VISITED_VIEWS: (state, view) => { |
| | | for (const [i, v] of state.visitedViews.entries()) { |
| | | if (v.path === view.path) { |
| | | state.visitedViews.splice(i, 1) |
| | | break |
| | | } |
| | | } |
| | | for (const i of state.cachedViews) { |
| | | if (i === view.name) { |
| | | const index = state.cachedViews.indexOf(i) |
| | | state.cachedViews.splice(index, 1) |
| | | break |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | actions: { |
| | | |
| | | delVisitedViews ({ |
| | | commit, |
| | | state |
| | | }, view) { |
| | | return new Promise((resolve) => { |
| | | commit('DEL_VISITED_VIEWS', view) |
| | | resolve([...state.visitedViews]) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |