index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="go-content-box" :class="[`bg-depth${depth}`, flex && 'flex']">
  3. <div v-if="showTop" class="top go-mt-0 go-flex-no-wrap">
  4. <n-space class="go-flex-no-wrap">
  5. <n-ellipsis>
  6. <n-text>{{ title }}</n-text>
  7. </n-ellipsis>
  8. <div class="mt-1">
  9. <slot name="icon"></slot>
  10. </div>
  11. </n-space>
  12. <n-space>
  13. <slot name="top-right"></slot>
  14. <n-icon
  15. v-show="backIcon"
  16. size="20"
  17. class="go-cursor-pointer"
  18. @click="backHandle"
  19. >
  20. <ChevronBackOutlineIcon />
  21. </n-icon>
  22. </n-space>
  23. </div>
  24. <aside class="content">
  25. <n-scrollbar x-scrollable>
  26. <n-scrollbar>
  27. <slot></slot>
  28. </n-scrollbar>
  29. </n-scrollbar>
  30. </aside>
  31. <div v-if="showBottom" class="bottom go-mt-0">
  32. <slot name="bottom"></slot>
  33. </div>
  34. </div>
  35. </template>
  36. <script setup lang="ts">
  37. import { icon } from '@/plugins'
  38. const { ChevronBackOutlineIcon } = icon.ionicons5
  39. const emit = defineEmits(['back'])
  40. defineProps({
  41. title: String,
  42. showTop: {
  43. type: Boolean,
  44. default: true
  45. },
  46. showBottom: {
  47. type: Boolean,
  48. default: false
  49. },
  50. flex: {
  51. type: Boolean,
  52. default: false
  53. },
  54. // back
  55. backIcon: {
  56. type: Boolean,
  57. default: true
  58. },
  59. // 背景深度
  60. depth: {
  61. type: Number,
  62. default: 1
  63. }
  64. })
  65. const backHandle = () => {
  66. emit('back')
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. $topHeight: 36px;
  71. @include go(content-box) {
  72. height: calc(100vh - #{$--header-height});
  73. margin: 1px;
  74. margin-bottom: 0;
  75. &.bg-depth0 {
  76. @include filter-bg-color('background-color1');
  77. .bottom,
  78. .top {
  79. @include filter-bg-color('background-color1');
  80. }
  81. }
  82. &.bg-depth1 {
  83. @include filter-bg-color('background-color1');
  84. .bottom,
  85. .top {
  86. @include filter-bg-color('background-color2');
  87. }
  88. }
  89. &.bg-depth2 {
  90. @include filter-bg-color('background-color2');
  91. .bottom,
  92. .top {
  93. @include filter-bg-color('background-color3');
  94. }
  95. }
  96. &.bg-depth3 {
  97. @include filter-bg-color('background-color3');
  98. .bottom,
  99. .top {
  100. @include filter-bg-color('background-color4');
  101. }
  102. }
  103. &.flex {
  104. flex: 1;
  105. }
  106. .top,
  107. .bottom {
  108. display: flex;
  109. justify-content: space-between;
  110. flex-wrap: nowrap;
  111. align-items: center;
  112. height: 36px;
  113. padding: 0 10px;
  114. .mt-1 {
  115. margin-top: 2px;
  116. }
  117. }
  118. .content {
  119. height: calc(100vh - #{$--header-height} - #{$topHeight});
  120. overflow: hidden;
  121. }
  122. }
  123. </style>