Browse Source

feat: close tab on mouse mid-button click

DevDengChao 2 tháng trước cách đây
mục cha
commit
14d508d630
1 tập tin đã thay đổi với 10 bổ sung0 xóa
  1. 10 0
      src/layout/components/TagsView/src/TagsView.vue

+ 10 - 0
src/layout/components/TagsView/src/TagsView.vue

@@ -255,6 +255,15 @@ const canShowIcon = (item: RouteLocationNormalizedLoaded) => {
   return false
 }
 
+const closeTabOnMouseMidClick = (e: MouseEvent, item) => {
+  // 中键:button === 1
+  if (e.button === 1) {
+    e.preventDefault()
+    e.stopPropagation()
+    closeSelectedTag(item)
+  }
+}
+
 onBeforeMount(() => {
   initTags()
   addTags()
@@ -293,6 +302,7 @@ watch(
             v-for="item in visitedViews"
             :key="item.fullPath"
             :ref="itemRefs.set"
+            @auxclick="closeTabOnMouseMidClick($event, item)"
             :class="[
               `${prefixCls}__item`,
               tagsViewImmerse ? `${prefixCls}__item--immerse` : '',