|
@@ -1,11 +1,11 @@
|
|
const state = {
|
|
const state = {
|
|
visitedViews: [],
|
|
visitedViews: [],
|
|
- cachedViews: []
|
|
|
|
|
|
+ cachedViews: ['AppChildMain']
|
|
}
|
|
}
|
|
|
|
|
|
const mutations = {
|
|
const mutations = {
|
|
ADD_VISITED_VIEW: (state, view) => {
|
|
ADD_VISITED_VIEW: (state, view) => {
|
|
- if (state.visitedViews.some(v => v.path === view.path)) return
|
|
|
|
|
|
+ if (state.visitedViews.some((v) => v.path === view.path)) return
|
|
state.visitedViews.push(
|
|
state.visitedViews.push(
|
|
Object.assign({}, view, {
|
|
Object.assign({}, view, {
|
|
title: view.meta.title || 'no-name'
|
|
title: view.meta.title || 'no-name'
|
|
@@ -33,7 +33,7 @@ const mutations = {
|
|
},
|
|
},
|
|
|
|
|
|
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
|
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
|
- state.visitedViews = state.visitedViews.filter(v => {
|
|
|
|
|
|
+ state.visitedViews = state.visitedViews.filter((v) => {
|
|
return v.meta.affix || v.path === view.path
|
|
return v.meta.affix || v.path === view.path
|
|
})
|
|
})
|
|
},
|
|
},
|
|
@@ -47,12 +47,12 @@ const mutations = {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- DEL_ALL_VISITED_VIEWS: state => {
|
|
|
|
|
|
+ DEL_ALL_VISITED_VIEWS: (state) => {
|
|
// keep affix tags
|
|
// keep affix tags
|
|
- const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
|
|
|
|
|
|
+ const affixTags = state.visitedViews.filter((tag) => tag.meta.affix)
|
|
state.visitedViews = affixTags
|
|
state.visitedViews = affixTags
|
|
},
|
|
},
|
|
- DEL_ALL_CACHED_VIEWS: state => {
|
|
|
|
|
|
+ DEL_ALL_CACHED_VIEWS: (state) => {
|
|
state.cachedViews = []
|
|
state.cachedViews = []
|
|
},
|
|
},
|
|
|
|
|
|
@@ -79,7 +79,7 @@ const actions = {
|
|
},
|
|
},
|
|
|
|
|
|
delView({ dispatch, state }, view) {
|
|
delView({ dispatch, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
dispatch('delVisitedView', view)
|
|
dispatch('delVisitedView', view)
|
|
dispatch('delCachedView', view)
|
|
dispatch('delCachedView', view)
|
|
resolve({
|
|
resolve({
|
|
@@ -89,20 +89,20 @@ const actions = {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
delVisitedView({ commit, state }, view) {
|
|
delVisitedView({ commit, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
commit('DEL_VISITED_VIEW', view)
|
|
commit('DEL_VISITED_VIEW', view)
|
|
resolve([...state.visitedViews])
|
|
resolve([...state.visitedViews])
|
|
})
|
|
})
|
|
},
|
|
},
|
|
delCachedView({ commit, state }, view) {
|
|
delCachedView({ commit, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
commit('DEL_CACHED_VIEW', view)
|
|
commit('DEL_CACHED_VIEW', view)
|
|
resolve([...state.cachedViews])
|
|
resolve([...state.cachedViews])
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
delOthersViews({ dispatch, state }, view) {
|
|
delOthersViews({ dispatch, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
dispatch('delOthersVisitedViews', view)
|
|
dispatch('delOthersVisitedViews', view)
|
|
dispatch('delOthersCachedViews', view)
|
|
dispatch('delOthersCachedViews', view)
|
|
resolve({
|
|
resolve({
|
|
@@ -112,20 +112,20 @@ const actions = {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
delOthersVisitedViews({ commit, state }, view) {
|
|
delOthersVisitedViews({ commit, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
commit('DEL_OTHERS_VISITED_VIEWS', view)
|
|
commit('DEL_OTHERS_VISITED_VIEWS', view)
|
|
resolve([...state.visitedViews])
|
|
resolve([...state.visitedViews])
|
|
})
|
|
})
|
|
},
|
|
},
|
|
delOthersCachedViews({ commit, state }, view) {
|
|
delOthersCachedViews({ commit, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
commit('DEL_OTHERS_CACHED_VIEWS', view)
|
|
commit('DEL_OTHERS_CACHED_VIEWS', view)
|
|
resolve([...state.cachedViews])
|
|
resolve([...state.cachedViews])
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
delAllViews({ dispatch, state }, view) {
|
|
delAllViews({ dispatch, state }, view) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
dispatch('delAllVisitedViews', view)
|
|
dispatch('delAllVisitedViews', view)
|
|
dispatch('delAllCachedViews', view)
|
|
dispatch('delAllCachedViews', view)
|
|
resolve({
|
|
resolve({
|
|
@@ -135,13 +135,13 @@ const actions = {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
delAllVisitedViews({ commit, state }) {
|
|
delAllVisitedViews({ commit, state }) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
commit('DEL_ALL_VISITED_VIEWS')
|
|
commit('DEL_ALL_VISITED_VIEWS')
|
|
resolve([...state.visitedViews])
|
|
resolve([...state.visitedViews])
|
|
})
|
|
})
|
|
},
|
|
},
|
|
delAllCachedViews({ commit, state }) {
|
|
delAllCachedViews({ commit, state }) {
|
|
- return new Promise(resolve => {
|
|
|
|
|
|
+ return new Promise((resolve) => {
|
|
commit('DEL_ALL_CACHED_VIEWS')
|
|
commit('DEL_ALL_CACHED_VIEWS')
|
|
resolve([...state.cachedViews])
|
|
resolve([...state.cachedViews])
|
|
})
|
|
})
|