ChatMessages.vue 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161
  1. <template>
  2. <div class="chat-messages-container">
  3. <!-- 左侧对话缩略导航 -->
  4. <div
  5. v-if="qaPairs.length > 0"
  6. class="conversation-nav"
  7. ref="navRef"
  8. @mouseenter="onNavMove"
  9. @mousemove="onNavMove"
  10. @mouseleave="onNavLeave"
  11. @scroll="onNavScroll"
  12. >
  13. <div
  14. v-for="(pair, pIdx) in qaPairs"
  15. :key="pIdx"
  16. :class="['nav-line', { 'nav-line-hot': nearestLineIndex === pIdx, active: activeMessage && activeMessage === messages[pair.startIndex] }]"
  17. :style="{ width: `${navLineWidth(pIdx)}px` }"
  18. @click="scrollToPair(pair)"
  19. ></div>
  20. </div>
  21. <Transition name="tooltip-fade">
  22. <div v-if="hoveredPair" ref="tooltipRef" class="conversation-tooltip" :style="{ top: `${tooltipTop}px` }">
  23. <span class="tooltip-arrow" :style="{ top: `${tooltipArrowTop}px` }"></span>
  24. <div v-if="hoveredPair.question" class="tooltip-row">
  25. <span class="tooltip-label tooltip-label-q">问</span>
  26. <span class="tooltip-text">{{ hoveredPair.question }}</span>
  27. </div>
  28. <div v-if="hoveredPair.answer" class="tooltip-row">
  29. <span class="tooltip-label tooltip-label-a">答</span>
  30. <span class="tooltip-text">{{ hoveredPair.answer }}</span>
  31. </div>
  32. </div>
  33. </Transition>
  34. <div class="chat-messages" ref="messagesRef">
  35. <!-- 新对话缺省图 -->
  36. <div v-if="messages.length === 0" class="welcome-empty">
  37. <img :src="getCssUrl('--img-chat-welcome-img')" class="welcome-img" />
  38. </div>
  39. <div v-for="(message, index) in messages" :key="index" :class="['message-wrapper', message.type]" @mouseleave="copiedMessageIndex = -1">
  40. <!-- AI消息 -->
  41. <div v-if="message.type === 'ai'" class="ai-message">
  42. <div class="message-body">
  43. <!-- 思考过程折叠卡片 -->
  44. <div v-if="message.thinkingSteps && message.thinkingSteps.length > 0" class="thinking-card">
  45. <div class="thinking-duration-bar" @click="toggleThinkingCard(index)">
  46. <span v-if="getDurationText(message)" class="thinking-duration">{{ getDurationText(message) }}</span>
  47. <div :class="['thinking-arrow', { expanded: !collapsedThinking[index] }]">
  48. <img :src="getCssUrl('--img-chat-arrow-icon')" width="12" height="12" />
  49. </div>
  50. </div>
  51. <Transition name="collapse">
  52. <div v-show="!collapsedThinking[index]" class="thinking-collapse-wrap">
  53. <div class="thinking-header" @click="toggleThinkingContent(index)">
  54. <div class="thinking-header-left">
  55. <div class="thinking-icon"></div>
  56. <span class="thinking-title">思考过程</span>
  57. </div>
  58. <div v-if="message.thinkingContent" :class="['thinking-arrow', { expanded: !collapsedThinkingContent[index] }]">
  59. <img :src="getCssUrl('--img-chat-arrow-icon')" width="10" height="10" />
  60. </div>
  61. </div>
  62. <!-- thinking_token 思考内容 -->
  63. <Transition name="collapse">
  64. <div v-if="message.thinkingContent && !collapsedThinkingContent[index]" class="thinking-content-body">
  65. {{ message.thinkingContent }}
  66. </div>
  67. </Transition>
  68. <div class="thinking-body">
  69. <div
  70. v-for="(group, groupIdx) in groupStepsByAgent(message.thinkingSteps)"
  71. :key="groupIdx"
  72. class="agent-group"
  73. @click="handleAgentGroupClick(index, group)"
  74. >
  75. <div class="agent-group-header">
  76. <div class="agent-group-header-left">
  77. <div class="agent-group-icon"></div>
  78. <span class="agent-group-name">{{ group.agent }}</span>
  79. </div>
  80. <span v-if="getLatestStepMessage(group)" class="agent-group-latest">
  81. {{ getLatestStepMessage(group) }}
  82. </span>
  83. <div class="thinking-arrow agent-arrow">
  84. <img :src="getCssUrl('--img-chat-next-icon')" width="10" height="10" />
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </Transition>
  91. </div>
  92. <div
  93. v-if="message.content"
  94. class="message-text"
  95. v-html="
  96. renderMarkdown(
  97. message.content,
  98. tableIcons,
  99. message.citations?.items?.length ? Math.max(...message.citations.items.map((i) => i.id)) : undefined
  100. )
  101. "
  102. @click="handleFootnoteClick($event, index)"
  103. ></div>
  104. <!-- 数据来源卡片 citations -->
  105. <div v-if="message.citations" class="citations-card">
  106. <div v-if="message.citations.model_only" class="citations-header citations-header-simple">
  107. <span class="citations-title">本回答依据模型知识生成,仅供参考</span>
  108. </div>
  109. <template v-else-if="message.citations.items?.length">
  110. <div class="citations-header" @click="toggleCitations(index)">
  111. <div class="citations-header-left">
  112. <span class="citations-title">数据来源</span>
  113. <span class="citations-count">{{ message.citations.items.length }}</span>
  114. </div>
  115. <div :class="['thinking-arrow', { expanded: !collapsedCitations[index] }]">
  116. <img :src="getCssUrl('--img-chat-arrow-icon')" width="10" height="10" />
  117. </div>
  118. </div>
  119. <div v-show="!collapsedCitations[index]" class="citations-body">
  120. <div v-for="item in message.citations.items" :key="item.id" :id="`citation-${index}-${item.id}`" class="citation-item">
  121. <div class="citation-item-row">
  122. <span :class="['citation-badge', `citation-badge-${item.type}`]">{{ item.type_cn }}</span>
  123. <span class="citation-title-text">{{ item.title }}</span>
  124. <span v-if="item.search_url" class="citation-link">知识库检索</span>
  125. <span v-if="item.url" class="citation-link">链接</span>
  126. </div>
  127. <div class="citation-item-attrs">
  128. <span v-if="item.source_system" class="citation-attr">{{ item.source_system }}</span>
  129. <span v-if="item.fetched_at" class="citation-attr">{{ item.fetched_at }}</span>
  130. </div>
  131. <div v-if="item.snippet" class="citation-snippet" :title="item.snippet">{{ item.snippet }}</div>
  132. </div>
  133. </div>
  134. </template>
  135. </div>
  136. <div v-if="message.wordDownloadUrl" class="word-download-area">
  137. <a-button type="link" @click="emit('download-word', message.wordDownloadUrl)"> 下载报告文件 (.docx) </a-button>
  138. </div>
  139. <!-- 文件操作卡片 -->
  140. <div v-if="message.downloadFiles?.length" class="download-file-cards">
  141. <div v-for="(file, fIdx) in message.downloadFiles" :key="fIdx" class="download-file-card" @click="handlePreviewFile(file)">
  142. <div class="file-card-info">
  143. <div class="file-card-icon" :style="{ backgroundImage: getFileIconVar(file.filename) }"></div>
  144. <div class="file-card-text">
  145. <span class="file-card-name">{{ file.filename }}</span>
  146. <span class="file-card-hint">点击预览文件</span>
  147. </div>
  148. </div>
  149. <div class="file-card-actions">
  150. <button class="file-action-btn download-btn" @click.stop="handleDownloadFile(file.url, file.filename)">
  151. <img :src="getCssUrl('--img-chat-download-icon-btn')" width="14" height="14" />
  152. <span>下载</span>
  153. </button>
  154. <button v-if="isEditableFile(file.filename)" class="file-action-btn edit-btn" @click.stop="handleEditFile(file.url, file.filename)">
  155. <img :src="getCssUrl('--img-chat-edit-icon')" width="14" height="14" />
  156. <span>编辑</span>
  157. </button>
  158. </div>
  159. </div>
  160. </div>
  161. <div v-show="message.isLoading" class="loading-dots">
  162. <span class="dot"></span>
  163. <span class="dot"></span>
  164. <span class="dot"></span>
  165. </div>
  166. <!-- ask_user 交互提问 UI(分步向导) -->
  167. <div v-if="message.isPendingApproval && message.pendingApprovalData?.ask_user" class="approval-card">
  168. <div class="approval-icon"></div>
  169. <div class="approval-content">
  170. <div class="approval-title">{{ message.pendingApprovalData?.message }}</div>
  171. <!-- 计划内容 -->
  172. <div v-if="message.pendingApprovalData?.plan" class="approval-plan">
  173. <div class="approval-plan-label">执行计划</div>
  174. <div class="approval-plan-content">{{ message.pendingApprovalData.plan }}</div>
  175. </div>
  176. <!-- 步骤指示器 -->
  177. <div v-if="message.pendingApprovalData.ask_user.questions.length > 1" class="ask-user-stepper">
  178. <div
  179. v-for="(_, sIdx) in message.pendingApprovalData.ask_user.questions"
  180. :key="sIdx"
  181. :class="[
  182. 'ask-user-step-dot',
  183. {
  184. active: sIdx === (askUserCurrentStep[index] ?? 0),
  185. completed: sIdx < (askUserCurrentStep[index] ?? 0) || !!(askUserAnswers[index]?.[sIdx] && askUserAnswers[index][sIdx].trim()),
  186. },
  187. ]"
  188. @click="askUserCurrentStep[index] = sIdx"
  189. ></div>
  190. <span class="ask-user-step-text"
  191. >{{ (askUserCurrentStep[index] ?? 0) + 1 }} / {{ message.pendingApprovalData.ask_user.questions.length }}</span
  192. >
  193. </div>
  194. <!-- 当前问题 -->
  195. <div v-if="message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0]" class="ask-user-question">
  196. <div class="ask-user-question-text">
  197. {{ message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0].question }}
  198. <span
  199. v-if="message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0].required !== false"
  200. class="ask-user-required"
  201. >*</span
  202. >
  203. </div>
  204. <!-- multiple_choice 类型 -->
  205. <div
  206. v-if="message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0].type === 'multiple_choice'"
  207. class="ask-user-choices"
  208. >
  209. <div
  210. v-for="(choice, cIdx) in message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0].choices"
  211. :key="cIdx"
  212. :class="[
  213. 'ask-user-choice',
  214. {
  215. selected:
  216. askUserAnswers[index]?.[askUserCurrentStep[index] ?? 0] === getChoiceValue(choice) &&
  217. !askUserOtherSelected[index]?.[askUserCurrentStep[index] ?? 0],
  218. },
  219. ]"
  220. @click="selectChoice(index, askUserCurrentStep[index] ?? 0, choice, message.pendingApprovalData.ask_user.questions.length)"
  221. >
  222. <span>{{ getChoiceValue(choice) }}</span>
  223. </div>
  224. <!-- Other 选项 -->
  225. <div
  226. :class="['ask-user-choice', { selected: askUserOtherSelected[index]?.[askUserCurrentStep[index] ?? 0] }]"
  227. @click="selectOther(index, askUserCurrentStep[index] ?? 0)"
  228. >
  229. <span>其他</span>
  230. </div>
  231. <input
  232. v-if="askUserOtherSelected[index]?.[askUserCurrentStep[index] ?? 0]"
  233. class="ask-user-other-input"
  234. placeholder="请输入..."
  235. :value="askUserAnswers[index]?.[askUserCurrentStep[index] ?? 0]"
  236. @input="askUserAnswers[index][askUserCurrentStep[index] ?? 0] = ($event.target as HTMLInputElement).value"
  237. />
  238. </div>
  239. <!-- text 类型 -->
  240. <div
  241. v-else-if="message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0].type === 'text'"
  242. class="ask-user-text"
  243. >
  244. <textarea
  245. class="ask-user-textarea"
  246. placeholder="请输入..."
  247. :value="askUserAnswers[index]?.[askUserCurrentStep[index] ?? 0]"
  248. @input="askUserAnswers[index][askUserCurrentStep[index] ?? 0] = ($event.target as HTMLTextAreaElement).value"
  249. ></textarea>
  250. </div>
  251. </div>
  252. <!-- 操作按钮 -->
  253. <div class="approval-actions">
  254. <button v-if="(askUserCurrentStep[index] ?? 0) > 0" class="approval-btn nav-btn" @click="goPrevStep(index)">上一步</button>
  255. <button
  256. v-if="(askUserCurrentStep[index] ?? 0) < message.pendingApprovalData.ask_user.questions.length - 1"
  257. class="approval-btn approve-btn"
  258. :disabled="
  259. !isCurrentStepAnswered(
  260. index,
  261. askUserCurrentStep[index] ?? 0,
  262. message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0]
  263. )
  264. "
  265. @click="goNextStep(index, message.pendingApprovalData.ask_user.questions.length)"
  266. >下一步</button
  267. >
  268. <button
  269. v-if="(askUserCurrentStep[index] ?? 0) === message.pendingApprovalData.ask_user.questions.length - 1"
  270. class="approval-btn approve-btn"
  271. :disabled="
  272. !isCurrentStepAnswered(
  273. index,
  274. askUserCurrentStep[index] ?? 0,
  275. message.pendingApprovalData.ask_user.questions[askUserCurrentStep[index] ?? 0]
  276. )
  277. "
  278. @click="handleSubmitAskUser(index)"
  279. >提交</button
  280. >
  281. <button class="approval-btn reject-btn" @click="handleCancelAskUser">取消</button>
  282. </div>
  283. </div>
  284. </div>
  285. </div>
  286. <!-- AI消息操作栏 -->
  287. <div class="message-actions">
  288. <div class="action-btn" @click="copyMessageContent(message.content, index)" :title="copiedMessageIndex === index ? '复制成功' : '复制'">
  289. <img :src="copyIconUrl(index)" width="14" height="14" />
  290. </div>
  291. <span v-if="message.createdAt" class="action-time">{{ formatFullTime(message.createdAt) }}</span>
  292. </div>
  293. </div>
  294. <!-- 用户消息 -->
  295. <div v-else class="user-message">
  296. <div class="message-body">
  297. <div class="message-text" v-html="renderMarkdown(message.content, tableIcons)"></div>
  298. <div v-if="message.attachedFile" class="attached-file-card" @click="emit('file-preview', message.attachedFile)">
  299. <div class="file-icon-card" :style="{ backgroundImage: getFileIconVar(message.attachedFile.name) }"></div>
  300. <div class="file-info-card">
  301. <div class="file-name-card">{{ message.attachedFile.name }}</div>
  302. <div class="file-size-card">{{ formatFileSize(message.attachedFile.size) }}</div>
  303. </div>
  304. </div>
  305. </div>
  306. <!-- 用户消息操作栏 -->
  307. <div class="message-actions">
  308. <div class="action-btn" @click="copyMessageContent(message.content, index)" :title="copiedMessageIndex === index ? '复制成功' : '复制'">
  309. <img :src="copyIconUrl(index)" width="14" height="14" />
  310. </div>
  311. <span v-if="message.createdAt" class="action-time">{{ formatFullTime(message.createdAt) }}</span>
  312. </div>
  313. </div>
  314. </div>
  315. </div>
  316. <!-- 回到底部按钮 -->
  317. <div v-if="!isAtBottom" class="scroll-to-bottom" @click="scrollToBottom">
  318. <div class="scroll-to-bottom-icon"></div>
  319. </div>
  320. </div>
  321. </template>
  322. <script setup lang="ts">
  323. import { ref, reactive, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';
  324. import dayjs from 'dayjs';
  325. import {
  326. renderMarkdown,
  327. formatFileSize,
  328. tableHtmlToMarkdown,
  329. tableHtmlToCsv,
  330. isMdFile,
  331. isTextFile,
  332. isWordFile,
  333. isExcelFile,
  334. isImageFile,
  335. isPdfFile,
  336. getFileIconVar,
  337. } from './utils';
  338. import { getToken } from '/@/utils/auth';
  339. import { message } from 'ant-design-vue';
  340. import type { Message, AttachedFile, ThinkingStep } from './types';
  341. // import katex from 'katex';
  342. // import 'katex/dist/katex.min.css';
  343. // Cache CSS variable lookups to avoid repeated getComputedStyle calls on every render
  344. const cssUrlCache = new Map<string, string>();
  345. const getCssUrl = (varName: string) => {
  346. if (!cssUrlCache.has(varName)) {
  347. const val = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
  348. cssUrlCache.set(varName, val.replace(/^url\(["']?/, '').replace(/["']?\)$/, ''));
  349. }
  350. return cssUrlCache.get(varName)!;
  351. };
  352. // Clear cache when theme changes (observed via MutationObserver on html class)
  353. const themeObserver = new MutationObserver(() => cssUrlCache.clear());
  354. themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
  355. onBeforeUnmount(() => themeObserver.disconnect());
  356. const tableIcons = {
  357. copy: getCssUrl('--img-chat-copy-icon'),
  358. download: getCssUrl('--img-chat-download-icon-btn'),
  359. preview: getCssUrl('--img-chat-preview-icon'),
  360. copySuccess: getCssUrl('--img-chat-copy-success-icon'),
  361. };
  362. const copyIconUrl = computed(() => {
  363. const icon = getCssUrl('--img-chat-copy-icon');
  364. const successIcon = getCssUrl('--img-chat-copy-success-icon');
  365. return (index: number) => (copiedMessageIndex.value === index ? successIcon : icon);
  366. });
  367. // 全局计时器 - 每秒刷新一次,用于实时显示思考耗时
  368. const nowTs = ref(Date.now());
  369. let timerInterval: ReturnType<typeof setInterval> | null = null;
  370. const getDurationText = (message: Message): string => {
  371. // 优先使用后端返回的 duration_ms(已包含 baseDurationMs 累加)
  372. if (message.durationMs) {
  373. const totalSec = Math.round(message.durationMs / 1000);
  374. const min = Math.floor(totalSec / 60);
  375. const sec = totalSec % 60;
  376. return `已工作 ${min}分${sec.toString().padStart(2, '0')}秒`;
  377. }
  378. // 审批等待中 - 暂停显示中断前的累计时长
  379. if (message.isPendingApproval && message.pendingApprovalData?.elapsedMs) {
  380. const totalSec = Math.round(message.pendingApprovalData.elapsedMs / 1000);
  381. const min = Math.floor(totalSec / 60);
  382. const sec = totalSec % 60;
  383. return `已工作 ${min}分${sec.toString().padStart(2, '0')}秒`;
  384. }
  385. // 前端实时计时(含中断前累计时长)
  386. if (message.generateStartTime && message.isLoading) {
  387. const baseMs = message.baseDurationMs || 0;
  388. const elapsed = Math.floor((nowTs.value - message.generateStartTime + baseMs) / 1000);
  389. const min = Math.floor(elapsed / 60);
  390. const sec = elapsed % 60;
  391. return `已工作 ${min}分${sec.toString().padStart(2, '0')}秒`;
  392. }
  393. return '';
  394. };
  395. const props = defineProps<{
  396. messages: Message[];
  397. }>();
  398. // Track the last pendingApprovalData reference to detect new interrupts
  399. const lastApprovalDataRef = new Map<number, any>();
  400. // 自动初始化 ask_user 答案状态
  401. watch(
  402. () => props.messages,
  403. (msgs) => {
  404. msgs.forEach((msg, idx) => {
  405. if (msg.isPendingApproval && msg.pendingApprovalData?.ask_user?.questions) {
  406. // Only reinitialize if pendingApprovalData object reference changed (new interrupt)
  407. const lastRef = lastApprovalDataRef.get(idx);
  408. if (lastRef !== msg.pendingApprovalData) {
  409. lastApprovalDataRef.set(idx, msg.pendingApprovalData);
  410. initAskUserAnswers(idx, msg.pendingApprovalData.ask_user.questions);
  411. }
  412. } else {
  413. lastApprovalDataRef.delete(idx);
  414. }
  415. });
  416. },
  417. { immediate: true, deep: true }
  418. );
  419. export interface AgentDetailData {
  420. messageIndex: number;
  421. agent: string;
  422. agentId?: string;
  423. }
  424. const emit = defineEmits<{
  425. (e: 'file-preview', file: AttachedFile): void;
  426. (e: 'download-word', url: string): void;
  427. (e: 'open-file-preview', file: AttachedFile): void;
  428. (e: 'ask-user-submit', answers: string[]): void;
  429. (e: 'ask-user-cancel'): void;
  430. (e: 'agent-detail-click', data: AgentDetailData): void;
  431. (e: 'open-markdown-tab', payload: { title: string; content: string }): void;
  432. }>();
  433. const isEditableFile = (filename: string) => isMdFile(filename) || isTextFile(filename);
  434. const handleDownloadFile = (url: string, filename: string) => {
  435. if (!url) return;
  436. const a = document.createElement('a');
  437. a.href = url;
  438. a.download = filename;
  439. document.body.appendChild(a);
  440. a.click();
  441. document.body.removeChild(a);
  442. };
  443. const handleEditFile = async (url: string, filename: string) => {
  444. try {
  445. const resp = await fetch(url, { headers: { 'X-Access-Token': getToken() } });
  446. if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
  447. const content = await resp.text();
  448. const ext = filename.split('.').pop()?.toLowerCase() || '';
  449. const mimeMap: Record<string, string> = {
  450. md: 'text/markdown',
  451. txt: 'text/plain',
  452. json: 'application/json',
  453. xml: 'text/xml',
  454. yaml: 'text/yaml',
  455. yml: 'text/yaml',
  456. csv: 'text/csv',
  457. };
  458. const file: AttachedFile = {
  459. id: `report-${url}`,
  460. name: filename,
  461. size: content.length,
  462. type: mimeMap[ext] || 'text/plain',
  463. content,
  464. uploadTime: new Date().toISOString(),
  465. };
  466. emit('open-file-preview', file);
  467. } catch (err) {
  468. console.error('获取文件内容失败:', err);
  469. message.error('获取文件内容失败');
  470. }
  471. };
  472. // 点击文件卡片:按类型拉取内容并在右侧辅助面板打开预览标签
  473. const handlePreviewFile = async (file: { url: string; filename: string }) => {
  474. if (!file.url) return;
  475. try {
  476. const resp = await fetch(file.url, { headers: { 'X-Access-Token': getToken() } });
  477. if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
  478. const ext = file.filename.split('.').pop()?.toLowerCase() || '';
  479. const mimeMap: Record<string, string> = {
  480. md: 'text/markdown',
  481. txt: 'text/plain',
  482. json: 'application/json',
  483. xml: 'text/xml',
  484. yaml: 'text/yaml',
  485. yml: 'text/yaml',
  486. csv: 'text/csv',
  487. };
  488. const id = `report-${file.url}`;
  489. const uploadTime = new Date().toISOString();
  490. let previewFile: AttachedFile;
  491. if (mimeMap[ext]) {
  492. const content = await resp.text();
  493. previewFile = { id, name: file.filename, size: content.length, type: mimeMap[ext], content, uploadTime };
  494. } else if (isWordFile(file.filename) || isExcelFile(file.filename)) {
  495. const arrayBuffer = await resp.arrayBuffer();
  496. previewFile = { id, name: file.filename, size: arrayBuffer.byteLength, type: 'application/octet-stream', arrayBuffer, uploadTime };
  497. } else if (isImageFile(file.filename) || isPdfFile(file.filename)) {
  498. const blob = await resp.blob();
  499. const dataUrl = await new Promise<string>((resolve, reject) => {
  500. const reader = new FileReader();
  501. reader.onload = () => resolve(reader.result as string);
  502. reader.onerror = () => reject(reader.error);
  503. reader.readAsDataURL(blob);
  504. });
  505. previewFile = { id, name: file.filename, size: blob.size, type: blob.type, preview: dataUrl, uploadTime };
  506. } else {
  507. // 不支持的格式回退为直接下载
  508. handleDownloadFile(file.url, file.filename);
  509. return;
  510. }
  511. emit('file-preview', previewFile);
  512. } catch (err) {
  513. console.error('获取文件内容失败:', err);
  514. message.error('文件预览失败,请尝试下载查看');
  515. }
  516. };
  517. // ask_user 答案状态(按消息索引存储)
  518. const askUserAnswers = reactive<Record<number, string[]>>({});
  519. const askUserOtherSelected = reactive<Record<number, boolean[]>>({});
  520. const askUserCurrentStep = reactive<Record<number, number>>({});
  521. // choice 可能是字符串或 { value: "..." } 对象,统一提取字符串
  522. const getChoiceValue = (choice: any): string => {
  523. if (typeof choice === 'string') return choice;
  524. if (choice && typeof choice === 'object' && 'value' in choice) return choice.value;
  525. return String(choice);
  526. };
  527. const initAskUserAnswers = (index: number, questions: { question: string; type: string; choices?: any[] }[]) => {
  528. // Always reinitialize when called - handles repeated interrupts from backend
  529. askUserAnswers[index] = questions.map(() => '');
  530. askUserOtherSelected[index] = questions.map(() => false);
  531. askUserCurrentStep[index] = 0;
  532. };
  533. const isCurrentStepAnswered = (msgIndex: number, qIndex: number, question: { required?: boolean; type: string }) => {
  534. const answers = askUserAnswers[msgIndex];
  535. if (!answers) return false;
  536. if (question.required === false && !answers[qIndex]) return true;
  537. return !!(answers[qIndex] && answers[qIndex].trim() !== '');
  538. };
  539. const goNextStep = (msgIndex: number, totalQuestions: number) => {
  540. if (askUserCurrentStep[msgIndex] < totalQuestions - 1) {
  541. askUserCurrentStep[msgIndex]++;
  542. }
  543. };
  544. const goPrevStep = (msgIndex: number) => {
  545. if (askUserCurrentStep[msgIndex] > 0) {
  546. askUserCurrentStep[msgIndex]--;
  547. }
  548. };
  549. const selectChoice = (msgIndex: number, qIndex: number, choice: any, totalQuestions: number) => {
  550. if (!askUserAnswers[msgIndex]) return;
  551. askUserAnswers[msgIndex][qIndex] = getChoiceValue(choice);
  552. askUserOtherSelected[msgIndex][qIndex] = false;
  553. // 单选自动跳到下一题(非最后一题时)
  554. if (qIndex < totalQuestions - 1) {
  555. goNextStep(msgIndex, totalQuestions);
  556. }
  557. };
  558. const selectOther = (msgIndex: number, qIndex: number) => {
  559. if (!askUserOtherSelected[msgIndex]) return;
  560. askUserOtherSelected[msgIndex][qIndex] = true;
  561. askUserAnswers[msgIndex][qIndex] = '';
  562. };
  563. const handleSubmitAskUser = (index: number) => {
  564. // 防御性初始化:如果答案数组未初始化,从 pendingApprovalData 回退
  565. if (!askUserAnswers[index]) {
  566. const msg = props.messages[index];
  567. if (msg?.pendingApprovalData?.ask_user?.questions) {
  568. initAskUserAnswers(index, msg.pendingApprovalData.ask_user.questions);
  569. } else {
  570. return;
  571. }
  572. }
  573. const answers = askUserAnswers[index];
  574. if (!answers) return;
  575. emit('ask-user-submit', [...answers]);
  576. };
  577. const handleCancelAskUser = () => {
  578. emit('ask-user-cancel');
  579. };
  580. const messagesRef = ref<HTMLElement>();
  581. const collapsedThinking = reactive<Record<number, boolean>>({});
  582. const collapsedThinkingContent = reactive<Record<number, boolean>>({});
  583. const collapsedCitations = reactive<Record<number, boolean>>({});
  584. const isAtBottom = ref(true);
  585. const copiedMessageIndex = ref(-1);
  586. const handleTableAction = (e: Event) => {
  587. const target = (e.target as HTMLElement).closest('.table-action-btn') as HTMLElement;
  588. if (!target) return;
  589. const action = target.dataset.action;
  590. const encodedTable = target.dataset.table;
  591. if (!action || !encodedTable) return;
  592. const tableHtml = decodeURIComponent(encodedTable);
  593. switch (action) {
  594. case 'copy': {
  595. const markdown = tableHtmlToMarkdown(tableHtml);
  596. const doCopy = async () => {
  597. try {
  598. await navigator.clipboard.writeText(markdown);
  599. } catch {
  600. const ta = document.createElement('textarea');
  601. ta.value = markdown;
  602. ta.style.position = 'fixed';
  603. ta.style.opacity = '0';
  604. document.body.appendChild(ta);
  605. ta.select();
  606. document.execCommand('copy');
  607. document.body.removeChild(ta);
  608. }
  609. };
  610. doCopy().then(() => {
  611. const btn = target;
  612. const img = btn.querySelector('img');
  613. const successIcon = btn.dataset.iconSuccess;
  614. const originalIcon = btn.dataset.icon;
  615. if (img && successIcon) {
  616. img.src = successIcon;
  617. btn.title = '复制成功';
  618. const reset = () => {
  619. img.src = originalIcon!;
  620. btn.title = '复制Markdown';
  621. wrapper.removeEventListener('mouseleave', reset);
  622. };
  623. const wrapper = btn.closest('.markdown-table-wrapper')!;
  624. wrapper.addEventListener('mouseleave', reset);
  625. }
  626. });
  627. break;
  628. }
  629. case 'csv': {
  630. const csv = tableHtmlToCsv(tableHtml);
  631. const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
  632. const url = URL.createObjectURL(blob);
  633. const a = document.createElement('a');
  634. a.href = url;
  635. a.download = `table_${Date.now()}.csv`;
  636. a.click();
  637. URL.revokeObjectURL(url);
  638. break;
  639. }
  640. case 'preview': {
  641. // 在右侧面板新建标签页展示表格渲染效果
  642. emit('open-markdown-tab', { title: '表格预览', content: tableHtmlToMarkdown(tableHtml) });
  643. break;
  644. }
  645. }
  646. };
  647. const checkScrollBottom = () => {
  648. const el = messagesRef.value;
  649. if (!el) return;
  650. const threshold = 50;
  651. isAtBottom.value = el.scrollHeight - el.scrollTop - el.clientHeight < threshold;
  652. };
  653. const scrollToBottom = () => {
  654. const el = messagesRef.value;
  655. if (el) {
  656. el.scrollTop = el.scrollHeight - el.clientHeight;
  657. }
  658. };
  659. const forceScrollToBottom = () => {
  660. const el = messagesRef.value;
  661. if (el) {
  662. el.scrollTop = el.scrollHeight - el.clientHeight;
  663. // 使用 requestAnimationFrame 确保 DOM 渲染完成后再滚动一次
  664. requestAnimationFrame(() => {
  665. el.scrollTop = el.scrollHeight - el.clientHeight;
  666. });
  667. }
  668. isAtBottom.value = true;
  669. };
  670. onMounted(() => {
  671. messagesRef.value?.addEventListener('click', handleTableAction);
  672. messagesRef.value?.addEventListener('scroll', checkScrollBottom);
  673. timerInterval = setInterval(() => {
  674. nowTs.value = Date.now();
  675. }, 1000);
  676. });
  677. onBeforeUnmount(() => {
  678. messagesRef.value?.removeEventListener('click', handleTableAction);
  679. messagesRef.value?.removeEventListener('scroll', checkScrollBottom);
  680. if (timerInterval) {
  681. clearInterval(timerInterval);
  682. timerInterval = null;
  683. }
  684. });
  685. const toggleThinkingCard = (index: number) => {
  686. collapsedThinking[index] = !collapsedThinking[index];
  687. };
  688. const toggleThinkingContent = (index: number) => {
  689. collapsedThinkingContent[index] = !collapsedThinkingContent[index];
  690. };
  691. const handleAgentGroupClick = (messageIndex: number, group: AgentGroup) => {
  692. emit('agent-detail-click', {
  693. messageIndex,
  694. agent: group.agent,
  695. agentId: group.agentId,
  696. });
  697. };
  698. const toggleCitations = (index: number) => {
  699. collapsedCitations[index] = !collapsedCitations[index];
  700. };
  701. const handleFootnoteClick = (e: Event, msgIndex: number) => {
  702. const target = (e.target as HTMLElement).closest('.footnote-ref') as HTMLElement;
  703. if (!target) return;
  704. const n = target.dataset.n;
  705. if (!n) return;
  706. const el = document.getElementById(`citation-${msgIndex}-${n}`);
  707. if (el) {
  708. el.scrollIntoView({ behavior: 'smooth', block: 'center' });
  709. el.classList.add('citation-highlight');
  710. setTimeout(() => el.classList.remove('citation-highlight'), 1500);
  711. }
  712. };
  713. const getLatestStepMessage = (group: AgentGroup): string => {
  714. if (group.steps.length === 0) return '';
  715. const last = group.steps[group.steps.length - 1];
  716. if (last.type === 'executing') return last.message || '正在执行...';
  717. if (last.type === 'tool_call') return last.message || last.tool || '';
  718. if (last.type === 'tool_result') return last.message || '';
  719. if (last.type === 'agent_start') return last.message || '';
  720. if (last.type === 'agent_done') return last.message || '';
  721. if (last.type === 'updated_todo_list') return '任务列表已更新';
  722. return '';
  723. };
  724. interface AgentGroup {
  725. agent: string;
  726. agentId?: string;
  727. steps: ThinkingStep[];
  728. }
  729. const groupStepsByAgent = (steps: ThinkingStep[]): AgentGroup[] => {
  730. const groupMap = new Map<string, AgentGroup>();
  731. for (const step of steps) {
  732. const agentName = step.agent || '系统';
  733. const groupKey = step.agentId || agentName;
  734. if (!groupMap.has(groupKey)) {
  735. groupMap.set(groupKey, { agent: agentName, agentId: step.agentId, steps: [] });
  736. }
  737. groupMap.get(groupKey)!.steps.push(step);
  738. }
  739. return Array.from(groupMap.values());
  740. };
  741. const formatFullTime = (createdAt: string) => {
  742. return dayjs(createdAt).format('YYYY-MM-DD HH:mm:ss');
  743. };
  744. const copyMessageContent = async (content: string, index: number) => {
  745. if (!content) return;
  746. try {
  747. await navigator.clipboard.writeText(content);
  748. copiedMessageIndex.value = index;
  749. } catch {
  750. const textarea = document.createElement('textarea');
  751. textarea.value = content;
  752. textarea.style.position = 'fixed';
  753. textarea.style.opacity = '0';
  754. document.body.appendChild(textarea);
  755. textarea.select();
  756. document.execCommand('copy');
  757. document.body.removeChild(textarea);
  758. copiedMessageIndex.value = index;
  759. }
  760. };
  761. // ===== 左侧对话缩略导航 =====
  762. interface QaPair {
  763. startIndex: number;
  764. question: string;
  765. answer: string;
  766. }
  767. const toPlainText = (md: string): string =>
  768. md
  769. .replace(/```[\s\S]*?```/g, ' [代码] ')
  770. .replace(/`[^`]*`/g, ' ')
  771. .replace(/<[^>]+>/g, '')
  772. .replace(/!\[[^\]]*\]\([^)]*\)/g, '')
  773. .replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
  774. .replace(/^#{1,6}\s*/gm, '')
  775. .replace(/[*_~>|]/g, '')
  776. .replace(/\s+/g, ' ')
  777. .trim();
  778. const truncateText = (text: string, max = 50): string => (text.length > max ? `${text.slice(0, max)}…` : text);
  779. // 一轮问答 = 一条用户消息 + 其后的连续 AI 消息
  780. const qaPairs = computed<QaPair[]>(() => {
  781. const pairs: QaPair[] = [];
  782. let current: QaPair | null = null;
  783. props.messages.forEach((msg, index) => {
  784. if (msg.type === 'user') {
  785. if (current) pairs.push(current);
  786. current = { startIndex: index, question: truncateText(toPlainText(msg.content)), answer: '' };
  787. } else {
  788. if (!current) current = { startIndex: index, question: '', answer: '' };
  789. const part = msg.isLoading && !msg.content ? '正在生成...' : toPlainText(msg.content);
  790. if (part) current.answer = truncateText(current.answer ? `${current.answer} ${part}` : part);
  791. }
  792. });
  793. if (current) pairs.push(current);
  794. return pairs;
  795. });
  796. const navRef = ref<HTMLElement>();
  797. const tooltipRef = ref<HTMLElement>();
  798. const hoveredPair = ref<QaPair | null>(null);
  799. const tooltipTop = ref(0);
  800. const tooltipArrowTop = ref(0);
  801. const activeMessage = ref<Message | null>(null);
  802. // 鼠标在导航列内的 Y 坐标(导航列内容坐标系,随滚动补偿);null 表示未悬浮
  803. const navMouseY = ref<number | null>(null);
  804. // 各横线中心 Y(导航列内容坐标系),消息变化/列滚动后重建
  805. const lineCenters = ref<number[]>([]);
  806. const updateLineCenters = () => {
  807. const nav = navRef.value;
  808. if (!nav) {
  809. lineCenters.value = [];
  810. return;
  811. }
  812. const centers: number[] = [];
  813. nav.querySelectorAll<HTMLElement>('.nav-line').forEach((line) => centers.push(line.offsetTop + line.offsetHeight / 2));
  814. lineCenters.value = centers;
  815. };
  816. // 宽度随与鼠标的距离连续衰减(高斯),形成平滑的"长-中-短"波形
  817. const navLineWidth = (pIdx: number): number => {
  818. const mouseY = navMouseY.value;
  819. if (mouseY === null) return 10;
  820. const dist = Math.abs((lineCenters.value[pIdx] ?? 0) - mouseY);
  821. return 10 + 8 * Math.exp(-(dist * dist) / (2 * 14 * 14));
  822. };
  823. const nearestLineIndex = computed(() => {
  824. const mouseY = navMouseY.value;
  825. if (mouseY === null) return -1;
  826. let best = -1;
  827. let bestDist = Infinity;
  828. lineCenters.value.forEach((center, i) => {
  829. const dist = Math.abs(center - mouseY);
  830. if (dist < bestDist) {
  831. bestDist = dist;
  832. best = i;
  833. }
  834. });
  835. return best;
  836. });
  837. let lastTooltipIndex = -1;
  838. const applyTooltip = async (pIdx: number) => {
  839. const pair = qaPairs.value[pIdx];
  840. if (!pair) {
  841. hoveredPair.value = null;
  842. return;
  843. }
  844. hoveredPair.value = pair;
  845. await nextTick();
  846. const tooltip = tooltipRef.value;
  847. const nav = navRef.value;
  848. const container = nav?.parentElement as HTMLElement | null;
  849. if (!tooltip || !nav || !container) return;
  850. const lineCenterY = nav.offsetTop + (lineCenters.value[pIdx] ?? 0) - nav.scrollTop;
  851. const tooltipH = tooltip.offsetHeight;
  852. const maxTop = Math.max(8, container.clientHeight - tooltipH - 8);
  853. tooltipTop.value = Math.max(8, Math.min(maxTop, lineCenterY - tooltipH / 2));
  854. tooltipArrowTop.value = Math.max(6, Math.min(tooltipH - 16, lineCenterY - tooltipTop.value - 5));
  855. };
  856. const onNavMove = (e: MouseEvent) => {
  857. const nav = navRef.value;
  858. if (!nav) return;
  859. // 横线数量变化(新增问答/首次悬浮)时重建坐标
  860. if (lineCenters.value.length !== qaPairs.value.length) updateLineCenters();
  861. navMouseY.value = e.clientY - nav.getBoundingClientRect().top + nav.scrollTop;
  862. const nearest = nearestLineIndex.value;
  863. if (nearest >= 0 && nearest !== lastTooltipIndex) {
  864. lastTooltipIndex = nearest;
  865. applyTooltip(nearest);
  866. }
  867. };
  868. const onNavLeave = () => {
  869. navMouseY.value = null;
  870. hoveredPair.value = null;
  871. lastTooltipIndex = -1;
  872. };
  873. const onNavScroll = () => {
  874. updateLineCenters();
  875. if (lastTooltipIndex >= 0) applyTooltip(lastTooltipIndex);
  876. };
  877. const scrollToPair = (pair: QaPair) => {
  878. activeMessage.value = props.messages[pair.startIndex];
  879. const wrappers = messagesRef.value?.querySelectorAll('.message-wrapper');
  880. const el = wrappers?.[pair.startIndex] as HTMLElement | undefined;
  881. if (!el) return;
  882. el.scrollIntoView({ behavior: 'smooth', block: 'start' });
  883. el.classList.add('nav-located-highlight');
  884. setTimeout(() => el.classList.remove('nav-located-highlight'), 1500);
  885. };
  886. defineExpose({ messagesRef, isAtBottom, forceScrollToBottom, initAskUserAnswers });
  887. </script>
  888. <style scoped lang="less">
  889. .chat-messages-container {
  890. flex: 1;
  891. position: relative;
  892. display: flex;
  893. flex-direction: row;
  894. overflow: hidden;
  895. }
  896. .conversation-nav {
  897. position: relative;
  898. width: 28px;
  899. flex-shrink: 0;
  900. display: flex;
  901. flex-direction: column;
  902. align-items: center;
  903. overflow-y: auto;
  904. padding: 6px 0;
  905. scrollbar-width: none;
  906. &::-webkit-scrollbar {
  907. display: none;
  908. }
  909. .nav-line {
  910. width: 10px;
  911. height: 3px;
  912. border-radius: 2px;
  913. background: rgba(139, 148, 158, 0.4);
  914. margin: 5px 0;
  915. flex-shrink: 0;
  916. cursor: pointer;
  917. transition:
  918. width 0.15s ease-out,
  919. background 0.2s;
  920. &:first-child {
  921. margin-top: auto;
  922. }
  923. &:last-child {
  924. margin-bottom: auto;
  925. }
  926. &.nav-line-hot {
  927. background: #0a84ff;
  928. }
  929. &.active {
  930. background: #0a84ff;
  931. }
  932. }
  933. }
  934. .conversation-tooltip {
  935. position: absolute;
  936. left: 36px;
  937. width: 260px;
  938. background: linear-gradient(135deg, #0a1628 0%, #0d2137 50%, #0a1e35 100%);
  939. border: 1px solid #1a4a6f;
  940. border-radius: 8px;
  941. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  942. padding: 10px 12px;
  943. z-index: 20;
  944. pointer-events: none;
  945. .tooltip-arrow {
  946. position: absolute;
  947. left: -6px;
  948. width: 10px;
  949. height: 10px;
  950. transform: rotate(45deg);
  951. background: #0d2137;
  952. border-left: 1px solid #1a4a6f;
  953. border-bottom: 1px solid #1a4a6f;
  954. }
  955. .tooltip-row {
  956. display: flex;
  957. align-items: flex-start;
  958. gap: 8px;
  959. font-size: 12px;
  960. line-height: 1.5;
  961. & + .tooltip-row {
  962. margin-top: 8px;
  963. padding-top: 8px;
  964. border-top: 1px solid rgba(63, 80, 106, 0.3);
  965. }
  966. .tooltip-label {
  967. flex-shrink: 0;
  968. width: 16px;
  969. height: 16px;
  970. line-height: 16px;
  971. margin-top: 1px;
  972. text-align: center;
  973. border-radius: 3px;
  974. font-size: 11px;
  975. &-q {
  976. color: #79c0ff;
  977. background: rgba(10, 132, 255, 0.15);
  978. }
  979. &-a {
  980. color: #8b949e;
  981. background: rgba(139, 148, 158, 0.15);
  982. }
  983. }
  984. .tooltip-text {
  985. color: #c9d1d9;
  986. word-break: break-word;
  987. }
  988. }
  989. }
  990. .tooltip-fade-enter-active,
  991. .tooltip-fade-leave-active {
  992. transition: opacity 0.15s ease;
  993. }
  994. .tooltip-fade-enter-from,
  995. .tooltip-fade-leave-to {
  996. opacity: 0;
  997. }
  998. .chat-messages {
  999. flex: 1;
  1000. overflow-y: auto;
  1001. padding: 20px;
  1002. position: relative;
  1003. .welcome-empty {
  1004. position: absolute;
  1005. top: 50%;
  1006. left: 50%;
  1007. transform: translate(-50%, -50%);
  1008. display: flex;
  1009. align-items: center;
  1010. justify-content: center;
  1011. .welcome-img {
  1012. max-width: 300px;
  1013. max-height: 300px;
  1014. object-fit: contain;
  1015. }
  1016. }
  1017. .message-wrapper {
  1018. // margin-bottom: 20px;
  1019. &.nav-located-highlight {
  1020. background: rgba(10, 132, 255, 0.08);
  1021. border-radius: 6px;
  1022. }
  1023. .ai-message {
  1024. display: flex;
  1025. flex-wrap: wrap;
  1026. .message-agent {
  1027. display: flex;
  1028. margin-bottom: 8px;
  1029. opacity: 0;
  1030. }
  1031. .message-body {
  1032. padding: 12px 12px 4px 12px;
  1033. border-radius: 6px;
  1034. width: 100%;
  1035. min-width: 0;
  1036. overflow: hidden;
  1037. /* 思考过程卡片 */
  1038. .thinking-card {
  1039. margin-bottom: 12px;
  1040. overflow: hidden;
  1041. .thinking-duration-bar {
  1042. display: flex;
  1043. align-items: center;
  1044. justify-content: space-between;
  1045. padding: 8px 14px;
  1046. border-bottom: 1px solid rgba(63, 80, 106, 0.3);
  1047. cursor: pointer;
  1048. user-select: none;
  1049. transition: background 0.2s;
  1050. &:hover {
  1051. background: rgba(10, 132, 255, 0.12);
  1052. }
  1053. .thinking-duration {
  1054. font-size: 16px;
  1055. color: #8b949e;
  1056. }
  1057. .thinking-arrow {
  1058. color: #8b949e;
  1059. display: flex;
  1060. align-items: center;
  1061. transition: transform 0.2s;
  1062. &.expanded {
  1063. transform: rotate(180deg);
  1064. }
  1065. }
  1066. }
  1067. .thinking-header {
  1068. display: flex;
  1069. align-items: center;
  1070. justify-content: space-between;
  1071. padding: 10px 14px;
  1072. cursor: pointer;
  1073. user-select: none;
  1074. transition: background 0.2s;
  1075. &:hover {
  1076. background: rgba(10, 132, 255, 0.05);
  1077. }
  1078. .thinking-header-left {
  1079. display: flex;
  1080. align-items: center;
  1081. gap: 8px;
  1082. }
  1083. .thinking-arrow {
  1084. display: flex;
  1085. align-items: center;
  1086. transition: transform 0.2s;
  1087. &.expanded {
  1088. transform: rotate(180deg);
  1089. }
  1090. }
  1091. .thinking-icon {
  1092. width: 16px;
  1093. height: 16px;
  1094. background-image: var(--img-chat-thinking-icon);
  1095. background-repeat: no-repeat;
  1096. background-size: 100% 100%;
  1097. }
  1098. .thinking-title {
  1099. font-size: 13px;
  1100. font-weight: 500;
  1101. color: #8b949e;
  1102. }
  1103. .thinking-count {
  1104. font-size: 12px;
  1105. color: #8b949e;
  1106. background: rgba(10, 132, 255, 0.1);
  1107. padding: 1px 6px;
  1108. border-radius: 10px;
  1109. }
  1110. }
  1111. .thinking-content-body {
  1112. margin: 0 14px 8px;
  1113. padding: 8px 12px;
  1114. max-height: 200px;
  1115. overflow-y: auto;
  1116. font-size: 13px;
  1117. line-height: 1.6;
  1118. color: #8b949e;
  1119. white-space: pre-wrap;
  1120. word-break: break-word;
  1121. background: rgba(10, 13, 23, 0.3);
  1122. border-radius: 6px;
  1123. }
  1124. .thinking-body {
  1125. padding: 8px 14px;
  1126. .agent-group {
  1127. margin-bottom: 8px;
  1128. border: 1px solid transparent;
  1129. border-radius: 6px;
  1130. overflow: hidden;
  1131. transition: border-color 0.2s;
  1132. cursor: pointer;
  1133. &:hover {
  1134. border-color: rgba(63, 80, 106, 0.25);
  1135. background: rgba(10, 132, 255, 0.05);
  1136. }
  1137. &:last-child {
  1138. margin-bottom: 0;
  1139. }
  1140. .agent-group-header {
  1141. display: flex;
  1142. align-items: center;
  1143. justify-content: space-between;
  1144. padding: 8px 12px;
  1145. user-select: none;
  1146. .agent-group-header-left {
  1147. display: flex;
  1148. align-items: center;
  1149. gap: 8px;
  1150. }
  1151. .agent-group-icon {
  1152. width: 14px;
  1153. height: 14px;
  1154. background-image: var(--img-chat-agent-icon);
  1155. background-repeat: no-repeat;
  1156. background-size: 100% 100%;
  1157. flex-shrink: 0;
  1158. }
  1159. .agent-group-name {
  1160. font-size: 13px;
  1161. font-weight: 500;
  1162. color: #fff;
  1163. }
  1164. .agent-group-latest {
  1165. font-size: 12px;
  1166. color: #8b949e;
  1167. margin-left: 8px;
  1168. overflow: hidden;
  1169. text-overflow: ellipsis;
  1170. white-space: nowrap;
  1171. flex: 1;
  1172. min-width: 0;
  1173. }
  1174. .agent-arrow {
  1175. margin-left: 8px;
  1176. flex-shrink: 0;
  1177. display: flex;
  1178. align-items: center;
  1179. }
  1180. }
  1181. }
  1182. }
  1183. }
  1184. .collapse-enter-active,
  1185. .collapse-leave-active {
  1186. transition: all 0.25s ease;
  1187. overflow: hidden;
  1188. }
  1189. .collapse-enter-from,
  1190. .collapse-leave-to {
  1191. opacity: 0;
  1192. max-height: 0;
  1193. padding-top: 0;
  1194. padding-bottom: 0;
  1195. margin-top: 0;
  1196. margin-bottom: 0;
  1197. }
  1198. .collapse-enter-to,
  1199. .collapse-leave-from {
  1200. opacity: 1;
  1201. max-height: 500px;
  1202. }
  1203. .message-text {
  1204. font-size: 14px;
  1205. font-weight: 400;
  1206. line-height: 1.6;
  1207. color: #e0e6ed;
  1208. word-break: break-word;
  1209. overflow-wrap: break-word;
  1210. :deep(.session-ref-icon) {
  1211. width: 14px;
  1212. height: 14px;
  1213. vertical-align: -2px;
  1214. }
  1215. :deep(h1),
  1216. :deep(h2),
  1217. :deep(h3),
  1218. :deep(h4),
  1219. :deep(h5),
  1220. :deep(h6) {
  1221. color: #fff;
  1222. }
  1223. :deep(p) {
  1224. margin: 0;
  1225. }
  1226. :deep(code) {
  1227. background: rgba(10, 132, 255, 0.1);
  1228. padding: 1px 4px;
  1229. border-radius: 3px;
  1230. font-size: 12px;
  1231. }
  1232. :deep(pre) {
  1233. background: rgba(10, 132, 255, 0.1);
  1234. padding: 8px;
  1235. border-radius: 4px;
  1236. overflow-x: auto;
  1237. margin: 6px 0;
  1238. white-space: pre-wrap;
  1239. }
  1240. :deep(pre code) {
  1241. background: transparent;
  1242. padding: 0;
  1243. }
  1244. :deep(ul),
  1245. :deep(ol) {
  1246. padding-left: 18px;
  1247. margin: 4px 0;
  1248. }
  1249. :deep(blockquote) {
  1250. border-left: 3px solid rgba(10, 132, 255, 0.3);
  1251. padding-left: 10px;
  1252. margin: 6px 0;
  1253. color: #8b949e;
  1254. }
  1255. :deep(table) {
  1256. border-collapse: collapse;
  1257. margin: 6px 0;
  1258. }
  1259. :deep(th),
  1260. :deep(td) {
  1261. border: 1px solid rgba(63, 80, 106, 0.5);
  1262. padding: 4px 8px;
  1263. }
  1264. :deep(th) {
  1265. background: rgba(10, 132, 255, 0.1);
  1266. }
  1267. :deep(strong) {
  1268. font-weight: 600;
  1269. }
  1270. :deep(.markdown-table-wrapper) {
  1271. position: relative;
  1272. margin: 6px 0;
  1273. max-width: 100%;
  1274. overflow-x: auto;
  1275. .table-actions {
  1276. position: absolute;
  1277. top: 4px;
  1278. right: 4px;
  1279. display: flex;
  1280. gap: 2px;
  1281. opacity: 0;
  1282. transition: opacity 0.2s;
  1283. z-index: 1;
  1284. }
  1285. &:hover .table-actions {
  1286. opacity: 1;
  1287. }
  1288. .table-action-btn {
  1289. width: 26px;
  1290. height: 26px;
  1291. display: flex;
  1292. align-items: center;
  1293. justify-content: center;
  1294. border-radius: 4px;
  1295. color: #8b949e;
  1296. cursor: pointer;
  1297. background: rgba(22, 27, 34, 0.8);
  1298. backdrop-filter: blur(4px);
  1299. transition: all 0.2s;
  1300. &:hover {
  1301. color: #e0e6ed;
  1302. background: rgba(10, 132, 255, 0.3);
  1303. }
  1304. }
  1305. }
  1306. }
  1307. }
  1308. .loading-dots {
  1309. display: flex;
  1310. align-items: center;
  1311. gap: 6px;
  1312. padding: 4px 0;
  1313. min-height: 16px;
  1314. .dot {
  1315. width: 8px;
  1316. height: 8px;
  1317. border-radius: 50%;
  1318. background: rgba(10, 132, 255, 0.4);
  1319. animation: dot-bounce 1.4s ease-in-out infinite both;
  1320. &:nth-child(1) {
  1321. animation-delay: 0s;
  1322. }
  1323. &:nth-child(2) {
  1324. animation-delay: 0.2s;
  1325. }
  1326. &:nth-child(3) {
  1327. animation-delay: 0.4s;
  1328. }
  1329. }
  1330. }
  1331. @keyframes dot-bounce {
  1332. 0%,
  1333. 80%,
  1334. 100% {
  1335. transform: scale(0.6);
  1336. opacity: 0.4;
  1337. }
  1338. 40% {
  1339. transform: scale(1);
  1340. opacity: 1;
  1341. }
  1342. }
  1343. .approval-card {
  1344. display: flex;
  1345. align-items: flex-start;
  1346. gap: 12px;
  1347. padding: 14px 16px;
  1348. margin-top: 12px;
  1349. background: #002f4a;
  1350. border: 1px solid #005482;
  1351. border-radius: 8px;
  1352. .approval-icon {
  1353. width: 36px;
  1354. height: 36px;
  1355. background-image: var(--img-chat-session-approve-icon);
  1356. background-repeat: no-repeat;
  1357. background-size: 100% 100%;
  1358. flex-shrink: 0;
  1359. }
  1360. .approval-content {
  1361. flex: 1;
  1362. .approval-title {
  1363. font-size: 14px;
  1364. font-weight: 600;
  1365. color: #e0e6ed;
  1366. margin-bottom: 6px;
  1367. }
  1368. .approval-plan {
  1369. margin-bottom: 14px;
  1370. padding: 10px 12px;
  1371. background: rgba(10, 132, 255, 0.08);
  1372. border: 1px solid rgba(10, 132, 255, 0.2);
  1373. border-radius: 6px;
  1374. .approval-plan-label {
  1375. font-size: 12px;
  1376. color: #0a84ff;
  1377. font-weight: 600;
  1378. margin-bottom: 6px;
  1379. }
  1380. .approval-plan-content {
  1381. font-size: 13px;
  1382. color: #c9d1d9;
  1383. line-height: 1.6;
  1384. white-space: pre-wrap;
  1385. }
  1386. }
  1387. .ask-user-question {
  1388. margin-bottom: 14px;
  1389. .ask-user-question-text {
  1390. font-size: 13px;
  1391. color: #c9d1d9;
  1392. margin-bottom: 8px;
  1393. line-height: 1.5;
  1394. .ask-user-required {
  1395. color: #f85149;
  1396. margin-left: 2px;
  1397. }
  1398. }
  1399. .ask-user-choices {
  1400. display: flex;
  1401. flex-direction: column;
  1402. gap: 6px;
  1403. .ask-user-choice {
  1404. display: flex;
  1405. align-items: center;
  1406. padding: 8px 12px;
  1407. background: rgba(255, 255, 255, 0.04);
  1408. border: 1px solid rgba(63, 80, 106, 0.4);
  1409. border-radius: 6px;
  1410. cursor: pointer;
  1411. font-size: 13px;
  1412. color: #c9d1d9;
  1413. transition: all 0.2s;
  1414. &:hover {
  1415. background: rgba(10, 132, 255, 0.1);
  1416. border-color: rgba(10, 132, 255, 0.4);
  1417. }
  1418. &.selected {
  1419. background: rgba(10, 132, 255, 0.15);
  1420. border-color: #0a84ff;
  1421. color: #fff;
  1422. }
  1423. }
  1424. .ask-user-other-input {
  1425. margin-top: 4px;
  1426. padding: 8px 12px;
  1427. font-size: 13px;
  1428. color: #e0e6ed;
  1429. background: rgba(255, 255, 255, 0.06);
  1430. border: 1px solid rgba(63, 80, 106, 0.5);
  1431. border-radius: 6px;
  1432. outline: none;
  1433. width: 100%;
  1434. &:focus {
  1435. border-color: #0a84ff;
  1436. background: rgba(10, 132, 255, 0.08);
  1437. }
  1438. &::placeholder {
  1439. color: #6e7681;
  1440. }
  1441. }
  1442. }
  1443. .ask-user-text {
  1444. .ask-user-textarea {
  1445. width: 100%;
  1446. min-height: 60px;
  1447. padding: 8px 12px;
  1448. font-size: 13px;
  1449. color: #e0e6ed;
  1450. background: rgba(255, 255, 255, 0.06);
  1451. border: 1px solid rgba(63, 80, 106, 0.5);
  1452. border-radius: 6px;
  1453. outline: none;
  1454. resize: vertical;
  1455. font-family: inherit;
  1456. &:focus {
  1457. border-color: #0a84ff;
  1458. background: rgba(10, 132, 255, 0.08);
  1459. }
  1460. &::placeholder {
  1461. color: #6e7681;
  1462. }
  1463. }
  1464. }
  1465. }
  1466. .ask-user-stepper {
  1467. display: flex;
  1468. align-items: center;
  1469. gap: 6px;
  1470. margin-bottom: 14px;
  1471. .ask-user-step-dot {
  1472. width: 8px;
  1473. height: 8px;
  1474. border-radius: 50%;
  1475. background: rgba(63, 80, 106, 0.5);
  1476. cursor: pointer;
  1477. transition: all 0.2s;
  1478. &.active {
  1479. background: #0a84ff;
  1480. width: 20px;
  1481. border-radius: 4px;
  1482. }
  1483. &.completed {
  1484. background: rgba(10, 132, 255, 0.5);
  1485. }
  1486. }
  1487. .ask-user-step-text {
  1488. margin-left: 6px;
  1489. font-size: 12px;
  1490. color: #6e7681;
  1491. }
  1492. }
  1493. .approval-actions {
  1494. display: flex;
  1495. gap: 10px;
  1496. .approval-btn {
  1497. padding: 6px 20px;
  1498. border-radius: 6px;
  1499. font-size: 13px;
  1500. font-weight: 500;
  1501. cursor: pointer;
  1502. border: none;
  1503. transition: all 0.2s;
  1504. &.approve-btn {
  1505. background: #0a84ff;
  1506. color: #fff;
  1507. &:hover:not(:disabled) {
  1508. background: #3a9bfd;
  1509. }
  1510. &:disabled {
  1511. opacity: 0.4;
  1512. cursor: not-allowed;
  1513. }
  1514. }
  1515. &.nav-btn {
  1516. background: rgba(255, 255, 255, 0.08);
  1517. color: #c9d1d9;
  1518. border: 1px solid rgba(63, 80, 106, 0.5);
  1519. &:hover {
  1520. background: rgba(255, 255, 255, 0.15);
  1521. }
  1522. }
  1523. &.reject-btn {
  1524. background: rgba(255, 255, 255, 0.08);
  1525. color: #e0e6ed;
  1526. border: 1px solid rgba(63, 80, 106, 0.5);
  1527. &:hover {
  1528. background: rgba(255, 255, 255, 0.15);
  1529. }
  1530. }
  1531. }
  1532. }
  1533. }
  1534. }
  1535. .citations-card {
  1536. margin-bottom: 12px;
  1537. overflow: hidden;
  1538. .citations-header {
  1539. display: flex;
  1540. align-items: center;
  1541. justify-content: space-between;
  1542. padding: 8px 14px;
  1543. border-bottom: 1px solid rgba(63, 80, 106, 0.3);
  1544. cursor: pointer;
  1545. user-select: none;
  1546. transition: background 0.2s;
  1547. &:hover {
  1548. background: rgba(10, 132, 255, 0.08);
  1549. }
  1550. &.citations-header-simple {
  1551. cursor: default;
  1552. &:hover {
  1553. background: transparent;
  1554. }
  1555. }
  1556. .citations-header-left {
  1557. display: flex;
  1558. align-items: center;
  1559. gap: 8px;
  1560. }
  1561. .citations-title {
  1562. font-size: 13px;
  1563. font-weight: 500;
  1564. color: #8b949e;
  1565. }
  1566. .citations-count {
  1567. font-size: 12px;
  1568. color: #8b949e;
  1569. background: rgba(10, 132, 255, 0.1);
  1570. padding: 1px 6px;
  1571. border-radius: 10px;
  1572. }
  1573. .thinking-arrow {
  1574. display: flex;
  1575. align-items: center;
  1576. transition: transform 0.2s;
  1577. &.expanded {
  1578. transform: rotate(180deg);
  1579. }
  1580. }
  1581. }
  1582. .citations-body {
  1583. padding: 4px 14px;
  1584. .citation-item {
  1585. padding: 6px 0;
  1586. border-bottom: 1px solid rgba(63, 80, 106, 0.15);
  1587. &:last-child {
  1588. border-bottom: none;
  1589. }
  1590. &.citation-highlight {
  1591. background: rgba(10, 132, 255, 0.08);
  1592. border-radius: 4px;
  1593. padding: 6px 8px;
  1594. margin: 0 -8px;
  1595. }
  1596. .citation-item-row {
  1597. display: flex;
  1598. align-items: center;
  1599. gap: 8px;
  1600. line-height: 1.5;
  1601. .citation-badge {
  1602. font-size: 12px;
  1603. color: #79c0ff;
  1604. font-family: monospace;
  1605. background: rgba(10, 132, 255, 0.1);
  1606. padding: 1px 5px;
  1607. border-radius: 3px;
  1608. white-space: nowrap;
  1609. flex-shrink: 0;
  1610. }
  1611. .citation-badge-knowledge_base {
  1612. color: #3fb950;
  1613. background: rgba(46, 160, 67, 0.1);
  1614. }
  1615. .citation-badge-web {
  1616. color: #d29922;
  1617. background: rgba(210, 153, 34, 0.1);
  1618. }
  1619. .citation-badge-calc {
  1620. color: #a371f7;
  1621. background: rgba(163, 113, 247, 0.1);
  1622. }
  1623. .citation-title-text {
  1624. font-size: 13px;
  1625. color: #b0b8c4;
  1626. overflow: hidden;
  1627. text-overflow: ellipsis;
  1628. white-space: nowrap;
  1629. min-width: 0;
  1630. }
  1631. .citation-link {
  1632. font-size: 12px;
  1633. color: #0a84ff;
  1634. text-decoration: none;
  1635. white-space: nowrap;
  1636. flex-shrink: 0;
  1637. }
  1638. }
  1639. .citation-item-attrs {
  1640. display: flex;
  1641. align-items: center;
  1642. flex-wrap: wrap;
  1643. gap: 4px 10px;
  1644. padding-left: 0;
  1645. margin-top: 2px;
  1646. .citation-attr {
  1647. font-size: 12px;
  1648. color: #8b949e;
  1649. white-space: nowrap;
  1650. }
  1651. .citation-low-score {
  1652. color: #d29922;
  1653. }
  1654. }
  1655. .citation-snippet {
  1656. margin-top: 4px;
  1657. font-size: 12px;
  1658. color: #8b949e;
  1659. line-height: 1.5;
  1660. overflow: hidden;
  1661. text-overflow: ellipsis;
  1662. white-space: nowrap;
  1663. }
  1664. }
  1665. }
  1666. }
  1667. .download-file-cards {
  1668. display: flex;
  1669. flex-direction: column;
  1670. gap: 8px;
  1671. margin-top: 12px;
  1672. .download-file-card {
  1673. display: flex;
  1674. align-items: center;
  1675. justify-content: space-between;
  1676. padding: 12px 16px;
  1677. background: linear-gradient(135deg, rgba(0, 47, 74, 0.8) 0%, rgba(0, 60, 90, 0.6) 100%);
  1678. border: 1px solid rgba(0, 84, 130, 0.6);
  1679. border-radius: 10px;
  1680. cursor: pointer;
  1681. transition: all 0.2s ease;
  1682. &:hover {
  1683. border-color: rgba(10, 132, 255, 0.4);
  1684. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  1685. }
  1686. .file-card-info {
  1687. display: flex;
  1688. align-items: center;
  1689. gap: 12px;
  1690. min-width: 0;
  1691. flex: 1;
  1692. .file-card-icon {
  1693. width: 36px;
  1694. height: 36px;
  1695. background-image: var(--img-chat-download-icon);
  1696. background-repeat: no-repeat;
  1697. background-size: 100% 100%;
  1698. flex-shrink: 0;
  1699. opacity: 0.9;
  1700. }
  1701. .file-card-text {
  1702. display: flex;
  1703. flex-direction: column;
  1704. gap: 2px;
  1705. min-width: 0;
  1706. .file-card-name {
  1707. font-size: 13px;
  1708. font-weight: 500;
  1709. color: #e0e6ed;
  1710. overflow: hidden;
  1711. text-overflow: ellipsis;
  1712. white-space: nowrap;
  1713. }
  1714. .file-card-hint {
  1715. font-size: 11px;
  1716. color: #6e7681;
  1717. }
  1718. }
  1719. }
  1720. .file-card-actions {
  1721. display: flex;
  1722. gap: 8px;
  1723. flex-shrink: 0;
  1724. .file-action-btn {
  1725. display: inline-flex;
  1726. align-items: center;
  1727. gap: 5px;
  1728. padding: 6px 14px;
  1729. border-radius: 7px;
  1730. font-size: 12px;
  1731. font-weight: 500;
  1732. cursor: pointer;
  1733. border: none;
  1734. transition: all 0.2s ease;
  1735. white-space: nowrap;
  1736. &.download-btn {
  1737. background: rgba(255, 255, 255, 0.08);
  1738. color: #c9d1d9;
  1739. border: 1px solid rgba(63, 80, 106, 0.5);
  1740. &:hover {
  1741. background: rgba(255, 255, 255, 0.14);
  1742. color: #e0e6ed;
  1743. border-color: rgba(63, 80, 106, 0.8);
  1744. }
  1745. }
  1746. &.edit-btn {
  1747. background: linear-gradient(135deg, #0a84ff 0%, #0066cc 100%);
  1748. color: #fff;
  1749. border: 1px solid rgba(10, 132, 255, 0.5);
  1750. box-shadow: 0 2px 6px rgba(10, 132, 255, 0.2);
  1751. &:hover {
  1752. background: linear-gradient(135deg, #3a9bfd 0%, #0a84ff 100%);
  1753. box-shadow: 0 3px 10px rgba(10, 132, 255, 0.35);
  1754. }
  1755. }
  1756. }
  1757. }
  1758. }
  1759. }
  1760. }
  1761. .user-message {
  1762. display: flex;
  1763. flex-wrap: wrap;
  1764. justify-content: flex-end;
  1765. align-items: flex-start;
  1766. .message-agent {
  1767. display: flex;
  1768. margin-bottom: 8px;
  1769. margin-left: 5px;
  1770. }
  1771. .message-body {
  1772. background: rgba(10, 132, 255, 0.15);
  1773. padding: 12px;
  1774. border-radius: 6px 0 6px 6px;
  1775. max-width: 700px;
  1776. min-width: 0;
  1777. overflow: hidden;
  1778. .message-text {
  1779. font-size: 14px;
  1780. font-weight: 400;
  1781. line-height: 1.6;
  1782. color: #e0e6ed;
  1783. word-break: break-word;
  1784. overflow-wrap: break-word;
  1785. :deep(.session-ref-icon) {
  1786. width: 14px;
  1787. height: 14px;
  1788. vertical-align: -2px;
  1789. }
  1790. :deep(h1, h2, h3, h4, h5, h6) {
  1791. color: #fff;
  1792. }
  1793. :deep(p) {
  1794. margin: 0;
  1795. }
  1796. :deep(code) {
  1797. background: rgba(0, 0, 0, 0.2);
  1798. padding: 1px 4px;
  1799. border-radius: 3px;
  1800. font-size: 12px;
  1801. }
  1802. :deep(pre) {
  1803. background: rgba(0, 0, 0, 0.2);
  1804. padding: 8px;
  1805. border-radius: 4px;
  1806. overflow-x: auto;
  1807. margin: 6px 0;
  1808. white-space: pre-wrap;
  1809. }
  1810. :deep(pre code) {
  1811. background: transparent;
  1812. padding: 0;
  1813. }
  1814. }
  1815. .attached-file-card {
  1816. margin-top: 10px;
  1817. background: rgba(255, 255, 255, 0.08);
  1818. border-radius: 6px;
  1819. display: flex;
  1820. align-items: center;
  1821. gap: 10px;
  1822. padding: 8px;
  1823. cursor: pointer;
  1824. transition: all 0.3s;
  1825. &:hover {
  1826. background: rgba(255, 255, 255, 0.15);
  1827. }
  1828. .file-icon-card {
  1829. width: 32px;
  1830. height: 32px;
  1831. background-image: var(--img-chat-attach-icon);
  1832. background-repeat: no-repeat;
  1833. background-size: 100% 100%;
  1834. flex-shrink: 0;
  1835. }
  1836. .file-info-card {
  1837. flex: 1;
  1838. min-width: 0;
  1839. .file-name-card {
  1840. font-size: 12px;
  1841. font-weight: 400;
  1842. line-height: 1.4;
  1843. color: #e0e6ed;
  1844. overflow: hidden;
  1845. text-overflow: ellipsis;
  1846. white-space: nowrap;
  1847. margin-bottom: 2px;
  1848. }
  1849. .file-size-card {
  1850. font-size: 11px;
  1851. font-weight: 400;
  1852. line-height: 1.3;
  1853. color: #8b949e;
  1854. }
  1855. }
  1856. }
  1857. }
  1858. }
  1859. .ai-message,
  1860. .user-message {
  1861. .message-actions {
  1862. display: flex;
  1863. align-items: center;
  1864. gap: 8px;
  1865. width: 100%;
  1866. opacity: 0;
  1867. transition: opacity 0.2s;
  1868. .action-btn {
  1869. width: 26px;
  1870. height: 26px;
  1871. display: flex;
  1872. align-items: center;
  1873. justify-content: center;
  1874. border-radius: 4px;
  1875. color: #8b949e;
  1876. cursor: pointer;
  1877. transition: all 0.2s;
  1878. &:hover {
  1879. color: #e0e6ed;
  1880. background: rgba(10, 132, 255, 0.15);
  1881. }
  1882. }
  1883. .action-time {
  1884. font-size: 12px;
  1885. color: #8b949e;
  1886. }
  1887. }
  1888. &:hover .message-actions {
  1889. opacity: 1;
  1890. }
  1891. }
  1892. .ai-message .message-actions {
  1893. padding: 0 0 0 10px;
  1894. }
  1895. .user-message .message-actions {
  1896. padding: 4px 0 0 0;
  1897. justify-content: flex-end;
  1898. }
  1899. }
  1900. }
  1901. .scroll-to-bottom {
  1902. position: absolute;
  1903. bottom: 20px;
  1904. left: 50%;
  1905. transform: translateX(-50%);
  1906. z-index: 10;
  1907. .scroll-to-bottom-icon {
  1908. width: 40px;
  1909. height: 40px;
  1910. border-radius: 50%;
  1911. background: rgba(255, 255, 255, 0.15);
  1912. backdrop-filter: blur(4px);
  1913. background-image: var(--img-chat-scroll-bottom);
  1914. background-repeat: no-repeat;
  1915. background-size: 20px 20px;
  1916. background-position: center;
  1917. cursor: pointer;
  1918. transition: all 0.2s;
  1919. &:hover {
  1920. background-color: rgba(255, 255, 255, 0.25);
  1921. }
  1922. }
  1923. }
  1924. </style>