ThinkingPanel.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <div class="thinking-panel">
  3. <div class="panel-header">
  4. <div class="panel-left">
  5. <div class="agent-avatar-small"></div>
  6. <div class="panel-title-group">
  7. <div class="panel-title">{{ currentDisplayAgent?.agentName || '智能分析' }}</div>
  8. </div>
  9. </div>
  10. <div class="close-btn" @click="emit('close')">
  11. <div class="btn-close-icon"></div>
  12. </div>
  13. </div>
  14. <div class="thinking-section">
  15. <div class="section-content thinking-content" ref="thinkingContentRef">
  16. <div v-if="!thinkingSections.length" class="empty-thinking">暂无思考过程</div>
  17. <div v-for="(section, idx) in thinkingSections" :key="idx" :class="['timeline-item', `timeline-${section.type}`]">
  18. <div class="timeline-marker">
  19. <div class="timeline-dot"></div>
  20. <div v-if="idx < thinkingSections.length - 1" class="timeline-line"></div>
  21. </div>
  22. <div class="timeline-body">
  23. <div class="timeline-header">
  24. <span class="timeline-label">{{ section.label }}</span>
  25. </div>
  26. <div class="timeline-text" v-html="renderMarkdown(section.content)"></div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="agent-horizontal-list" v-if="selectedAgentParentMsg?.agentAnswers?.length">
  32. <div
  33. v-for="agent in selectedAgentParentMsg!.agentAnswers"
  34. :key="agent.id"
  35. :class="['agent-chip', { active: currentDisplayAgent?.id === agent.id }]"
  36. @click="emit('select-agent', agent)"
  37. >
  38. <div class="chip-body">
  39. <div class="chip-icon"></div>
  40. <div class="chip-name">
  41. {{ agent.agentName || '智能分析' }}
  42. </div>
  43. </div>
  44. <div class="chip-status">
  45. <span v-if="agent.status === 'thinking'">正在连接</span>
  46. <span v-else>已完成</span>
  47. </div>
  48. <div class="chip-border"></div>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script setup lang="ts">
  54. import { ref } from 'vue';
  55. import { renderMarkdown } from './utils';
  56. import type { AgentAnswer, Message, ThinkingSection } from './types';
  57. defineProps<{
  58. currentDisplayAgent: AgentAnswer | null;
  59. selectedAgentParentMsg: Message | null;
  60. thinkingSections: ThinkingSection[];
  61. }>();
  62. const emit = defineEmits<{
  63. (e: 'select-agent', answer: AgentAnswer): void;
  64. (e: 'close'): void;
  65. }>();
  66. const thinkingContentRef = ref<HTMLElement | null>(null);
  67. defineExpose({ thinkingContentRef });
  68. </script>
  69. <style scoped lang="less">
  70. .thinking-panel {
  71. height: 100%;
  72. width: 100%;
  73. display: flex;
  74. flex-direction: column;
  75. padding: 12px 16px;
  76. .panel-header {
  77. display: flex;
  78. padding: 0;
  79. justify-content: space-between;
  80. align-items: center;
  81. margin-bottom: 6px;
  82. flex-shrink: 0;
  83. .panel-left {
  84. display: flex;
  85. align-items: center;
  86. gap: 12px;
  87. }
  88. .agent-avatar-small {
  89. width: 35px;
  90. height: 36px;
  91. border-radius: 8px;
  92. background-image: var(--img-chat-panel-header);
  93. background-repeat: no-repeat;
  94. background-size: 100% 100%;
  95. flex-shrink: 0;
  96. }
  97. .panel-title-group {
  98. display: flex;
  99. flex-direction: column;
  100. line-height: 1;
  101. }
  102. .panel-title {
  103. font-size: 15px;
  104. font-weight: 600;
  105. line-height: 1.4;
  106. color: #0a84ff;
  107. }
  108. .close-btn {
  109. cursor: pointer;
  110. width: 36px;
  111. height: 36px;
  112. background-image: var(--img-chat-upload-bg);
  113. background-repeat: no-repeat;
  114. background-size: 100% 100%;
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. flex-shrink: 0;
  119. transition: all 0.3s;
  120. margin-bottom: auto;
  121. .btn-close-icon {
  122. width: 20px;
  123. height: 20px;
  124. background-image: var(--img-chat-close-icon);
  125. background-repeat: no-repeat;
  126. background-size: 100% 100%;
  127. }
  128. }
  129. }
  130. .thinking-section {
  131. flex: 1;
  132. height: 0;
  133. display: flex;
  134. flex-direction: column;
  135. border: 1px solid #0a84ff;
  136. border-radius: 4px 4px 0 0;
  137. .thinking-content {
  138. flex: 1;
  139. background: rgba(10, 132, 255, 0.05);
  140. border: 1px solid rgba(63, 80, 106, 0.5);
  141. border-radius: 8px;
  142. padding: 20px 16px;
  143. overflow-y: auto;
  144. font-size: 12px;
  145. font-weight: 400;
  146. color: #e0e6ed;
  147. line-height: 1.6;
  148. .empty-thinking {
  149. color: #8b949e;
  150. font-style: italic;
  151. text-align: center;
  152. padding: 32px 0;
  153. }
  154. .timeline-item {
  155. display: flex;
  156. gap: 0;
  157. position: relative;
  158. .timeline-marker {
  159. display: flex;
  160. flex-direction: column;
  161. align-items: center;
  162. width: 28px;
  163. flex-shrink: 0;
  164. position: relative;
  165. }
  166. .timeline-dot {
  167. width: 12px;
  168. height: 12px;
  169. border-radius: 50%;
  170. border: 2px solid #fff;
  171. flex-shrink: 0;
  172. margin-top: 6px;
  173. position: relative;
  174. z-index: 1;
  175. }
  176. .timeline-line {
  177. flex: 1;
  178. width: 0;
  179. min-height: 16px;
  180. margin: 4px 0;
  181. border-left: 2px dashed #8b949e;
  182. }
  183. &.timeline-select {
  184. .timeline-dot {
  185. background: #0a84ff;
  186. box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
  187. }
  188. .timeline-header {
  189. color: #e0e6ed;
  190. }
  191. }
  192. &.timeline-params {
  193. display: none;
  194. .timeline-dot {
  195. background: #faad14;
  196. box-shadow: 0 0 0 3px rgba(223, 91, 12, 0.15);
  197. }
  198. .timeline-header {
  199. color: #e0e6ed;
  200. }
  201. }
  202. &.timeline-result {
  203. .timeline-dot {
  204. background: #52c41a;
  205. box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
  206. }
  207. }
  208. .timeline-body {
  209. flex: 1;
  210. min-width: 0;
  211. padding-bottom: 16px;
  212. padding-left: 12px;
  213. }
  214. .timeline-header {
  215. font-size: 13px;
  216. font-weight: 500;
  217. margin-bottom: 8px;
  218. line-height: 1.4;
  219. }
  220. .timeline-text {
  221. font-size: 14px;
  222. font-weight: 400;
  223. color: #e0e6ed;
  224. line-height: 1.6;
  225. :deep(p) {
  226. margin: 0 0 6px;
  227. }
  228. :deep(code) {
  229. background: rgba(10, 132, 255, 0.1);
  230. padding: 2px 6px;
  231. border-radius: 3px;
  232. font-family: monospace;
  233. font-size: 12px;
  234. }
  235. :deep(pre) {
  236. background: rgba(10, 132, 255, 0.1);
  237. padding: 10px;
  238. border-radius: 4px;
  239. overflow-x: auto;
  240. margin: 8px 0;
  241. }
  242. :deep(pre code) {
  243. background: transparent;
  244. padding: 0;
  245. }
  246. :deep(ul),
  247. :deep(ol) {
  248. padding-left: 20px;
  249. margin: 4px 0;
  250. }
  251. :deep(li) {
  252. margin-bottom: 2px;
  253. }
  254. :deep(h1),
  255. :deep(h2),
  256. :deep(h3),
  257. :deep(h4) {
  258. margin: 8px 0 4px;
  259. font-weight: 600;
  260. }
  261. :deep(blockquote) {
  262. border-left: 3px solid rgba(63, 80, 106, 0.5);
  263. padding-left: 12px;
  264. margin: 8px 0;
  265. color: #8b949e;
  266. }
  267. :deep(table) {
  268. border-collapse: collapse;
  269. width: 100%;
  270. margin: 8px 0;
  271. }
  272. :deep(th),
  273. :deep(td) {
  274. border: 1px solid rgba(63, 80, 106, 0.5);
  275. padding: 6px 10px;
  276. text-align: left;
  277. }
  278. :deep(th) {
  279. background: rgba(10, 132, 255, 0.1);
  280. font-weight: 600;
  281. }
  282. :deep(strong) {
  283. font-weight: 600;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. .agent-horizontal-list {
  290. display: flex;
  291. gap: 10px;
  292. padding: 8px 0;
  293. overflow-x: auto;
  294. align-items: center;
  295. flex-shrink: 0;
  296. border-radius: 0 0 4px 4px;
  297. border-top: none;
  298. background-color: rgba(10, 132, 255, 0.05);
  299. }
  300. .agent-chip {
  301. display: flex;
  302. align-items: center;
  303. gap: 10px;
  304. padding: 8px 12px 8px 20px;
  305. background: rgba(10, 132, 255, 0.08);
  306. border-radius: 10px;
  307. border: 1px solid rgba(63, 80, 106, 0.5);
  308. min-width: 140px;
  309. cursor: pointer;
  310. transition: all 0.2s;
  311. position: relative;
  312. .chip-body {
  313. display: flex;
  314. align-items: start;
  315. gap: 8px;
  316. flex-direction: column;
  317. }
  318. .chip-border {
  319. position: absolute;
  320. left: 10px;
  321. top: 16px;
  322. width: 5px;
  323. height: 35px;
  324. border: 2px solid #0a84ff;
  325. pointer-events: none;
  326. border-right: none;
  327. }
  328. .chip-icon {
  329. width: 24px;
  330. height: 24px;
  331. background-image: var(--img-chat-thinking-bg);
  332. background-repeat: no-repeat;
  333. background-size: 100% 100%;
  334. }
  335. .chip-name {
  336. font-size: 13px;
  337. font-weight: 500;
  338. line-height: 1.4;
  339. color: #e0e6ed;
  340. white-space: nowrap;
  341. overflow: hidden;
  342. text-overflow: ellipsis;
  343. width: 100px;
  344. }
  345. .chip-status {
  346. font-size: 11px;
  347. font-weight: 400;
  348. line-height: 1.3;
  349. color: #8b949e;
  350. position: absolute;
  351. top: 10px;
  352. right: 10px;
  353. }
  354. &.active {
  355. background-color: rgba(10, 132, 255, 0.12);
  356. box-shadow: 0 6px 18px rgba(10, 132, 255, 0.06);
  357. border-color: #0a84ff;
  358. .chip-status {
  359. color: #0a84ff;
  360. }
  361. }
  362. }
  363. }
  364. </style>