no message

Former-commit-id: 0c19f83985ef8b25d0c30a7fb861808a6490c180
This commit is contained in:
liyang
2018-11-06 23:29:50 +08:00
parent 9de364f6ee
commit d4c28522fe
4 changed files with 36 additions and 23 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "d2-admin",
"version": "1.5.6",
"version": "1.5.7",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
@@ -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
+25 -8
View File
@@ -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()
}
}
]
},
@@ -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',
+9 -10
View File
@@ -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: {
@@ -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
@@ -109,7 +114,7 @@ export default {
// 添加进当前显示的页面数组
state.opened.push(newTag)
// 如果这个页面需要缓存 将其添加到缓存设置
if (get(newTag, 'meta.cache', false)) {
if (isKeepAlive(newTag)) {
commit('keepAlivePush', tag.name)
}
// 持久化
@@ -145,6 +150,7 @@ export default {
} else {
// 页面以前没有打开过
let page = state.pool.find(t => t.name === name)
// 如果这里没有找到 page 代表这个路由虽然在框架内 但是不参与标签页显示
if (page) {
await dispatch('add', {
tag: page,
@@ -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 删除一个页面的缓存设置