|
@@ -1,31 +1,27 @@
|
|
|
const state = {
|
|
|
visitedViews: [],
|
|
|
- cachedViews: [],
|
|
|
- menuDict: {}
|
|
|
+ cachedViews: []
|
|
|
}
|
|
|
|
|
|
const mutations = {
|
|
|
- SELECT_MENU: (state,menu)=> {
|
|
|
- state.menuDict[menu.url] = menu.title;
|
|
|
- },
|
|
|
ADD_VISITED_VIEW: (state, view) => {
|
|
|
console.log("ADD_VISITED_VIEW");
|
|
|
console.log(view.path);
|
|
|
- console.log(state.menuDict[view.path] );
|
|
|
|
|
|
- if (state.visitedViews.some(v => v.path === view.path)) return
|
|
|
+ if (state.visitedViews.some(v => v.fullPath === view.fullPath)) return
|
|
|
|
|
|
- // var newView = Object.assign({}, view, {
|
|
|
- // title: state.menuDict[view.path] || view.meta.title || 'no-name'
|
|
|
- // });
|
|
|
+ var newView = Object.assign({}, view, {
|
|
|
+ title: view.meta.title || 'no-name'
|
|
|
+ });
|
|
|
|
|
|
- // console.log(newView);
|
|
|
+ console.log(newView);
|
|
|
|
|
|
state.visitedViews.push({
|
|
|
path : view.path,
|
|
|
- title: state.menuDict[view.path] || view.meta.title || 'no-name',
|
|
|
+ title: view.query.title || view.meta.title || 'no-name',
|
|
|
meta: view.meta,
|
|
|
name: view.name,
|
|
|
+ query: view.query,
|
|
|
fullPath: view.fullPath
|
|
|
})
|
|
|
// state.visitedViews.push({
|
|
@@ -43,7 +39,7 @@ const mutations = {
|
|
|
|
|
|
DEL_VISITED_VIEW: (state, view) => {
|
|
|
for (const [i, v] of state.visitedViews.entries()) {
|
|
|
- if (v.path === view.path) {
|
|
|
+ if (v.fullPath === view.fullPath) {
|
|
|
state.visitedViews.splice(i, 1)
|
|
|
break
|
|
|
}
|
|
@@ -56,7 +52,7 @@ const mutations = {
|
|
|
|
|
|
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
|
|
|
state.visitedViews = state.visitedViews.filter(v => {
|
|
|
- return v.meta.affix || v.path === view.path
|
|
|
+ return v.meta.affix || v.fullPath === view.fullPath
|
|
|
})
|
|
|
},
|
|
|
DEL_OTHERS_CACHED_VIEWS: (state, view) => {
|
|
@@ -80,7 +76,7 @@ const mutations = {
|
|
|
|
|
|
UPDATE_VISITED_VIEW: (state, view) => {
|
|
|
for (let v of state.visitedViews) {
|
|
|
- if (v.path === view.path) {
|
|
|
+ if (v.fullPath === view.fullPath) {
|
|
|
v = Object.assign(v, view)
|
|
|
break
|
|
|
}
|
|
@@ -89,9 +85,6 @@ const mutations = {
|
|
|
}
|
|
|
|
|
|
const actions = {
|
|
|
- selectMenu({commit},menu) {
|
|
|
- commit('SELECT_MENU', menu)
|
|
|
- },
|
|
|
addView({ dispatch }, view) {
|
|
|
console.log("addView");
|
|
|
|
|
@@ -104,6 +97,7 @@ const actions = {
|
|
|
addCachedView({ commit }, view) {
|
|
|
commit('ADD_CACHED_VIEW', view)
|
|
|
},
|
|
|
+
|
|
|
delView({ dispatch, state }, view) {
|
|
|
return new Promise(resolve => {
|
|
|
dispatch('delVisitedView', view)
|