|
@@ -1,14 +1,7 @@
|
|
|
<script setup lang="ts">
|
|
|
-import {
|
|
|
- computed,
|
|
|
- nextTick,
|
|
|
- onMounted,
|
|
|
- ref,
|
|
|
- type StyleValue,
|
|
|
- useTemplateRef,
|
|
|
-} from 'vue';
|
|
|
+import { computed, nextTick, onMounted, ref, useTemplateRef } from 'vue';
|
|
|
|
|
|
-import { preferences } from '@vben-core/preferences';
|
|
|
+import { CSS_VARIABLE_LAYOUT_CONTENT_HEIGHT } from '@vben-core/shared/constants';
|
|
|
import { cn } from '@vben-core/shared/utils';
|
|
|
|
|
|
interface Props {
|
|
@@ -19,8 +12,6 @@ interface Props {
|
|
|
* 根据content可见高度自适应
|
|
|
*/
|
|
|
autoContentHeight?: boolean;
|
|
|
- /** 头部固定(暂未实现) */
|
|
|
- fixedHeader?: boolean;
|
|
|
headerClass?: string;
|
|
|
footerClass?: string;
|
|
|
}
|
|
@@ -29,13 +20,7 @@ defineOptions({
|
|
|
name: 'Page',
|
|
|
});
|
|
|
|
|
|
-const {
|
|
|
- contentClass = '',
|
|
|
- description = '',
|
|
|
- autoContentHeight = false,
|
|
|
- title = '',
|
|
|
- fixedHeader = false,
|
|
|
-} = defineProps<Props>();
|
|
|
+const { autoContentHeight = false } = defineProps<Props>();
|
|
|
|
|
|
const headerHeight = ref(0);
|
|
|
const footerHeight = ref(0);
|
|
@@ -44,22 +29,11 @@ const shouldAutoHeight = ref(false);
|
|
|
const headerRef = useTemplateRef<HTMLDivElement>('headerRef');
|
|
|
const footerRef = useTemplateRef<HTMLDivElement>('footerRef');
|
|
|
|
|
|
-const headerStyle = computed<StyleValue>(() => {
|
|
|
- return fixedHeader
|
|
|
- ? {
|
|
|
- position: 'sticky',
|
|
|
- zIndex: 200,
|
|
|
- top:
|
|
|
- preferences.header.mode === 'fixed' ? 'var(--vben-header-height)' : 0,
|
|
|
- }
|
|
|
- : undefined;
|
|
|
-});
|
|
|
-
|
|
|
const contentStyle = computed(() => {
|
|
|
if (autoContentHeight) {
|
|
|
return {
|
|
|
height: shouldAutoHeight.value
|
|
|
- ? `calc(var(--vben-content-height) - ${headerHeight.value}px - ${footerHeight.value}px)`
|
|
|
+ ? `calc(var(${CSS_VARIABLE_LAYOUT_CONTENT_HEIGHT}) - ${headerHeight.value}px)`
|
|
|
: '0',
|
|
|
// 'overflow-y': shouldAutoHeight.value?'auto':'unset',
|
|
|
};
|
|
@@ -97,28 +71,26 @@ onMounted(() => {
|
|
|
ref="headerRef"
|
|
|
:class="
|
|
|
cn(
|
|
|
- 'bg-card relative px-6 py-4',
|
|
|
+ 'bg-card border-border relative flex items-end border-b px-6 py-4',
|
|
|
headerClass,
|
|
|
- fixedHeader
|
|
|
- ? 'border-border border-b transition-all duration-200'
|
|
|
- : '',
|
|
|
)
|
|
|
"
|
|
|
- :style="headerStyle"
|
|
|
>
|
|
|
- <slot name="title">
|
|
|
- <div v-if="title" class="mb-2 flex text-lg font-semibold">
|
|
|
- {{ title }}
|
|
|
- </div>
|
|
|
- </slot>
|
|
|
+ <div class="flex-auto">
|
|
|
+ <slot name="title">
|
|
|
+ <div v-if="title" class="mb-2 flex text-lg font-semibold">
|
|
|
+ {{ title }}
|
|
|
+ </div>
|
|
|
+ </slot>
|
|
|
|
|
|
- <slot name="description">
|
|
|
- <p v-if="description" class="text-muted-foreground">
|
|
|
- {{ description }}
|
|
|
- </p>
|
|
|
- </slot>
|
|
|
+ <slot name="description">
|
|
|
+ <p v-if="description" class="text-muted-foreground">
|
|
|
+ {{ description }}
|
|
|
+ </p>
|
|
|
+ </slot>
|
|
|
+ </div>
|
|
|
|
|
|
- <div v-if="$slots.extra" class="absolute bottom-4 right-4">
|
|
|
+ <div v-if="$slots.extra">
|
|
|
<slot name="extra"></slot>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -132,8 +104,8 @@ onMounted(() => {
|
|
|
ref="footerRef"
|
|
|
:class="
|
|
|
cn(
|
|
|
- footerClass,
|
|
|
'bg-card align-center absolute bottom-0 left-0 right-0 flex px-6 py-4',
|
|
|
+ footerClass,
|
|
|
)
|
|
|
"
|
|
|
>
|