message-abstract-video.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div :class="['message-abstract-video']">
  3. <div class="message-abstract-video-box">
  4. <img
  5. :src="videoUrl"
  6. :class="['video-snapshot']"
  7. >
  8. <Icon
  9. :file="playIcon"
  10. class="video-play"
  11. />
  12. </div>
  13. </div>
  14. </template>
  15. <script setup lang="ts">
  16. import { computed } from '../../../../../adapter-vue';
  17. import Icon from '../../../../common/Icon.vue';
  18. import playIcon from '../../../../../assets/icon/video-play.png';
  19. import { IVideoMessageContent } from '../../../../../interface';
  20. interface IProps {
  21. messageContent: Record<string, unknown> | IVideoMessageContent | undefined;
  22. }
  23. const props = withDefaults(defineProps<IProps>(), {
  24. messageContent: () => ({}) as IVideoMessageContent,
  25. });
  26. const videoUrl = computed<string>(() => {
  27. return (props.messageContent as IVideoMessageContent).snapshotUrl || (props.messageContent as IVideoMessageContent).url;
  28. });
  29. </script>
  30. <style scoped lang="scss">
  31. @import "../../../../../assets/styles/common";
  32. .message-abstract-video {
  33. max-width: 100px;
  34. max-height: 100px;
  35. width: 100px;
  36. height: 100px;
  37. overflow: hidden;
  38. background-color: #fff;
  39. &-box {
  40. max-width: 100px;
  41. max-height: 100px;
  42. width: 100px;
  43. height: 100px;
  44. overflow: hidden;
  45. background-color: #fff;
  46. position: relative;
  47. .video-snapshot {
  48. max-width: 100px;
  49. max-height: 100px;
  50. width: 100px;
  51. height: 100px;
  52. object-fit: contain;
  53. }
  54. .video-play {
  55. position: absolute;
  56. top: 0;
  57. right: 0;
  58. left: 0;
  59. bottom: 0;
  60. z-index: 3;
  61. width: 35px;
  62. height: 35px;
  63. margin: auto;
  64. }
  65. }
  66. }</style>