message-abstract-text.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div
  3. :class="[
  4. 'message-abstract-text',
  5. `message-abstract-text-${highlightType}`,
  6. `message-abstract-text-${displayType}`,
  7. ]"
  8. >
  9. <span
  10. v-for="(contentItem, index) in contentText"
  11. :key="index"
  12. :class="[(contentItem && contentItem.isHighlight) ? 'highlight' : 'normal']"
  13. >
  14. {{ transformTextWithKeysToEmojiNames(contentItem.text) }}
  15. </span>
  16. </div>
  17. </template>
  18. <script setup lang="ts">
  19. import { ref, withDefaults } from '../../../../../adapter-vue';
  20. import { transformTextWithKeysToEmojiNames } from '../../../../TUIChat/emoji-config';
  21. import { IHighlightContent } from '../../../type';
  22. interface IProps {
  23. content: IHighlightContent[];
  24. highlightType: 'font' | 'background';
  25. displayType: 'info' | 'bubble';
  26. }
  27. const props = withDefaults(defineProps<IProps>(), {
  28. content: () => ([]) as IHighlightContent[],
  29. highlightType: 'font',
  30. displayType: 'info',
  31. });
  32. const contentText = ref<Array<{ text: string; isHighlight: boolean }>>(props.content);
  33. </script>
  34. <style scoped lang="scss">
  35. @import "../../../../../assets/styles/common";
  36. .message-abstract-text {
  37. justify-content: flex-start;
  38. &-font {
  39. color: #999;
  40. .highlight {
  41. color: #007aff;
  42. }
  43. .normal {
  44. color: #999;
  45. }
  46. }
  47. &-background {
  48. color: #1f2329;
  49. .highlight {
  50. background-color: #007aff33;
  51. }
  52. .normal {
  53. font-size: 14px;
  54. }
  55. }
  56. &-info {
  57. overflow: hidden;
  58. text-overflow: ellipsis;
  59. white-space: nowrap;
  60. font-size: 12px;
  61. .highlight {
  62. font-size: 12px;
  63. }
  64. .normal {
  65. font-size: 12px;
  66. }
  67. }
  68. &-bubble {
  69. font-size: 14px;
  70. .highlight {
  71. font-size: 14px;
  72. }
  73. .normal {
  74. font-size: 14px;
  75. }
  76. }
  77. }
  78. </style>