AIChat.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. <template>
  2. <div class="chat-container">
  3. <!-- 欢迎界面 -->
  4. <div v-if="!isChating" class="welcome-section">
  5. <h1 class="welcome-title">Hi, 欢迎回来~</h1>
  6. <p class="welcome-subtitle">我是您的AI助理,能帮你编写整理资料,快来试试吧</p>
  7. </div>
  8. <!-- 聊天记录区域 -->
  9. <div class="chat-messages" v-show="isChating" ref="messagesRef" :class="{ 'chat-active': isChating }">
  10. <div v-for="(message, index) in messages" :key="index"
  11. :class="['message', message.role === 'user' ? 'user' : 'assistant']">
  12. <div class="avatar" v-if="message.content">
  13. <img :src="message.role === 'user' ? userAvatar : assistantAvatar" :alt="message.role">
  14. </div>
  15. <div class="content" v-if="message.content">
  16. <div class="text markdown-body" v-html="message.content"></div>
  17. <div class="message-actions" v-if="message.role === 'assistant'">
  18. <div class="left-actions">
  19. <button class="action-btn" @click="copyContent(message.content)">
  20. <img src="@/assets/icon-copy.png" alt="复制">
  21. </button>
  22. <!-- <button class="action-btn" @click="toggleFavorite(message.id)">
  23. <img src="@/assets/icon-star.png" alt="收藏">
  24. </button> -->
  25. <button class="action-btn reanswer" @click="reAnswer(message.id)">
  26. <img src="@/assets/icon-reanswer.png" alt="重新回答">
  27. <span>重新回答</span>
  28. </button>
  29. </div>
  30. <!-- <div class="right-actions">
  31. <button class="action-btn" @click="handleLike(message.id, true)">
  32. <img src="@/assets/icon-like.png" alt="点赞">
  33. </button>
  34. <button class="action-btn" @click="handleLike(message.id, false)">
  35. <img src="@/assets/icon-dislike.png" alt="反对">
  36. </button>
  37. </div> -->
  38. </div>
  39. <!-- <div class="time">{{ formatTime(message.time) }}</div> -->
  40. </div>
  41. </div>
  42. <div v-if="loading" class="message assistant">
  43. <div class="avatar">
  44. <img :src="assistantAvatar" alt="assistant">
  45. </div>
  46. <div class="content">
  47. <div class="typing">正在输入...</div>
  48. </div>
  49. </div>
  50. </div>
  51. <!-- 输入区域 -->
  52. <div class="chat-input" :class="{ 'chat-active': isChating }">
  53. <div class="input-container">
  54. <textarea
  55. v-model="inputMessage"
  56. @keydown.enter.prevent="handleSend"
  57. placeholder="输入消息,按Enter发送"
  58. rows="3"
  59. ></textarea>
  60. <div class="input-actions">
  61. <div class="select-wrap">
  62. <el-select v-model="selectedModel" class="model-select" :disabled="isChating">
  63. <el-option v-for="model in models" :key="model.id" :value="model.id" :label="model.name">
  64. {{ model.name }}
  65. </el-option>
  66. </el-select>
  67. </div>
  68. <button @click="handleSend" :disabled="loading || !inputMessage.trim()" class="send-button">
  69. <img src="@/assets/icon-send.png" alt="发送">
  70. 立即生成
  71. </button>
  72. </div>
  73. </div>
  74. </div>
  75. <!-- 知识库列表 -->
  76. <div class="knowledge-base" v-if="!isChating">
  77. <div class="knowledge-tags">
  78. <button
  79. v-for="(item, index) in knowledgeList"
  80. :key="index"
  81. :class="['knowledge-tag', { active: selectedKnowledge.includes(item.datasetId) }]"
  82. @click="toggleKnowledge(item.datasetId)"
  83. >
  84. {{ item.name }}
  85. </button>
  86. </div>
  87. </div>
  88. <!-- 页面底部文字提示 -->
  89. <div class="page-bottom-tips" :class="{ 'is-collapse': userStore.isCollapse }">
  90. <p v-if="!isChating">该AI工具仅限内部使用,严禁外泄知识库资料</p>
  91. <p>所有内容均由AI生成,仅供参考</p>
  92. </div>
  93. </div>
  94. </template>
  95. <script setup>
  96. import { ref, onMounted, nextTick, watch } from 'vue'
  97. import { useRoute } from 'vue-router'
  98. import userAvatar from '@/assets/user-avatar.png'
  99. import assistantAvatar from '@/assets/assistant-avatar.png'
  100. import { post,get } from '@/utils/request'
  101. import { ElMessage } from 'element-plus'
  102. import MarkdownIt from 'markdown-it'
  103. import hljs from 'highlight.js'
  104. import 'highlight.js/styles/github.css'
  105. import { useUserStore } from '../stores/user'
  106. const userStore = useUserStore()
  107. const route = useRoute()
  108. const messagesRef = ref(null)
  109. const inputMessage = ref('')
  110. const loading = ref(false)
  111. const isChating = ref(false)
  112. const selectedKnowledge = ref([])
  113. const selectedModel = ref('DeepSeek')
  114. const sessionId = ref('')
  115. const chatId = ref('')
  116. // 对话模型列表
  117. const models = ref([
  118. { id: 'DeepSeek', name: 'DeepSeek' },
  119. { id: 'gpt-4', name: 'GPT-4' },
  120. { id: 'qwen', name: 'Qwen' }
  121. ])
  122. // 知识库列表
  123. const knowledgeList = ref([])
  124. // 获取知识库列表
  125. const getKnowledgeList = async () => {
  126. try {
  127. const userId = userStore.userInfo.id
  128. const response = await get('/admin/user/chat/knowInfoList?userId='+userId)
  129. // console.log('response', response);
  130. if (response.data) {
  131. knowledgeList.value = response.data
  132. // 默认选中第一个知识库
  133. selectedKnowledge.value = [knowledgeList.value[0].datasetId]
  134. } else {
  135. ElMessage.error('获取知识库列表失败')
  136. }
  137. } catch (error) {
  138. console.error('获取知识库列表失败:', error)
  139. ElMessage.error('获取知识库列表失败')
  140. }
  141. }
  142. const messages = ref([])
  143. // 创建 markdown-it 实例,配置代码高亮
  144. const md = new MarkdownIt({
  145. html: false,
  146. breaks: true,
  147. linkify: true,
  148. highlight: function (str, lang) {
  149. if (lang && hljs.getLanguage(lang)) {
  150. try {
  151. return `<pre class="hljs"><code>${hljs.highlight(str, { language: lang, ignoreIllegals: true }).value}</code></pre>`
  152. } catch (__) {}
  153. }
  154. // 使用默认的转义
  155. return `<pre class="hljs"><code>${md.utils.escapeHtml(str)}</code></pre>`
  156. }
  157. })
  158. const formatTime = (time) => {
  159. return new Date(time).toLocaleTimeString()
  160. }
  161. const toggleKnowledge = (id) => {
  162. const index = selectedKnowledge.value.indexOf(id)
  163. if (index === -1) {
  164. selectedKnowledge.value.push(id)
  165. } else {
  166. selectedKnowledge.value.splice(index, 1)
  167. }
  168. }
  169. const scrollToBottom = async () => {
  170. await nextTick()
  171. if (messagesRef.value) {
  172. messagesRef.value.scrollTop = messagesRef.value.scrollHeight
  173. }
  174. }
  175. const handleSend = async () => {
  176. if (selectedKnowledge.value.length === 0) {
  177. ElMessage.warning('请先选择知识库')
  178. return
  179. }
  180. const message = inputMessage.value.trim()
  181. if (!message || loading.value) return
  182. // 保存当前消息,供后续使用
  183. const currentMessage = message
  184. if (!isChating.value) {
  185. isChating.value = true
  186. }
  187. // 如果没有session_id和chat_id,先获取它们
  188. if (!sessionId.value || !chatId.value) {
  189. try {
  190. const response = await post('/admin/user/chat/create', {
  191. userId: userStore.userInfo.id,
  192. datasetIds: selectedKnowledge.value.join(',')
  193. })
  194. if (response.data) {
  195. sessionId.value = response.data.sessionId
  196. chatId.value = response.data.chatId
  197. } else {
  198. ElMessage.error('初始化对话失败')
  199. return
  200. }
  201. } catch (error) {
  202. console.error('初始化对话失败:', error)
  203. ElMessage.error('初始化对话失败,请重试')
  204. return
  205. }
  206. }
  207. // 添加用户消息
  208. messages.value.push({
  209. role: 'user',
  210. content: currentMessage,
  211. time: new Date()
  212. })
  213. // 清空输入框
  214. inputMessage.value = ''
  215. await scrollToBottom()
  216. // 开始流式响应
  217. loading.value = true
  218. simulateStreamResponse(currentMessage)
  219. }
  220. const simulateStreamResponse = async (question) => {
  221. loading.value = true;
  222. const messageIndex = messages.value.length;
  223. messages.value.push({
  224. id: Date.now(),
  225. role: 'assistant',
  226. content: '',
  227. time: new Date()
  228. });
  229. const token = localStorage.getItem('token')
  230. let accumulatedText = ''; // 用于累积接收到的文本
  231. // /admin/user/chat/converse
  232. // /admin/ragflow/chat/converse
  233. //请求ai聊天接口
  234. const eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}/admin/user/chat/converse?chat_id=${chatId.value}&question=${encodeURIComponent(question)}&stream=true&session_id=${sessionId.value}&user_id=${userStore.userInfo.id}&token=${token}`);
  235. eventSource.onmessage = async (event) => {
  236. try {
  237. const data = JSON.parse(event.data);
  238. if (data.data === true) {
  239. // 处理think标签
  240. let processedText = accumulatedText;
  241. const thinkEndRegex = /([^<])<\/think>/g;
  242. const matches = [...processedText.matchAll(thinkEndRegex)];
  243. for (const match of matches) {
  244. const beforeThinkEnd = processedText.substring(0, match.index + match[1].length);
  245. const afterThinkEnd = processedText.substring(match.index + match[1].length);
  246. console.log('beforeThinkEnd',beforeThinkEnd);
  247. console.log('afterThinkEnd',afterThinkEnd);
  248. // 在对应的</think>标签前添加<think>标签
  249. processedText = '<think>' + beforeThinkEnd + afterThinkEnd;
  250. }
  251. console.log('processedText',processedText);
  252. // 如果内容包含think标签,分别处理think标签内外的内容
  253. if (processedText.includes('<think>') && processedText.includes('</think>')) {
  254. let finalContent = '';
  255. let currentPos = 0;
  256. while (true) {
  257. const thinkStart = processedText.indexOf('<think>', currentPos);
  258. const thinkEnd = processedText.indexOf('</think>', currentPos);
  259. if (thinkStart === -1 || thinkEnd === -1) {
  260. // 处理剩余的文本
  261. if (currentPos < processedText.length) {
  262. finalContent += md.render(processedText.substring(currentPos));
  263. }
  264. break;
  265. }
  266. // 处理think标签之前的内容(需要markdown渲染)
  267. if (thinkStart > currentPos) {
  268. finalContent += md.render(processedText.substring(currentPos, thinkStart));
  269. }
  270. // 添加think标签内的内容(原样保留)
  271. const thinkContent = processedText.substring(thinkStart, thinkEnd + 8);
  272. finalContent += thinkContent;
  273. currentPos = thinkEnd + 8;
  274. }
  275. messages.value[messageIndex].content = finalContent;
  276. } else {
  277. // 如果没有think标签,进行普通的markdown渲染
  278. messages.value[messageIndex].content = md.render(processedText);
  279. }
  280. eventSource.close();
  281. // 发送事件通知更新历史记录
  282. window.dispatchEvent(new Event('updateHistory'));
  283. loading.value = false;
  284. await scrollToBottom();
  285. return;
  286. }
  287. if (data.data && data.data.answer) {
  288. console.log('data.data.answer',data.data.answer);
  289. // 累积接收到的文本
  290. accumulatedText += data.data.answer;
  291. // 临时显示文本
  292. messages.value[messageIndex].content = accumulatedText;
  293. await nextTick();
  294. await scrollToBottom();
  295. }
  296. } catch (error) {
  297. console.error('Parse error:', error);
  298. }
  299. };
  300. eventSource.onerror = (error) => {
  301. console.error('EventSource error:', error);
  302. eventSource.close();
  303. loading.value = false;
  304. if (!messages.value[messageIndex].content) {
  305. ElMessage.error('对话请求失败,请重试');
  306. }
  307. };
  308. eventSource.onopen = () => {
  309. console.log('连接已建立');
  310. };
  311. }
  312. // 修改复制功能,去除HTML标签
  313. const copyContent = (content) => {
  314. // 创建临时元素来去除HTML标签
  315. const temp = document.createElement('div')
  316. temp.innerHTML = content
  317. const plainText = temp.textContent || temp.innerText
  318. navigator.clipboard.writeText(plainText)
  319. ElMessage.success('复制成功')
  320. }
  321. const toggleFavorite = (messageId) => {
  322. // TODO: 实现收藏功能
  323. }
  324. const reAnswer = (messageId) => {
  325. // 找到当前消息的索引
  326. const currentIndex = messages.value.findIndex(msg => msg.id === messageId);
  327. if (currentIndex === -1) return;
  328. // 找到这条消息之前最近的用户消息
  329. let userMessageIndex = currentIndex - 1;
  330. while (userMessageIndex >= 0) {
  331. if (messages.value[userMessageIndex].role === 'user') {
  332. // 获取用户的问题
  333. const question = messages.value[userMessageIndex].content;
  334. // 设置输入框的内容
  335. inputMessage.value = question;
  336. // 触发发送
  337. handleSend();
  338. break;
  339. }
  340. userMessageIndex--;
  341. }
  342. scrollToBottom();
  343. }
  344. const handleLike = (messageId, isLike) => {
  345. // TODO: 实现点赞/反对功能
  346. }
  347. // 获取历史记录
  348. const getHistoryChat = async (historyId) => {
  349. try {
  350. const response = await get(`/admin/userHistoryLog/selectById?id=${historyId}`)
  351. if (response.data) {
  352. const { chatId: historyChatId, sessionId: historySessionId, askList } = response.data
  353. chatId.value = historyChatId
  354. sessionId.value = historySessionId
  355. // 清空现有消息
  356. messages.value = []
  357. // 按照 askSeq 排序对话记录
  358. const sortedMessages = askList.sort((a, b) => Number(a.askSeq) - Number(b.askSeq))
  359. // 添加所有对话记录
  360. for (const message of sortedMessages) {
  361. // 添加用户问题
  362. messages.value.push({
  363. role: 'user',
  364. content: message.askContent,
  365. time: new Date(message.createTime)
  366. })
  367. // 处理AI回答
  368. try {
  369. let answerContent = message.answerContent
  370. let formattedAnswer = ''
  371. // 按照 data: 分割字符串
  372. const responses = answerContent.split('data:')
  373. console.log('responses',responses);
  374. // 遍历所有分割后的响应
  375. for (const response of responses) {
  376. console.log('response==========',response);
  377. if (response.trim() && !response.includes('"data": true')) {
  378. console.log('response.trim()',response.trim());
  379. try {
  380. const jsonData = JSON.parse(response.trim())
  381. console.log('jsonData',jsonData);
  382. if (jsonData.data && jsonData.data.answer) {
  383. formattedAnswer += jsonData.data.answer
  384. }
  385. } catch (e) {
  386. console.warn('解析单条回答内容失败:', e)
  387. }
  388. }
  389. }
  390. // 如果没有成功解析出任何内容,使用原始内容
  391. if (!formattedAnswer.trim()) {
  392. formattedAnswer = answerContent
  393. }
  394. // 添加AI回答
  395. messages.value.push({
  396. id: message.id,
  397. role: 'assistant',
  398. content: md.render(formattedAnswer),
  399. time: new Date(message.createTime)
  400. })
  401. } catch (error) {
  402. console.error('处理回答内容失败:', error)
  403. // 如果处理失败,直接显示原始内容
  404. messages.value.push({
  405. id: message.id,
  406. role: 'assistant',
  407. content: answerContent,
  408. time: new Date(message.createTime)
  409. })
  410. }
  411. }
  412. isChating.value = true
  413. await nextTick()
  414. scrollToBottom()
  415. }
  416. } catch (error) {
  417. console.error('获取历史记录失败:', error)
  418. ElMessage.error('获取历史记录失败')
  419. }
  420. }
  421. // 初始化对话
  422. const initChat = async () => {
  423. messages.value = []
  424. await getKnowledgeList() // 获取最新的知识库列表
  425. chatId.value = ''
  426. sessionId.value = ''
  427. isChating.value = false
  428. }
  429. // 监听路由参数变化
  430. watch(() => route.query.newChat, async (newVal) => {
  431. if(newVal) {
  432. await initChat()
  433. }
  434. }, { immediate: true })
  435. onMounted(async () => {
  436. const historyId = route.query.historyId
  437. if (historyId) {
  438. await getHistoryChat(historyId)
  439. } else {
  440. await getKnowledgeList() // 如果不是历史记录,需要获取知识库列表
  441. }
  442. scrollToBottom()
  443. })
  444. </script>
  445. <style lang="scss" scoped>
  446. .chat-container {
  447. height: 100%;
  448. display: flex;
  449. flex-direction: column;
  450. background: url('@/assets/ai-chat-bg.png') no-repeat center center;
  451. background-size: cover;
  452. &:has(.chat-active){
  453. background: #fff;
  454. }
  455. .welcome-section {
  456. margin-top: 100px;
  457. text-align: center;
  458. padding: 40px 20px;
  459. .welcome-title {
  460. font-size: 28px;
  461. margin-bottom: 12px;
  462. }
  463. .welcome-subtitle {
  464. color: #635a5a;
  465. }
  466. }
  467. .knowledge-base {
  468. width: 800px;
  469. margin: 24px auto 0;
  470. .knowledge-tags {
  471. display: flex;
  472. flex-wrap: wrap;
  473. gap: 12px;
  474. justify-content: left;
  475. .knowledge-tag {
  476. padding: 8px 16px;
  477. border: 1px solid #DADDE8;
  478. border-radius: 15px;
  479. background: transparent;
  480. cursor: pointer;
  481. transition: all 0.3s;
  482. color: #414967;
  483. &:hover {
  484. background: #f5f7fa;
  485. }
  486. &.active {
  487. color: #FF7575;
  488. border-color: #FF7575;
  489. }
  490. }
  491. }
  492. }
  493. .chat-messages {
  494. flex: 1;
  495. overflow-y: auto;
  496. padding: 20px 20%;
  497. transition: all 0.3s;
  498. &.chat-active {
  499. padding-bottom: 100px;
  500. }
  501. .message {
  502. display: flex;
  503. margin-bottom: 100px;
  504. .avatar{
  505. img{
  506. width: 40px;
  507. height: 40px;
  508. }
  509. }
  510. .text {
  511. padding: 10px 20px;
  512. font-size: 16px;
  513. }
  514. &.user {
  515. flex-direction: row-reverse;
  516. .content {
  517. margin-right: 12px;
  518. margin-left: 0;
  519. .text {
  520. background: #FFF5F5;
  521. color: #1B1C21;
  522. border-radius: 10px 2px 10px 10px;
  523. }
  524. .time {
  525. text-align: right;
  526. }
  527. }
  528. }
  529. &.assistant{
  530. .avatar{
  531. margin-right: 10px;
  532. }
  533. }
  534. &.assistant .content .text {
  535. // background: rgba(255, 255, 255, 0.9);
  536. border-radius: 2px 10px 10px 10px;
  537. }
  538. .message-actions {
  539. display: flex;
  540. justify-content: space-between;
  541. margin-top: 8px;
  542. .left-actions, .right-actions {
  543. display: flex;
  544. gap: 8px;
  545. }
  546. .action-btn {
  547. background: none;
  548. border: none;
  549. padding: 4px;
  550. cursor: pointer;
  551. display: flex;
  552. align-items: center;
  553. gap: 4px;
  554. img {
  555. width: 16px;
  556. height: 16px;
  557. }
  558. &.reanswer span {
  559. font-size: 12px;
  560. color: #666;
  561. }
  562. }
  563. }
  564. }
  565. }
  566. .chat-input {
  567. // width: fit-content;
  568. margin: 0 auto;
  569. padding: 20px;
  570. background: rgba(255, 255, 255, 0.9);
  571. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  572. backdrop-filter: blur(10px);
  573. border-radius: 20px;
  574. min-width: 800px;
  575. &.chat-active{
  576. position: fixed;
  577. bottom: 0;
  578. left: $sidebar-width;
  579. right: 0;
  580. padding: 20px;
  581. box-shadow: none;
  582. }
  583. .input-container {
  584. max-width: 800px;
  585. margin: 0 auto;
  586. textarea {
  587. width: 100%;
  588. padding: 12px;
  589. border: 1px solid #dcdfe6;
  590. border-radius: 15px;
  591. background: rgba(255, 255, 255, 0.9);
  592. resize: none;
  593. font-size: 14px;
  594. line-height: 1.5;
  595. &:focus {
  596. outline: none;
  597. border-color: $primary-color;
  598. }
  599. }
  600. .input-actions {
  601. display: flex;
  602. justify-content: space-between;
  603. align-items: center;
  604. margin-top: 12px;
  605. .select-wrap{
  606. width: 300px;
  607. .el-select{
  608. color: #414967;
  609. }
  610. :deep(.el-select__wrapper){
  611. height: 46px;
  612. width: 176px;
  613. border-radius: 80px;
  614. background: #FFE9E9;
  615. border: none;
  616. box-shadow: none;
  617. .el-select__placeholder{
  618. color: #414967;
  619. font-size: 20px;
  620. }
  621. .el-select__caret{
  622. font-size: 20px;
  623. }
  624. }
  625. }
  626. .send-button {
  627. display: flex;
  628. align-items: center;
  629. gap: 14px;
  630. padding: 5px 20px 5px 8px;
  631. background: linear-gradient(135deg, #F89494 0%, #FE3636 100%);
  632. border: none;
  633. border-radius: 60px;
  634. color: white;
  635. font-size: 18px;
  636. cursor: pointer;
  637. font-weight: 500;
  638. transition: background 0.3s;
  639. img {
  640. width: 30px;
  641. height: 30px;
  642. }
  643. &:disabled {
  644. background: #f7b0b0;
  645. cursor: not-allowed;
  646. }
  647. }
  648. }
  649. }
  650. }
  651. // 添加 markdown 样式
  652. .markdown-body {
  653. line-height: 1.6;
  654. font-size: 14px;
  655. p {
  656. margin: 8px 0;
  657. }
  658. h1, h2, h3, h4, h5, h6 {
  659. margin: 16px 0 8px;
  660. font-weight: 600;
  661. }
  662. code {
  663. background-color: rgba(175, 184, 193, 0.2);
  664. padding: 0.2em 0.4em;
  665. border-radius: 6px;
  666. font-family: monospace;
  667. }
  668. pre {
  669. background-color: #f6f8fa;
  670. border-radius: 6px;
  671. padding: 16px;
  672. overflow: auto;
  673. margin: 16px 0;
  674. code {
  675. background-color: transparent;
  676. padding: 0;
  677. font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  678. font-size: 14px;
  679. line-height: 1.45;
  680. tab-size: 4;
  681. }
  682. &.hljs {
  683. background: #f6f8fa;
  684. border: 1px solid #e1e4e8;
  685. }
  686. }
  687. ul, ol {
  688. padding-left: 20px;
  689. margin: 8px 0;
  690. }
  691. table {
  692. border-collapse: collapse;
  693. margin: 8px 0;
  694. th, td {
  695. border: 1px solid #d0d7de;
  696. padding: 6px 13px;
  697. }
  698. th {
  699. background-color: #f6f8fa;
  700. }
  701. }
  702. blockquote {
  703. border-left: 4px solid #d0d7de;
  704. padding-left: 16px;
  705. margin: 8px 0;
  706. color: #656d76;
  707. }
  708. img {
  709. max-width: 100%;
  710. height: auto;
  711. }
  712. a {
  713. color: #0969da;
  714. text-decoration: none;
  715. &:hover {
  716. text-decoration: underline;
  717. }
  718. }
  719. code {
  720. font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  721. font-size: 0.9em;
  722. padding: 0.2em 0.4em;
  723. margin: 0;
  724. background-color: rgba(175, 184, 193, 0.2);
  725. border-radius: 6px;
  726. }
  727. }
  728. }
  729. </style>