mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-24 02:00:25 +08:00
feat(MultipleTab): add tabs auto collapse interaction in fold mode and setting (#3256)
* fix: validateFields await missing * feat(MultipleTab): add tabs auto collapse interaction and setting * chore(locales): update setting name to better reflect its purpose --------- Co-authored-by: invalid w <wangjuesix@gmail.com>
This commit is contained in:
parent
b976933766
commit
191e809b6d
@ -15,6 +15,8 @@ export function useMultipleTabSetting() {
|
|||||||
|
|
||||||
const getShowFold = computed(() => appStore.getMultiTabsSetting.showFold);
|
const getShowFold = computed(() => appStore.getMultiTabsSetting.showFold);
|
||||||
|
|
||||||
|
const getAutoCollapse = computed(() => appStore.getMultiTabsSetting.autoCollapse);
|
||||||
|
|
||||||
function setMultipleTabSetting(multiTabsSetting: Partial<MultiTabsSetting>) {
|
function setMultipleTabSetting(multiTabsSetting: Partial<MultiTabsSetting>) {
|
||||||
appStore.setProjectConfig({ multiTabsSetting });
|
appStore.setProjectConfig({ multiTabsSetting });
|
||||||
}
|
}
|
||||||
@ -24,5 +26,6 @@ export function useMultipleTabSetting() {
|
|||||||
getShowQuick,
|
getShowQuick,
|
||||||
getShowRedo,
|
getShowRedo,
|
||||||
getShowFold,
|
getShowFold,
|
||||||
|
getAutoCollapse,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :style="getPlaceholderDomStyle" v-if="getIsShowPlaceholderDom"></div>
|
<div
|
||||||
|
:class="[`${prefixCls}__placeholder`]"
|
||||||
|
:style="getPlaceholderDomStyle"
|
||||||
|
v-if="getIsShowPlaceholderDom"
|
||||||
|
></div>
|
||||||
<div :style="getWrapStyle" :class="getClass">
|
<div :style="getWrapStyle" :class="getClass">
|
||||||
<LayoutHeader v-if="getShowInsetHeaderRef" />
|
<LayoutHeader v-if="getShowInsetHeaderRef" />
|
||||||
<MultipleTabs v-if="getShowTabs" :key="tabStore.getLastDragEndIndex" />
|
<MultipleTabs v-if="getShowTabs" :key="tabStore.getLastDragEndIndex" />
|
||||||
@ -31,7 +35,7 @@
|
|||||||
const tabStore = useMultipleTabStore();
|
const tabStore = useMultipleTabStore();
|
||||||
const { prefixCls } = useDesign('layout-multiple-header');
|
const { prefixCls } = useDesign('layout-multiple-header');
|
||||||
|
|
||||||
const { getCalcContentWidth, getSplit } = useMenuSetting();
|
const { getCalcContentWidth, getSplit, getShowMenu } = useMenuSetting();
|
||||||
const { getIsMobile } = useAppInject();
|
const { getIsMobile } = useAppInject();
|
||||||
const {
|
const {
|
||||||
getFixed,
|
getFixed,
|
||||||
@ -43,7 +47,7 @@
|
|||||||
|
|
||||||
const { getFullContent } = useFullContent();
|
const { getFullContent } = useFullContent();
|
||||||
|
|
||||||
const { getShowMultipleTab } = useMultipleTabSetting();
|
const { getShowMultipleTab, getAutoCollapse } = useMultipleTabSetting();
|
||||||
|
|
||||||
const getShowTabs = computed(() => {
|
const getShowTabs = computed(() => {
|
||||||
return unref(getShowMultipleTab) && !unref(getFullContent);
|
return unref(getShowMultipleTab) && !unref(getFullContent);
|
||||||
@ -68,8 +72,11 @@
|
|||||||
return unref(getFixed) || unref(getShowFullHeaderRef);
|
return unref(getFixed) || unref(getShowFullHeaderRef);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getIsUnFold = computed(() => !unref(getShowMenu) && !unref(getShowHeader));
|
||||||
|
|
||||||
const getPlaceholderDomStyle = computed((): CSSProperties => {
|
const getPlaceholderDomStyle = computed((): CSSProperties => {
|
||||||
let height = 0;
|
let height = 0;
|
||||||
|
if (!(unref(getAutoCollapse) && unref(getIsUnFold))) {
|
||||||
if (
|
if (
|
||||||
(unref(getShowFullHeaderRef) || !unref(getSplit)) &&
|
(unref(getShowFullHeaderRef) || !unref(getSplit)) &&
|
||||||
unref(getShowHeader) &&
|
unref(getShowHeader) &&
|
||||||
@ -81,6 +88,7 @@
|
|||||||
height += TABS_HEIGHT;
|
height += TABS_HEIGHT;
|
||||||
}
|
}
|
||||||
setHeaderHeight(height);
|
setHeaderHeight(height);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
height: `${height}px`,
|
height: `${height}px`,
|
||||||
};
|
};
|
||||||
@ -125,5 +133,9 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__placeholder {
|
||||||
|
transition: height 0.6s ease-in-out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<Layout :class="prefixCls" v-bind="lockEvents">
|
<Layout :class="prefixCls" v-bind="lockEvents">
|
||||||
<LayoutFeatures />
|
<LayoutFeatures />
|
||||||
<LayoutHeader fixed v-if="getShowFullHeaderRef" />
|
<LayoutHeader fixed v-if="getShowFullHeaderRef" />
|
||||||
<Layout :class="[layoutClass]">
|
<Layout :class="[layoutClass, `${prefixCls}-out`]">
|
||||||
<LayoutSideBar v-if="getShowSidebar || getIsMobile" />
|
<LayoutSideBar v-if="getShowSidebar || getIsMobile" />
|
||||||
<Layout :class="`${prefixCls}-main`">
|
<Layout :class="`${prefixCls}-main`">
|
||||||
<LayoutMultipleHeader />
|
<LayoutMultipleHeader />
|
||||||
@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
import { useAppInject } from '/@/hooks/web/useAppInject';
|
import { useAppInject } from '/@/hooks/web/useAppInject';
|
||||||
|
|
||||||
|
import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'DefaultLayout',
|
name: 'DefaultLayout',
|
||||||
components: {
|
components: {
|
||||||
@ -46,6 +48,7 @@
|
|||||||
const { getIsMobile } = useAppInject();
|
const { getIsMobile } = useAppInject();
|
||||||
const { getShowFullHeaderRef } = useHeaderSetting();
|
const { getShowFullHeaderRef } = useHeaderSetting();
|
||||||
const { getShowSidebar, getIsMixSidebar, getShowMenu } = useMenuSetting();
|
const { getShowSidebar, getIsMixSidebar, getShowMenu } = useMenuSetting();
|
||||||
|
const { getAutoCollapse } = useMultipleTabSetting();
|
||||||
|
|
||||||
// Create a lock screen monitor
|
// Create a lock screen monitor
|
||||||
const lockEvents = useLockPage();
|
const lockEvents = useLockPage();
|
||||||
@ -55,6 +58,11 @@
|
|||||||
if (unref(getIsMixSidebar) || unref(getShowMenu)) {
|
if (unref(getIsMixSidebar) || unref(getShowMenu)) {
|
||||||
cls.push('ant-layout-has-sider');
|
cls.push('ant-layout-has-sider');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!unref(getShowMenu) && unref(getAutoCollapse)) {
|
||||||
|
cls.push('ant-layout-auto-collapse-tabs');
|
||||||
|
}
|
||||||
|
|
||||||
return cls;
|
return cls;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -89,4 +97,14 @@
|
|||||||
margin-left: 1px;
|
margin-left: 1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.@{prefix-cls}-out {
|
||||||
|
&.ant-layout-has-sider {
|
||||||
|
.@{prefix-cls} {
|
||||||
|
&-main {
|
||||||
|
margin-left: 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -89,7 +89,8 @@ export default defineComponent({
|
|||||||
getShowSearch,
|
getShowSearch,
|
||||||
} = useHeaderSetting();
|
} = useHeaderSetting();
|
||||||
|
|
||||||
const { getShowMultipleTab, getShowQuick, getShowRedo, getShowFold } = useMultipleTabSetting();
|
const { getShowMultipleTab, getShowQuick, getShowRedo, getShowFold, getAutoCollapse } =
|
||||||
|
useMultipleTabSetting();
|
||||||
|
|
||||||
const getShowMenuRef = computed(() => {
|
const getShowMenuRef = computed(() => {
|
||||||
return unref(getShowMenu) && !unref(getIsHorizontal);
|
return unref(getShowMenu) && !unref(getIsHorizontal);
|
||||||
@ -221,6 +222,12 @@ export default defineComponent({
|
|||||||
def={unref(getMenuFixed)}
|
def={unref(getMenuFixed)}
|
||||||
disabled={!unref(getShowMenuRef) || unref(getIsMixSidebar)}
|
disabled={!unref(getShowMenuRef) || unref(getIsMixSidebar)}
|
||||||
/>
|
/>
|
||||||
|
<SwitchItem
|
||||||
|
title={t('layout.setting.autoCollapseTabsInFold')}
|
||||||
|
event={HandlerEnum.TABS_AUTO_COLLAPSE}
|
||||||
|
def={unref(getAutoCollapse)}
|
||||||
|
disabled={!unref(getShowMultipleTab)}
|
||||||
|
/>
|
||||||
<SelectItem
|
<SelectItem
|
||||||
title={t('layout.setting.mixSidebarTrigger')}
|
title={t('layout.setting.mixSidebarTrigger')}
|
||||||
event={HandlerEnum.MENU_TRIGGER_MIX_SIDEBAR}
|
event={HandlerEnum.MENU_TRIGGER_MIX_SIDEBAR}
|
||||||
|
@ -42,6 +42,7 @@ export enum HandlerEnum {
|
|||||||
TABS_SHOW_REDO,
|
TABS_SHOW_REDO,
|
||||||
TABS_SHOW,
|
TABS_SHOW,
|
||||||
TABS_SHOW_FOLD,
|
TABS_SHOW_FOLD,
|
||||||
|
TABS_AUTO_COLLAPSE,
|
||||||
|
|
||||||
LOCK_TIME,
|
LOCK_TIME,
|
||||||
FULL_CONTENT,
|
FULL_CONTENT,
|
||||||
|
@ -153,6 +153,9 @@ export function handler(event: HandlerEnum, value: any): DeepPartial<ProjectConf
|
|||||||
case HandlerEnum.TABS_SHOW_FOLD:
|
case HandlerEnum.TABS_SHOW_FOLD:
|
||||||
return { multiTabsSetting: { showFold: value } };
|
return { multiTabsSetting: { showFold: value } };
|
||||||
|
|
||||||
|
case HandlerEnum.TABS_AUTO_COLLAPSE:
|
||||||
|
return { multiTabsSetting: { autoCollapse: value } };
|
||||||
|
|
||||||
// ============header==================
|
// ============header==================
|
||||||
case HandlerEnum.HEADER_THEME:
|
case HandlerEnum.HEADER_THEME:
|
||||||
updateHeaderBgColor(value);
|
updateHeaderBgColor(value);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@prefix-cls: ~'@{namespace}-multiple-tabs';
|
@prefix-cls: ~'@{namespace}-multiple-tabs';
|
||||||
|
@prefix-cls-default-layout: ~'@{namespace}-default-layout';
|
||||||
|
|
||||||
html[data-theme='light'] {
|
html[data-theme='light'] {
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
@ -8,6 +9,25 @@ html[data-theme='light'] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.@{prefix-cls-default-layout}-out {
|
||||||
|
&.ant-layout-auto-collapse-tabs {
|
||||||
|
.@{prefix-cls} {
|
||||||
|
margin-top: -(@multiple-height + 2);
|
||||||
|
opacity: 0.1;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&--hover {
|
||||||
|
margin-top: 0;
|
||||||
|
transition-delay: 0s;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.@{prefix-cls} {
|
||||||
|
transition: margin 0.2s ease-in-out 0.6s, opacity 0.2s ease-in-out 0.6s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.@{prefix-cls} {
|
.@{prefix-cls} {
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
height: @multiple-height + 2;
|
height: @multiple-height + 2;
|
||||||
|
@ -50,6 +50,9 @@
|
|||||||
|
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { useMouse } from '@vueuse/core';
|
||||||
|
import { multipleTabHeight } from '/@/settings/designSetting';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'MultipleTabs',
|
name: 'MultipleTabs',
|
||||||
components: {
|
components: {
|
||||||
@ -78,11 +81,14 @@
|
|||||||
|
|
||||||
const unClose = computed(() => unref(getTabsState).length === 1);
|
const unClose = computed(() => unref(getTabsState).length === 1);
|
||||||
|
|
||||||
|
const { y: mouseY } = useMouse();
|
||||||
|
|
||||||
const getWrapClass = computed(() => {
|
const getWrapClass = computed(() => {
|
||||||
return [
|
return [
|
||||||
prefixCls,
|
prefixCls,
|
||||||
{
|
{
|
||||||
[`${prefixCls}--hide-close`]: unref(unClose),
|
[`${prefixCls}--hide-close`]: unref(unClose),
|
||||||
|
[`${prefixCls}--hover`]: unref(mouseY) < multipleTabHeight,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
"mixSidebarTrigger": "Mixed menu Trigger",
|
"mixSidebarTrigger": "Mixed menu Trigger",
|
||||||
"triggerHover": "Hover",
|
"triggerHover": "Hover",
|
||||||
"triggerClick": "Click",
|
"triggerClick": "Click",
|
||||||
"mixSidebarFixed": "Fixed expanded menu"
|
"mixSidebarFixed": "Fixed expanded menu",
|
||||||
|
"autoCollapseTabsInFold": "Auto collapse tabs in fold"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -90,6 +90,7 @@
|
|||||||
"mixSidebarTrigger": "混合菜单触发方式",
|
"mixSidebarTrigger": "混合菜单触发方式",
|
||||||
"triggerHover": "悬停",
|
"triggerHover": "悬停",
|
||||||
"triggerClick": "点击",
|
"triggerClick": "点击",
|
||||||
"mixSidebarFixed": "固定展开菜单"
|
"mixSidebarFixed": "固定展开菜单",
|
||||||
|
"autoCollapseTabsInFold": "fold模式下自动收起标签页"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,8 @@ import { ThemeEnum } from '../enums/appEnum';
|
|||||||
|
|
||||||
export const prefixCls = 'vben';
|
export const prefixCls = 'vben';
|
||||||
|
|
||||||
|
export const multipleTabHeight = 30;
|
||||||
|
|
||||||
export const darkMode = ThemeEnum.LIGHT;
|
export const darkMode = ThemeEnum.LIGHT;
|
||||||
|
|
||||||
// app theme preset color
|
// app theme preset color
|
||||||
|
@ -135,6 +135,8 @@ const setting: ProjectConfig = {
|
|||||||
showRedo: true,
|
showRedo: true,
|
||||||
// Whether to show the collapse button
|
// Whether to show the collapse button
|
||||||
showFold: true,
|
showFold: true,
|
||||||
|
// Auto collapsed
|
||||||
|
autoCollapse: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Transition Setting
|
// Transition Setting
|
||||||
|
1
types/config.d.ts
vendored
1
types/config.d.ts
vendored
@ -41,6 +41,7 @@ export interface MultiTabsSetting {
|
|||||||
canDrag: boolean;
|
canDrag: boolean;
|
||||||
showRedo: boolean;
|
showRedo: boolean;
|
||||||
showFold: boolean;
|
showFold: boolean;
|
||||||
|
autoCollapse: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HeaderSetting {
|
export interface HeaderSetting {
|
||||||
|
Loading…
Reference in New Issue
Block a user