index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <el-container class="ai-layout">
  3. <!-- 左侧:会话列表 -->
  4. <el-aside width="260px" class="conversation-container">
  5. <div>
  6. <!-- 左顶部:新建对话 -->
  7. <el-button class="w-1/1 btn-new-conversation" type="primary">
  8. <Icon icon="ep:plus" class="mr-5px" />
  9. 新建对话
  10. </el-button>
  11. <!-- 左顶部:搜索对话 -->
  12. <el-input
  13. v-model="searchName"
  14. size="large"
  15. class="mt-10px search-input"
  16. placeholder="搜索历史记录"
  17. @keyup="searchConversation"
  18. >
  19. <template #prefix>
  20. <Icon icon="ep:search" />
  21. </template>
  22. </el-input>
  23. <!-- 左中间:对话列表 -->
  24. <div class="conversation-list" >
  25. <!-- TODO @芋艿,置顶、聊天记录、一星期钱、30天前,前端对数据重新做一下分组,或者后端接口改一下 -->
  26. <div>
  27. <el-text class="mx-1" size="small" tag="b">置顶</el-text>
  28. </div>
  29. <el-row v-for="conversation in conversationList" :key="conversation.id">
  30. <div
  31. :class="conversation.id === conversationId ? 'conversation active' : 'conversation'"
  32. @click="changeConversation(conversation)"
  33. >
  34. <div class="title-wrapper">
  35. <img class="avatar" :src="conversation.avatar" />
  36. <span class="title">{{ conversation.title }}</span>
  37. </div>
  38. <div class="button-wrapper">
  39. <el-icon title="编辑" @click="updateConversationTitle(conversation)">
  40. <Icon icon="ep:edit" />
  41. </el-icon>
  42. <el-icon title="删除会话" @click="deleteConversationTitle(conversation)">
  43. <Icon icon="ep:delete" />
  44. </el-icon>
  45. </div>
  46. </div>
  47. </el-row>
  48. </div>
  49. </div>
  50. <!-- 左底部:工具栏 -->
  51. <div class="tool-box">
  52. <div>
  53. <Icon icon="ep:user" />
  54. <el-text size="small">角色仓库</el-text>
  55. </div>
  56. <div>
  57. <Icon icon="ep:delete" />
  58. <el-text size="small" >清空未置顶对话</el-text>
  59. </div>
  60. </div>
  61. </el-aside>
  62. <!-- 右侧:会话详情 -->
  63. <el-container class="detail-container">
  64. <!-- 右顶部 TODO 芋艿:右对齐 -->
  65. <el-header class="header">
  66. <div class="title">
  67. 标题......
  68. </div>
  69. <div>
  70. <el-button>3.5-turbo-0125 <Icon icon="ep:setting" /></el-button>
  71. <el-button>
  72. <Icon icon="ep:user" />
  73. </el-button>
  74. <el-button>
  75. <Icon icon="ep:download" />
  76. </el-button>
  77. <el-button>
  78. <Icon icon="ep:arrow-up" />
  79. </el-button>
  80. </div>
  81. </el-header>
  82. <el-main>对话列表</el-main>
  83. <el-footer>
  84. <el-input
  85. class="prompt-input"
  86. type="textarea"
  87. placeholder="请输入提示词..."
  88. />
  89. </el-footer>
  90. </el-container>
  91. </el-container>
  92. </template>
  93. <script setup lang="ts">
  94. const conversationList = [
  95. {
  96. id: 1,
  97. title: '测试标题',
  98. avatar:
  99. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  100. },
  101. {
  102. id: 2,
  103. title: '测试对话',
  104. avatar:
  105. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  106. }
  107. ]
  108. const conversationId = ref(1)
  109. const searchName = ref('')
  110. const leftHeight = window.innerHeight - 240 // TODO 芋艿:这里还不太对
  111. const changeConversation = (conversation) => {
  112. console.log(conversation)
  113. conversationId.value = conversation.id
  114. // TODO 芋艿:待实现
  115. }
  116. const updateConversationTitle = (conversation) => {
  117. console.log(conversation)
  118. // TODO 芋艿:待实现
  119. }
  120. const deleteConversationTitle = (conversation) => {
  121. console.log(conversation)
  122. // TODO 芋艿:待实现
  123. }
  124. const searchConversation = () => {
  125. // TODO 芋艿:待实现
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .ai-layout {
  130. // TODO @范 这里height不能 100% 先这样临时处理
  131. position: absolute;
  132. flex: 1;
  133. top: 0;
  134. left: 0;
  135. height: 100%;
  136. width: 100%;
  137. //padding: 15px 15px;
  138. }
  139. .conversation-container {
  140. position: relative;
  141. display: flex;
  142. flex-direction: column;
  143. justify-content: space-between;
  144. padding: 0 10px;
  145. padding-top: 10px;
  146. .btn-new-conversation {
  147. padding: 18px 0;
  148. }
  149. .search-input {
  150. margin-top: 20px;
  151. }
  152. .conversation-list {
  153. margin-top: 20px;
  154. .conversation {
  155. display: flex;
  156. flex-direction: row;
  157. justify-content: space-between;
  158. flex: 1;
  159. padding: 0 5px;
  160. margin-top: 10px;
  161. cursor: pointer;
  162. border-radius: 5px;
  163. align-items: center;
  164. line-height: 30px;
  165. &.active {
  166. background-color: #e6e6e6;
  167. .button {
  168. display: inline-block;
  169. }
  170. }
  171. .title-wrapper {
  172. display: flex;
  173. flex-direction: row;
  174. align-items: center;
  175. }
  176. .title {
  177. padding: 5px 10px;
  178. max-width: 220px;
  179. font-size: 14px;
  180. overflow: hidden;
  181. white-space: nowrap;
  182. text-overflow: ellipsis;
  183. }
  184. .avatar {
  185. width: 28px;
  186. height: 28px;
  187. display: flex;
  188. flex-direction: row;
  189. justify-items: center;
  190. }
  191. // 对话编辑、删除
  192. .button-wrapper {
  193. right: 2px;
  194. display: flex;
  195. flex-direction: row;
  196. justify-items: center;
  197. color: #606266;
  198. .el-icon {
  199. margin-right: 5px;
  200. }
  201. }
  202. }
  203. }
  204. // 角色仓库、清空未设置对话
  205. .tool-box {
  206. line-height: 35px;
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. color: var(--el-text-color);
  211. > div {
  212. display: flex;
  213. align-items: center;
  214. color: #606266;
  215. padding: 0;
  216. margin: 0;
  217. > span {
  218. margin-left: 5px;
  219. }
  220. }
  221. }
  222. }
  223. .detail-container {
  224. background: #ffffff;
  225. .header {
  226. display: flex;
  227. flex-direction: row;
  228. align-items: center;
  229. justify-content: space-between;
  230. background: #fbfbfb;
  231. .title {
  232. font-size: 23px;
  233. font-weight: bold;
  234. }
  235. }
  236. .prompt-input {
  237. }
  238. }
  239. </style>