mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-23 01:30:26 +08:00
feat: allow close tab when mouse middle button click (#5347)
Some checks are pending
CI / Test (ubuntu-latest) (push) Waiting to run
CI / Test (windows-latest) (push) Waiting to run
CI / Lint (ubuntu-latest) (push) Waiting to run
CI / Lint (windows-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / CI OK (push) Blocked by required conditions
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Deploy Website on push / Deploy Push Playground Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Docs Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Antd Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Element Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Naive Ftp (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
Some checks are pending
CI / Test (ubuntu-latest) (push) Waiting to run
CI / Test (windows-latest) (push) Waiting to run
CI / Lint (ubuntu-latest) (push) Waiting to run
CI / Lint (windows-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / CI OK (push) Blocked by required conditions
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Deploy Website on push / Deploy Push Playground Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Docs Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Antd Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Element Ftp (push) Waiting to run
Deploy Website on push / Deploy Push Naive Ftp (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
* 偏好设置增加鼠标中键关闭标签页的设置
This commit is contained in:
parent
624beb6fa0
commit
b8bffd884c
@ -80,6 +80,7 @@ exports[`defaultPreferences immutability test > should not modify the config obj
|
|||||||
"enable": true,
|
"enable": true,
|
||||||
"height": 38,
|
"height": 38,
|
||||||
"keepAlive": true,
|
"keepAlive": true,
|
||||||
|
"middleClickToClose": false,
|
||||||
"persist": true,
|
"persist": true,
|
||||||
"showIcon": true,
|
"showIcon": true,
|
||||||
"showMaximize": true,
|
"showMaximize": true,
|
||||||
|
@ -80,6 +80,7 @@ const defaultPreferences: Preferences = {
|
|||||||
enable: true,
|
enable: true,
|
||||||
height: 38,
|
height: 38,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
|
middleClickToClose: false,
|
||||||
persist: true,
|
persist: true,
|
||||||
showIcon: true,
|
showIcon: true,
|
||||||
showMaximize: true,
|
showMaximize: true,
|
||||||
|
@ -168,6 +168,8 @@ interface TabbarPreferences {
|
|||||||
height: number;
|
height: number;
|
||||||
/** 开启标签页缓存功能 */
|
/** 开启标签页缓存功能 */
|
||||||
keepAlive: boolean;
|
keepAlive: boolean;
|
||||||
|
/** 是否点击中键时关闭标签 */
|
||||||
|
middleClickToClose: boolean;
|
||||||
/** 是否持久化标签 */
|
/** 是否持久化标签 */
|
||||||
persist: boolean;
|
persist: boolean;
|
||||||
/** 是否开启多标签页图标 */
|
/** 是否开启多标签页图标 */
|
||||||
|
@ -56,6 +56,20 @@ const tabsView = computed(() => {
|
|||||||
} as TabConfig;
|
} as TabConfig;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function onMouseDown(e: MouseEvent, tab: TabConfig) {
|
||||||
|
if (
|
||||||
|
e.button === 1 &&
|
||||||
|
tab.closable &&
|
||||||
|
!tab.affixTab &&
|
||||||
|
tabsView.value.length > 1 &&
|
||||||
|
props.middleClickToClose
|
||||||
|
) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
emit('close', tab.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -82,6 +96,7 @@ const tabsView = computed(() => {
|
|||||||
class="tabs-chrome__item draggable translate-all group relative -mr-3 flex h-full select-none items-center"
|
class="tabs-chrome__item draggable translate-all group relative -mr-3 flex h-full select-none items-center"
|
||||||
data-tab-item="true"
|
data-tab-item="true"
|
||||||
@click="active = tab.key"
|
@click="active = tab.key"
|
||||||
|
@mousedown="onMouseDown($event, tab)"
|
||||||
>
|
>
|
||||||
<VbenContextMenu
|
<VbenContextMenu
|
||||||
:handler-data="tab"
|
:handler-data="tab"
|
||||||
|
@ -62,6 +62,20 @@ const tabsView = computed(() => {
|
|||||||
} as TabConfig;
|
} as TabConfig;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function onMouseDown(e: MouseEvent, tab: TabConfig) {
|
||||||
|
if (
|
||||||
|
e.button === 1 &&
|
||||||
|
tab.closable &&
|
||||||
|
!tab.affixTab &&
|
||||||
|
tabsView.value.length > 1 &&
|
||||||
|
props.middleClickToClose
|
||||||
|
) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
emit('close', tab.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -85,6 +99,7 @@ const tabsView = computed(() => {
|
|||||||
class="tab-item [&:not(.is-active)]:hover:bg-accent translate-all group relative flex cursor-pointer select-none"
|
class="tab-item [&:not(.is-active)]:hover:bg-accent translate-all group relative flex cursor-pointer select-none"
|
||||||
data-tab-item="true"
|
data-tab-item="true"
|
||||||
@click="active = tab.key"
|
@click="active = tab.key"
|
||||||
|
@mousedown="onMouseDown($event, tab)"
|
||||||
>
|
>
|
||||||
<VbenContextMenu
|
<VbenContextMenu
|
||||||
:handler-data="tab"
|
:handler-data="tab"
|
||||||
|
@ -33,6 +33,11 @@ export interface TabsProps {
|
|||||||
* 仅限 tabs-chrome
|
* 仅限 tabs-chrome
|
||||||
*/
|
*/
|
||||||
maxWidth?: number;
|
maxWidth?: number;
|
||||||
|
/**
|
||||||
|
* @zh_CN 点击中键时关闭Tab
|
||||||
|
*/
|
||||||
|
middleClickToClose?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh_CN tab最小宽度
|
* @zh_CN tab最小宽度
|
||||||
* 仅限 tabs-chrome
|
* 仅限 tabs-chrome
|
||||||
@ -43,11 +48,11 @@ export interface TabsProps {
|
|||||||
* @zh_CN 是否显示图标
|
* @zh_CN 是否显示图标
|
||||||
*/
|
*/
|
||||||
showIcon?: boolean;
|
showIcon?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh_CN 标签页风格
|
* @zh_CN 标签页风格
|
||||||
*/
|
*/
|
||||||
styleType?: TabsStyleType;
|
styleType?: TabsStyleType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @zh_CN 选项卡数据
|
* @zh_CN 选项卡数据
|
||||||
*/
|
*/
|
||||||
|
@ -57,6 +57,7 @@ if (!preferences.tabbar.persist) {
|
|||||||
:style-type="preferences.tabbar.styleType"
|
:style-type="preferences.tabbar.styleType"
|
||||||
:tabs="currentTabs"
|
:tabs="currentTabs"
|
||||||
:wheelable="preferences.tabbar.wheelable"
|
:wheelable="preferences.tabbar.wheelable"
|
||||||
|
:middle-click-to-close="preferences.tabbar.middleClickToClose"
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
@sort-tabs="tabbarStore.sortTabs"
|
@sort-tabs="tabbarStore.sortTabs"
|
||||||
@unpin="unpinTab"
|
@unpin="unpinTab"
|
||||||
|
@ -22,6 +22,9 @@ const tabbarWheelable = defineModel<boolean>('tabbarWheelable');
|
|||||||
const tabbarStyleType = defineModel<string>('tabbarStyleType');
|
const tabbarStyleType = defineModel<string>('tabbarStyleType');
|
||||||
const tabbarShowMore = defineModel<boolean>('tabbarShowMore');
|
const tabbarShowMore = defineModel<boolean>('tabbarShowMore');
|
||||||
const tabbarShowMaximize = defineModel<boolean>('tabbarShowMaximize');
|
const tabbarShowMaximize = defineModel<boolean>('tabbarShowMaximize');
|
||||||
|
const tabbarMiddleClickToClose = defineModel<boolean>(
|
||||||
|
'tabbarMiddleClickToClose',
|
||||||
|
);
|
||||||
|
|
||||||
const styleItems = computed((): SelectOption[] => [
|
const styleItems = computed((): SelectOption[] => [
|
||||||
{
|
{
|
||||||
@ -61,6 +64,9 @@ const styleItems = computed((): SelectOption[] => [
|
|||||||
>
|
>
|
||||||
{{ $t('preferences.tabbar.wheelable') }}
|
{{ $t('preferences.tabbar.wheelable') }}
|
||||||
</SwitchItem>
|
</SwitchItem>
|
||||||
|
<SwitchItem v-model="tabbarMiddleClickToClose" :disabled="!tabbarEnable">
|
||||||
|
{{ $t('preferences.tabbar.middleClickClose') }}
|
||||||
|
</SwitchItem>
|
||||||
<SwitchItem v-model="tabbarShowIcon" :disabled="!tabbarEnable">
|
<SwitchItem v-model="tabbarShowIcon" :disabled="!tabbarEnable">
|
||||||
{{ $t('preferences.tabbar.icon') }}
|
{{ $t('preferences.tabbar.icon') }}
|
||||||
</SwitchItem>
|
</SwitchItem>
|
||||||
|
@ -116,6 +116,9 @@ const tabbarPersist = defineModel<boolean>('tabbarPersist');
|
|||||||
const tabbarDraggable = defineModel<boolean>('tabbarDraggable');
|
const tabbarDraggable = defineModel<boolean>('tabbarDraggable');
|
||||||
const tabbarWheelable = defineModel<boolean>('tabbarWheelable');
|
const tabbarWheelable = defineModel<boolean>('tabbarWheelable');
|
||||||
const tabbarStyleType = defineModel<string>('tabbarStyleType');
|
const tabbarStyleType = defineModel<string>('tabbarStyleType');
|
||||||
|
const tabbarMiddleClickToClose = defineModel<boolean>(
|
||||||
|
'tabbarMiddleClickToClose',
|
||||||
|
);
|
||||||
|
|
||||||
const navigationStyleType = defineModel<NavigationStyleType>(
|
const navigationStyleType = defineModel<NavigationStyleType>(
|
||||||
'navigationStyleType',
|
'navigationStyleType',
|
||||||
@ -362,6 +365,7 @@ async function handleReset() {
|
|||||||
v-model:tabbar-show-more="tabbarShowMore"
|
v-model:tabbar-show-more="tabbarShowMore"
|
||||||
v-model:tabbar-style-type="tabbarStyleType"
|
v-model:tabbar-style-type="tabbarStyleType"
|
||||||
v-model:tabbar-wheelable="tabbarWheelable"
|
v-model:tabbar-wheelable="tabbarWheelable"
|
||||||
|
v-model:tabbar-middle-click-to-close="tabbarMiddleClickToClose"
|
||||||
/>
|
/>
|
||||||
</Block>
|
</Block>
|
||||||
<Block :title="$t('preferences.widget.title')">
|
<Block :title="$t('preferences.widget.title')">
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
"twoColumnTip": "Vertical Two Column Menu Mode",
|
"twoColumnTip": "Vertical Two Column Menu Mode",
|
||||||
"headerSidebarNav": "Header Vertical",
|
"headerSidebarNav": "Header Vertical",
|
||||||
"headerSidebarNavTip": "Header Full Width, Sidebar Navigation Mode",
|
"headerSidebarNavTip": "Header Full Width, Sidebar Navigation Mode",
|
||||||
|
"headerTwoColumn": "Header Two Column",
|
||||||
|
"headerTwoColumnTip": "Header Navigation & Sidebar Two Column co-exists",
|
||||||
"mixedMenu": "Mixed Menu",
|
"mixedMenu": "Mixed Menu",
|
||||||
"mixedMenuTip": "Vertical & Horizontal Menu Co-exists",
|
"mixedMenuTip": "Vertical & Horizontal Menu Co-exists",
|
||||||
"fullContent": "Full Content",
|
"fullContent": "Full Content",
|
||||||
@ -62,6 +64,7 @@
|
|||||||
"persist": "Persist Tabs",
|
"persist": "Persist Tabs",
|
||||||
"draggable": "Enable Draggable Sort",
|
"draggable": "Enable Draggable Sort",
|
||||||
"wheelable": "Support Mouse Wheel",
|
"wheelable": "Support Mouse Wheel",
|
||||||
|
"middleClickClose": "Close Tab when Mouse Middle Button Click",
|
||||||
"wheelableTip": "When enabled, the Tabbar area responds to vertical scrolling events of the scroll wheel.",
|
"wheelableTip": "When enabled, the Tabbar area responds to vertical scrolling events of the scroll wheel.",
|
||||||
"styleType": {
|
"styleType": {
|
||||||
"title": "Tabs Style",
|
"title": "Tabs Style",
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
"persist": "持久化标签页",
|
"persist": "持久化标签页",
|
||||||
"draggable": "启动拖拽排序",
|
"draggable": "启动拖拽排序",
|
||||||
"wheelable": "启用纵向滚轮响应",
|
"wheelable": "启用纵向滚轮响应",
|
||||||
|
"middleClickClose": "点击鼠标中键关闭标签页",
|
||||||
"wheelableTip": "开启后,标签栏区域可以响应滚轮的纵向滚动事件。\n关闭时,只能响应系统的横向滚动事件(需要按下Shift再滚动滚轮)",
|
"wheelableTip": "开启后,标签栏区域可以响应滚轮的纵向滚动事件。\n关闭时,只能响应系统的横向滚动事件(需要按下Shift再滚动滚轮)",
|
||||||
"styleType": {
|
"styleType": {
|
||||||
"title": "标签页风格",
|
"title": "标签页风格",
|
||||||
|
Loading…
Reference in New Issue
Block a user