index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <el-container>
  3. <!-- 左侧:会话列表 -->
  4. <el-aside width="260px" class="conversation-container">
  5. <!-- 左顶部:新建对话 -->
  6. <el-button class="w-1/1" type="primary">
  7. <Icon icon="ep:plus" class="mr-5px" />
  8. 新建对话
  9. </el-button>
  10. <!-- 左顶部:搜索对话 -->
  11. <el-input
  12. v-model="searchName"
  13. class="mt-10px"
  14. placeholder="搜索历史记录"
  15. @keyup="searchConversation"
  16. >
  17. <template #prefix>
  18. <Icon icon="ep:search" />
  19. </template>
  20. </el-input>
  21. <!-- 左中间:对话列表 -->
  22. <div class="conversation-list" :style="{ height: leftHeight + 'px' }">
  23. <el-row v-for="conversation in conversationList" :key="conversation.id">
  24. <div
  25. :class="conversation.id === conversationId ? 'conversation active' : 'conversation'"
  26. @click="changeConversation(conversation)"
  27. >
  28. <el-image :src="conversation.avatar" class="avatar" />
  29. <span class="title">{{ conversation.title }}</span>
  30. <span class="button">
  31. <!-- TODO 芋艿:缺置顶按钮 -->
  32. <el-icon title="编辑" @click="updateConversationTitle(conversation)">
  33. <Icon icon="ep:edit" />
  34. </el-icon>
  35. <el-icon title="删除会话" @click="deleteConversationTitle(conversation)">
  36. <Icon icon="ep:delete" />
  37. </el-icon>
  38. </span>
  39. </div>
  40. </el-row>
  41. </div>
  42. <!-- 左底部:工具栏 TODO 芋艿:50% 不太对 -->
  43. <div class="tool-box">
  44. <sapn class="w-1/2"> <Icon icon="ep:user" /> 角色仓库 </sapn>
  45. <sapn class="w-1/2"> <Icon icon="ep:delete" />清空未置顶对话</sapn>
  46. </div>
  47. </el-aside>
  48. <!-- 右侧:会话详情 -->
  49. <el-container class="detail-container">
  50. <!-- 右顶部 TODO 芋艿:右对齐 -->
  51. <el-header class="header">
  52. <el-button>3.5-turbo-0125 <Icon icon="ep:setting" /></el-button>
  53. <el-button>
  54. <Icon icon="ep:user" />
  55. </el-button>
  56. <el-button>
  57. <Icon icon="ep:download" />
  58. </el-button>
  59. <el-button>
  60. <Icon icon="ep:arrow-up" />
  61. </el-button>
  62. </el-header>
  63. <el-main>对话列表</el-main>
  64. <el-footer>发送消息框</el-footer>
  65. </el-container>
  66. </el-container>
  67. </template>
  68. <script setup lang="ts">
  69. const conversationList = [
  70. {
  71. id: 1,
  72. title: '测试标题',
  73. avatar:
  74. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  75. },
  76. {
  77. id: 2,
  78. title: '测试对话',
  79. avatar:
  80. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  81. }
  82. ]
  83. const conversationId = ref(1)
  84. const searchName = ref('')
  85. const leftHeight = window.innerHeight - 240 // TODO 芋艿:这里还不太对
  86. const changeConversation = (conversation) => {
  87. console.log(conversation)
  88. conversationId.value = conversation.id
  89. // TODO 芋艿:待实现
  90. }
  91. const updateConversationTitle = (conversation) => {
  92. console.log(conversation)
  93. // TODO 芋艿:待实现
  94. }
  95. const deleteConversationTitle = (conversation) => {
  96. console.log(conversation)
  97. // TODO 芋艿:待实现
  98. }
  99. const searchConversation = () => {
  100. // TODO 芋艿:待实现
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .conversation-container {
  105. .conversation-list {
  106. .conversation {
  107. display: flex;
  108. justify-content: flex-start;
  109. width: 100%;
  110. padding: 5px 5px 0 0;
  111. cursor: pointer;
  112. &.active {
  113. // TODO 芋艿:这里不太对
  114. background-color: #343540;
  115. .button {
  116. display: inline;
  117. }
  118. }
  119. .title {
  120. padding: 5px 10px;
  121. max-width: 220px;
  122. font-size: 14px;
  123. overflow: hidden;
  124. white-space: nowrap;
  125. text-overflow: ellipsis;
  126. }
  127. .avatar {
  128. width: 28px;
  129. height: 28px;
  130. border-radius: 50%;
  131. }
  132. .button {
  133. position: absolute;
  134. right: 2px;
  135. top: 16px;
  136. .el-icon {
  137. margin-right: 5px;
  138. }
  139. }
  140. }
  141. .tool-box {
  142. display: flex;
  143. justify-content: flex-start;
  144. padding: 0 20px 10px 20px;
  145. border-top: 1px solid black;
  146. }
  147. }
  148. }
  149. .detail-container {
  150. .header {
  151. width: 100%;
  152. height: 30px;
  153. display: flex;
  154. flex-direction: row;
  155. align-items: center;
  156. justify-content: center;
  157. padding-top: 10px;
  158. }
  159. }
  160. </style>