ImageBlock2.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <Touchable
  3. touchable
  4. v-bind="props"
  5. :flexShrink="0"
  6. :innerStyle="{ borderRadius: theme.resolveThemeSize(radius), overflow: 'hidden', }"
  7. :width="width"
  8. @click="$emit('click')"
  9. >
  10. <Image
  11. :src="src"
  12. :height="imageHeight"
  13. :radius="imageRadius"
  14. width="100%"
  15. round
  16. mode="aspectFill"
  17. />
  18. <slot name="desc">
  19. <FlexCol :padding="15">
  20. <IconTextBlock
  21. :title="title"
  22. :desc="desc"
  23. :extra="extra"
  24. :extraMpSlotState="Boolean($slots.extra)"
  25. >
  26. <template v-if="$slots.extra" #extra>
  27. <slot name="extra" />
  28. </template>
  29. </IconTextBlock>
  30. </FlexCol>
  31. </slot>
  32. </Touchable>
  33. </template>
  34. <script lang="ts">
  35. /**
  36. * 组件说明:图片块2。
  37. *
  38. * 该组件可以用于显示图片,支持在图片下方显示描述。
  39. *
  40. * 该组件的默认高度为 200rpx。
  41. */
  42. export default {}
  43. </script>
  44. <script setup lang="ts">
  45. import { useTheme } from '@/components/theme/ThemeDefine';
  46. import Image from '../../basic/Image.vue';
  47. import Touchable from '@/components/feedback/Touchable.vue';
  48. import type { FlexProps } from '../../layout/FlexView.vue';
  49. import IconTextBlock from './IconTextBlock.vue';
  50. import FlexCol from '@/components/layout/FlexCol.vue';
  51. export interface ImageBlock2Props extends Partial<FlexProps> {
  52. /**
  53. * 宽度。
  54. */
  55. width?: string | number;
  56. /**
  57. * 高度。
  58. */
  59. imageHeight?: string | number;
  60. /**
  61. * 图片的路径。
  62. */
  63. src?: string;
  64. /**
  65. * 图片的圆角。
  66. */
  67. imageRadius?: string | number;
  68. /**
  69. * 图片下方显示标题。
  70. */
  71. title?: string;
  72. /**
  73. * 图片下方显示描述。
  74. */
  75. desc?: string;
  76. /**
  77. * 图片下方显示额外信息。
  78. */
  79. extra?: string;
  80. }
  81. const theme = useTheme();
  82. const props = withDefaults(defineProps<ImageBlock2Props>(), {
  83. width: 400,
  84. imageHeight: 250,
  85. imageRadius: 0,
  86. direction: 'column',
  87. backgroundColor: "white",
  88. overflow: "hidden",
  89. })
  90. defineEmits([
  91. "click"
  92. ])
  93. </script>
  94. <style lang="scss">
  95. .nana-image-desc {
  96. color: #fff;
  97. font-size: 25rpx;
  98. white-space: nowrap;
  99. overflow: hidden;
  100. text-overflow: ellipsis;
  101. }
  102. </style>