|
|
|
@ -6,9 +6,7 @@ const state = {
|
|
|
|
|
|
|
|
|
|
const mutations = {
|
|
|
|
|
ADD_IFRAME_VIEW: (state, view) => {
|
|
|
|
|
// console.log(111);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
// console.log(view);
|
|
|
|
|
|
|
|
|
|
if (state.iframeViews.some((v) => v.path === view.path)) return;
|
|
|
|
|
state.iframeViews.push(
|
|
|
|
|
Object.assign({}, view, {
|
|
|
|
@ -17,9 +15,7 @@ const mutations = {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
ADD_VISITED_VIEW: (state, view) => {
|
|
|
|
|
// console.log(222);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
// console.log(view);
|
|
|
|
|
|
|
|
|
|
if (state.visitedViews.some((v) => v.path === view.path)) return;
|
|
|
|
|
state.visitedViews.push(
|
|
|
|
|
Object.assign({}, view, {
|
|
|
|
@ -28,18 +24,14 @@ const mutations = {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
ADD_CACHED_VIEW: (state, view) => {
|
|
|
|
|
// console.log(333);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
// console.log(view);
|
|
|
|
|
;
|
|
|
|
|
if (state.cachedViews.includes(view.name)) return;
|
|
|
|
|
if (view.meta && !view.meta.noCache) {
|
|
|
|
|
state.cachedViews.push(view.name);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
DEL_VISITED_VIEW: (state, view) => {
|
|
|
|
|
// console.log(444);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
// console.log(view);
|
|
|
|
|
|
|
|
|
|
for (const [i, v] of state.visitedViews.entries()) {
|
|
|
|
|
if (v.path === view.path) {
|
|
|
|
|
state.visitedViews.splice(i, 1);
|
|
|
|
@ -51,23 +43,19 @@ const mutations = {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
DEL_IFRAME_VIEW: (state, view) => {
|
|
|
|
|
// console.log(555);
|
|
|
|
|
// console.log(state,view);
|
|
|
|
|
|
|
|
|
|
state.iframeViews = state.iframeViews.filter(
|
|
|
|
|
(item) => item.path !== view.path
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
DEL_CACHED_VIEW: (state, view) => {
|
|
|
|
|
console.log(666);
|
|
|
|
|
console.log(state);
|
|
|
|
|
console.log(view);
|
|
|
|
|
|
|
|
|
|
const index = state.cachedViews.indexOf(view.name);
|
|
|
|
|
index > -1 && state.cachedViews.splice(index, 1);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
|
|
|
|
// console.log(777);
|
|
|
|
|
// console.log(state,view);
|
|
|
|
|
|
|
|
|
|
state.visitedViews = state.visitedViews.filter((v) => {
|
|
|
|
|
return v.meta.affix || v.path === view.path;
|
|
|
|
|
});
|
|
|
|
@ -76,8 +64,7 @@ const mutations = {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
|
|
|
|
// console.log(888);
|
|
|
|
|
// console.log(state,view);
|
|
|
|
|
|
|
|
|
|
const index = state.cachedViews.indexOf(view.name);
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
state.cachedViews = state.cachedViews.slice(index, index + 1);
|
|
|
|
@ -86,17 +73,14 @@ const mutations = {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
DEL_ALL_VISITED_VIEWS: (state) => {
|
|
|
|
|
// keep affix tags
|
|
|
|
|
// console.log(999);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
|
|
|
|
|
const affixTags = state.visitedViews.filter((tag) => tag.meta.affix);
|
|
|
|
|
state.visitedViews = affixTags;
|
|
|
|
|
state.iframeViews = [];
|
|
|
|
|
},
|
|
|
|
|
DEL_ALL_CACHED_VIEWS: (state) => {
|
|
|
|
|
state.cachedViews = [];
|
|
|
|
|
// console.log(101010);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
UPDATE_VISITED_VIEW: (state, view) => {
|
|
|
|
|
for (let v of state.visitedViews) {
|
|
|
|
|