Skip to content

Commit b2c919b

Browse files
committed
feat(global-tab): add support for switching tabs with right mouse button click
1 parent 8dc17e6 commit b2c919b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/layouts/modules/global-tab/index.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const isPCFlag = isPC();
2727
2828
const TAB_DATA_ID = 'data-tab-id';
2929
const MIDDLE_MOUSE_BUTTON = 1;
30+
const RIGHT_MOUSE_BUTTON = 2;
3031
3132
type TabNamedNodeMap = NamedNodeMap & {
3233
[TAB_DATA_ID]: Attr;
@@ -99,6 +100,12 @@ function handleMousedown(e: MouseEvent, tab: App.Global.Tab) {
99100
handleCloseTab(tab);
100101
}
101102
103+
function switchTab(e: MouseEvent, tab: App.Global.Tab) {
104+
if ([MIDDLE_MOUSE_BUTTON, RIGHT_MOUSE_BUTTON].includes(e.button)) return;
105+
106+
tabStore.switchRouteByTab(tab);
107+
}
108+
102109
async function refresh() {
103110
appStore.reloadPage(500);
104111
}
@@ -197,7 +204,7 @@ init();
197204
:active="tab.id === tabStore.activeTabId"
198205
:active-color="themeStore.themeColor"
199206
:closable="!tabStore.isTabRetain(tab.id)"
200-
@pointerdown="tabStore.switchRouteByTab(tab)"
207+
@pointerdown="switchTab($event, tab)"
201208
@mousedown="handleMousedown($event, tab)"
202209
@close="handleCloseTab(tab)"
203210
@contextmenu="handleContextMenu($event, tab.id)"

0 commit comments

Comments
 (0)