index.vue 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. <script setup lang="ts">
  2. import { ref, nextTick, onMounted, computed, onUnmounted, reactive } from 'vue'
  3. import { Local } from '/@/utils/storage'
  4. import { User, ChatDotRound, Delete, Edit, Check, Close } from '@element-plus/icons-vue'
  5. import { MarkdownPlugin } from '/@/components/markdown/type/markdown'
  6. import EChartsPlugin from '/@/components/markdown/plugins/echarts'
  7. import ToolsLoadingPlugin from '/@/components/markdown/plugins/tools-loading'
  8. import Markdown from '/@/components/markdown/Markdown.vue'
  9. import assist from '/@/api/assist'
  10. import { ChatResponse, LmConfigInfo, Message } from '/@/api/assist/type'
  11. import { useLoading } from '/@/utils/loading-util'
  12. import { Setting as EleSetting } from '@element-plus/icons-vue'
  13. import { useRouter } from 'vue-router'
  14. const plugins: Array<MarkdownPlugin<any>> = [EChartsPlugin(), ToolsLoadingPlugin()]
  15. //聊天管理接口
  16. // 消息列表
  17. const messages = ref<Message[]>([])
  18. // 输入框内容
  19. const inputMessage = ref('')
  20. const messagesContainer = ref<HTMLElement>()
  21. // 选中的工具和模型
  22. const selectedTool = ref([])
  23. // 工具选择
  24. const toolOptions = ref([
  25. {
  26. value: 'code',
  27. label: '代码工具',
  28. children: [
  29. {
  30. value: 'codebase-retrieval',
  31. label: '代码库检索',
  32. },
  33. {
  34. value: 'str-replace-editor',
  35. label: '代码编辑器',
  36. },
  37. {
  38. value: 'save-file',
  39. label: '文件保存',
  40. },
  41. ],
  42. },
  43. {
  44. value: 'web',
  45. label: '网络工具',
  46. children: [
  47. {
  48. value: 'web-search',
  49. label: '网络搜索',
  50. },
  51. {
  52. value: 'web-fetch',
  53. label: '网页获取',
  54. },
  55. ],
  56. },
  57. {
  58. value: 'system',
  59. label: '系统工具',
  60. children: [
  61. {
  62. value: 'execute-command',
  63. label: '命令执行',
  64. },
  65. {
  66. value: 'launch-process',
  67. label: '进程启动',
  68. },
  69. ],
  70. },
  71. ])
  72. const prompt = ref<string>('')
  73. const openPromptDialog = ref(false)
  74. // 模型选择
  75. const modelOptions = ref<LmConfigInfo[]>([])
  76. const {loading: loadingModels, doLoading: loadModel} = useLoading(async ()=> {
  77. const data: {list: LmConfigInfo[],total: number} = await assist.model.getList().catch(() => {
  78. return {
  79. list: []
  80. }
  81. })
  82. modelOptions.value = data.list
  83. selectedModel.value = data.list[0] ?? undefined
  84. })
  85. onMounted(loadModel)
  86. const selectedModel = ref<LmConfigInfo | undefined>(undefined)
  87. const chatInstance = ref<(() => void) | undefined>(undefined)
  88. onUnmounted(() => chatInstance.value?.())
  89. // 是否正在对话
  90. const isConversationActive = computed(() => chatInstance.value !== undefined)
  91. const clearMessage = () => {
  92. stopConversation()
  93. messages.value = []
  94. }
  95. // 发送消息
  96. const sendMessage = () => {
  97. if (!inputMessage.value.trim()) return
  98. messages.value.push({
  99. id: Date.now(),
  100. role: 'user',
  101. content: inputMessage.value,
  102. timestamp: Date.now(),
  103. })
  104. const rtn = reactive<Message>({
  105. id: Date.now(),
  106. role: 'assistant',
  107. content: '',
  108. timestamp: Date.now(),
  109. })
  110. inputMessage.value = ''
  111. scrollToBottom()
  112. //
  113. // let toolcall: { name: string; param?: string; value?: string } | undefined = undefined
  114. chatInstance.value = assist.chat({
  115. chatRequest: {
  116. message: prompt.value ? [
  117. {
  118. id: 0,
  119. role: 'system',
  120. content: prompt.value,
  121. timestamp: Date.now(),
  122. },
  123. ...messages.value,
  124. ]: messages.value,
  125. modelClassId: selectedModel.value
  126. },
  127. onReceive: (resp: ChatResponse) => {
  128. switch (resp.type) {
  129. case 'message':
  130. rtn.content += resp.message
  131. break
  132. case 'toolcall':
  133. rtn.content += `
  134. \`\`\`tools-loading
  135. request
  136. ${resp.request.name}
  137. ${resp.request.data.replace('\n', '')}
  138. \`\`\`
  139. `
  140. break
  141. case 'toolres':
  142. rtn.content += `
  143. \`\`\`tools-loading
  144. resp
  145. ${resp.response.name}
  146. ${resp.response.data.replace('\n', '')}
  147. \`\`\`
  148. `
  149. break
  150. case 'error':
  151. rtn.content += `
  152. > ### 系统报错
  153. > ${resp.error}
  154. `
  155. break
  156. }
  157. },
  158. onComplete: (e) => {
  159. if (e !== undefined) {
  160. rtn.content += `
  161. `
  162. }
  163. rtn.content += '\n'
  164. chatInstance.value = undefined
  165. },
  166. })
  167. messages.value.push(rtn)
  168. }
  169. // 终止对话
  170. const stopConversation = () => {
  171. chatInstance.value?.()
  172. chatInstance.value = undefined
  173. }
  174. // 滚动到底部
  175. const scrollToBottom = () => {
  176. nextTick(() => {
  177. if (messagesContainer.value) {
  178. messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight
  179. }
  180. })
  181. }
  182. // 会话管理模块
  183. // 所有会话
  184. const conversations = ref<{ id: number; title: string }[]>([])
  185. // 当前活跃会话
  186. const activeConversationId = ref<number | undefined>(undefined)
  187. // 选择会话
  188. const selectConversation = (id: number) => {
  189. activeConversationId.value = id
  190. }
  191. // 删除会话
  192. const deleteConversation = (id: number) => {
  193. // TODO: 实现删除对话逻辑
  194. }
  195. // 编辑会话状态管理
  196. const editingConversationId = ref<number | undefined>(undefined)
  197. const editingTitle = ref('')
  198. // 编辑会话摘要
  199. const editSummary = (id: number) => {
  200. const conversation = conversations.value.find((conv) => conv.id === id)
  201. if (conversation) {
  202. // 设置当前编辑的会话ID
  203. editingConversationId.value = id
  204. editingTitle.value = conversation.title
  205. // 下一帧聚焦到输入框
  206. nextTick(() => {
  207. const editInput = document.querySelector('.edit-input .el-input__inner') as HTMLInputElement
  208. if (editInput) {
  209. editInput.focus()
  210. editInput.select()
  211. }
  212. })
  213. }
  214. }
  215. // 确认编辑
  216. const confirmEdit = (id: number) => {
  217. const conversation = conversations.value.find((conv) => conv.id === id)
  218. if (conversation && editingTitle.value.trim()) {
  219. conversation.title = editingTitle.value.trim()
  220. // 清除编辑状态
  221. editingConversationId.value = undefined
  222. editingTitle.value = ''
  223. }
  224. }
  225. // 取消编辑
  226. const cancelEdit = () => {
  227. // 清除编辑状态
  228. editingConversationId.value = undefined
  229. editingTitle.value = ''
  230. }
  231. onMounted(() => {
  232. scrollToBottom()
  233. })
  234. //杂项
  235. const getUserInfos = ref<{
  236. avatar: string
  237. userName: string
  238. }>(Local.get('userInfo') || {})
  239. const router = useRouter()
  240. const redirectToModelManager = () => router.push('manage/model')
  241. </script>
  242. <template>
  243. <el-container class="chat-container">
  244. <!-- 左侧会话列表 -->
  245. <el-aside width="300px" class="chat-sidebar">
  246. <div class="sidebar-header">
  247. <h3>对话历史</h3>
  248. <el-button round :icon="EleSetting" size="small" @click="redirectToModelManager"></el-button>
  249. </div>
  250. <el-scrollbar class="conversation-list">
  251. <div
  252. v-for="conv in conversations"
  253. :key="conv.id"
  254. @click="editingConversationId !== conv.id ? selectConversation(conv.id) : () => {}"
  255. :class="['conversation-item', { active: activeConversationId === conv.id, editing: editingConversationId === conv.id }]"
  256. >
  257. <!-- 非编辑状态 -->
  258. <div v-if="editingConversationId !== conv.id" class="conversation-content">
  259. <span class="conversation-title">{{ conv.title }}</span>
  260. </div>
  261. <!-- 编辑状态 -->
  262. <div v-else class="conversation-edit-content">
  263. <el-input v-model="editingTitle" size="small" @keydown.enter="confirmEdit(conv.id)" @keydown.esc="cancelEdit" class="edit-input" />
  264. </div>
  265. <!-- 操作按钮 -->
  266. <div class="conversation-actions">
  267. <!-- 非编辑状态的按钮 -->
  268. <template v-if="editingConversationId !== conv.id">
  269. <el-button
  270. type="primary"
  271. size="small"
  272. :icon="Edit"
  273. @click.stop="editSummary(conv.id)"
  274. class="action-btn edit-btn"
  275. title="编辑摘要"
  276. plain
  277. circle
  278. />
  279. <el-button
  280. type="danger"
  281. size="small"
  282. :icon="Delete"
  283. @click.stop="deleteConversation(conv.id)"
  284. class="action-btn delete-btn"
  285. title="删除对话"
  286. plain
  287. circle
  288. />
  289. </template>
  290. <!-- 编辑状态的按钮 -->
  291. <template v-else>
  292. <el-button type="success" size="small" @click.stop="confirmEdit(conv.id)" class="action-btn confirm-btn" title="确认修改" plain circle>
  293. <el-icon>
  294. <Check />
  295. </el-icon>
  296. </el-button>
  297. <el-button type="info" size="small" @click.stop="cancelEdit(conv.id)" class="action-btn cancel-btn" title="取消编辑" plain circle>
  298. <el-icon>
  299. <Close />
  300. </el-icon>
  301. </el-button>
  302. </template>
  303. </div>
  304. </div>
  305. </el-scrollbar>
  306. <el-button type="primary" size="large" class="create-conversation-btn">创建对话</el-button>
  307. </el-aside>
  308. <!-- 右侧聊天区域 -->
  309. <el-main class="chat-main">
  310. <!-- 消息展示区域 -->
  311. <div class="messages-container" ref="messagesContainer">
  312. <div v-if="messages.length !== 0">
  313. <div v-for="message in messages" :key="message.id" :class="['message-wrapper', message.role]">
  314. <!-- AI消息 -->
  315. <div v-if="message.role === 'assistant'" class="ai-message-container">
  316. <el-avatar class="message-avatar" :icon="ChatDotRound" />
  317. <div class="message-bubble ai-bubble">
  318. <Markdown v-if="message.content !== ''" :content="message.content" :plugins="plugins" class="markdown-content" />
  319. <div v-else class="loading-container">
  320. <div class="loading-dots">
  321. <span class="dot"></span>
  322. <span class="dot"></span>
  323. <span class="dot"></span>
  324. </div>
  325. <span class="loading-text">AI正在思考中...</span>
  326. </div>
  327. </div>
  328. </div>
  329. <!-- 用户消息 -->
  330. <div v-if="message.role === 'user'" class="user-message-container">
  331. <div class="message-bubble user-bubble">
  332. {{ message.content }}
  333. </div>
  334. <el-avatar class="message-avatar" :src="getUserInfos.avatar" :icon="User" />
  335. </div>
  336. </div>
  337. </div>
  338. <!-- 空状态页面 -->
  339. <div v-else class="empty-content">
  340. <!-- 主图标 -->
  341. <div class="empty-icon">
  342. <el-icon :size="80" color="#d1d5db">
  343. <ChatDotRound />
  344. </el-icon>
  345. </div>
  346. <!-- 标题和描述 -->
  347. <div class="empty-text">
  348. <h2 class="empty-title">开始新的对话</h2>
  349. <p class="empty-description">选择工具和模型,然后在下方输入您的问题开始对话</p>
  350. </div>
  351. <!-- 快速开始提示 -->
  352. <div class="quick-start">
  353. <div class="quick-start-item">
  354. <span class="step-number">1</span>
  355. <span class="step-text">选择需要的工具</span>
  356. </div>
  357. <div class="quick-start-item">
  358. <span class="step-number">2</span>
  359. <span class="step-text">选择AI模型</span>
  360. </div>
  361. <div class="quick-start-item">
  362. <span class="step-number">3</span>
  363. <span class="step-text">输入问题并发送</span>
  364. </div>
  365. </div>
  366. <!-- 示例问题 -->
  367. <div class="example-questions">
  368. <h4>试试这些问题:</h4>
  369. <div class="question-tags">
  370. <el-tag class="question-tag" @click="inputMessage = '帮我查看设备运行状态和告警信息'" type="info">
  371. 帮我查看设备运行状态和告警信息
  372. </el-tag>
  373. <el-tag class="question-tag" @click="inputMessage = '分析用户权限配置和角色分配情况'" type="success">
  374. 分析用户权限配置和角色分配情况
  375. </el-tag>
  376. <el-tag class="question-tag" @click="inputMessage = '检查系统性能和在线用户统计'" type="warning"> 检查系统性能和在线用户统计 </el-tag>
  377. </div>
  378. </div>
  379. </div>
  380. <div class="messages-spacer"></div>
  381. </div>
  382. <div class="input-container">
  383. <!-- 工具和模型选择行 -->
  384. <div class="selection-row">
  385. <!-- 工具选择 -->
  386. <div class="tool-selector">
  387. <el-cascader
  388. v-model="selectedTool"
  389. :options="toolOptions"
  390. :show-all-levels="false"
  391. :props="{ multiple: true }"
  392. collapse-tags
  393. collapse-tags-tooltip
  394. clearable
  395. size="small"
  396. style="width: 200px"
  397. />
  398. </div>
  399. <!-- 模型选择 -->
  400. <div class="model-selector">
  401. <el-select :loading="loadingModels" v-model="selectedModel" placeholder="选择模型" size="small" style="width: 200px">
  402. <el-option v-for="item in modelOptions" :key="item.id" :label="item.modelName" :value="item.id" />
  403. </el-select>
  404. </div>
  405. <!-- 提示词输入框 -->
  406. <div class="prompt-selector">
  407. <el-input
  408. v-model="prompt"
  409. placeholder="点击设置提示词..."
  410. size="small"
  411. style="width: 200px"
  412. readonly
  413. @click="openPromptDialog = true"
  414. />
  415. </div>
  416. </div>
  417. <!-- 输入框和按钮行 -->
  418. <div class="input-row">
  419. <!-- 输入框 -->
  420. <div class="message-input-wrapper">
  421. <el-input
  422. v-model="inputMessage"
  423. type="textarea"
  424. placeholder="请输入您的问题..."
  425. :rows="2"
  426. resize="none"
  427. @keydown.enter.ctrl="sendMessage"
  428. @keydown.enter.meta="sendMessage"
  429. :disabled="isConversationActive"
  430. />
  431. </div>
  432. <!-- 按钮组 -->
  433. <div class="button-group">
  434. <el-button
  435. type="warning"
  436. size="small"
  437. @click="clearMessage"
  438. style="margin-left: 12px"
  439. >
  440. 清空
  441. </el-button>
  442. <el-button
  443. v-if="!isConversationActive"
  444. type="primary"
  445. size="small"
  446. @click="sendMessage"
  447. @keyup.ctrl.enter="sendMessage"
  448. :disabled="!inputMessage.trim()"
  449. >
  450. 发送
  451. </el-button>
  452. <el-button v-else type="danger" size="small" @click="stopConversation"> 终止</el-button>
  453. </div>
  454. </div>
  455. </div>
  456. </el-main>
  457. <!-- 提示词设置对话框 -->
  458. <el-dialog
  459. v-model="openPromptDialog"
  460. title="设置提示词"
  461. width="600px"
  462. :before-close="() => { openPromptDialog = false }"
  463. >
  464. <el-input
  465. v-model="prompt"
  466. type="textarea"
  467. placeholder="请输入提示词..."
  468. :rows="8"
  469. resize="none"
  470. />
  471. <template #footer>
  472. <div class="dialog-footer">
  473. <el-button @click="openPromptDialog = false">取消</el-button>
  474. <el-button type="primary" @click="openPromptDialog = false">确定</el-button>
  475. </div>
  476. </template>
  477. </el-dialog>
  478. </el-container>
  479. </template>
  480. <style scoped lang="scss">
  481. :deep(.el-icon) {
  482. margin-right: 0 !important;
  483. }
  484. .chat-container {
  485. height: 100%;
  486. background: var(--el-bg-color-page);
  487. }
  488. .create-conversation-btn {
  489. margin: 16px;
  490. }
  491. /* 左侧边栏样式 */
  492. .chat-sidebar {
  493. background: var(--el-bg-color);
  494. border-right: 1px solid var(--el-border-color-light);
  495. display: flex;
  496. flex-direction: column;
  497. }
  498. .sidebar-header {
  499. padding: 20px;
  500. border-bottom: 1px solid var(--el-border-color-light);
  501. display: flex;
  502. justify-content: space-between;
  503. h3 {
  504. margin: 0;
  505. color: var(--el-text-color-primary);
  506. font-size: 16px;
  507. font-weight: 600;
  508. }
  509. }
  510. .conversation-list {
  511. flex: 1;
  512. padding: 10px;
  513. }
  514. .conversation-item {
  515. display: flex;
  516. align-items: center;
  517. justify-content: space-between;
  518. padding: 12px 16px;
  519. margin-bottom: 8px;
  520. border-radius: 8px;
  521. transition: all 0.2s;
  522. color: var(--el-text-color-regular);
  523. border: 1px solid transparent;
  524. position: relative;
  525. cursor: pointer;
  526. &:hover {
  527. background: var(--el-fill-color-light);
  528. color: var(--el-text-color-primary);
  529. .conversation-actions {
  530. opacity: 1;
  531. }
  532. }
  533. &.active {
  534. background: var(--el-color-primary-light-9);
  535. color: var(--el-color-primary);
  536. border-color: var(--el-color-primary-light-7);
  537. .conversation-actions {
  538. opacity: 1;
  539. }
  540. }
  541. &.editing {
  542. background: var(--el-color-warning-light-9);
  543. border-color: var(--el-color-warning-light-7);
  544. .conversation-actions {
  545. opacity: 1;
  546. }
  547. }
  548. }
  549. .conversation-content {
  550. flex: 1;
  551. min-width: 0;
  552. cursor: pointer;
  553. }
  554. .conversation-edit-content {
  555. flex: 1;
  556. min-width: 0;
  557. }
  558. .edit-input {
  559. width: 100%;
  560. :deep(.el-input__inner) {
  561. font-size: 14px;
  562. padding: 4px 8px;
  563. height: 28px;
  564. line-height: 20px;
  565. }
  566. }
  567. .conversation-title {
  568. display: block;
  569. overflow: hidden;
  570. text-overflow: ellipsis;
  571. white-space: nowrap;
  572. }
  573. .conversation-actions {
  574. display: flex;
  575. align-items: center;
  576. gap: 4px;
  577. opacity: 0;
  578. transition: opacity 0.2s;
  579. flex-shrink: 0;
  580. }
  581. .action-btn {
  582. width: 28px !important;
  583. height: 28px !important;
  584. padding: 0 !important;
  585. margin: 0 2px;
  586. }
  587. /* 右侧聊天区域样式 */
  588. .chat-main {
  589. display: flex;
  590. flex-direction: column;
  591. padding: 0;
  592. background: var(--el-bg-color-page);
  593. position: relative;
  594. }
  595. .messages-container {
  596. flex: 1;
  597. padding: 20px;
  598. overflow-y: auto;
  599. }
  600. .messages-spacer {
  601. height: 160px;
  602. }
  603. .message-wrapper {
  604. margin-bottom: 20px;
  605. &:last-child {
  606. margin-bottom: 0;
  607. }
  608. }
  609. /* AI消息样式 */
  610. .ai-message-container {
  611. display: flex;
  612. align-items: flex-start;
  613. gap: 12px;
  614. }
  615. .ai-bubble {
  616. background: var(--el-fill-color-light);
  617. color: var(--el-text-color-primary);
  618. position: relative;
  619. min-width: 70%;
  620. max-width: 90%;
  621. border: 1px solid var(--el-border-color-lighter);
  622. &::before {
  623. content: '';
  624. position: absolute;
  625. left: -8px;
  626. top: 12px;
  627. width: 0;
  628. height: 0;
  629. border-right: 8px solid var(--el-fill-color-light);
  630. border-top: 8px solid transparent;
  631. border-bottom: 8px solid transparent;
  632. }
  633. }
  634. /* 用户消息样式 */
  635. .user-message-container {
  636. display: flex;
  637. align-items: flex-start;
  638. gap: 12px;
  639. justify-content: flex-end;
  640. }
  641. .user-bubble {
  642. background: var(--el-color-primary);
  643. color: white;
  644. position: relative;
  645. max-width: 70%;
  646. &::after {
  647. content: '';
  648. position: absolute;
  649. right: -8px;
  650. top: 12px;
  651. width: 0;
  652. height: 0;
  653. border-left: 8px solid var(--el-color-primary);
  654. border-top: 8px solid transparent;
  655. border-bottom: 8px solid transparent;
  656. }
  657. }
  658. /* 消息气泡通用样式 */
  659. .message-bubble {
  660. padding: 12px 16px;
  661. border-radius: 12px;
  662. line-height: 1.5;
  663. word-wrap: break-word;
  664. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  665. }
  666. .message-avatar {
  667. flex-shrink: 0;
  668. margin-top: 2px;
  669. }
  670. /* 加载动画样式 */
  671. .loading-container {
  672. display: flex;
  673. align-items: center;
  674. gap: 12px;
  675. padding: 8px 0;
  676. color: var(--el-text-color-secondary);
  677. }
  678. .loading-dots {
  679. display: flex;
  680. gap: 4px;
  681. }
  682. .dot {
  683. width: 6px;
  684. height: 6px;
  685. border-radius: 50%;
  686. background-color: var(--el-color-primary);
  687. animation: loading-bounce 1.4s ease-in-out infinite both;
  688. }
  689. .dot:nth-child(1) {
  690. animation-delay: -0.32s;
  691. }
  692. .dot:nth-child(2) {
  693. animation-delay: -0.16s;
  694. }
  695. .dot:nth-child(3) {
  696. animation-delay: 0s;
  697. }
  698. @keyframes loading-bounce {
  699. 0%, 80%, 100% {
  700. transform: scale(0.8);
  701. opacity: 0.5;
  702. }
  703. 40% {
  704. transform: scale(1);
  705. opacity: 1;
  706. }
  707. }
  708. .loading-text {
  709. font-size: 14px;
  710. font-weight: 500;
  711. }
  712. .tools-button {
  713. margin-bottom: 10px;
  714. color: var(--el-text-color-regular);
  715. }
  716. .message-input {
  717. margin-bottom: 12px;
  718. :deep(.el-textarea__inner) {
  719. border-radius: 8px;
  720. resize: none;
  721. }
  722. }
  723. .input-actions {
  724. display: flex;
  725. justify-content: flex-end;
  726. gap: 12px;
  727. }
  728. /* Markdown 内容样式优化 - 接入Element Plus颜色系统 */
  729. :deep(.markdown-content) {
  730. /* 标题样式 */
  731. h1,
  732. h2,
  733. h3,
  734. h4,
  735. h5,
  736. h6 {
  737. margin-top: 24px;
  738. margin-bottom: 16px;
  739. font-weight: 600;
  740. line-height: 1.25;
  741. color: var(--el-text-color-primary);
  742. }
  743. h1 {
  744. font-size: 2em;
  745. border-bottom: 1px solid var(--el-border-color-light);
  746. padding-bottom: 8px;
  747. }
  748. h2 {
  749. font-size: 1.5em;
  750. border-bottom: 1px solid var(--el-border-color-lighter);
  751. padding-bottom: 6px;
  752. }
  753. h3 {
  754. font-size: 1.25em;
  755. }
  756. /* 段落样式 */
  757. p {
  758. margin-bottom: 16px;
  759. line-height: 1.6;
  760. color: var(--el-text-color-regular);
  761. }
  762. /* 代码块样式 */
  763. pre {
  764. background-color: var(--el-fill-color-light);
  765. border: 1px solid var(--el-border-color-light);
  766. border-radius: 6px;
  767. padding: 16px;
  768. overflow: auto;
  769. margin: 16px 0;
  770. color: var(--el-text-color-primary);
  771. }
  772. /* 行内代码样式 */
  773. code {
  774. background-color: var(--el-fill-color-light);
  775. color: var(--el-color-danger);
  776. padding: 2px 4px;
  777. border-radius: 3px;
  778. font-size: 85%;
  779. border: 1px solid var(--el-border-color-lighter);
  780. }
  781. /* 引用块样式 */
  782. blockquote {
  783. border-left: 4px solid var(--el-color-primary);
  784. padding-left: 16px;
  785. margin: 16px 0;
  786. color: var(--el-text-color-secondary);
  787. background-color: var(--el-fill-color-extra-light);
  788. padding: 12px 16px;
  789. border-radius: 4px;
  790. }
  791. /* 列表样式 */
  792. ul,
  793. ol {
  794. margin: 16px 0;
  795. padding-left: 32px;
  796. color: var(--el-text-color-regular);
  797. }
  798. li {
  799. margin: 4px 0;
  800. line-height: 1.6;
  801. }
  802. /* 表格样式 */
  803. table {
  804. border-collapse: collapse;
  805. margin: 16px 0;
  806. width: 100%;
  807. border: 1px solid var(--el-border-color-light);
  808. }
  809. th,
  810. td {
  811. border: 1px solid var(--el-border-color-light);
  812. padding: 8px 12px;
  813. text-align: left;
  814. }
  815. th {
  816. background-color: var(--el-fill-color-light);
  817. font-weight: 600;
  818. color: var(--el-text-color-primary);
  819. }
  820. td {
  821. color: var(--el-text-color-regular);
  822. }
  823. /* 分割线样式 */
  824. hr {
  825. border: none;
  826. border-top: 1px solid var(--el-border-color-light);
  827. margin: 24px 0;
  828. }
  829. /* 链接样式 */
  830. a {
  831. color: var(--el-color-primary);
  832. text-decoration: none;
  833. &:hover {
  834. color: var(--el-color-primary-light-3);
  835. text-decoration: underline;
  836. }
  837. }
  838. /* 强调文本样式 */
  839. strong {
  840. font-weight: 600;
  841. color: var(--el-text-color-primary);
  842. }
  843. em {
  844. font-style: italic;
  845. color: var(--el-text-color-regular);
  846. }
  847. }
  848. .input-container {
  849. position: absolute;
  850. width: 85%;
  851. left: 50%;
  852. bottom: 25px;
  853. transform: translate(-50%, 0);
  854. background: var(--el-bg-color);
  855. border: 1px solid var(--el-border-color-light);
  856. border-radius: 12px;
  857. padding: 16px;
  858. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  859. display: flex;
  860. flex-direction: column;
  861. gap: 12px;
  862. }
  863. .selection-row {
  864. display: flex;
  865. align-items: center;
  866. gap: 12px;
  867. flex-wrap: wrap;
  868. }
  869. .tool-selector,
  870. .model-selector,
  871. .prompt-selector {
  872. flex-shrink: 0;
  873. }
  874. .input-row {
  875. display: flex;
  876. align-items: flex-end;
  877. gap: 12px;
  878. }
  879. .message-input-wrapper {
  880. flex: 1;
  881. min-width: 0;
  882. }
  883. .message-input-wrapper :deep(.el-textarea__inner) {
  884. border-radius: 8px;
  885. resize: none;
  886. font-size: 14px;
  887. line-height: 1.4;
  888. }
  889. .button-group {
  890. display: flex;
  891. flex-direction: column;
  892. gap: 6px;
  893. flex-shrink: 0;
  894. }
  895. .button-group .el-button {
  896. min-width: 60px;
  897. }
  898. /* 提示词输入框样式 */
  899. .prompt-selector .el-input {
  900. cursor: pointer;
  901. }
  902. .prompt-selector .el-input__inner {
  903. cursor: pointer;
  904. }
  905. /* 对话框样式 */
  906. .dialog-footer {
  907. text-align: right;
  908. }
  909. /* 响应式调整 */
  910. /* 空状态页面样式 */
  911. .empty-content {
  912. text-align: center;
  913. max-width: 600px;
  914. width: 100%;
  915. position: absolute;
  916. left: 50%;
  917. top: 50%;
  918. transform: translate(-50%, -50%);
  919. }
  920. .empty-icon {
  921. margin-bottom: 24px;
  922. opacity: 0.6;
  923. }
  924. .empty-text {
  925. margin-bottom: 40px;
  926. }
  927. .empty-title {
  928. font-size: 28px;
  929. font-weight: 600;
  930. color: var(--el-text-color-primary);
  931. margin: 0 0 12px 0;
  932. }
  933. .empty-description {
  934. font-size: 16px;
  935. color: var(--el-text-color-regular);
  936. margin: 0;
  937. line-height: 1.5;
  938. }
  939. .quick-start {
  940. display: flex;
  941. justify-content: center;
  942. gap: 40px;
  943. margin-bottom: 40px;
  944. flex-wrap: wrap;
  945. }
  946. .quick-start-item {
  947. display: flex;
  948. align-items: center;
  949. gap: 12px;
  950. color: var(--el-text-color-regular);
  951. }
  952. .step-number {
  953. display: flex;
  954. align-items: center;
  955. justify-content: center;
  956. width: 24px;
  957. height: 24px;
  958. background: var(--el-color-primary);
  959. color: white;
  960. border-radius: 50%;
  961. font-size: 12px;
  962. font-weight: 600;
  963. flex-shrink: 0;
  964. }
  965. .step-text {
  966. font-size: 14px;
  967. font-weight: 500;
  968. }
  969. .example-questions {
  970. h4 {
  971. font-size: 16px;
  972. font-weight: 600;
  973. color: var(--el-text-color-primary);
  974. margin: 0 0 16px 0;
  975. }
  976. }
  977. .question-tags {
  978. display: flex;
  979. flex-wrap: wrap;
  980. gap: 12px;
  981. justify-content: center;
  982. }
  983. .question-tag {
  984. cursor: pointer;
  985. transition: all 0.2s ease;
  986. font-size: 13px;
  987. padding: 8px 16px;
  988. border-radius: 20px;
  989. &:hover {
  990. transform: translateY(-1px);
  991. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  992. }
  993. }
  994. </style>