index.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446
  1. <template>
  2. <div class="chat bg-white">
  3. <div class="flex items-center h-screen relative" >
  4. <div class="leftInfo relative" v-show="!showNodata" >
  5. <div class="history">
  6. <!-- historyActive -->
  7. <div class="historyBox" v-for="(item, index) in allRecords" :key="index">
  8. <div class="top flex w-full cursor-pointer" @click="item.open = !item.open">
  9. <div class="photo">
  10. <img class="object-cover" :src="baseApi + item.picture" alt="">
  11. </div>
  12. <div class="info flex-1 ml-2 flex flex-col justify-around">
  13. <div class="text-sm font-semibold">{{ item.characterName }}</div>
  14. <div class="text-sm text-gray-400">{{ item.prologue }}</div>
  15. </div>
  16. <div class="flex items-center text-lg" style="height: 48px;">
  17. <i v-if="!item.open" class="el-icon-arrow-down" style="font-size: 16px;"></i>
  18. <i v-else class="el-icon-arrow-up" style="font-size: 16px;"></i>
  19. </div>
  20. </div>
  21. <!-- <transition name="el-zoom-in-top"> -->
  22. <div class="dialogueList mt-4" v-show="item.open">
  23. <div class="flex justify-between mb-2">
  24. <el-button v-if="item.isDelete == 0" type="primary" class="flex-1" round @click="newStart_juese(item)">新的对话</el-button>
  25. <div v-else class="flex-1 rounded border border-gray-200 text-sm p-2 text-gray-600">
  26. {{item.characterName}}已经被设定为私有或被创建者删除。
  27. </div>
  28. <el-dropdown
  29. class="flex justify-end items-center ml-2"
  30. trigger="click"
  31. @command="handleCommand2($event, item)"
  32. >
  33. <div class=" w-8 h-8 bg-gray-100 rounded flex justify-center items-center cursor-pointer">
  34. <i slot="reference" class="el-icon-more"></i>
  35. </div>
  36. <el-dropdown-menu slot="dropdown" >
  37. <el-dropdown-item command="2">删除</el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. </div>
  41. <div class="dialogue flex justify-between items-center w-full h-16 rounded-md px-2 mb-2 cursor-pointer relative"
  42. :class="info.id == item.id && index2 == recordsIndex && 'historyActive'"
  43. v-for="(item2, index2) in item.chatCharacterList"
  44. :key="index2"
  45. @click.self="clickDialogue(item, item2, index2)"
  46. >
  47. <span @click.self="clickDialogue(item, item2, index2)">
  48. <i v-if="item2.sceneId || item2.sceneIcon" class="el-icon-video-camera"></i>
  49. {{ item2.chatTitle }}
  50. </span>
  51. <span @click.self="clickDialogue(item, item2, index2)" class=" text-sm text-gray-500">{{ item2.createTime }}</span>
  52. <el-dropdown
  53. class="dialogueIconBg absolute h-16 w-20 right-0 flex justify-end items-center pr-4"
  54. trigger="click"
  55. @command="handleCommand($event, item, item2 )"
  56. >
  57. <div >
  58. <i slot="reference" class="el-icon-more"></i>
  59. </div>
  60. <el-dropdown-menu slot="dropdown" >
  61. <el-dropdown-item command="1">修改标题</el-dropdown-item>
  62. <el-dropdown-item command="2">删除</el-dropdown-item>
  63. </el-dropdown-menu>
  64. </el-dropdown>
  65. </div>
  66. </div>
  67. <!-- </transition> -->
  68. </div>
  69. </div>
  70. <!-- 角色详情 -->
  71. <div class="chatInfo absolute top-0 left-0 w-full h-full z-30 bg-white" v-show="showInfo == 1">
  72. <div class="flex flex-col p-4 h-full">
  73. <div class="flex justify-between items-center text-base mb-3">
  74. <div>角色详情</div>
  75. <i class="el-icon-close cursor-pointer" @click="showInfoChange(0)"></i>
  76. </div>
  77. <div class="flex">
  78. <span class="chatInfo_photo">
  79. <img class="w-16 h-16 rounded-full overflow-hidden object-cover" :src="baseApi + info.picture">
  80. </span>
  81. <div class="w-0 flex-1 ml-2">
  82. <div class="text-xl font-medium">{{ info.characterName }}</div>
  83. <div class="mt-1 text-gray-500 text-sm">Rochat No.75680</div>
  84. </div>
  85. </div>
  86. <div class="flex mt-4">
  87. <div class="hot flex w-auto items-center px-2 py-1 text-sm mr-2 rounded-full">
  88. <v-icon name="fire" scale="1"/>
  89. <span class="ml-1">{{ info.hotCount }}</span>
  90. </div>
  91. </div>
  92. <div class="flex justify-around mt-4">
  93. <div class=" rounded-full w-32 text-center py-2 text-sm cursor-pointer" style="border: solid 1px #000">分享</div>
  94. <div class=" rounded-full w-32 text-center py-2 text-sm cursor-pointer" style="border: solid 1px #000" @click="showDetail = !showDetail">角色详情</div>
  95. </div>
  96. <transition name="el-zoom-in-top">
  97. <div v-show="showDetail" >
  98. <div class="mt-5 text-base pb-3 border-b border-gray-200">
  99. <div>
  100. <i class="el-icon-document"></i>
  101. 简介
  102. </div>
  103. <div class="mt-3 text-sm max-h-48">
  104. {{ info.prologue }}
  105. </div>
  106. </div>
  107. <div class="flex justify-between items-center mt-5 text-base pb-3 border-b border-gray-200">
  108. <div>
  109. <i class="el-icon-user"></i>
  110. 创作人
  111. </div>
  112. <div class="text-sm max-h-48">
  113. {{ info.author }}
  114. </div>
  115. </div>
  116. <div class="flex justify-between items-center mt-5 text-base pb-3 border-b border-gray-200">
  117. <div>
  118. <i class="el-icon-time"></i>
  119. 创建时间
  120. </div>
  121. <div class="text-sm max-h-48">
  122. {{ info.createTime }}
  123. </div>
  124. </div>
  125. <div class="mt-5 text-base">
  126. <i class="el-icon-discount"></i>
  127. 特征
  128. </div>
  129. <div class="tags mt-4 pb-3">
  130. <span class="tag" v-for="(item, index) in info.labelArr" :key="index">
  131. {{ item }}
  132. </span>
  133. </div>
  134. </div>
  135. </transition>
  136. <div class="mt-5 text-base pb-3 flex-1 flex flex-col">
  137. <div>
  138. <!-- <i class="el-icon-document"></i> -->
  139. 查看场景
  140. </div>
  141. <div class="mt-3 text-sm max-h-48">
  142. <div v-if="info.sceneList && info.sceneList.length > 0" class="grid grid-cols-2 gap-2 mb-4 cursor-pointer">
  143. <template v-for="(item, index) in info.sceneList" >
  144. <div v-if="item.isDelete == 0" class="flex flex-col justify-center" :key="index" @click="sceneChange(item)">
  145. <img class=" rounded w-full h-24 object-cover" :src="baseApi + item.background" alt="">
  146. <div>{{ item.sceneName }}</div>
  147. <div class=" text-gray-400">{{ item.sceneDescription }}</div>
  148. </div>
  149. </template>
  150. </div>
  151. <el-empty v-else description="暂无场景"></el-empty>
  152. <div class="flex justify-center mt-10">
  153. <el-button type="primary" round @click="toCreateScene">创建场景</el-button>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <!-- 场景详情 -->
  160. <div class="absolute top-0 left-0 w-full h-full z-30 bg-white overflow-hidden" v-show="showInfo == 2">
  161. <div class="flex flex-col p-4 h-full">
  162. <div class="flex justify-between items-center text-base mb-3">
  163. <div>场景详情</div>
  164. <i class="el-icon-close cursor-pointer" @click="showInfoChange(0)"></i>
  165. </div>
  166. <div class=" text-gray-500">{{ sceneInfo.sceneDescription }}</div>
  167. </div>
  168. </div>
  169. </div>
  170. <div class="content" :class="fullScreen && 'contentFull'" v-show="!showNodata" :style="{ backgroundImage: `url(${baseApi}${sceneInfo.background})`}">
  171. <!-- <div class="leftImg">
  172. <img :src="baseApi + info.picture" alt="">
  173. <div class="aiInfo">
  174. <span class="photo">
  175. <img :src="baseApi + info.picture">
  176. </span>
  177. <div class="info">
  178. <div class="name">{{ info.characterName }}</div>
  179. <div class="tags">
  180. <span class="tag" v-for="(item, index) in info.labelArr" :key="index">
  181. {{ item }}
  182. </span>
  183. </div>
  184. <div class="infoContent">{{ info.prologue }}</div>
  185. </div>
  186. </div>
  187. </div> -->
  188. <div class="fullScreenButton rounded-full border border-gray-200" @click="clickFullScreen">
  189. <i class="el-icon-arrow-left" v-if="!fullScreen"></i>
  190. <i class="el-icon-arrow-right" v-else></i>
  191. </div>
  192. <div class="chat-box" >
  193. <div class="chatBoxTitle absolute top-0">
  194. <div>
  195. {{ info.characterName }}
  196. <el-dropdown
  197. v-if="sceneId"
  198. class="flex justify-end items-center"
  199. trigger="click"
  200. @command="handleCommand3"
  201. @visible-change="dropdown3Show = !dropdown3Show"
  202. >
  203. <div>
  204. <div slot="reference" class="flex justify-center items-center cursor-pointer text-white">
  205. 已进入场景:{{ sceneInfo.sceneName }}
  206. <i class="el-icon-arrow-up ml-2" style="font-size: 16px;" v-if="dropdown3Show"></i>
  207. <i class="el-icon-arrow-down ml-2" style="font-size: 16px;" v-else></i>
  208. </div>
  209. </div>
  210. <el-dropdown-menu slot="dropdown" >
  211. <el-dropdown-item command="1">场景详情</el-dropdown-item>
  212. <el-dropdown-item command="2">新场景对话</el-dropdown-item>
  213. <el-dropdown-item command="3">回到常规对话</el-dropdown-item>
  214. </el-dropdown-menu>
  215. </el-dropdown>
  216. </div>
  217. <div class="flex w-60 justify-end">
  218. <el-tooltip effect="dark" content="设定" placement="bottom">
  219. <el-popover
  220. placement="bottom"
  221. width="400"
  222. trigger="click">
  223. <div class="p-2">
  224. <div class="flex justify-between mb-4">
  225. <span>语音自动播放</span>
  226. <el-switch v-model="setting.value1">
  227. </el-switch>
  228. </div>
  229. <div class="flex justify-between">
  230. <span>全屏幕</span>
  231. <el-switch v-model="fullScreen">
  232. </el-switch>
  233. </div>
  234. </div>
  235. <i slot="reference" class="fa-solid fa-sliders cursor-pointer text-xl mr-6"></i>
  236. </el-popover>
  237. </el-tooltip>
  238. <el-tooltip effect="dark" content="角色详情" placement="bottom">
  239. <i class="fa-solid fa-file-invoice cursor-pointer text-xl mr-6" @click="showInfoChange(1)"></i>
  240. </el-tooltip>
  241. <el-tooltip v-if="!sceneId" effect="dark" content="开始新的对话" placement="bottom">
  242. <i class="fa-solid fa-comment-medical cursor-pointer text-xl mr-6" @click="newStart"></i>
  243. </el-tooltip>
  244. <el-tooltip effect="dark" content="历史对话" placement="bottom">
  245. <i class="fa-solid fa-clock-rotate-left cursor-pointer text-xl" @click="showInfoChange(0)"></i>
  246. </el-tooltip>
  247. </div>
  248. </div>
  249. <audio ref="audio" muted v-show="false" :src="audioUrl" autoplay="" @ended="audioEnd" controls></audio>
  250. <div class="messages" ref="messages">
  251. <template v-for="(item, index) in returnMessage">
  252. <div v-if="item.role == 'assistant'" class="mb-4 flex" :key="index">
  253. <!-- ai返回的信息 -->
  254. <div class="pt-2 photo">
  255. <img
  256. :src="baseApi + info.picture"
  257. class="rounded-full w-14 h-14 object-cover"
  258. />
  259. </div>
  260. <div class="messageRight">
  261. <div class="message mt-4 ml-4 p-2 rounded-r-md rounded-bl-md text-xs" >
  262. <div v-if="item.voiceFilePosition" class="yyPlayBg mb-2 w-16 p-1 cursor-pointer" >
  263. <img v-if="audioPlayIndex == index" class="yyPlay" src="@/assets/images/播放/yyPlay1.png" alt="" >
  264. <img v-else class="yyPlay" src="@/assets/images/播放/yyPlay.png" alt="" @click="playAudio(item.voiceFilePosition, index)">
  265. <!-- <svg-icon class="icon" class-name="speech-icon" icon-class="speech" @click.stop="click" /> -->
  266. </div>
  267. <div v-show="!item.content" class="loadingMessage" >
  268. <div v-loading="!item.content" element-loading-background="rgba(0, 0, 0, 0.0)"></div>
  269. </div>
  270. <p style="white-space: pre-line;" v-show="item.content">{{ item.content }} </p>
  271. <div class="messageOptions" v-show="returnMessage.length == 1">
  272. <div class="option" v-for="(item, index) in messageOptions" :key="index" @click="messageOptionClick(item.chatGuidance)">
  273. {{ item.chatGuidance }}
  274. </div>
  275. </div>
  276. </div>
  277. </div>
  278. </div>
  279. <!-- 用户发送的信息 -->
  280. <div v-if="item.role == 'user'" class="mb-4 flex me" :key="index">
  281. <div class="pt-2 photo">
  282. <img
  283. :src="$store.state.user.avatar"
  284. class="rounded-full w-14 h-14 object-cover"
  285. />
  286. </div>
  287. <div class="messageRight">
  288. <div class="messageUser mr-4 mt-4 p-2 rounded-l-md rounded-br-md text-xs">
  289. {{ item.content }}
  290. </div>
  291. </div>
  292. </div>
  293. </template>
  294. </div>
  295. <div class="inputBox absolute left-2 right-2 bottom-4 " @click="inputBoxClick">
  296. <input
  297. v-if="canChat"
  298. ref="input"
  299. type="text"
  300. placeholder="输入消息..."
  301. class="w-full flex-1 py-2 px-4 rounded-l-lg text-sm focus:outline-none"
  302. v-model="content"
  303. @keydown="Enterkey"
  304. />
  305. <div class="flex pt-6 justify-between" v-if="canChat">
  306. <div class="tools w-36 flex justify-between">
  307. <i class="el-icon-setting text-2xl cursor-pointer" @click="showConfig = true"></i>
  308. <i class="el-icon-picture-outline text-2xl cursor-pointer"></i>
  309. <i class="el-icon-s-opportunity text-2xl cursor-pointer"></i>
  310. </div>
  311. <button @click.prevent="getStreamChatWithWeb" class="px-4 rounded-r-lg text-sm text-gray-400" :class="content && 'planeColor'">
  312. <v-icon name="paper-plane" scale="1.5"/>
  313. </button>
  314. </div>
  315. <div v-if="!canChat" class=" flex w-full text-sm text-gray-400">
  316. 当前角色或场景已被设定为私有或被创作者删除,但你任然可以查看历史对话。
  317. </div>
  318. </div>
  319. </div>
  320. </div>
  321. <div v-show="showNodata" class=" w-full h-full flex flex-col justify-center items-center">
  322. <el-empty description="暂无聊天记录,点击按钮并探索新角色。"></el-empty>
  323. <el-button type="primary" round @click="$router.push('/')">寻找一个角色</el-button>
  324. </div>
  325. <el-dialog
  326. title="配置"
  327. :visible.sync="showConfig"
  328. width="500px"
  329. >
  330. <p class="text-base">身分</p>
  331. <p class="text-sm text-gray-400">选择你和角色聊天的身份</p>
  332. <div class="flex items-start py-3 border-b border-gray-200">
  333. <el-radio-group class="radio" v-model="configForm.radio1">
  334. <el-radio-button label="上海"></el-radio-button>
  335. </el-radio-group>
  336. <el-button>
  337. <i class="el-icon-sort" style="transform: rotate(90deg);"></i>
  338. </el-button>
  339. </div>
  340. <p class="text-base mt-3">选择模型</p>
  341. <p class="text-sm text-gray-400">每个模型可能有不同的效果,仅对当前对话有影响</p>
  342. <div class="flex items-start py-3 border-b border-gray-200">
  343. <el-radio-group class="radio" v-model="configForm.radio2">
  344. <el-radio-button v-for="(item, index) in modelList" :key="index" :label="item.id">{{ item.model }}</el-radio-button>
  345. </el-radio-group>
  346. </div>
  347. <p class="text-base mt-3">角色语言</p>
  348. <p class="text-sm text-gray-400">请选择角色的回复语言</p>
  349. <div class="flex items-start py-3">
  350. <el-radio-group class="radio" v-model="configForm.radio3">
  351. <el-radio-button label="自动"></el-radio-button>
  352. <el-radio-button label="简体中文"></el-radio-button>
  353. <el-radio-button label="繁體中文"></el-radio-button>
  354. <el-radio-button label="English"></el-radio-button>
  355. <el-radio-button label="Español"></el-radio-button>
  356. </el-radio-group>
  357. </div>
  358. <span slot="footer" class="dialog-footer">
  359. <el-button @click="showConfig = false">取 消</el-button>
  360. <el-button type="primary" @click="showConfig = false">确 定</el-button>
  361. </span>
  362. </el-dialog>
  363. </div>
  364. </div>
  365. </template>
  366. <script>
  367. import Header from "@/views/homeComponents/Header.vue"
  368. import {
  369. streamChatWithWebApi,
  370. getGuidanceApi,
  371. getModelListApi,
  372. addChatApi,
  373. getChatCharacterRecordsApi,
  374. getChatRecordApi,
  375. updateTitleApi,
  376. clearRecordApi,
  377. getVoiceFileApi
  378. } from "@/api/chat.js"
  379. import { detailApi } from "@/api/detail.js"
  380. import { Message, MessageBox, Notification, Loading } from 'element-ui'
  381. import 'vue-awesome/icons/paper-plane'
  382. import 'vue-awesome/icons/fire'
  383. export default {
  384. components: {
  385. Header
  386. },
  387. data() {
  388. return {
  389. // 是否全屏
  390. fullScreen: false,
  391. // 角色所有聊天列表
  392. allRecords: [],
  393. // 聊天记录id
  394. recordId: null,
  395. // 选中的角色聊天记录
  396. historyRes: [],
  397. recordsIndex: null,
  398. showDetail: false,
  399. showConfig: false,
  400. showInfo: 0,
  401. messageOptions: [],
  402. info: {},
  403. messageLoading: false,
  404. returnMessage: [],
  405. content: '',
  406. audioPlayIndex: null,
  407. configForm: {
  408. radio1: null,
  409. radio2: null,
  410. radio3: null,
  411. },
  412. // 对话接口是否返回错误状态
  413. resError: false,
  414. // 模型列表
  415. modelList: [],
  416. setting: {
  417. value1: false,
  418. value2: false,
  419. },
  420. //音频相关↓
  421. //音频地址
  422. audioUrl: '',
  423. videoLoop: null,
  424. videoLoopTime: 0,
  425. //场景下拉菜单
  426. dropdown3Show: false,
  427. // 场景对话相关
  428. sceneId: null,
  429. sceneInfo: {},
  430. }
  431. },
  432. computed: {
  433. canChat() {
  434. console.log(this.info, 'this.info');
  435. if (!this.sceneId) {
  436. if (this.info.isDelete == 1) {
  437. console.log(1);
  438. return false
  439. } else {
  440. console.log(2);
  441. return true
  442. }
  443. } else {
  444. if (this.sceneInfo.isDelete == 1) {
  445. return false
  446. } else {
  447. return true
  448. }
  449. }
  450. },
  451. showNodata() {
  452. return this.allRecords.length == 0 && !this.$route.query.characterId
  453. }
  454. },
  455. mounted() {
  456. this.init()
  457. },
  458. watch: {
  459. '$route.query.characterId': {
  460. handler(newVal, lodVal) {
  461. console.log(newVal, 'newVal');
  462. if (!newVal) {
  463. this.$nextTick(() => {
  464. this.showInfoChange(0)
  465. })
  466. }
  467. },
  468. deep: true
  469. },
  470. returnMessage: {
  471. handler(newVal, lodVal) {
  472. this.$nextTick(() => {
  473. let messages = this.$refs.messages
  474. messages.scrollTop = messages.scrollHeight
  475. })
  476. },
  477. deep: true
  478. }
  479. },
  480. methods: {
  481. async init() {
  482. // 获取模型列表
  483. this.getModelList()
  484. // 获取用户所有聊天记录
  485. await this.getChatCharacterRecords()
  486. // 如果用角色id获取角色详情
  487. if (this.$route.query.characterId) {
  488. if (this.$route.query.sceneId) {
  489. this.sceneId = this.$route.query.sceneId
  490. }
  491. this.showInfoChange(1)
  492. await this.getDetail(this.$route.query.characterId)
  493. } else {
  494. this.allRecords[0].open = true
  495. await this.getDetail(this.allRecords[0].id)
  496. }
  497. // 查找当前角色是否有对话记录
  498. this.searchHistory(this.info.id)
  499. },
  500. // 左侧面板变化
  501. showInfoChange(index) {
  502. this.fullScreen = false
  503. this.showInfo = index
  504. },
  505. // 全屏
  506. clickFullScreen() {
  507. this.fullScreen = !this.fullScreen
  508. },
  509. // 点击聊天记录切换聊天
  510. async clickDialogue(value1, value2, index) {
  511. console.log(value2, 'value2');
  512. let _this = this
  513. this.audioUrl = ""
  514. this.messageOptions = []
  515. this.returnMessage = []
  516. if (this.$route.query.characterId) {
  517. this.$route.query.characterId = value1.id
  518. }
  519. if (!value2) {
  520. return
  521. }
  522. // 如果点击的是场景聊天
  523. if (value2.sceneId) {
  524. this.sceneId = value2.sceneId
  525. await this.getDetail(value1.id)
  526. // 从角色详情中获取场景列表
  527. let sceneList = this.info.sceneList
  528. // 获取当前聊天对应的场景
  529. for (let i = 0; i < sceneList.length; i++) {
  530. const element = sceneList[i];
  531. if (element.sceneId == value2.sceneId) {
  532. _this.sceneInfo = element
  533. }
  534. }
  535. } else {
  536. this.sceneId = null
  537. this.sceneInfo = {}
  538. await this.getDetail(value1.id)
  539. }
  540. this.recordId = value2.id
  541. this.getChatRecord(value2.id)
  542. this.recordsIndex = index
  543. },
  544. // 场景下拉菜单
  545. handleCommand3(value) {
  546. if (value == 1) {
  547. this.showInfoChange(2)
  548. } else if (value == 2) {
  549. // 情况聊天记录
  550. this.returnMessage = []
  551. // 新建场景对话
  552. this.newStart()
  553. // 增加开场白
  554. this.returnMessage.push({
  555. role: 'assistant',
  556. content: this.sceneInfo.sceneWelcome
  557. })
  558. } else if (value == 3) {
  559. // 回到常规对话
  560. // 遍历当前聊天记录是否有常规对话
  561. let messages = null
  562. for (let i = 0; i < this.allRecords.length; i++) {
  563. const element = this.allRecords[i];
  564. if (element.id == this.info.id) {
  565. messages = element
  566. }
  567. }
  568. console.log(messages, 'messages');
  569. let flag = false
  570. for (let i = 0; i < messages.chatCharacterList.length; i++) {
  571. const element = messages.chatCharacterList[i];
  572. console.log(element, 'element');
  573. if (!element.sceneId) {
  574. flag = true
  575. this.clickDialogue(messages, element, i)
  576. break
  577. }
  578. }
  579. // 如果聊天记录里没有常规对话,则新增一个常规对话
  580. if (!flag) {
  581. this.sceneId = null
  582. this.sceneInfo = {}
  583. this.newStart()
  584. }
  585. }
  586. },
  587. // 聊天记录列表-角色下拉菜单
  588. handleCommand2(value, value1) {
  589. if (value == 2) {
  590. this.$confirm('此操作将永久删除该角色所有聊天记录, 是否继续?', '提示', {
  591. confirmButtonText: '确定',
  592. cancelButtonText: '取消',
  593. type: 'warning'
  594. }).then(() => {
  595. this.clearRecord(value1)
  596. })
  597. }
  598. },
  599. // 聊天记录列表-角色-聊天记录下拉菜单
  600. handleCommand(value, value1, value2) {
  601. console.log(value, 'value');
  602. if (value == 1) {
  603. this.editDialogueTitle(value1, value2)
  604. } else if (value == 2) {
  605. this.$confirm('此操作将永久删除该聊天记录, 是否继续?', '提示', {
  606. confirmButtonText: '确定',
  607. cancelButtonText: '取消',
  608. type: 'warning'
  609. }).then(() => {
  610. this.clearRecord(value1, value2)
  611. })
  612. }
  613. },
  614. // 聊天记录新增对话
  615. async newStart_juese(value) {
  616. console.log(value, 'value');
  617. this.audioUrl = ""
  618. this.messageOptions = []
  619. this.returnMessage = []
  620. // 点击聊天记录切换聊天
  621. if (this.$route.query.characterId) {
  622. this.$route.query.characterId = value.id
  623. }
  624. await this.getDetail(value.id)
  625. this.recordId = await this.addChat()
  626. for (let i = 0; i < this.allRecords.length; i++) {
  627. const element = this.allRecords[i];
  628. if (element.id == this.info.id) {
  629. element.chatCharacterList.push({
  630. chatTitle: "常规聊天",
  631. createTime: '',
  632. id: this.recordId
  633. })
  634. this.recordsIndex = element.chatCharacterList.length - 1
  635. }
  636. }
  637. },
  638. // 修改聊天记录标题
  639. editDialogueTitle(value1, value2) {
  640. this.$prompt('新标题名称', '修改标题', {
  641. confirmButtonText: '确定',
  642. cancelButtonText: '取消',
  643. }).then(({ value }) => {
  644. let params = {
  645. chatTitle: value,
  646. id: value2.id
  647. }
  648. updateTitleApi(params).then(res => {
  649. console.log(res, '修改标题');
  650. this.$message({
  651. type: 'success',
  652. message: '修改成功!'
  653. });
  654. this.getChatCharacterRecords()
  655. })
  656. })
  657. },
  658. clearRecord(value1, value2) {
  659. let params = {
  660. characterId: value1.id,
  661. }
  662. if (value2) {
  663. params.recordId = value2.id
  664. }
  665. clearRecordApi(params).then(res => {
  666. this.$message({
  667. type: 'success',
  668. message: '删除成功!'
  669. });
  670. this.getChatCharacterRecords()
  671. })
  672. },
  673. async getChatRecord(recordId) {
  674. let params = {
  675. characterId: this.info.id,
  676. recordId: recordId
  677. }
  678. getChatRecordApi(params).then(res => {
  679. console.log(res, '查询到的聊天记录');
  680. let array = res.data
  681. // this.returnMessage
  682. this.historyRes = res.data
  683. for (let i = 0; i < array.length; i++) {
  684. const element = array[i];
  685. let history = JSON.parse(element.history)
  686. history.map(item => {
  687. if (item.role == 'assistant') {
  688. item.voiceFilePosition = element.voiceFilePosition
  689. }
  690. })
  691. this.returnMessage = [...this.returnMessage, ...history]
  692. }
  693. })
  694. },
  695. searchHistory(characterId) {
  696. // 查看对话记录是否有选中的角色
  697. // console.log('查看对话记录是否有选中的角色');
  698. let flg = false
  699. for (let i = 0; i < this.allRecords.length; i++) {
  700. const element = this.allRecords[i];
  701. // 如果有则选中角色的最新一条记录并获取对话聊天记录
  702. if (element.id == characterId) {
  703. console.log(element, '查看对话记录是否有选中的角色');
  704. flg = true
  705. element.open = true
  706. // 二级对话判断当前是普通对话还是场景对话
  707. // 取对应的最后一条消息记录
  708. let chatCharacterList = element.chatCharacterList
  709. let chatCharacter = null
  710. let index = null
  711. for (let i = 0; i < chatCharacterList.length; i++) {
  712. const element2 = chatCharacterList[i];
  713. if (this.$route.query.sceneId == element2.sceneId) {
  714. chatCharacter = element2
  715. index = i
  716. } else if (!this.$route.query.sceneId && !element2.sceneId) {
  717. chatCharacter = element2
  718. index = i
  719. }
  720. }
  721. // 如果有聊天记录则点击
  722. if (chatCharacter) {
  723. this.clickDialogue(element, chatCharacter, index)
  724. } else {
  725. // 如果没有场景聊天记录则新增场景聊天
  726. // 从角色详情中获取场景列表
  727. let sceneList = this.info.sceneList
  728. // 获取当前聊天对应的场景
  729. for (let i = 0; i < sceneList.length; i++) {
  730. const element = sceneList[i];
  731. if (element.sceneId == this.$route.query.sceneId) {
  732. this.sceneInfo = element
  733. }
  734. }
  735. }
  736. // this.recordsIndex = element.chatCharacterList.length - 1
  737. // let recordId = element.chatCharacterList[element.chatCharacterList.length - 1].id
  738. // this.recordId = recordId
  739. // this.getChatRecord(recordId)
  740. }
  741. }
  742. // 如果没有聊天记录,则增加开场聊天引导
  743. if (!flg) {
  744. this.getGuidance(this.info.id)
  745. }
  746. },
  747. async getChatCharacterRecords() {
  748. let res = await getChatCharacterRecordsApi()
  749. console.log(res, '聊天记录');
  750. if (res.data) {
  751. for (let i = 0; i < res.data.length; i++) {
  752. const element = res.data[i];
  753. if(this.info.id == element.id) {
  754. element.open = true
  755. } else {
  756. element.open = false
  757. }
  758. }
  759. this.allRecords = res.data
  760. }
  761. },
  762. // 新增对话记录
  763. async addChat() {
  764. let params = {
  765. characterId: this.info.id,
  766. chatTitle: ""
  767. }
  768. if (this.sceneId) {
  769. params.sceneId = this.sceneId
  770. }
  771. let res = await addChatApi(params)
  772. console.log(res, '新增对话记录');
  773. return res.data
  774. },
  775. getModelList() {
  776. getModelListApi().then(res => {
  777. console.log(res, '模型列表');
  778. this.modelList = res.data
  779. })
  780. },
  781. inputBoxClick() {
  782. this.$refs.input.focus()
  783. },
  784. async getDetail(id) {
  785. let res = await detailApi(id)
  786. console.log(res, '角色详情');
  787. this.info = res.data
  788. this.configForm.radio2 = this.info.modelId
  789. // let HistoryMessage = JSON.parse(localStorage.getItem(`[userId:${123},aiId:${this.info.id}]`));
  790. // if (HistoryMessage) {
  791. // this.returnMessage = HistoryMessage
  792. // } else {
  793. // this.returnMessage.push({
  794. // role: 'assistant',
  795. // content: this.info.firstContent
  796. // })
  797. // localStorage.setItem(`[userId:${123},aiId:${this.info.id}]`, JSON.stringify(this.returnMessage));
  798. // }
  799. if (this.sceneId) {
  800. let sceneList = this.info.sceneList
  801. for (let i = 0; i < sceneList.length; i++) {
  802. const element = sceneList[i];
  803. if (element.sceneId == this.sceneId) {
  804. this.returnMessage.push({
  805. role: 'assistant',
  806. content: element.sceneWelcome
  807. })
  808. }
  809. }
  810. } else {
  811. this.returnMessage.push({
  812. role: 'assistant',
  813. content: this.info.firstContent
  814. })
  815. }
  816. },
  817. getGuidance(id) {
  818. getGuidanceApi(id).then(res => {
  819. console.log(res, '聊天引导');
  820. this.messageOptions = res.data
  821. })
  822. },
  823. goBack() {
  824. this.$router.back()
  825. },
  826. async newStart() {
  827. // 新业务,创建一个新的对话记录
  828. this.recordId = await this.addChat()
  829. for (let i = 0; i < this.allRecords.length; i++) {
  830. const element = this.allRecords[i];
  831. if (element.id == this.info.id) {
  832. if (this.sceneId) {
  833. element.chatCharacterList.push({
  834. chatTitle: "场景聊天",
  835. createTime: '',
  836. id: this.recordId,
  837. sceneIcon: true
  838. })
  839. } else {
  840. element.chatCharacterList.push({
  841. chatTitle: "常规聊天",
  842. createTime: '',
  843. id: this.recordId
  844. })
  845. }
  846. this.recordsIndex = element.chatCharacterList.length - 1
  847. }
  848. }
  849. this.returnMessage = []
  850. this.getDetail(this.info.id)
  851. // 废弃》》
  852. // 清空历史数据
  853. // localStorage.removeItem(`[userId:${123},aiId:${this.info.id}]`);
  854. // this.returnMessage = []
  855. // this.getDetail(this.info.id)
  856. },
  857. Enterkey(e) {
  858. if (e.keyCode == 13) {
  859. this.getStreamChatWithWeb()
  860. }
  861. },
  862. // 前往创建场景
  863. toCreateScene() {
  864. this.$router.push({
  865. name: 'CreateScene',
  866. query: {
  867. characterId: this.info.id,
  868. }
  869. })
  870. },
  871. async getStreamChatWithWeb_old() {
  872. this.messageLoading = true
  873. if (!this.content) {
  874. return
  875. }
  876. this.returnMessage.push({
  877. role: 'user',
  878. content: this.content
  879. })
  880. let HistoryMessage = JSON.parse(localStorage.getItem(`[userId:${123},aiId:${this.info.id}]`));
  881. // 历史记录取最新的20条传给后端
  882. if (HistoryMessage && HistoryMessage.length > 20) {
  883. HistoryMessage = HistoryMessage.slice(HistoryMessage.length - 1, 20)
  884. }
  885. let params = {
  886. historyMessage: HistoryMessage || [],
  887. characterId: this.info.id,
  888. prompt: JSON.parse(JSON.stringify(this.content))
  889. }
  890. // 清空输入框的值
  891. this.content = ''
  892. // 新增一条ai信息
  893. this.returnMessage.push({
  894. role: 'assistant',
  895. content: ''
  896. })
  897. let res = await streamChatWithWebApi(params)
  898. console.log(res.data.message.content, 'res');
  899. let content = res.data.message.content
  900. let index = 0
  901. let xing = 1
  902. let messageInterval = setInterval(() => {
  903. if (index > content.length - 1) {
  904. console.log('结束');
  905. // 消息全部显示后存到历史localStorage
  906. let HistoryMessage = []
  907. // 历史只存100条,长度超出截取最新的
  908. if (this.returnMessage.length > 100) {
  909. HistoryMessage = JSON.stringify(this.returnMessage.slice(this.returnMessage.length - 100, 100))
  910. } else {
  911. HistoryMessage = JSON.stringify(this.returnMessage)
  912. }
  913. localStorage.setItem(`[userId:${123},aiId:${this.info.id}]`, HistoryMessage);
  914. clearInterval(messageInterval)
  915. return
  916. }
  917. console.log(content[index], 'content[index]');
  918. if (content[index] == "*") {
  919. if (xing == 1) {
  920. xing = 2
  921. this.returnMessage[this.returnMessage.length - 1].content += "("
  922. } else if (xing == 2) {
  923. xing = 1
  924. this.returnMessage[this.returnMessage.length - 1].content += ")"
  925. }
  926. } else {
  927. this.returnMessage[this.returnMessage.length - 1].content += content[index]
  928. }
  929. index += 1
  930. }, 50)
  931. },
  932. async getStreamChatWithWeb() {
  933. this.textCache = ''
  934. this.resError = false
  935. this.messageLoading = true
  936. if (!this.content) {
  937. return
  938. }
  939. // 初始化定时器和audio的状态
  940. if (this.videoLoop) {
  941. clearInterval(this.videoLoop)
  942. this.videoLoop = null
  943. this.audioUrl = ''
  944. this.$refs.audio.currentTime = 0;
  945. this.$refs.audio.pause()
  946. }
  947. // 如果没有对话记录id,新增对话记录
  948. if (!this.recordId) {
  949. this.recordId = await this.addChat()
  950. }
  951. this.returnMessage.push({
  952. role: 'user',
  953. content: this.content
  954. })
  955. let HistoryMessage = JSON.parse(JSON.stringify(this.returnMessage))
  956. HistoryMessage = HistoryMessage.slice(0, -1)
  957. console.log(HistoryMessage, 'HistoryMessage');
  958. // 历史记录取最新的20条传给后端
  959. if (HistoryMessage && HistoryMessage.length > 20) {
  960. HistoryMessage = HistoryMessage.slice(HistoryMessage.length - 1, 20)
  961. }
  962. let params = {
  963. historyMessage: HistoryMessage,
  964. characterId: this.info.id,
  965. prompt: this.content,
  966. modelId: this.configForm.radio2,
  967. recordId: this.recordId,
  968. }
  969. // 如果当前是场景对话则需要传sceneId
  970. if (this.sceneId) {
  971. params.sceneId = this.sceneId
  972. }
  973. // 新增一条ai信息
  974. this.returnMessage.push({
  975. role: 'assistant',
  976. content: '',
  977. voiceFilePosition: '',
  978. })
  979. // 清空输入框的值
  980. this.content = ''
  981. let res = await streamChatWithWebApi(params)
  982. console.log(res, 'res');
  983. this.messageLoading = false
  984. if (res.status != 200) {
  985. this.$message.error(res.statusText)
  986. this.returnMessage.splice(this.returnMessage.length - 1, 2)
  987. return
  988. }
  989. const reader = res.body.getReader()
  990. const decoder=new TextDecoder()
  991. while(1){
  992. const {done, value} = await reader.read()
  993. // console.log(done, 'done');
  994. if(done){
  995. console.log(value, '结束value');
  996. // if (typeof(value) == "undefined") {
  997. // this.$message.error('错误')
  998. // this.returnMessage.splice(this.returnMessage.length - 1, 1)
  999. // }
  1000. // 每次对话完刷新聊天记录
  1001. this.getChatCharacterRecords()
  1002. let params = {
  1003. characterId: this.info.id,
  1004. recordId: this.recordId
  1005. }
  1006. let historyRes = await getChatRecordApi(params)
  1007. this.historyRes = historyRes.data
  1008. // 如果开启自动播放,则查询并播放语音
  1009. this.audioUrl = ""
  1010. if (!this.resError) {
  1011. let index = this.historyRes.length * 2
  1012. this.initAudio(index)
  1013. }
  1014. console.log('结束');
  1015. break;
  1016. }
  1017. //txt就是一个一个的字 然后添加到页面上就可以了
  1018. const txt = decoder.decode(value).split('data:')
  1019. // const txt = decoder.decode(value)
  1020. this.addMessage(txt)
  1021. // let data = JSON.parse(txt).message.content
  1022. console.log(txt, 'txt');
  1023. // if (this.isJSON(txt) && JSON.parse(txt).code != 200) {
  1024. // let data = JSON.parse(txt)
  1025. // this.$message.error(data.msg)
  1026. // this.returnMessage.splice(this.returnMessage.length - 1, 1)
  1027. // break;
  1028. // }
  1029. }
  1030. },
  1031. addMessage(value) {
  1032. // console.log(value, 'value');
  1033. for (let i = 0; i < value.length; i++) {
  1034. const element = value[i];
  1035. if (this.isJSON(element)) {
  1036. if(JSON.parse(element).code == 401) {
  1037. this.returnMessage.splice(this.returnMessage.length - 1, 1)
  1038. this.noLogin(element)
  1039. break;
  1040. }
  1041. if(JSON.parse(element).code == 500) {
  1042. console.log(JSON.parse(element), 'JSON.parse(element)');
  1043. this.returnMessage.splice(this.returnMessage.length - 2, 2)
  1044. this.$message.error(JSON.parse(element).content || '系统错误请联系管理员')
  1045. this.resError = true
  1046. break;
  1047. }
  1048. let txt = JSON.parse(element).content
  1049. this.returnMessage[this.returnMessage.length - 1].content += txt
  1050. }
  1051. }
  1052. },
  1053. noLogin(value) {
  1054. let _this = this
  1055. MessageBox.confirm(
  1056. value.content,
  1057. "系统提示",
  1058. {
  1059. confirmButtonText: "前往登录",
  1060. cancelButtonText: "取消",
  1061. type: "warning",
  1062. }
  1063. )
  1064. .then(() => {
  1065. // isRelogin.show = false;
  1066. this.$store.dispatch("LogOut").then(() => {
  1067. // location.href = "/";
  1068. _this.$refs.Header.showLogin()
  1069. });
  1070. })
  1071. .catch(() => {
  1072. // isRelogin.show = false;
  1073. });
  1074. },
  1075. isJSON(str) {
  1076. if (typeof str == 'string') {
  1077. try {
  1078. JSON.parse(str);
  1079. return true;
  1080. } catch(e) {
  1081. // console.log(e);
  1082. return false;
  1083. }
  1084. }
  1085. },
  1086. messageOptionClick(value) {
  1087. this.content = value
  1088. this.getStreamChatWithWeb()
  1089. },
  1090. // 播放聊天语音
  1091. initAudio(index) {
  1092. // 从聊天记录获取id
  1093. let history = this.historyRes[ index / 2 - 1]
  1094. console.log(history, 'history');
  1095. this.loopGetVoice(history.id, index)
  1096. },
  1097. playAudio(url, index) {
  1098. this.audioUrl = url
  1099. this.audioPlayIndex = index
  1100. this.$refs.audio.volume = 1
  1101. setTimeout(() => {
  1102. if (this.audioUrl) {
  1103. this.$refs.audio.play()
  1104. }
  1105. }, 1000)
  1106. },
  1107. async loopGetVoice(id, index) {
  1108. // 获取语音文件
  1109. let params = {
  1110. id: id
  1111. }
  1112. let fileRes = await getVoiceFileApi(params)
  1113. console.log(fileRes, 'file>>>');
  1114. if (fileRes.data) {
  1115. console.log(this.returnMessage[index], 'sssssssssss');
  1116. this.returnMessage[index].voiceFilePosition = fileRes.data.voiceFilePosition
  1117. // 有语音文件则直接播放
  1118. if (this.setting.value1) {
  1119. this.playAudio(fileRes.data.voiceFilePosition, index)
  1120. }
  1121. } else {
  1122. // 没有语音文件则开启定时器每两秒查询一次
  1123. this.videoLoopTime = 0
  1124. this.videoLoop = setInterval(() => {
  1125. console.log(this.videoLoopTime, '定时器');
  1126. // 如果计时器超过20秒则关闭不再获取语音文件
  1127. if (this.videoLoopTime >= 20) {
  1128. clearInterval(this.videoLoop)
  1129. this.videoLoop = null
  1130. }
  1131. this.videoLoopTime += 2
  1132. getVoiceFileApi(params).then(res => {
  1133. // 如果获取到语音文件则关闭计时器并播放语音
  1134. if (res.data) {
  1135. clearInterval(this.videoLoop)
  1136. this.videoLoop = null
  1137. this.returnMessage[index].voiceFilePosition = res.data.voiceFilePosition
  1138. if (this.setting.value1) {
  1139. this.playAudio(res.data.voiceFilePosition, index)
  1140. }
  1141. }
  1142. })
  1143. }, 2000)
  1144. }
  1145. },
  1146. audioEnd() {
  1147. // console.log('播放结束');
  1148. this.audioPlayIndex = null
  1149. },
  1150. // 场景业务相关↓
  1151. async sceneChange(item) {
  1152. console.log(item, 'item');
  1153. this.$message({
  1154. message: `已进入场景${item.sceneName}`,
  1155. type: 'success'
  1156. });
  1157. // 当用户选中场景
  1158. this.sceneInfo = item
  1159. // 切换当前场景id
  1160. this.sceneId = item.sceneId
  1161. // 情况聊天记录
  1162. this.returnMessage = []
  1163. // 新建场景对话
  1164. this.newStart()
  1165. // 增加开场白
  1166. // this.returnMessage.push({
  1167. // role: 'assistant',
  1168. // content: item.sceneWelcome
  1169. // })
  1170. }
  1171. }
  1172. }
  1173. </script>
  1174. <style lang="scss" scoped>
  1175. .fullScreenButton {
  1176. position: absolute;
  1177. top: 50%;
  1178. left: 0;
  1179. transform: translateX(-50%) translateY(-50%);
  1180. z-index: 50;
  1181. background: #fff;
  1182. display: flex;
  1183. justify-content: center;
  1184. align-items: center;
  1185. width: 1.6rem;
  1186. height: 1.6rem;
  1187. cursor: pointer;
  1188. }
  1189. .chat {
  1190. height: 100vh;
  1191. }
  1192. .leftInfo {
  1193. width: 375px;
  1194. height: 100%;
  1195. padding: 32px 24px;
  1196. overflow-y: auto;
  1197. >.history {
  1198. width: 100%;
  1199. height: 100%;
  1200. display: flex;
  1201. flex-direction: column;
  1202. >.historyBox {
  1203. padding: 8px;
  1204. border-radius: 15px;
  1205. border: solid 1px var(--color1);
  1206. margin-bottom: 10px;
  1207. .top {
  1208. >.photo {
  1209. >img {
  1210. width: 48px;
  1211. height: 48px;
  1212. border-radius: 50%;
  1213. }
  1214. }
  1215. >.info {
  1216. width: calc(100% - 60px - 16px);
  1217. >div {
  1218. overflow: hidden; /* 确保超出容器的文本被裁剪 */
  1219. white-space: nowrap; /* 确保文本在一行内显示 */
  1220. text-overflow: ellipsis; /* 使用省略号表示文本超出 */
  1221. }
  1222. }
  1223. }
  1224. }
  1225. }
  1226. >.chatInfo {
  1227. overflow: hidden;
  1228. .chatInfo_photo {
  1229. >img {
  1230. }
  1231. }
  1232. .hot {
  1233. color: #f03d3d;
  1234. background: #fff1f1;
  1235. }
  1236. .tags {
  1237. margin-top: 10px;
  1238. .tag {
  1239. display: inline-flex;
  1240. justify-content: center;
  1241. padding: 5px 10px;
  1242. border-radius: 4px;
  1243. border: solid 1px var(--color1);
  1244. margin-right: 5px;
  1245. }
  1246. }
  1247. }
  1248. }
  1249. .content {
  1250. z-index: 40;
  1251. position: absolute;
  1252. right: 0;
  1253. background-repeat: no-repeat;
  1254. background-attachment: fixed;
  1255. background-size: cover;
  1256. background-color: #fff;
  1257. display: flex;
  1258. height: 100%;
  1259. justify-content: center;
  1260. width: calc(100% - 375px);
  1261. border-left: solid 1px var(--color1);
  1262. transition: width 0.5s ease;
  1263. >.chat-box {
  1264. position: relative;
  1265. background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0) 75%, rgba(0, 0, 0, 0.4) 100%);
  1266. background-size: auto;
  1267. // border: 1px solid #635677 !important;
  1268. box-sizing: border-box;
  1269. display: flex;
  1270. flex-direction: column;
  1271. height: 100%;
  1272. width: 100%;
  1273. padding: 55px 25px 170px 25px;
  1274. >.chatBoxTitle {
  1275. color: #fff;
  1276. margin-top: 15px;
  1277. width: calc(100% - 50px);
  1278. height: 30px;
  1279. display: flex;
  1280. justify-content: space-between;
  1281. align-items: center;
  1282. }
  1283. }
  1284. }
  1285. .contentFull {
  1286. width: 100%;
  1287. }
  1288. .historyActive {
  1289. background: var(--color1);
  1290. }
  1291. .dialogue:hover {
  1292. background: var(--color1);
  1293. .dialogueIconBg {
  1294. display: flex;
  1295. }
  1296. }
  1297. .dialogueIconBg {
  1298. display: none;
  1299. background: linear-gradient(90deg, rgba(0, 0, 0, 0) 10%, var(--color1) 50%, var(--color1) 100%);
  1300. }
  1301. .messages {
  1302. height: calc(100% - 68px );
  1303. overflow-y: auto;
  1304. }
  1305. .messages::-webkit-scrollbar {
  1306. width: 0px;
  1307. }
  1308. .messageRight {
  1309. max-width: calc(100% - 72px);
  1310. // min-width: 400px;
  1311. }
  1312. .yyPlayBg {
  1313. // background: rgba(103, 103, 168, 1);
  1314. // border-radius: 999px;
  1315. // position: absolute;
  1316. .icon {
  1317. height: 24px;
  1318. width: 96px;
  1319. }
  1320. }
  1321. .yyPlay {
  1322. width: 15px;
  1323. height: 15px;
  1324. // background: url('../../assets/images/播放/yyPlay.gif') no-repeat;
  1325. // background-size: 170% 170%;
  1326. // background-position: 50% 50%;
  1327. // animation: heart-burst steps(28) 0.9s infinite both;
  1328. // animation-play-state: paused;
  1329. // height: 50px;
  1330. // background: #fff;
  1331. }
  1332. .message {
  1333. // background: #ffffff0f;
  1334. // border: 1px solid #5b5b5e;
  1335. background: var(--bg-color3);
  1336. color: #fff;
  1337. font-size: 14px;
  1338. // flex: 1;
  1339. }
  1340. .messageUser {
  1341. background: rgba(255, 255, 255, 0.9);
  1342. border: 1px solid var(--color1);
  1343. // max-width: calc(100% - 72px);
  1344. font-size: 14px;
  1345. width: auto;
  1346. // min-width: 400px;
  1347. }
  1348. .photo {
  1349. width: 56px;
  1350. }
  1351. .me {
  1352. flex-direction: row-reverse;
  1353. }
  1354. .loadingMessage {
  1355. position: relative;
  1356. // display: flex;
  1357. // justify-content: center;
  1358. width: 120px;
  1359. height: 64px;
  1360. }
  1361. .messageOptions {
  1362. // margin-top: 20px;
  1363. display: flex;
  1364. flex-wrap: wrap;
  1365. justify-content: space-around;
  1366. min-width: 400px;
  1367. .option {
  1368. background: #ade4ff32;
  1369. // border: 1px solid #5b5b5e;
  1370. border-radius: 10px;
  1371. padding: 10px;
  1372. width: 40%;
  1373. height: 50px;
  1374. margin-top: 10px;
  1375. cursor: pointer;
  1376. }
  1377. }
  1378. .inputBox {
  1379. border: solid 1px var(--color1);
  1380. border-radius: 10px;
  1381. padding: 24px;
  1382. background: #fff;
  1383. max-width: 900px;
  1384. margin: 0 auto;
  1385. }
  1386. .planeColor {
  1387. color: var(--bg-color1);
  1388. }
  1389. </style>
  1390. <style scoped>
  1391. .loadingMessage >>> .el-loading-parent--relative {
  1392. width: 100%;
  1393. height: 100%;
  1394. }
  1395. .loadingMessage >>> .el-loading-spinner {
  1396. display: flex;
  1397. justify-content: center;
  1398. }
  1399. .mButton {
  1400. border: solid 0px;
  1401. }
  1402. .radio >>> .el-radio-button {
  1403. margin-bottom: 5px;
  1404. margin-right: 10px;
  1405. /* border-left: solid 1px #DCDFE6; */
  1406. }
  1407. .radio >>> .el-radio-button__inner {
  1408. border-left: solid 1px #DCDFE6;
  1409. border-radius: 4px;
  1410. }
  1411. .radio >>> .el-radio-button__orig-radio:checked + .el-radio-button__inner {
  1412. border-left: solid 1px var(--bg-color1);
  1413. background-color: var(--bg-color1);
  1414. border-color: var(--bg-color1);
  1415. -webkit-box-shadow: -1px 0 0 0 var(--bg-color1);
  1416. box-shadow: -1px 0 0 0 var(--bg-color1);
  1417. }
  1418. </style>