Skip to content

Commit

Permalink
Merge branch 'hotfix/1.5.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
FairyEver committed Nov 6, 2018
2 parents 97240ed + 0c19f83 commit 85cebf9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d2-admin",
"version": "1.5.6",
"version": "1.5.7",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
Expand Down
5 changes: 1 addition & 4 deletions src/layout/header-aside/components/header-size/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ export default {
// 清空缓存设置
this.pageKeepAliveClean()
// 刷新此页面
const { path, query } = this.$route
this.$router.replace({
path: '/redirect/' + JSON.stringify({ path, query })
})
this.$router.replace('/refresh')
}
},
immediate: true
Expand Down
33 changes: 25 additions & 8 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,36 @@ const frameIn = [
redirect: { name: 'index' },
component: layoutHeaderAside,
children: [
// 首页 必须 name:index
{
path: 'index',
name: 'index',
meta,
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()
}
}
]
},
Expand All @@ -28,14 +53,6 @@ const frameIn = [
* 在主框架之外显示
*/
const frameOut = [
// 页面重定向使用 必须保留
{
path: '/redirect/:path*',
component: {
beforeCreate () { this.$router.replace(JSON.parse(this.$route.params.path)) },
render: h => h()
}
},
// 登录
{
path: '/login',
Expand Down
19 changes: 9 additions & 10 deletions src/store/modules/d2admin/modules/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { remove, get } from 'lodash'
// 设置文件
import setting from '@/setting.js'

// 判定是否需要缓存
const isKeepAlive = data => get(data, 'meta.cache', false)

export default {
namespaced: true,
state: {
Expand Down Expand Up @@ -87,7 +90,9 @@ export default {
page.query = query || page.query
state.opened.splice(index, 1, page)
// 增加缓存设置
commit('keepAlivePush', page.name)
if (isKeepAlive(page)) {
commit('keepAlivePush', page.name)
}
// 持久化
await dispatch('opend2db')
// end
Expand All @@ -109,7 +114,7 @@ export default {
// 添加进当前显示的页面数组
state.opened.push(newTag)
// 如果这个页面需要缓存 将其添加到缓存设置
if (get(newTag, 'meta.cache', false)) {
if (isKeepAlive(newTag)) {
commit('keepAlivePush', tag.name)
}
// 持久化
Expand Down Expand Up @@ -145,6 +150,7 @@ export default {
} else {
// 页面以前没有打开过
let page = state.pool.find(t => t.name === name)
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) {
await dispatch('add', {
tag: page,
Expand Down Expand Up @@ -334,14 +340,7 @@ export default {
* @param {Object} state vuex state
*/
keepAliveRefresh (state) {
state.keepAlive = state.opened.filter(item => {
if (item.meta) {
if (item.meta.notCache) {
return false
}
}
return true
}).map(e => e.name)
state.keepAlive = state.opened.filter(item => isKeepAlive(item)).map(e => e.name)
},
/**
* @description 删除一个页面的缓存设置
Expand Down

0 comments on commit 85cebf9

Please sign in to comment.