From bc97252bd86163e5e8de0af6f52964e469bae904 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Sun, 1 Jul 2018 11:52:33 +0800 Subject: [PATCH] no message Former-commit-id: 057dd0a1deaad680e991751bd1a36a9d17825fa8 [formerly 057dd0a1deaad680e991751bd1a36a9d17825fa8 [formerly 057dd0a1deaad680e991751bd1a36a9d17825fa8 [formerly 057dd0a1deaad680e991751bd1a36a9d17825fa8 [formerly 8e83a63e10145658744dd21445dad8eba44466a0 [formerly bd51475e9a45b64342a539141a2d3bad2b93defc]]]]] Former-commit-id: 596bba56eb613636f5f5c7c7f5cbdb55a3d250d9 Former-commit-id: d6b4414ef70ac46f6c3c72392166d5d9d4810d10 Former-commit-id: c07b8cc58f3c720acb72e1393bf0fd13547cf329 [formerly 5ed4b1e3f9a4ef644f679333a491940a9c6af078] Former-commit-id: c105880757bab8347a1c01d2c80f3784e0644bd8 Former-commit-id: b6129e20f9b75fce0d57eaad8db6498081b0ce51 Former-commit-id: 7612a3fe80fc49b88f8d850cb95a801e3c55ec69 Former-commit-id: 2a12c98c9f4d98436aed048cb079746dcc111b57 Former-commit-id: 38c475e3433acee4767d71aec229899729d1e01f --- .../core/d2-multiple-page-control/index.vue | 22 +++--- src/store/modules/d2admin.js | 77 ++++++++++++++----- 2 files changed, 68 insertions(+), 31 deletions(-) diff --git a/src/components/core/d2-multiple-page-control/index.vue b/src/components/core/d2-multiple-page-control/index.vue index 0411588d..ede0c9ae 100644 --- a/src/components/core/d2-multiple-page-control/index.vue +++ b/src/components/core/d2-multiple-page-control/index.vue @@ -65,20 +65,20 @@ export default { handleControlItemClick (command) { switch (command) { case 'left': - console.log('left') - break; + this.closeAllTagLeft() + break case 'right': - console.log('right') - break; + this.closeAllTagRight() + break case 'other': - console.log('other') - break; + this.closeAllTagOther() + break case 'all': - console.log('all') - break; + this.closeAllTagAll() + break default: console.log('无效指令') - break; + break } }, /** @@ -104,7 +104,7 @@ export default { /** * 点击 tab 上的删除按钮后首先触发这里 */ - handleTabsEdit(tagName, action) { + handleTabsEdit (tagName, action) { if (action === 'remove') { // 首页的删除按钮已经隐藏 因此这里不用判断是 index this.closeTag(tagName) @@ -126,7 +126,7 @@ export default { * 关闭其它的 tag */ closeAllTagOther () { - // + this.$store.commit('d2adminTagCloseOther') }, /** * 关闭全部的 tag diff --git a/src/store/modules/d2admin.js b/src/store/modules/d2admin.js index 5af348ab..9deb3927 100644 --- a/src/store/modules/d2admin.js +++ b/src/store/modules/d2admin.js @@ -22,7 +22,8 @@ export default { }, mutations: { /** - * 将 state 中某一项存储到数据库 + * @class 通用工具 + * @description 将 state 中某一项存储到数据库 * @param {state} state vuex state */ d2adminVuex2Db (state, key) { @@ -37,7 +38,8 @@ export default { } }, /** - * 设置当前激活的页面 name + * @class pageCurrent + * @description 设置当前激活的页面 name * @param {state} state vuex state * @param {string} name new name */ @@ -45,7 +47,17 @@ export default { state.pageCurrent = name }, /** - * 更新页面列表上的某一项 + * @class tagPool + * @description 保存 tagPool (候选池) + * @param {state} state vuex state + * @param {Array} tagPool tags + */ + d2adminTagPoolSet (state, tagPool) { + state.tagPool = tagPool + }, + /** + * @class pageOpenedList + * @description 更新页面列表上的某一项 * @param {state} state vuex state * @param {info} param1 new page info */ @@ -59,20 +71,13 @@ export default { this.commit('d2adminVuex2Db', 'pageOpenedList') }, /** - * 保存 tagPool (候选池) - * @param {state} state vuex state - * @param {Array} tagPool tags - */ - d2adminTagPoolSet (state, tagPool) { - state.tagPool = tagPool - }, - /** - * 新增一个 tag (打开一个页面) + * @class pageOpenedList + * @description 新增一个 tag (打开一个页面) * @param {state} state vuex state * @param {object} param1 new tag info */ d2adminTagIncreate (state, { tag, argu, query }) { - // 设置新的 tag + // 设置新的 tag 在新打开一个以前没打开过的页面时使用 let newTag = tag newTag.argu = argu || newTag.argu newTag.query = query || newTag.query @@ -82,7 +87,8 @@ export default { this.commit('d2adminVuex2Db', 'pageOpenedList') }, /** - * 关闭一个 tag (关闭一个页面) + * @class pageOpenedList + * @description 关闭一个 tag (关闭一个页面) * @param {state} state vuex state * @param {string} name close tag name */ @@ -92,16 +98,43 @@ export default { if (index >= 0) { state.pageOpenedList.splice(index, 1) } + // 更新设置到数据库 + this.commit('d2adminVuex2Db', 'pageOpenedList') }, /** - * 关闭所有 tag + * @class pageOpenedList + * @description 关闭当前激活之外的 tag + * @param {state} state vuex state + */ + d2adminTagCloseOther (state) { + let currentIndex = 0 + state.pageOpenedList.forEach((page, index) => { + if (page.name === state.pageCurrent) { + currentIndex = index + } + }) + if (currentIndex === 0) { + state.pageOpenedList.splice(1) + } else { + state.pageOpenedList.splice(currentIndex + 1) + state.pageOpenedList.splice(1, currentIndex - 1) + } + // 更新设置到数据库 + this.commit('d2adminVuex2Db', 'pageOpenedList') + }, + /** + * @class pageOpenedList + * @description 关闭所有 tag * @param {state} state vuex state */ d2adminTagCloseAll (state) { state.pageOpenedList.splice(1) + // 更新设置到数据库 + this.commit('d2adminVuex2Db', 'pageOpenedList') }, /** - * 切换全屏 + * @class isFullScreen + * @description 切换全屏 * @param {state} state vuex state */ d2adminFullScreenToggle (state) { @@ -114,14 +147,16 @@ export default { } }, /** - * 切换灰度状态 + * @class isGrayMode + * @description 切换灰度状态 * @param {state} state vuex state */ d2adminGrayModeToggle (state) { state.isGrayMode = !state.isGrayMode }, /** - * 设置灰度模式 + * @class isGrayMode + * @description 设置灰度模式 * @param {state} state vuex state * @param {boolean} value new value */ @@ -129,7 +164,8 @@ export default { state.isGrayMode = value }, /** - * 激活一个主题(应用到dom上) + * @class themeActive + * @description 激活一个主题(应用到dom上) * @param {state} state vuex state * @param {string} themeValue 需要激活的主题名称 */ @@ -144,7 +180,8 @@ export default { this.commit('d2adminVuex2Db', 'themeActive') }, /** - * 从数据库加载主题设置 + * @class themeActive + * @description 从数据库加载主题设置 * @param {state} state vuex state */ d2adminThemeLoad (state) {