message-text.vue 794 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <div>
  3. <span
  4. v-for="(item, index) in data.text"
  5. :key="index"
  6. >
  7. <span
  8. v-if="item.name === 'text'"
  9. class="text"
  10. >{{ item.text }}</span>
  11. <img
  12. v-else
  13. class="emoji"
  14. :src="item.src"
  15. >
  16. </span>
  17. </div>
  18. </template>
  19. <script lang="ts" setup>
  20. import { watchEffect, ref } from '../../../../adapter-vue';
  21. interface IProps {
  22. content: Record<string, any>;
  23. }
  24. const props = withDefaults(defineProps<IProps>(), {
  25. content: () => ({}),
  26. });
  27. const data = ref();
  28. watchEffect(() => {
  29. data.value = props.content;
  30. });
  31. </script>
  32. <style lang="scss" scoped>
  33. .emoji {
  34. width: 20px;
  35. height: 20px;
  36. }
  37. .text {
  38. white-space: pre-wrap;
  39. word-break: break-word;
  40. font-size: 14px;
  41. text-size-adjust: none;
  42. }
  43. </style>