no message

Former-commit-id: 6c0824b8d2e59ef3a72a65a6044c1217cd3a351d [formerly c9f42aa09c4b0b5de2ac5473f9384d6f7e187063] [formerly 6c0824b8d2e59ef3a72a65a6044c1217cd3a351d [formerly c9f42aa09c4b0b5de2ac5473f9384d6f7e187063] [formerly 6c0824b8d2e59ef3a72a65a6044c1217cd3a351d [formerly c9f42aa09c4b0b5de2ac5473f9384d6f7e187063] [formerly c9f42aa09c4b0b5de2ac5473f9384d6f7e187063 [formerly 5dde11521f5740d96ce6b0c8b4d4dc6ec738bf57 [formerly e474ecb99ef86f507fc991cb4aeb89b6f4b7afc0]]]]]
Former-commit-id: 81e5bed2d676b45a8097efe31e1862e2065a8e54
Former-commit-id: 82dad2622857f00c98550e67eb002617f76871d5
Former-commit-id: d87b796d20ce2f6e113c44b45e09e88f154788be [formerly 3f52ba8cba47a6470c20c9495b639959f74022e3]
Former-commit-id: 054f1738830a6c8af8385e54c06efc097ecd4259
Former-commit-id: 61560008239c38171cf4798db3ba5763dbf3108a
Former-commit-id: ddff9ce6841ba7387b1a572321b5723b442839bf
Former-commit-id: 8f689cf6a6844f6afa197e1238954636b98836d8
Former-commit-id: c218d2c370666254593f7102c2a959ffdd175583
This commit is contained in:
liyang
2018-06-30 17:52:57 +08:00
parent 6ec19d0994
commit e09198e49b
6 changed files with 73 additions and 41 deletions

View File

