index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  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" @click="createConversation">
  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 @fain:置顶、聊天记录、一星期钱、30天前,前端对数据重新做一下分组,或者后端接口改一下 -->
  26. <div v-for="conversationKey in Object.keys(conversationMap)" :key="conversationKey" >
  27. <div v-if="conversationMap[conversationKey].length">
  28. <el-text class="mx-1" size="small" tag="b">{{conversationKey}}</el-text>
  29. </div>
  30. <el-row
  31. v-for="conversation in conversationMap[conversationKey]"
  32. :key="conversation.id"
  33. @click="handleConversationClick(conversation.id)">
  34. <div
  35. :class="conversation.id === conversationId ? 'conversation active' : 'conversation'"
  36. @click="changeConversation(conversation.id)"
  37. >
  38. <div class="title-wrapper">
  39. <img class="avatar" :src="conversation.roleAvatar"/>
  40. <span class="title">{{ conversation.title }}</span>
  41. </div>
  42. <!-- TODO @fan:缺一个【置顶】按钮,效果改成 hover 上去展示 -->
  43. <div class="button-wrapper">
  44. <el-icon title="编辑" @click="updateConversationTitle(conversation)">
  45. <Icon icon="ep:edit"/>
  46. </el-icon>
  47. <el-icon title="删除会话" @click="deleteChatConversation(conversation)">
  48. <Icon icon="ep:delete"/>
  49. </el-icon>
  50. </div>
  51. </div>
  52. </el-row>
  53. </div>
  54. </div>
  55. </div>
  56. <!-- 左底部:工具栏 -->
  57. <div class="tool-box">
  58. <div @click="handleRoleRepository">
  59. <Icon icon="ep:user"/>
  60. <el-text size="small">角色仓库</el-text>
  61. </div>
  62. <div @click="handleClearConversation">
  63. <Icon icon="ep:delete"/>
  64. <el-text size="small">清空未置顶对话</el-text>
  65. </div>
  66. </div>
  67. </el-aside>
  68. <!-- 右侧:会话详情 -->
  69. <el-container class="detail-container">
  70. <!-- 右顶部 TODO 芋艿:右对齐 -->
  71. <el-header class="header">
  72. <div class="title">
  73. {{ useConversation?.title }}
  74. </div>
  75. <div>
  76. <!-- TODO @fan:样式改下;这里我已经改成点击后,弹出了 -->
  77. <el-button type="primary" @click="openChatConversationUpdateForm">
  78. <span v-html="useConversation?.modelName"></span>
  79. <Icon icon="ep:setting" style="margin-left: 10px"/>
  80. </el-button>
  81. <el-button>
  82. <Icon icon="ep:user"/>
  83. </el-button>
  84. <el-button>
  85. <Icon icon="ep:download"/>
  86. </el-button>
  87. <el-button>
  88. <Icon icon="ep:arrow-up"/>
  89. </el-button>
  90. </div>
  91. </el-header>
  92. <!-- main -->
  93. <el-main class="main-container">
  94. <div class="message-container" ref="messageContainer">
  95. <div class="chat-list" v-for="(item, index) in list" :key="index">
  96. <!-- 靠左 message -->
  97. <!-- TODO 芋艿:类型判断 -->
  98. <div class="left-message message-item" v-if="item.type === 'system'">
  99. <div class="avatar">
  100. <el-avatar
  101. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  102. />
  103. </div>
  104. <div class="message">
  105. <div>
  106. <el-text class="time">{{ formatDate(item.createTime) }}</el-text>
  107. </div>
  108. <div class="left-text-container" ref="markdownViewRef">
  109. <!-- <div class="left-text markdown-view" v-html="item.content"></div>-->
  110. <!-- <mdPreview :content="item.content" :delay="false" />-->
  111. <MarkdownView class="left-text" :content="item.content" />
  112. </div>
  113. <div class="left-btns">
  114. <div class="btn-cus" @click="noCopy(item.content)">
  115. <img class="btn-image" src="../../../assets/ai/copy.svg"/>
  116. <el-text class="btn-cus-text">复制</el-text>
  117. </div>
  118. <div class="btn-cus" style="margin-left: 20px" @click="onDelete(item.id)">
  119. <img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px"/>
  120. <el-text class="btn-cus-text">删除</el-text>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <!-- 靠右 message -->
  126. <div class="right-message message-item" v-if="item.type === 'user'">
  127. <div class="avatar">
  128. <el-avatar
  129. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  130. />
  131. </div>
  132. <div class="message">
  133. <div>
  134. <el-text class="time">{{ formatDate(item.createTime) }}</el-text>
  135. </div>
  136. <div class="right-text-container">
  137. <div class="right-text">{{ item.content }}</div>
  138. <!-- <MarkdownView class="right-text" :content="item.content" />-->
  139. </div>
  140. <div class="right-btns">
  141. <div class="btn-cus" @click="noCopy(item.content)">
  142. <img class="btn-image" src="@/assets/ai/copy.svg"/>
  143. <el-text class="btn-cus-text">复制</el-text>
  144. </div>
  145. <div class="btn-cus" style="margin-left: 20px" @click="onDelete(item.id)">
  146. <img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px"/>
  147. <el-text class="btn-cus-text">删除</el-text>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <!-- 角色仓库抽屉 -->
  155. <el-drawer v-model="drawer" title="角色仓库" size="50%">
  156. <Role/>
  157. </el-drawer>
  158. </el-main>
  159. <el-footer class="footer-container">
  160. <form @submit.prevent="onSend" class="prompt-from">
  161. <textarea
  162. class="prompt-input"
  163. v-model="prompt"
  164. @keyup.enter="onSend"
  165. @input="onPromptInput"
  166. @compositionstart="onCompositionstart"
  167. @compositionend="onCompositionend"
  168. placeholder="问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"
  169. ></textarea>
  170. <div class="prompt-btns">
  171. <el-switch/>
  172. <el-button
  173. type="primary"
  174. size="default"
  175. @click="onSend()"
  176. :loading="conversationInProgress"
  177. v-if="conversationInProgress == false"
  178. >
  179. {{ conversationInProgress ? '进行中' : '发送' }}
  180. </el-button>
  181. <el-button
  182. type="danger"
  183. size="default"
  184. @click="stopStream()"
  185. v-if="conversationInProgress == true"
  186. >
  187. 停止
  188. </el-button>
  189. </div>
  190. </form>
  191. </el-footer>
  192. </el-container>
  193. </el-container>
  194. <ChatConversationUpdateForm
  195. ref="chatConversationUpdateFormRef"
  196. @success="getChatConversationList"
  197. />
  198. </template>
  199. <script setup lang="ts">
  200. import MarkdownView from '@/components/MarkdownView/index.vue'
  201. import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
  202. import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
  203. import ChatConversationUpdateForm from './components/ChatConversationUpdateForm.vue'
  204. import Role from '@/views/ai/chat/role/index.vue'
  205. import {formatDate} from '@/utils/formatTime'
  206. import {useClipboard} from '@vueuse/core'
  207. const route = useRoute() // 路由
  208. const message = useMessage() // 消息弹窗
  209. const conversationList = ref([] as ChatConversationVO[])
  210. const conversationMap = ref<any>({})
  211. // 初始化 copy 到粘贴板
  212. const {copy} = useClipboard()
  213. const drawer = ref<boolean>(false) // 角色仓库抽屉
  214. const searchName = ref('') // 查询的内容
  215. const inputTimeout = ref<any>() // 处理输入中回车的定时器
  216. const conversationId = ref<number | null>(null) // 选中的对话编号
  217. const conversationInProgress = ref(false) // 对话进行中
  218. const conversationInAbortController = ref<any>() // 对话进行中 abort 控制器(控制 stream 对话)
  219. const prompt = ref<string>() // prompt
  220. // 判断 消息列表 滚动的位置(用于判断是否需要滚动到消息最下方)
  221. const messageContainer: any = ref(null)
  222. const isScrolling = ref(false) //用于判断用户是否在滚动
  223. const isComposing = ref(false) // 判断用户是否在输入
  224. /** chat message 列表 */
  225. // defineOptions({ name: 'chatMessageList' })
  226. const list = ref<ChatMessageVO[]>([]) // 列表的数据
  227. const useConversation = ref<ChatConversationVO | null>(null) // 使用的 Conversation
  228. /** 新建对话 */
  229. const createConversation = async () => {
  230. // 新建对话
  231. const conversationId = await ChatConversationApi.createChatConversationMy(
  232. {} as unknown as ChatConversationVO
  233. )
  234. changeConversation(conversationId)
  235. // 刷新对话列表
  236. await getChatConversationList()
  237. }
  238. const changeConversation = (id: number) => {
  239. // 切换对话
  240. conversationId.value = id
  241. // TODO 芋艿:待实现
  242. // 刷新 message 列表
  243. messageList()
  244. }
  245. /** 更新聊天会话的标题 */
  246. const updateConversationTitle = async (conversation: ChatConversationVO) => {
  247. // 二次确认
  248. const {value} = await ElMessageBox.prompt('修改标题', {
  249. inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
  250. inputErrorMessage: '标题不能为空',
  251. inputValue: conversation.title
  252. })
  253. // 发起修改
  254. await ChatConversationApi.updateChatConversationMy({
  255. id: conversation.id,
  256. title: value
  257. } as ChatConversationVO)
  258. message.success('重命名成功')
  259. // 刷新列表
  260. await getChatConversationList()
  261. }
  262. /** 删除聊天会话 */
  263. const deleteChatConversation = async (conversation: ChatConversationVO) => {
  264. try {
  265. // 删除的二次确认
  266. await message.delConfirm(`是否确认删除会话 - ${conversation.title}?`)
  267. // 发起删除
  268. await ChatConversationApi.deleteChatConversationMy(conversation.id)
  269. message.success('会话已删除')
  270. // 刷新列表
  271. await getChatConversationList()
  272. } catch {
  273. }
  274. }
  275. const searchConversation = () => {
  276. // TODO fan:待实现
  277. }
  278. /** send */
  279. const onSend = async () => {
  280. // 判断用户是否在输入
  281. if (isComposing.value) {
  282. return
  283. }
  284. // 进行中不允许发送
  285. if (conversationInProgress.value) {
  286. return
  287. }
  288. const content = prompt.value?.trim() + ''
  289. if (content.length < 2) {
  290. ElMessage({
  291. message: '请输入内容!',
  292. type: 'error'
  293. })
  294. return
  295. }
  296. // TODO 芋艿:这块交互要在优化;应该是先插入到 UI 界面,里面会有当前的消息,和正在思考中;之后发起请求;
  297. // 清空输入框
  298. prompt.value = ''
  299. // const requestParams = {
  300. // conversationId: conversationId.value,
  301. // content: content
  302. // } as unknown as ChatMessageSendVO
  303. // // 添加 message
  304. const userMessage = {
  305. conversationId: conversationId.value,
  306. content: content
  307. } as ChatMessageVO
  308. // list.value.push(userMessage)
  309. // // 滚动到住下面
  310. // scrollToBottom()
  311. // stream
  312. await doSendStream(userMessage)
  313. //
  314. }
  315. const doSendStream = async (userMessage: ChatMessageVO) => {
  316. // 创建AbortController实例,以便中止请求
  317. conversationInAbortController.value = new AbortController()
  318. // 标记对话进行中
  319. conversationInProgress.value = true
  320. try {
  321. // 发送 event stream
  322. let isFirstMessage = true
  323. let content = ''
  324. ChatMessageApi.sendStream(
  325. userMessage.conversationId, // TODO 芋艿:这里可能要在优化;
  326. userMessage.content,
  327. conversationInAbortController.value,
  328. (message) => {
  329. console.log('message', message)
  330. const data = JSON.parse(message.data) // TODO 芋艿:类型处理;
  331. // debugger
  332. // 如果没有内容结束链接
  333. if (data.receive.content === '') {
  334. // 标记对话结束
  335. conversationInProgress.value = false
  336. // 结束 stream 对话
  337. conversationInAbortController.value.abort()
  338. }
  339. // 首次返回需要添加一个 message 到页面,后面的都是更新
  340. if (isFirstMessage) {
  341. isFirstMessage = false
  342. // debugger
  343. list.value.push(data.send)
  344. list.value.push(data.receive)
  345. } else {
  346. // debugger
  347. content = content + data.receive.content
  348. const lastMessage = list.value[list.value.length - 1]
  349. lastMessage.content = content
  350. list.value[list.value - 1] = lastMessage
  351. }
  352. // 滚动到最下面
  353. scrollToBottom()
  354. },
  355. (error) => {
  356. console.log('error', error)
  357. // 标记对话结束
  358. conversationInProgress.value = false
  359. // 结束 stream 对话
  360. conversationInAbortController.value.abort()
  361. },
  362. () => {
  363. console.log('close')
  364. // 标记对话结束
  365. conversationInProgress.value = false
  366. // 结束 stream 对话
  367. conversationInAbortController.value.abort()
  368. }
  369. )
  370. } finally {
  371. }
  372. }
  373. /** 查询列表 */
  374. const messageList = async () => {
  375. try {
  376. if (conversationId.value === null) {
  377. return
  378. }
  379. // 获取列表数据
  380. const res = await ChatMessageApi.messageList(conversationId.value)
  381. list.value = res
  382. // 滚动到最下面
  383. scrollToBottom()
  384. } finally {
  385. }
  386. }
  387. function scrollToBottom() {
  388. nextTick(() => {
  389. //注意要使用nexttick以免获取不到dom
  390. console.log('isScrolling.value', isScrolling.value)
  391. if (!isScrolling.value) {
  392. messageContainer.value.scrollTop =
  393. messageContainer.value.scrollHeight - messageContainer.value.offsetHeight
  394. }
  395. })
  396. }
  397. function handleScroll() {
  398. const scrollContainer = messageContainer.value
  399. const scrollTop = scrollContainer.scrollTop
  400. const scrollHeight = scrollContainer.scrollHeight
  401. const offsetHeight = scrollContainer.offsetHeight
  402. if (scrollTop + offsetHeight < scrollHeight) {
  403. // 用户开始滚动并在最底部之上,取消保持在最底部的效果
  404. isScrolling.value = true
  405. } else {
  406. // 用户停止滚动并滚动到最底部,开启保持到最底部的效果
  407. isScrolling.value = false
  408. }
  409. }
  410. function noCopy(content) {
  411. copy(content)
  412. ElMessage({
  413. message: '复制成功!',
  414. type: 'success'
  415. })
  416. }
  417. const onDelete = async (id) => {
  418. // 删除 message
  419. await ChatMessageApi.delete(id)
  420. ElMessage({
  421. message: '删除成功!',
  422. type: 'success'
  423. })
  424. // tip:如果 stream 进行中的 message,就需要调用 controller 结束
  425. stopStream()
  426. // 重新获取 message 列表
  427. await messageList()
  428. }
  429. const stopStream = async () => {
  430. // tip:如果 stream 进行中的 message,就需要调用 controller 结束
  431. if (conversationInAbortController.value) {
  432. conversationInAbortController.value.abort()
  433. }
  434. // 设置为 false
  435. conversationInProgress.value = false
  436. }
  437. /** 修改聊天会话 */
  438. const chatConversationUpdateFormRef = ref()
  439. const openChatConversationUpdateForm = async () => {
  440. chatConversationUpdateFormRef.value.open(conversationId.value)
  441. }
  442. // 输入
  443. const onCompositionstart = () => {
  444. console.log('onCompositionstart。。。.')
  445. isComposing.value = true
  446. }
  447. const onCompositionend = () => {
  448. // console.log('输入结束...')
  449. setTimeout(() => {
  450. console.log('输入结束...')
  451. isComposing.value = false
  452. }, 200)
  453. }
  454. const onPromptInput = (event) => {
  455. // 非输入法 输入设置为 true
  456. if (!isComposing.value) {
  457. // 回车 event data 是 null
  458. if (event.data == null) {
  459. return
  460. }
  461. console.log('setTimeout 输入开始...')
  462. isComposing.value = true
  463. }
  464. // 清理定时器
  465. if (inputTimeout.value) {
  466. clearTimeout(inputTimeout.value)
  467. }
  468. // 重置定时器
  469. inputTimeout.value = setTimeout(() => {
  470. console.log('setTimeout 输入结束...')
  471. isComposing.value = false
  472. }, 400)
  473. }
  474. const getConversation = async (conversationId: number | null) => {
  475. if (!conversationId) {
  476. return
  477. }
  478. // 获取对话信息
  479. useConversation.value = await ChatConversationApi.getChatConversationMy(conversationId)
  480. console.log('useConversation.value', useConversation.value)
  481. }
  482. /** 获得聊天会话列表 */
  483. const getChatConversationList = async () => {
  484. conversationList.value = await ChatConversationApi.getChatConversationMyList()
  485. // 默认选中第一条
  486. if (conversationList.value.length === 0) {
  487. conversationId.value = null
  488. list.value = []
  489. } else {
  490. if (conversationId.value === null) {
  491. conversationId.value = conversationList.value[0].id
  492. changeConversation(conversationList.value[0].id)
  493. }
  494. }
  495. // map
  496. const groupRes = await conversationTimeGroup(conversationList.value)
  497. conversationMap.value = groupRes
  498. }
  499. const conversationTimeGroup = async (list: ChatConversationVO[]) => {
  500. // 排序、指定、时间分组(今天、一天前、三天前、七天前、30天前)
  501. const groupMap = {
  502. '置顶': [],
  503. '今天': [],
  504. '一天前': [],
  505. '三天前': [],
  506. '七天前': [],
  507. '三十天前': []
  508. }
  509. // 当前时间的时间戳
  510. const now = Date.now();
  511. // 定义时间间隔常量(单位:毫秒)
  512. const oneDay = 24 * 60 * 60 * 1000;
  513. const threeDays = 3 * oneDay;
  514. const sevenDays = 7 * oneDay;
  515. const thirtyDays = 30 * oneDay;
  516. console.log('listlistlist', list)
  517. for (const conversation: ChatConversationVO of list) {
  518. // 置顶
  519. if (conversation.pinned) {
  520. groupMap['置顶'].push(conversation)
  521. continue
  522. }
  523. // 计算时间差(单位:毫秒)
  524. const diff = now - conversation.updateTime;
  525. // 根据时间间隔判断
  526. if (diff < oneDay) {
  527. groupMap['今天'].push(conversation)
  528. } else if (diff < threeDays) {
  529. groupMap['一天前'].push(conversation)
  530. } else if (diff < sevenDays) {
  531. groupMap['三天前'].push(conversation)
  532. } else if (diff < thirtyDays) {
  533. groupMap['七天前'].push(conversation)
  534. } else {
  535. groupMap['三十天前'].push(conversation)
  536. }
  537. }
  538. return groupMap
  539. }
  540. // 对话点击
  541. const handleConversationClick = async (id: number) => {
  542. // 切换对话
  543. conversationId.value = id
  544. console.log('conversationId.value', conversationId.value)
  545. // 获取列表数据
  546. await messageList()
  547. }
  548. // 角色仓库
  549. const handleRoleRepository = async () => {
  550. drawer.value = !drawer.value
  551. }
  552. // 清空对话
  553. const handleClearConversation = async () => {
  554. ElMessageBox.confirm(
  555. '确认后对话会全部清空,置顶的对话除外。',
  556. '确认提示',
  557. {
  558. confirmButtonText: '确认',
  559. cancelButtonText: '取消',
  560. type: 'warning',
  561. }
  562. )
  563. .then(async () => {
  564. await ChatConversationApi.deleteMyAllExceptPinned()
  565. ElMessage({
  566. message: '操作成功!',
  567. type: 'success'
  568. })
  569. // 清空选中的对话
  570. useConversation.value = null
  571. conversationId.value = null
  572. list.value = []
  573. // 获得聊天会话列表
  574. await getChatConversationList()
  575. })
  576. .catch(() => {
  577. })
  578. }
  579. /** 初始化 **/
  580. onMounted(async () => {
  581. // 设置当前对话
  582. if (route.query.conversationId) {
  583. conversationId.value = route.query.conversationId as number
  584. }
  585. // 获得聊天会话列表
  586. await getChatConversationList()
  587. // 获取对话信息
  588. await getConversation(conversationId.value)
  589. // 获取列表数据
  590. await messageList()
  591. // scrollToBottom();
  592. // await nextTick
  593. // 监听滚动事件,判断用户滚动状态
  594. messageContainer.value.addEventListener('scroll', handleScroll)
  595. // 添加 copy 监听
  596. messageContainer.value.addEventListener('click', (e: any) => {
  597. console.log(e)
  598. if (e.target.id === 'copy') {
  599. copy(e.target?.dataset?.copy)
  600. ElMessage({
  601. message: '复制成功!',
  602. type: 'success'
  603. })
  604. }
  605. })
  606. })
  607. </script>
  608. <style lang="scss" scoped>
  609. .ai-layout {
  610. // TODO @范 这里height不能 100% 先这样临时处理
  611. position: absolute;
  612. flex: 1;
  613. top: 0;
  614. left: 0;
  615. height: 100%;
  616. width: 100%;
  617. //padding: 15px 15px;
  618. }
  619. .conversation-container {
  620. position: relative;
  621. display: flex;
  622. flex-direction: column;
  623. justify-content: space-between;
  624. padding: 0 10px;
  625. padding-top: 10px;
  626. .btn-new-conversation {
  627. padding: 18px 0;
  628. }
  629. .search-input {
  630. margin-top: 20px;
  631. }
  632. .conversation-list {
  633. margin-top: 20px;
  634. .conversation {
  635. display: flex;
  636. flex-direction: row;
  637. justify-content: space-between;
  638. flex: 1;
  639. padding: 0 5px;
  640. margin-top: 10px;
  641. cursor: pointer;
  642. border-radius: 5px;
  643. align-items: center;
  644. line-height: 30px;
  645. &.active {
  646. background-color: #e6e6e6;
  647. .button {
  648. display: inline-block;
  649. }
  650. }
  651. .title-wrapper {
  652. display: flex;
  653. flex-direction: row;
  654. align-items: center;
  655. }
  656. .title {
  657. padding: 5px 10px;
  658. max-width: 220px;
  659. font-size: 14px;
  660. overflow: hidden;
  661. white-space: nowrap;
  662. text-overflow: ellipsis;
  663. }
  664. .avatar {
  665. width: 28px;
  666. height: 28px;
  667. display: flex;
  668. flex-direction: row;
  669. justify-items: center;
  670. }
  671. // 对话编辑、删除
  672. .button-wrapper {
  673. right: 2px;
  674. display: flex;
  675. flex-direction: row;
  676. justify-items: center;
  677. color: #606266;
  678. .el-icon {
  679. margin-right: 5px;
  680. }
  681. }
  682. }
  683. }
  684. // 角色仓库、清空未设置对话
  685. .tool-box {
  686. line-height: 35px;
  687. display: flex;
  688. justify-content: space-between;
  689. align-items: center;
  690. color: var(--el-text-color);
  691. > div {
  692. display: flex;
  693. align-items: center;
  694. color: #606266;
  695. padding: 0;
  696. margin: 0;
  697. cursor: pointer;
  698. > span {
  699. margin-left: 5px;
  700. }
  701. }
  702. }
  703. }
  704. // 头部
  705. .detail-container {
  706. background: #ffffff;
  707. .header {
  708. display: flex;
  709. flex-direction: row;
  710. align-items: center;
  711. justify-content: space-between;
  712. background: #fbfbfb;
  713. box-shadow: 0 0 0 0 #dcdfe6;
  714. .title {
  715. font-size: 18px;
  716. font-weight: bold;
  717. }
  718. }
  719. }
  720. // main 容器
  721. .main-container {
  722. margin: 0;
  723. padding: 0;
  724. position: relative;
  725. }
  726. .message-container {
  727. position: absolute;
  728. top: 0;
  729. bottom: 0;
  730. left: 0;
  731. right: 0;
  732. //width: 100%;
  733. //height: 100%;
  734. overflow-y: scroll;
  735. padding: 0 15px;
  736. }
  737. // 中间
  738. .chat-list {
  739. display: flex;
  740. flex-direction: column;
  741. overflow-y: hidden;
  742. .message-item {
  743. margin-top: 50px;
  744. }
  745. .left-message {
  746. display: flex;
  747. flex-direction: row;
  748. }
  749. .right-message {
  750. display: flex;
  751. flex-direction: row-reverse;
  752. justify-content: flex-start;
  753. }
  754. .avatar {
  755. //height: 170px;
  756. //width: 170px;
  757. }
  758. .message {
  759. display: flex;
  760. flex-direction: column;
  761. text-align: left;
  762. margin: 0 15px;
  763. .time {
  764. text-align: left;
  765. line-height: 30px;
  766. }
  767. .left-text-container {
  768. display: flex;
  769. flex-direction: column;
  770. overflow-wrap: break-word;
  771. background-color: rgba(228, 228, 228, 0.8);
  772. box-shadow: 0 0 0 1px rgba(228, 228, 228, 0.8);
  773. border-radius: 10px;
  774. padding: 10px 10px 5px 10px;
  775. .left-text {
  776. color: #393939;
  777. font-size: 0.95rem;
  778. }
  779. }
  780. .right-text-container {
  781. display: flex;
  782. flex-direction: row-reverse;
  783. .right-text {
  784. font-size: 0.95rem;
  785. color: #fff;
  786. display: inline;
  787. background-color: #267fff;
  788. color: #fff;
  789. box-shadow: 0 0 0 1px #267fff;
  790. border-radius: 10px;
  791. padding: 10px;
  792. width: auto;
  793. overflow-wrap: break-word;
  794. }
  795. }
  796. .left-btns,
  797. .right-btns {
  798. display: flex;
  799. flex-direction: row;
  800. margin-top: 8px;
  801. }
  802. }
  803. // 复制、删除按钮
  804. .btn-cus {
  805. display: flex;
  806. background-color: transparent;
  807. align-items: center;
  808. .btn-image {
  809. height: 20px;
  810. margin-right: 5px;
  811. }
  812. .btn-cus-text {
  813. color: #757575;
  814. }
  815. }
  816. .btn-cus:hover {
  817. cursor: pointer;
  818. }
  819. .btn-cus:focus {
  820. background-color: #8c939d;
  821. }
  822. }
  823. // 底部
  824. .footer-container {
  825. display: flex;
  826. flex-direction: column;
  827. height: auto;
  828. margin: 0;
  829. padding: 0;
  830. .prompt-from {
  831. display: flex;
  832. flex-direction: column;
  833. height: auto;
  834. border: 1px solid #e3e3e3;
  835. border-radius: 10px;
  836. margin: 20px 20px;
  837. padding: 9px 10px;
  838. }
  839. .prompt-input {
  840. height: 80px;
  841. //box-shadow: none;
  842. border: none;
  843. box-sizing: border-box;
  844. resize: none;
  845. padding: 0px 2px;
  846. //padding: 5px 5px;
  847. overflow: hidden;
  848. }
  849. .prompt-input:focus {
  850. outline: none;
  851. }
  852. .prompt-btns {
  853. display: flex;
  854. justify-content: space-between;
  855. padding-bottom: 0px;
  856. padding-top: 5px;
  857. }
  858. }
  859. </style>