Layout.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div class="layout">
  3. <div
  4. v-if="$slots.title"
  5. class="layout-title"
  6. >
  7. <slot name="title" />
  8. </div>
  9. <div
  10. class="layout-content"
  11. :style="cssVar"
  12. >
  13. <slot name="content" />
  14. </div>
  15. <div
  16. v-if="$slots.bottom"
  17. class="layout-bottom"
  18. >
  19. <slot name="bottom" />
  20. </div>
  21. </div>
  22. </template>
  23. <script setup lang='ts'>
  24. import { computed, useSlots } from 'vue'
  25. const slots = useSlots()
  26. const cssVar = computed(() => ({
  27. '--autoHeigh': slots.title && slots.bottom ? 'calc(100% - 95px)' : !slots.title && slots.bottom ? 'calc(100% - 50px)' : slots.title && !slots.bottom ? 'calc(100% - 45px)' : '100%'
  28. }))
  29. </script>
  30. <style lang="scss" scoped>
  31. .layout {
  32. height: 100%;
  33. padding: 40px 4% 0 4%;
  34. min-width: 327px;
  35. &-title {
  36. font-size: 18px;
  37. height: 25px;
  38. margin-bottom: 20px;
  39. }
  40. &-content {
  41. text-align: center;
  42. padding-bottom: 20px;
  43. display: flex;
  44. flex-wrap: wrap;
  45. align-content: flex-start;
  46. height: var(--autoHeigh);
  47. overflow-y: auto;
  48. gap: 15px;
  49. }
  50. &-bottom {
  51. width: 100%;
  52. height: 50px;
  53. display: flex;
  54. align-items: center;
  55. justify-content: space-between;
  56. :deep(.n-button) {
  57. --n-width: 30%;
  58. max-width: 200px;
  59. --n-border-radius: 10px;
  60. }
  61. }
  62. }
  63. </style>