@@ -34,7 +34,9 @@
</div>
<div class="d2-layout-main-body">
<transition name="fade-transverse">
<router-view/>
<keep-alive :include="pageCacheList">
<router-view/>
</keep-alive>
</transition>
</div>
</el-main>
@@ -68,7 +70,8 @@ export default {
computed: {
...mapState({
themeActive: state => state.d2admin.themeActive,
isGrayMode: state => state.d2admin.isGrayMode
isGrayMode: state => state.d2admin.isGrayMode,
pageCacheList: state => state.d2admin.pageCacheList
}),
styleLayoutMainGroup () {
return {

View File

@@ -1,13 +1,13 @@
<template>
<el-tabs
class="d2-multiple-page-control"
v-model="activeName"
:value="pageCurrent"
type="card"
@tab-click="handleClick">
<el-tab-pane
v-for="(page, index) in pageOpenedList"
:key="index"
:label="page.title"
:label="page.name"
:name="page.name">
</el-tab-pane>
</el-tabs>
@@ -23,12 +23,20 @@ export default {
},
computed: {
...mapState({
pageOpenedList: state => state.d2admin.pageOpenedList
pageOpenedList: state => state.d2admin.pageOpenedList,
pageCurrent: state => state.d2admin.pageCurrent
})
},
methods: {
handleClick (tab, event) {
// console.log(tab, event)
const page = this.pageOpenedList.find(page => page.name === tab.name)
if (page) {
this.$router.push({
name: page.name,
params: page.argu,
query: page.query
})
}
}
}
}

View File

@@ -6,7 +6,8 @@ const db = low(adapter)
db.defaults({
themeActive: [],
pageOpenedList: []
pageOpenedList: [],
pageCacheList: []
})
.write()

View File

@@ -59,21 +59,16 @@ util.openNewPage = function (vm, name, argu, query) {
})
if (pageOpend) {
// 页面以前打开过 但是新的页面可能 name 一样,参数不一样
vm.$store.commit('d2adminpageOpenedListUpdateItem', {
index: pageOpendIndex,
argu,
query
})
vm.$store.commit('d2adminpageOpenedListUpdateItem', { index: pageOpendIndex, argu, query })
} else {
// 页面以前没有打开过
const tagPool = vm.$store.state.d2admin.tagPool
let tag = tagPool.find(t => t.name === name)
if (tag) {
vm.$store.commit('d2adminTagIncreate', {
tag, argu, query
})
vm.$store.commit('d2adminTagIncreate', { tag, argu, query })
}
}
vm.$store.commit('d2adminPageSetCurrentName', name)
}
/**
@@ -81,7 +76,7 @@ util.openNewPage = function (vm, name, argu, query) {
* @param {*} ele element
* @param {array} targetArr array
*/
util.oneOf = function (ele, targetArr) {
util.isOneOf = function (ele, targetArr) {
if (targetArr.indexOf(ele) >= 0) {
return true
} else {

View File

@@ -39,13 +39,6 @@ router.afterEach(to => {
// 需要的信息
const app = router.app
const { name, params, query } = to
// dev
console.group('router.afterEach')
console.log('app: ', app)
console.log('name: ', name)
console.log('params: ', params)
console.log('query: ', query)
console.groupEnd()
// 多页控制 打开新的页面
util.openNewPage(app, name, params, query)
})

View File

@@ -11,29 +11,36 @@ export default {
// 主题
themeList,
themeActive: themeList[1],
// 可以在多页 tab 模式下显示的页面
tagPool: [],
// 当前显示的多页面列表
pageOpenedList: [
{
name: 'index',
title: '首页'
}
{ name: 'index', title: '首页' }
],
// 可以在多页 tab 模式下显示的页面
tagPool: []
// 当前页面
pageCurrent: '',
// 使用缓存的页面 (需要在页面中写 name)
pageCacheList: [],
// 不使用缓存的页面
pageDisableCacheList: [
'no-cache'
]
},
mutations: {
/**
* 设置当前激活的页面 name
* @param {state} state vuex state
* @param {string} name new name
*/
d2adminPageSetCurrentName (state, name) {
state.pageCurrent = name
},
/**
* 更新页面列表上的某一项
* @param {state} state vuex state
* @param {info} param1 new page info
*/
d2adminpageOpenedListUpdateItem (state, { index, argu, query }) {
// dev
console.group('d2adminpageOpenedListUpdateItem')
console.log('index: ', index)
console.log('argu: ', argu)
console.log('query: ', query)
console.groupEnd()
// 更新页面列表某一项
let page = state.pageOpenedList[index]
page.argu = argu || page.argu
@@ -64,12 +71,37 @@ export default {
* @param {object} param1 new tag info
*/
d2adminTagIncreate (state, { tag, argu, query }) {
// if (!Util.oneOf(tagObj.name, state.dontCache)) {
// state.cachePage.push(tagObj.name);
// localStorage.cachePage = JSON.stringify(state.cachePage);
// }
// state.pageOpenedList.push(tagObj);
// localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
// 设置新的 tag
let newTag = tag
newTag.argu = argu || newTag.argu
newTag.query = query || newTag.query
// 检查这个页面是不是属于不使用缓存的页面
if (!util.isOneOf(newTag.name, state.pageDisableCacheList)) {
// 在缓存页面的列表加入这个页面的 name
state.pageCacheList.push(newTag.name)
// 更新设置到数据库
const setting = db.get('pageCacheList').find({uuid: util.uuid()})
if (setting.value()) {
setting.assign({value: state.pageCacheList}).write()
} else {
db.get('pageCacheList').push({
uuid: util.uuid(),
value: state.pageCacheList
}).write()
}
}
// 添加进当前显示的页面数组
state.pageOpenedList.push(newTag)
// 更新设置到数据库
const setting = db.get('pageOpenedList').find({uuid: util.uuid()})
if (setting.value()) {
setting.assign({value: state.pageOpenedList}).write()
} else {
db.get('pageOpenedList').push({
uuid: util.uuid(),
value: state.pageOpenedList
}).write()
}
console.log('d2adminTagIncreate')
},
/**