message-input-button.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div :class="['message-input-button', !isPC && 'message-input-button-h5']">
  3. <button
  4. v-if="props.enableSend"
  5. class="message-input-button-cont"
  6. data-type="text"
  7. :disabled="false"
  8. @click="sendMessage"
  9. >
  10. <p
  11. v-if="displayHover"
  12. class="message-input-button-hover"
  13. >
  14. {{ TUITranslateService.t("TUIChat.按Enter发送,Ctrl+Enter换行") }}
  15. </p>
  16. {{ TUITranslateService.t("发送") }}
  17. </button>
  18. </div>
  19. </template>
  20. <script setup lang="ts">
  21. import { ref } from '../../../adapter-vue';
  22. import { TUITranslateService } from '@tencentcloud/chat-uikit-engine';
  23. import { TUIConstants } from '@tencentcloud/tui-core';
  24. import { isPC } from '../../../utils/env';
  25. import TUIChatConfig from '../config';
  26. const props = defineProps({
  27. enableSend: {
  28. type: Boolean,
  29. default: true,
  30. },
  31. });
  32. const displayHover = ref(TUIChatConfig.getChatType() !== TUIConstants.TUIChat.TYPE.ROOM);
  33. const emits = defineEmits(['sendMessage']);
  34. const sendMessage = () => {
  35. emits('sendMessage');
  36. };
  37. </script>
  38. <style scoped lang="scss">
  39. @import "../../../assets/styles/common";
  40. .message-input-button {
  41. position: absolute;
  42. bottom: 20px;
  43. right: 20px;
  44. &-h5 {
  45. position: static;
  46. }
  47. &-cont {
  48. padding: 8px 20px;
  49. border-radius: 4px;
  50. border: none;
  51. font-size: 14px;
  52. text-align: center;
  53. line-height: 20px;
  54. font-weight: 400;
  55. background: #006eff;
  56. color: #fff;
  57. letter-spacing: 0;
  58. cursor: pointer;
  59. }
  60. &-hover {
  61. display: none;
  62. justify-content: center;
  63. align-items: center;
  64. position: absolute;
  65. right: 120%;
  66. word-break: keep-all;
  67. height: 30px;
  68. white-space: nowrap;
  69. top: 0;
  70. bottom: 0;
  71. margin: auto 0;
  72. padding: 5px 10px;
  73. border-radius: 3px;
  74. background: #000;
  75. color: #fff;
  76. opacity: 0.3;
  77. &::before {
  78. content: "";
  79. position: absolute;
  80. width: 0;
  81. height: 0;
  82. right: -20px;
  83. border: 10px solid transparent;
  84. border-left: 10px solid #000;
  85. }
  86. }
  87. &:hover {
  88. .message-input-button-hover {
  89. display: flex;
  90. }
  91. }
  92. }
  93. </style>