layout-footer.vue 1010 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <script setup lang="ts">
  2. import type { CSSProperties } from 'vue';
  3. import { computed } from 'vue';
  4. interface Props {
  5. /**
  6. * 是否固定在顶部
  7. * @default true
  8. */
  9. fixed?: boolean;
  10. /**
  11. * 高度
  12. * @default 32
  13. */
  14. height?: number;
  15. /**
  16. * 是否显示
  17. * @default true
  18. */
  19. show?: boolean;
  20. /**
  21. * 高度
  22. * @default 100%
  23. */
  24. width?: string;
  25. /**
  26. * zIndex
  27. * @default 0
  28. */
  29. zIndex?: number;
  30. }
  31. const props = withDefaults(defineProps<Props>(), {
  32. fixed: true,
  33. height: 32,
  34. show: true,
  35. width: '100%',
  36. zIndex: 0,
  37. });
  38. const style = computed((): CSSProperties => {
  39. const { fixed, height, show, width, zIndex } = props;
  40. return {
  41. height: `${height}px`,
  42. marginBottom: show ? '0' : `-${height}px`,
  43. position: fixed ? 'fixed' : 'static',
  44. width,
  45. zIndex,
  46. };
  47. });
  48. </script>
  49. <template>
  50. <footer
  51. :style="style"
  52. class="bg-background-content bottom-0 w-full transition-all duration-200"
  53. >
  54. <slot></slot>
  55. </footer>
  56. </template>