Merge branch 'develop'

Former-commit-id: 81095a219824f8ddf2d52a30df0f6ee4a69d0456
This commit is contained in:
liyang
2019-01-28 19:48:27 +08:00
3 changed files with 23 additions and 32 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "d2-admin",
"version": "1.6.14",
"version": "1.6.15",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
@@ -32,7 +32,7 @@
<el-dropdown
size="default"
split-button
@click="handleControlBtnClick"
@click="closeAll"
@command="command => handleControlItemClick(command)">
<d2-icon name="times-circle"/>
<el-dropdown-menu slot="dropdown">
@@ -131,8 +131,7 @@ export default {
this.contextmenuFlag = false
}
const params = {
pageSelect: tagName,
vm: this
pageSelect: tagName
}
switch (command) {
case 'left':
@@ -145,19 +144,13 @@ export default {
this.closeOther(params)
break
case 'all':
this.closeAll(this)
this.closeAll()
break
default:
this.$message.error('无效的操作')
break
}
},
/**
* @description 接收点击关闭控制上按钮的事件
*/
handleControlBtnClick () {
this.closeAll(this)
},
/**
* @description 接收点击 tab 标签的事件
*/
+19 -21
View File
@@ -1,6 +1,5 @@
import { get } from 'lodash'
// 设置文件
import router from '@/router'
import setting from '@/setting.js'
// 判定是否需要缓存
@@ -168,9 +167,9 @@ export default {
* @class opened
* @description 关闭一个 tag (关闭一个页面)
* @param {Object} state vuex state
* @param {Object} param { tagName: 要关闭的标签名字, vm: vue }
* @param {Object} param { tagName: 要关闭的标签名字 }
*/
close ({ state, commit, dispatch }, { tagName, vm }) {
close ({ state, commit, dispatch }, { tagName }) {
return new Promise(async resolve => {
// 下个新的页面
let newPage = state.opened[0]
@@ -208,7 +207,7 @@ export default {
params,
query
}
vm.$router.push(routerObj)
router.push(routerObj)
}
// end
resolve()
@@ -218,9 +217,9 @@ export default {
* @class opened
* @description 关闭当前标签左边的标签
* @param {Object} state vuex state
* @param {Object} param { pageSelect: 当前选中的tagName, vm: vue }
* @param {Object} param { pageSelect: 当前选中的tagName }
*/
closeLeft ({ state, commit, dispatch }, { pageSelect, vm } = {}) {
closeLeft ({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
@@ -234,8 +233,8 @@ export default {
state.opened.splice(1, currentIndex - 1).forEach(({ name }) => commit('keepAliveRemove', name))
}
state.current = pageAim
if (vm && vm.$route.fullPath !== pageAim) {
vm.$router.push(pageAim)
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
}
// 持久化
await dispatch('opend2db')
@@ -247,9 +246,9 @@ export default {
* @class opened
* @description 关闭当前标签右边的标签
* @param {Object} state vuex state
* @param {Object} param { pageSelect: 当前选中的tagName, vm: vue }
* @param {Object} param { pageSelect: 当前选中的tagName }
*/
closeRight ({ state, commit, dispatch }, { pageSelect, vm } = {}) {
closeRight ({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
@@ -262,8 +261,8 @@ export default {
state.opened.splice(currentIndex + 1).forEach(({ name }) => commit('keepAliveRemove', name))
// 设置当前的页面
state.current = pageAim
if (vm && vm.$route.fullPath !== pageAim) {
vm.$router.push(pageAim)
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
}
// 持久化
await dispatch('opend2db')
@@ -275,9 +274,9 @@ export default {
* @class opened
* @description 关闭当前激活之外的 tag
* @param {Object} state vuex state
* @param {Object} param { pageSelect: 当前选中的tagName, vm: vue }
* @param {Object} param { pageSelect: 当前选中的tagName }
*/
closeOther ({ state, commit, dispatch }, { pageSelect, vm } = {}) {
closeOther ({ state, commit, dispatch }, { pageSelect } = {}) {
return new Promise(async resolve => {
const pageAim = pageSelect || state.current
let currentIndex = 0
@@ -295,8 +294,8 @@ export default {
}
// 设置新的页面
state.current = pageAim
if (vm && vm.$route.fullPath !== pageAim) {
vm.$router.push(pageAim)
if (router.app.$route.fullPath !== pageAim) {
router.push(pageAim)
}
// 持久化
await dispatch('opend2db')
@@ -308,17 +307,16 @@ export default {
* @class opened
* @description 关闭所有 tag
* @param {Object} state vuex state
* @param {Object} vm vue
*/
closeAll ({ state, commit, dispatch }, vm) {
closeAll ({ state, commit, dispatch }) {
return new Promise(async resolve => {
// 删除打开的页面 并在缓存设置中删除
state.opened.splice(1).forEach(({ name }) => commit('keepAliveRemove', name))
// 持久化
await dispatch('opend2db')
// 关闭所有的标签页后需要判断一次现在是不是在首页
if (vm.$route.name !== 'index') {
vm.$router.push({
if (router.app.$route.name !== 'index') {
router.push({
name: 'index'
})
}