TheChatView.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <script setup>
  2. import { ref, unref, computed } from 'vue';
  3. import UserTop from './userTop.vue';
  4. defineProps({
  5. isFooter: {
  6. type: Boolean,
  7. default: true
  8. },
  9. isBackBtn: {
  10. type: Boolean,
  11. default: false
  12. },
  13. leftTitle: {
  14. type: String,
  15. default: ''
  16. },
  17. isChatSlot: {
  18. type: Boolean,
  19. default: true
  20. },
  21. catalogData: {
  22. type: Array,
  23. default: () => []
  24. }
  25. })
  26. const emit = defineEmits(['onClickBack'])
  27. const targetScrollDom = ref(null);
  28. const voiceSwitchStatus = ref(false);
  29. const voiceName = computed(() => unref(voiceSwitchStatus) ? 'tool-voice-close' : 'tool-voice-open')
  30. const changeVoiceStatus = () => {
  31. voiceSwitchStatus.value = !voiceSwitchStatus.value;
  32. }
  33. const handleClickBack = () => {
  34. emit("onClickBack");
  35. }
  36. defineExpose({ targetScrollDom });
  37. </script>
  38. <template>
  39. <div class="flex-1 h-full chat-container">
  40. <div class="catalog-wrapper" v-if="catalogData.length">
  41. <slot name="catalog"></slot>
  42. </div>
  43. <div class="chat-wrapper w-full h-full flex flex-col rounded-[10px]">
  44. <div class="chat-header flex items-center justify-between py-[24px] px-[18px] ">
  45. <div class="left_inner" @click="handleClickBack">
  46. <span v-if="isBackBtn" class="back-btn"></span>
  47. <span v-if="leftTitle" class="left_title">{{ leftTitle }}</span>
  48. </div>
  49. <div class="right_inner flex items-center space-x-[16px]">
  50. <UserTop></UserTop>
  51. </div>
  52. </div>
  53. <main class="chat-main flex flex-1 flex-col justify-between" v-if="isChatSlot">
  54. <div class="chat-scroll" ref="targetScrollDom">
  55. <div class="w-[900px] m-auto ">
  56. <slot></slot>
  57. </div>
  58. </div>
  59. </main>
  60. <main class="control-main" v-if="!isChatSlot">
  61. <slot name="control"></slot>
  62. </main>
  63. <footer class="chat-footer relative w-[900px] m-auto pb-[10px]" v-if="isFooter">
  64. <slot name="footer" />
  65. </footer>
  66. </div>
  67. </div>
  68. </template>
  69. <style scoped lang="scss">
  70. .chat-container {
  71. position: relative;
  72. padding: 20px 20px 20px 0;
  73. overflow: hidden;
  74. .chat-header {
  75. .left_inner {
  76. display: flex;
  77. align-items: center;
  78. .back-btn {
  79. display: inline-block;
  80. width: 36px;
  81. height: 36px;
  82. border-radius: 8px;
  83. background: url("@/assets/images/chat/back-btn.png") no-repeat;
  84. background-size: cover;
  85. cursor: pointer;
  86. &:hover {
  87. background: #dceffe url("@/assets/images/chat/back-btn.png") no-repeat;
  88. background-size: cover;
  89. }
  90. }
  91. .left_title {
  92. font-size: 20px;
  93. font-weight: bold;
  94. color: #1A2029;
  95. }
  96. }
  97. }
  98. .chat-wrapper {
  99. border: 1px solid #fff;
  100. background: linear-gradient(180deg, rgba(238, 253, 255, 0.5) 0%, rgba(231, 243, 252, 0.5) 100%);
  101. .control-main {
  102. // flex: 1;
  103. height: calc(100vh - 124px);
  104. padding: 0 24px 24px 24px;
  105. }
  106. .chat-main {
  107. position: relative;
  108. min-height: calc(100% - 310px);
  109. color: #1A2029;
  110. .chat-scroll {
  111. overflow-x: hidden;
  112. overflow-y: auto;
  113. scroll-behavior: smooth;
  114. &::-webkit-scrollbar-thumb,
  115. &::-webkit-scrollbar-track {
  116. background: transparent;
  117. }
  118. &::-webkit-scrollbar {
  119. width: 0px;
  120. overflow-y: scroll;
  121. }
  122. }
  123. }
  124. }
  125. }
  126. </style>