Merge branch 'hotfix/1.5.7'

Former-commit-id: 85cebf9ea5a4dfb95a70ff466e11cc1e0cc19ef9
This commit is contained in:
liyang
2018-11-06 23:30:02 +08:00
4 changed files with 36 additions and 23 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "d2-admin", "name": "d2-admin",
"version": "1.5.6", "version": "1.5.7",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve --open", "serve": "vue-cli-service serve --open",
@@ -40,10 +40,7 @@ export default {
// 清空缓存设置 // 清空缓存设置
this.pageKeepAliveClean() this.pageKeepAliveClean()
// 刷新此页面 // 刷新此页面
const { path, query } = this.$route this.$router.replace('/refresh')
this.$router.replace({
path: '/redirect/' + JSON.stringify({ path, query })
})
} }
}, },
immediate: true immediate: true
+25 -8
View File
@@ -13,11 +13,36 @@ const frameIn = [
redirect: { name: 'index' }, redirect: { name: 'index' },
component: layoutHeaderAside, component: layoutHeaderAside,
children: [ children: [
// 首页 必须 name:index
{ {
path: 'index', path: 'index',
name: 'index', name: 'index',
meta, meta,
component: () => import('@/pages/index') component: () => import('@/pages/index')
},
// 刷新页面 必须保留
{
path: 'refresh',
name: 'refresh',
hidden: true,
component: {
beforeRouteEnter (to, from, next) {
next(vm => vm.$router.replace(from.fullPath))
},
render: h => h()
}
},
// 页面重定向 必须保留
{
path: 'redirect/:route*',
name: 'redirect',
hidden: true,
component: {
beforeRouteEnter (to, from, next) {
next(vm => vm.$router.replace(JSON.parse(from.params.route)))
},
render: h => h()
}
} }
] ]
}, },
@@ -28,14 +53,6 @@ const frameIn = [
* 在主框架之外显示 * 在主框架之外显示
*/ */
const frameOut = [ const frameOut = [
// 页面重定向使用 必须保留
{
path: '/redirect/:path*',
component: {
beforeCreate () { this.$router.replace(JSON.parse(this.$route.params.path)) },
render: h => h()
}
},
// 登录 // 登录
{ {
path: '/login', path: '/login',
+8 -9
View File
@@ -3,6 +3,9 @@ import { remove, get } from 'lodash'
// 设置文件 // 设置文件
import setting from '@/setting.js' import setting from '@/setting.js'
// 判定是否需要缓存
const isKeepAlive = data => get(data, 'meta.cache', false)
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
@@ -87,7 +90,9 @@ export default {
page.query = query || page.query page.query = query || page.query
state.opened.splice(index, 1, page) state.opened.splice(index, 1, page)
// 增加缓存设置 // 增加缓存设置
if (isKeepAlive(page)) {
commit('keepAlivePush', page.name) commit('keepAlivePush', page.name)
}
// 持久化 // 持久化
await dispatch('opend2db') await dispatch('opend2db')
// end // end
@@ -109,7 +114,7 @@ export default {
// 添加进当前显示的页面数组 // 添加进当前显示的页面数组
state.opened.push(newTag) state.opened.push(newTag)
// 如果这个页面需要缓存 将其添加到缓存设置 // 如果这个页面需要缓存 将其添加到缓存设置
if (get(newTag, 'meta.cache', false)) { if (isKeepAlive(newTag)) {
commit('keepAlivePush', tag.name) commit('keepAlivePush', tag.name)
} }
// 持久化 // 持久化
@@ -145,6 +150,7 @@ export default {
} else { } else {
// 页面以前没有打开过 // 页面以前没有打开过
let page = state.pool.find(t => t.name === name) let page = state.pool.find(t => t.name === name)
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) { if (page) {
await dispatch('add', { await dispatch('add', {
tag: page, tag: page,
@@ -334,14 +340,7 @@ export default {
* @param {Object} state vuex state * @param {Object} state vuex state
*/ */
keepAliveRefresh (state) { keepAliveRefresh (state) {
state.keepAlive = state.opened.filter(item => { state.keepAlive = state.opened.filter(item => isKeepAlive(item)).map(e => e.name)
if (item.meta) {
if (item.meta.notCache) {
return false
}
}
return true
}).map(e => e.name)
}, },
/** /**
* @description 删除一个页面的缓存设置 * @description 删除一个页面的缓存设置