优化菜单缓存逻辑
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
linkList: [],
|
linkList: [],
|
||||||
activePage: '',
|
activePage: '',
|
||||||
menuVisible: false,
|
menuVisible: false,
|
||||||
|
changeType: 0, //0-不刷新 1-刷新
|
||||||
menuItemList: [
|
menuItemList: [
|
||||||
{ key: '4', icon: 'reload', text: '刷 新' },
|
{ key: '4', icon: 'reload', text: '刷 新' },
|
||||||
{ key: '1', icon: 'arrow-left', text: '关闭左侧' },
|
{ key: '1', icon: 'arrow-left', text: '关闭左侧' },
|
||||||
@@ -98,25 +99,21 @@
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'$route': function(newRoute) {
|
'$route': function(newRoute) {
|
||||||
//console.log("新的路由",newRoute)
|
// console.log("新的路由",newRoute)
|
||||||
this.activePage = newRoute.fullPath
|
this.activePage = newRoute.fullPath
|
||||||
if (!this.multipage) {
|
if (!this.multipage) {
|
||||||
this.linkList = [newRoute.fullPath]
|
this.linkList = [newRoute.fullPath]
|
||||||
this.pageList = [Object.assign({},newRoute)]
|
this.pageList = [Object.assign({},newRoute)]
|
||||||
// update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
// update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||||
} else if(indexKey==newRoute.fullPath) {
|
} else if(indexKey==newRoute.fullPath) {
|
||||||
//首页时 判断是否缓存 没有缓存 刷新之
|
//首页时 直接刷新
|
||||||
if (newRoute.meta.keepAlive === false) {
|
this.routeReload()
|
||||||
this.routeReload()
|
|
||||||
}
|
|
||||||
// update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
// update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||||
}else if (this.linkList.indexOf(newRoute.fullPath) < 0) {
|
}else if (this.linkList.indexOf(newRoute.fullPath) < 0) {
|
||||||
this.linkList.push(newRoute.fullPath)
|
this.linkList.push(newRoute.fullPath)
|
||||||
this.pageList.push(Object.assign({},newRoute))
|
this.pageList.push(Object.assign({},newRoute))
|
||||||
// update-begin-author:sunjianlei date:20200103 for: 如果新增的页面配置了缓存路由,那么就强制刷新一遍
|
// update-begin-author:sunjianlei date:20200103 for: 如果新增的页面配置了缓存路由,那么就强制刷新一遍
|
||||||
if (newRoute.meta.keepAlive) {
|
this.routeReload()
|
||||||
this.routeReload()
|
|
||||||
}
|
|
||||||
// update-end-author:sunjianlei date:20200103 for: 如果新增的页面配置了缓存路由,那么就强制刷新一遍
|
// update-end-author:sunjianlei date:20200103 for: 如果新增的页面配置了缓存路由,那么就强制刷新一遍
|
||||||
} else if (this.linkList.indexOf(newRoute.fullPath) >= 0) {
|
} else if (this.linkList.indexOf(newRoute.fullPath) >= 0) {
|
||||||
let oldIndex = this.linkList.indexOf(newRoute.fullPath)
|
let oldIndex = this.linkList.indexOf(newRoute.fullPath)
|
||||||
@@ -124,8 +121,9 @@
|
|||||||
this.pageList.splice(oldIndex, 1, Object.assign({},newRoute,{meta:oldPositionRoute.meta}))
|
this.pageList.splice(oldIndex, 1, Object.assign({},newRoute,{meta:oldPositionRoute.meta}))
|
||||||
//给菜单id赋值,用于调用之后控制按钮的显示
|
//给菜单id赋值,用于调用之后控制按钮的显示
|
||||||
Vue.ls.set('funId', oldPositionRoute.meta.id, 7 * 24 * 60 * 60 * 1000)
|
Vue.ls.set('funId', oldPositionRoute.meta.id, 7 * 24 * 60 * 60 * 1000)
|
||||||
//每次切换都刷新
|
if(this.changeType) {
|
||||||
this.routeReload()
|
this.routeReload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'activePage': function(key) {
|
'activePage': function(key) {
|
||||||
@@ -180,9 +178,13 @@
|
|||||||
// update-end-author:sunjianlei date:20200120 for: 动态更改页面标题
|
// update-end-author:sunjianlei date:20200120 for: 动态更改页面标题
|
||||||
|
|
||||||
changePage(key) {
|
changePage(key) {
|
||||||
|
//切换页签
|
||||||
|
this.changeType = 0
|
||||||
this.activePage = key
|
this.activePage = key
|
||||||
},
|
},
|
||||||
tabCallBack() {
|
tabCallBack() {
|
||||||
|
//切换页签
|
||||||
|
this.changeType = 0
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
triggerWindowResizeEvent()
|
triggerWindowResizeEvent()
|
||||||
})
|
})
|
||||||
@@ -288,6 +290,7 @@
|
|||||||
let keyIndex = this.linkList.indexOf(key)
|
let keyIndex = this.linkList.indexOf(key)
|
||||||
if(keyIndex>=0){
|
if(keyIndex>=0){
|
||||||
//切换历史页签
|
//切换历史页签
|
||||||
|
this.changeType = 0
|
||||||
let currRouter = this.pageList[keyIndex]
|
let currRouter = this.pageList[keyIndex]
|
||||||
let meta = Object.assign({},currRouter.meta,{title:title})
|
let meta = Object.assign({},currRouter.meta,{title:title})
|
||||||
this.pageList.splice(keyIndex, 1, Object.assign({},currRouter,{meta:meta}))
|
this.pageList.splice(keyIndex, 1, Object.assign({},currRouter,{meta:meta}))
|
||||||
@@ -297,6 +300,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//打开新的页签
|
//打开新的页签
|
||||||
|
this.changeType = 1
|
||||||
this.pageList.push({
|
this.pageList.push({
|
||||||
name: title,
|
name: title,
|
||||||
path: key,
|
path: key,
|
||||||
|
|||||||
Reference in New Issue
Block a user