From 313af63f3348c9deb7a716e1836be6b26ca477d9 Mon Sep 17 00:00:00 2001 From: chenghongxing <1126263215@qq.com> Date: Wed, 30 Sep 2020 19:39:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20function=20of=20refreshing=20page?= =?UTF-8?q?;=20:star:=20#132=20=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/menu/Contextmenu.vue | 18 +++---- src/layouts/tabs/TabsHead.vue | 55 +++++++++++++++------- src/layouts/tabs/TabsView.vue | 73 +++++++++++++++++++---------- src/layouts/tabs/i18n.js | 3 ++ src/plugins/tabs-page-plugin.js | 4 ++ 5 files changed, 102 insertions(+), 51 deletions(-) diff --git a/src/components/menu/Contextmenu.vue b/src/components/menu/Contextmenu.vue index a93e332..0bec4b4 100644 --- a/src/components/menu/Contextmenu.vue +++ b/src/components/menu/Contextmenu.vue @@ -33,6 +33,7 @@ export default { left: 0, top: 0, target: null, + meta: null, selectedKeys: [] } }, @@ -45,14 +46,12 @@ export default { } }, created () { - const clickHandler = () => this.closeMenu() - const contextMenuHandler = e => this.setPosition(e) - window.addEventListener('click', clickHandler) - window.addEventListener('contextmenu', contextMenuHandler) - this.$emit('hook:beforeDestroy', () => { - window.removeEventListener('click', clickHandler) - window.removeEventListener('contextmenu', contextMenuHandler) - }) + window.addEventListener('click', this.closeMenu) + window.addEventListener('contextmenu', this.setPosition) + }, + beforeDestroy() { + window.removeEventListener('click', this.closeMenu) + window.removeEventListener('contextmenu', this.setPosition) }, methods: { closeMenu () { @@ -62,9 +61,10 @@ export default { this.left = e.clientX this.top = e.clientY this.target = e.target + this.meta = e.meta }, handleClick ({ key }) { - this.$emit('select', key, this.target) + this.$emit('select', key, this.target, this.meta) this.closeMenu() } } diff --git a/src/layouts/tabs/TabsHead.vue b/src/layouts/tabs/TabsHead.vue index 17e74db..69432f3 100644 --- a/src/layouts/tabs/TabsHead.vue +++ b/src/layouts/tabs/TabsHead.vue @@ -5,9 +5,6 @@ :class="['tabs-container', layout, pageWidth, {'affixed' : affixed, 'fixed-header' : fixedHeader, 'collapsed' : adminLayout.collapsed}]" :active-key="active" :hide-add="true" - @change="onChange" - @edit="onEdit" - @contextmenu="onContextmenu" > - {{pageName(page)}} +
+ + {{pageName(page)}} + +
@@ -58,11 +59,6 @@ } }, inject:['adminLayout'], - watch: { - 'adminLayout.collapsed': (val) => { - console.log(val) - } - }, created() { this.affixed = this.fixedTabs }, @@ -84,16 +80,19 @@ this.affixed = false } }, - onChange(key) { - this.$emit('change', key) - }, - onEdit(key, action) { - if (action === 'remove') { - this.$emit('close', key) + onTabClick(key) { + if (this.active !== key) { + this.$emit('change', key) } }, - onContextmenu(e) { - this.$emit('contextmenu', e) + onClose(key) { + this.$emit('close', key) + }, + onRefresh(page) { + this.$emit('refresh', page.fullPath, page) + }, + onContextmenu(pageKey, e) { + this.$emit('contextmenu', pageKey, e) }, pageName(page) { return this.$t(getI18nKey(page.keyPath)) @@ -103,6 +102,28 @@