Skip to content

Commit

Permalink
feat: tab支持使用鼠标中键关闭 (flipped-aurora#1840)
Browse files Browse the repository at this point in the history
* fix: 修复注释错误

* feat: tab支持使用鼠标中键进行关闭
  • Loading branch information
zhongmax authored and 伯努 committed Jul 31, 2024
1 parent 09bdd00 commit 3bf3327
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions web/src/view/layout/tabs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@contextmenu.prevent="openContextMenu($event)"
@tab-click="changeTab"
@tab-remove="removeTab"
@click.middle.prevent="middleCloseTab($event)"
>
<el-tab-pane
v-for="item in historys"
Expand Down Expand Up @@ -343,6 +344,21 @@ onUnmounted(() => {
emitter.off('collapse')
emitter.off('mobile')
})

const middleCloseTab = (e) => {
if (historys.value.length === 1 && route.name === defaultRouter.value) {
return false
}
let id = ''
if (e.srcElement.nodeName === 'SPAN') {
id = e.srcElement.offsetParent.id
} else {
id = e.srcElement.id
}
if (id) {
removeTab(id.substring(4))
}
}
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit 3bf3327

Please sign in to comment.