mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-11-17 06:03:42 +08:00
feat(global-tab): add support for switching tabs with right mouse button click
This commit is contained in:
@@ -27,6 +27,7 @@ const isPCFlag = isPC();
|
|||||||
|
|
||||||
const TAB_DATA_ID = 'data-tab-id';
|
const TAB_DATA_ID = 'data-tab-id';
|
||||||
const MIDDLE_MOUSE_BUTTON = 1;
|
const MIDDLE_MOUSE_BUTTON = 1;
|
||||||
|
const RIGHT_MOUSE_BUTTON = 2;
|
||||||
|
|
||||||
type TabNamedNodeMap = NamedNodeMap & {
|
type TabNamedNodeMap = NamedNodeMap & {
|
||||||
[TAB_DATA_ID]: Attr;
|
[TAB_DATA_ID]: Attr;
|
||||||
@@ -99,6 +100,12 @@ function handleMousedown(e: MouseEvent, tab: App.Global.Tab) {
|
|||||||
handleCloseTab(tab);
|
handleCloseTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function switchTab(e: MouseEvent, tab: App.Global.Tab) {
|
||||||
|
if ([MIDDLE_MOUSE_BUTTON, RIGHT_MOUSE_BUTTON].includes(e.button)) return;
|
||||||
|
|
||||||
|
tabStore.switchRouteByTab(tab);
|
||||||
|
}
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
appStore.reloadPage(500);
|
appStore.reloadPage(500);
|
||||||
}
|
}
|
||||||
@@ -197,7 +204,7 @@ init();
|
|||||||
:active="tab.id === tabStore.activeTabId"
|
:active="tab.id === tabStore.activeTabId"
|
||||||
:active-color="themeStore.themeColor"
|
:active-color="themeStore.themeColor"
|
||||||
:closable="!tabStore.isTabRetain(tab.id)"
|
:closable="!tabStore.isTabRetain(tab.id)"
|
||||||
@pointerdown="tabStore.switchRouteByTab(tab)"
|
@pointerdown="switchTab($event, tab)"
|
||||||
@mousedown="handleMousedown($event, tab)"
|
@mousedown="handleMousedown($event, tab)"
|
||||||
@close="handleCloseTab(tab)"
|
@close="handleCloseTab(tab)"
|
||||||
@contextmenu="handleContextMenu($event, tab.id)"
|
@contextmenu="handleContextMenu($event, tab.id)"
|
||||||
|
|||||||
Reference in New Issue
Block a user