2020-12-15 14:59:22 +08:00
|
|
|
<template>
|
2023-11-09 11:24:27 +08:00
|
|
|
<div
|
|
|
|
|
:class="[`${prefixCls}__placeholder`]"
|
|
|
|
|
:style="getPlaceholderDomStyle"
|
|
|
|
|
v-if="getIsShowPlaceholderDom"
|
|
|
|
|
></div>
|
2020-12-15 14:59:22 +08:00
|
|
|
<div :style="getWrapStyle" :class="getClass">
|
|
|
|
|
<LayoutHeader v-if="getShowInsetHeaderRef" />
|
2023-10-10 20:58:40 +08:00
|
|
|
<MultipleTabs v-if="getShowTabs" :key="tabStore.getLastDragEndIndex" />
|
2020-12-15 14:59:22 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2023-11-23 12:14:06 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { unref, computed, CSSProperties } from 'vue';
|
2020-12-15 14:59:22 +08:00
|
|
|
|
|
|
|
|
import LayoutHeader from './index.vue';
|
|
|
|
|
import MultipleTabs from '../tabs/index.vue';
|
|
|
|
|
|
2023-11-23 12:14:06 +08:00
|
|
|
import { useHeaderSetting } from '@/hooks/setting/useHeaderSetting';
|
|
|
|
|
import { useMenuSetting } from '@/hooks/setting/useMenuSetting';
|
|
|
|
|
import { useFullContent } from '@/hooks/web/useFullContent';
|
|
|
|
|
import { useMultipleTabSetting } from '@/hooks/setting/useMultipleTabSetting';
|
|
|
|
|
import { useAppInject } from '@/hooks/web/useAppInject';
|
|
|
|
|
import { useDesign } from '@/hooks/web/useDesign';
|
2021-06-11 09:37:17 +08:00
|
|
|
import { useLayoutHeight } from '../content/useContentViewHeight';
|
2023-11-23 12:14:06 +08:00
|
|
|
import { useMultipleTabStore } from '@/store/modules/multipleTab';
|
2020-12-15 14:59:22 +08:00
|
|
|
|
|
|
|
|
const HEADER_HEIGHT = 48;
|
|
|
|
|
|
|
|
|
|
const TABS_HEIGHT = 32;
|
2023-11-23 12:14:06 +08:00
|
|
|
|
|
|
|
|
defineOptions({ name: 'LayoutMultipleHeader' });
|
|
|
|
|
|
|
|
|
|
const { setHeaderHeight } = useLayoutHeight();
|
|
|
|
|
const tabStore = useMultipleTabStore();
|
|
|
|
|
const { prefixCls } = useDesign('layout-multiple-header');
|
|
|
|
|
|
|
|
|
|
const { getCalcContentWidth, getSplit, getShowMenu } = useMenuSetting();
|
|
|
|
|
const { getIsMobile } = useAppInject();
|
|
|
|
|
const { getFixed, getShowInsetHeaderRef, getShowFullHeaderRef, getHeaderTheme, getShowHeader } =
|
|
|
|
|
useHeaderSetting();
|
|
|
|
|
|
|
|
|
|
const { getFullContent } = useFullContent();
|
|
|
|
|
|
|
|
|
|
const { getShowMultipleTab, getAutoCollapse } = useMultipleTabSetting();
|
|
|
|
|
|
|
|
|
|
const getShowTabs = computed(() => {
|
|
|
|
|
return unref(getShowMultipleTab) && !unref(getFullContent);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getIsShowPlaceholderDom = computed(() => {
|
|
|
|
|
return unref(getFixed) || unref(getShowFullHeaderRef);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getWrapStyle = computed((): CSSProperties => {
|
|
|
|
|
const style: CSSProperties = {};
|
|
|
|
|
if (unref(getFixed)) {
|
|
|
|
|
style.width = unref(getIsMobile) ? '100%' : unref(getCalcContentWidth);
|
|
|
|
|
}
|
|
|
|
|
if (unref(getShowFullHeaderRef)) {
|
|
|
|
|
style.top = `${HEADER_HEIGHT}px`;
|
|
|
|
|
}
|
|
|
|
|
return style;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getIsFixed = computed(() => {
|
|
|
|
|
return unref(getFixed) || unref(getShowFullHeaderRef);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getIsUnFold = computed(() => !unref(getShowMenu) && !unref(getShowHeader));
|
|
|
|
|
|
|
|
|
|
const getPlaceholderDomStyle = computed((): CSSProperties => {
|
|
|
|
|
let height = 0;
|
|
|
|
|
if (!(unref(getAutoCollapse) && unref(getIsUnFold))) {
|
|
|
|
|
if (
|
|
|
|
|
(unref(getShowFullHeaderRef) || !unref(getSplit)) &&
|
|
|
|
|
unref(getShowHeader) &&
|
|
|
|
|
!unref(getFullContent)
|
|
|
|
|
) {
|
|
|
|
|
height += HEADER_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
if (unref(getShowMultipleTab) && !unref(getFullContent)) {
|
|
|
|
|
height += TABS_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
setHeaderHeight(height);
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
height: `${height}px`,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getClass = computed(() => {
|
|
|
|
|
return [
|
|
|
|
|
prefixCls,
|
|
|
|
|
`${prefixCls}--${unref(getHeaderTheme)}`,
|
|
|
|
|
{ [`${prefixCls}--fixed`]: unref(getIsFixed) },
|
|
|
|
|
];
|
2020-12-15 14:59:22 +08:00
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
@prefix-cls: ~'@{namespace}-layout-multiple-header';
|
|
|
|
|
|
|
|
|
|
.@{prefix-cls} {
|
|
|
|
|
flex: 0 0 auto;
|
2023-04-04 16:55:34 +08:00
|
|
|
transition: width 0.2s;
|
2020-12-15 14:59:22 +08:00
|
|
|
|
|
|
|
|
&--dark {
|
2021-05-23 22:46:22 +08:00
|
|
|
margin-left: -1px;
|
2020-12-15 14:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&--fixed {
|
|
|
|
|
position: fixed;
|
|
|
|
|
z-index: @multiple-tab-fixed-z-index;
|
2023-04-04 16:55:34 +08:00
|
|
|
top: 0;
|
2020-12-15 14:59:22 +08:00
|
|
|
width: 100%;
|
|
|
|
|
}
|
2023-11-09 11:24:27 +08:00
|
|
|
|
|
|
|
|
&__placeholder {
|
|
|
|
|
transition: height 0.6s ease-in-out;
|
|
|
|
|
}
|
2020-12-15 14:59:22 +08:00
|
|
|
}
|
|
|
|
|
</style>
|