index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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
  71. <Icon icon="ep:setting"/>
  72. </el-button>
  73. <el-button>
  74. <Icon icon="ep:user"/>
  75. </el-button>
  76. <el-button>
  77. <Icon icon="ep:download"/>
  78. </el-button>
  79. <el-button>
  80. <Icon icon="ep:arrow-up"/>
  81. </el-button>
  82. </div>
  83. </el-header>
  84. <!-- main -->
  85. <el-main class="main-container">
  86. <MessageList />
  87. </el-main>
  88. <el-footer class="footer-container">
  89. <textarea placeholder="问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"
  90. class="prompt-input">
  91. </textarea>
  92. <div class="prompt-btns">
  93. <el-switch/>
  94. <el-button type="primary" size="default">发送</el-button>
  95. </div>
  96. </el-footer>
  97. </el-container>
  98. </el-container>
  99. </template>
  100. <script setup lang="ts">
  101. import MessageList from './components/MessageList.vue'
  102. const conversationList = [
  103. {
  104. id: 1,
  105. title: '测试标题',
  106. avatar:
  107. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  108. },
  109. {
  110. id: 2,
  111. title: '测试对话',
  112. avatar:
  113. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  114. }
  115. ]
  116. const conversationId = ref(1)
  117. const searchName = ref('')
  118. const leftHeight = window.innerHeight - 240 // TODO 芋艿:这里还不太对
  119. const changeConversation = (conversation) => {
  120. console.log(conversation)
  121. conversationId.value = conversation.id
  122. // TODO 芋艿:待实现
  123. }
  124. const updateConversationTitle = (conversation) => {
  125. console.log(conversation)
  126. // TODO 芋艿:待实现
  127. }
  128. const deleteConversationTitle = (conversation) => {
  129. console.log(conversation)
  130. // TODO 芋艿:待实现
  131. }
  132. const searchConversation = () => {
  133. // TODO 芋艿:待实现
  134. }
  135. /** 初始化 **/
  136. onMounted(() => {
  137. })
  138. </script>
  139. <style lang="scss" scoped>
  140. .ai-layout {
  141. // TODO @范 这里height不能 100% 先这样临时处理
  142. position: absolute;
  143. flex: 1;
  144. top: 0;
  145. left: 0;
  146. height: 100%;
  147. width: 100%;
  148. //padding: 15px 15px;
  149. }
  150. .conversation-container {
  151. position: relative;
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: space-between;
  155. padding: 0 10px;
  156. padding-top: 10px;
  157. .btn-new-conversation {
  158. padding: 18px 0;
  159. }
  160. .search-input {
  161. margin-top: 20px;
  162. }
  163. .conversation-list {
  164. margin-top: 20px;
  165. .conversation {
  166. display: flex;
  167. flex-direction: row;
  168. justify-content: space-between;
  169. flex: 1;
  170. padding: 0 5px;
  171. margin-top: 10px;
  172. cursor: pointer;
  173. border-radius: 5px;
  174. align-items: center;
  175. line-height: 30px;
  176. &.active {
  177. background-color: #e6e6e6;
  178. .button {
  179. display: inline-block;
  180. }
  181. }
  182. .title-wrapper {
  183. display: flex;
  184. flex-direction: row;
  185. align-items: center;
  186. }
  187. .title {
  188. padding: 5px 10px;
  189. max-width: 220px;
  190. font-size: 14px;
  191. overflow: hidden;
  192. white-space: nowrap;
  193. text-overflow: ellipsis;
  194. }
  195. .avatar {
  196. width: 28px;
  197. height: 28px;
  198. display: flex;
  199. flex-direction: row;
  200. justify-items: center;
  201. }
  202. // 对话编辑、删除
  203. .button-wrapper {
  204. right: 2px;
  205. display: flex;
  206. flex-direction: row;
  207. justify-items: center;
  208. color: #606266;
  209. .el-icon {
  210. margin-right: 5px;
  211. }
  212. }
  213. }
  214. }
  215. // 角色仓库、清空未设置对话
  216. .tool-box {
  217. line-height: 35px;
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. color: var(--el-text-color);
  222. > div {
  223. display: flex;
  224. align-items: center;
  225. color: #606266;
  226. padding: 0;
  227. margin: 0;
  228. > span {
  229. margin-left: 5px;
  230. }
  231. }
  232. }
  233. }
  234. // 头部
  235. .detail-container {
  236. background: #ffffff;
  237. .header {
  238. display: flex;
  239. flex-direction: row;
  240. align-items: center;
  241. justify-content: space-between;
  242. background: #fbfbfb;
  243. box-shadow: 0 0 0 0 #dcdfe6;
  244. .title {
  245. font-size: 18px;
  246. font-weight: bold;
  247. }
  248. }
  249. }
  250. // main 容器
  251. .main-container {
  252. margin: 0;
  253. padding: 0;
  254. position: relative;
  255. }
  256. // 底部
  257. .footer-container {
  258. display: flex;
  259. flex-direction: column;
  260. height: auto;
  261. border: 1px solid #e3e3e3;
  262. border-radius: 10px;
  263. margin: 20px 20px;
  264. padding: 9px 10px;
  265. .prompt-input {
  266. height: 80px;
  267. //box-shadow: none;
  268. border: none;
  269. box-sizing: border-box;
  270. resize: none;
  271. padding: 0px 2px;
  272. //padding: 5px 5px;
  273. overflow: hidden;
  274. }
  275. .prompt-input:focus {
  276. outline: none;
  277. }
  278. .prompt-btns {
  279. display: flex;
  280. justify-content: space-between;
  281. padding-bottom: 0px;
  282. padding-top: 5px;
  283. }
  284. }
  285. </style>