index.vue 23 KB

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