index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. <template>
  2. <el-container class="ai-layout">
  3. <!-- 左侧:会话列表 -->
  4. <el-aside width="260px" class="conversation-container">
  5. <div>
  6. <!-- 左顶部:新建对话 -->
  7. <el-button class="w-1/1 btn-new-conversation" type="primary">
  8. <Icon icon="ep:plus" class="mr-5px"/>
  9. 新建对话
  10. </el-button>
  11. <!-- 左顶部:搜索对话 -->
  12. <el-input
  13. v-model="searchName"
  14. size="large"
  15. class="mt-10px search-input"
  16. placeholder="搜索历史记录"
  17. @keyup="searchConversation"
  18. >
  19. <template #prefix>
  20. <Icon icon="ep:search"/>
  21. </template>
  22. </el-input>
  23. <!-- 左中间:对话列表 -->
  24. <div class="conversation-list">
  25. <!-- TODO @芋艿,置顶、聊天记录、一星期钱、30天前,前端对数据重新做一下分组,或者后端接口改一下 -->
  26. <div>
  27. <el-text class="mx-1" size="small" tag="b">置顶</el-text>
  28. </div>
  29. <el-row v-for="conversation in conversationList" :key="conversation.id">
  30. <div
  31. :class="conversation.id === conversationId ? 'conversation active' : 'conversation'"
  32. @click="changeConversation(conversation)"
  33. >
  34. <div class="title-wrapper">
  35. <img class="avatar" :src="conversation.avatar"/>
  36. <span class="title">{{ conversation.title }}</span>
  37. </div>
  38. <div class="button-wrapper">
  39. <el-icon title="编辑" @click="updateConversationTitle(conversation)">
  40. <Icon icon="ep:edit"/>
  41. </el-icon>
  42. <el-icon title="删除会话" @click="deleteConversationTitle(conversation)">
  43. <Icon icon="ep:delete"/>
  44. </el-icon>
  45. </div>
  46. </div>
  47. </el-row>
  48. </div>
  49. </div>
  50. <!-- 左底部:工具栏 -->
  51. <div class="tool-box">
  52. <div>
  53. <Icon icon="ep:user"/>
  54. <el-text size="small">角色仓库</el-text>
  55. </div>
  56. <div>
  57. <Icon icon="ep:delete"/>
  58. <el-text size="small">清空未置顶对话</el-text>
  59. </div>
  60. </div>
  61. </el-aside>
  62. <!-- 右侧:会话详情 -->
  63. <el-container class="detail-container">
  64. <!-- 右顶部 TODO 芋艿:右对齐 -->
  65. <el-header class="header">
  66. <div class="title">
  67. 标题......
  68. </div>
  69. <div>
  70. <el-button>3.5-turbo-0125
  71. <Icon icon="ep:setting"/>
  72. </el-button>
  73. <el-button>
  74. <Icon icon="ep:user"/>
  75. </el-button>
  76. <el-button>
  77. <Icon icon="ep:download"/>
  78. </el-button>
  79. <el-button>
  80. <Icon icon="ep:arrow-up"/>
  81. </el-button>
  82. </div>
  83. </el-header>
  84. <!-- main -->
  85. <el-main class="main-container">
  86. <div class="message-container" ref="messageContainer">
  87. <div class="chat-list" v-for="(item, index) in list" :key="index">
  88. <!-- 靠左 message -->
  89. <div class="left-message message-item" v-if="item.type === 'system'">
  90. <div class="avatar">
  91. <el-avatar
  92. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  93. />
  94. </div>
  95. <div class="message">
  96. <div>
  97. <el-text class="time">{{ formatDate(item.createTime) }}</el-text>
  98. </div>
  99. <div class="left-text-container" ref="markdownViewRef">
  100. <div class="left-text markdown-view" v-html="item.content"></div>
  101. <!-- <mdPreview :content="item.content" :delay="false" />-->
  102. </div>
  103. <div class="left-btns">
  104. <div class="btn-cus" @click="noCopy(item.content)">
  105. <img class="btn-image" src="../../../assets/ai/copy.svg"/>
  106. <el-text class="btn-cus-text">复制</el-text>
  107. </div>
  108. <div class="btn-cus" style="margin-left: 20px;" @click="onDelete(item.id)">
  109. <img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px;"/>
  110. <el-text class="btn-cus-text">删除</el-text>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <!-- 靠右 message -->
  116. <div class="right-message message-item" v-if="item.type === 'user'">
  117. <div class="avatar">
  118. <el-avatar
  119. src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
  120. />
  121. </div>
  122. <div class="message">
  123. <div>
  124. <el-text class="time">{{ formatDate(item.createTime) }}</el-text>
  125. </div>
  126. <div class="right-text-container">
  127. <div class="right-text">{{ item.content }}</div>
  128. </div>
  129. <div class="right-btns">
  130. <div class="btn-cus" @click="noCopy(item.content)">
  131. <img class="btn-image" src="@/assets/ai/copy.svg"/>
  132. <el-text class="btn-cus-text">复制</el-text>
  133. </div>
  134. <div class="btn-cus" style="margin-left: 20px;" @click="onDelete(item.id)">
  135. <img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px;"/>
  136. <el-text class="btn-cus-text">删除</el-text>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </el-main>
  144. <el-footer class="footer-container">
  145. <form @submit.prevent="onSend" class="prompt-from">
  146. <textarea class="prompt-input" v-model="prompt" @keyup.enter="onSend"
  147. placeholder="问我任何问题...(Shift+Enter 换行,按下 Enter 发送)"></textarea>
  148. <div class="prompt-btns">
  149. <el-switch/>
  150. <el-button type="primary" size="default" @click="onSend()"
  151. :loading="conversationInProgress" v-if="conversationInProgress == false">
  152. {{ conversationInProgress ? '进行中' : '发送' }}
  153. </el-button>
  154. <el-button type="danger" size="default" @click="stopStream()"
  155. v-if="conversationInProgress == true">
  156. 停止
  157. </el-button>
  158. </div>
  159. </form>
  160. </el-footer>
  161. </el-container>
  162. </el-container>
  163. </template>
  164. <script setup lang="ts">
  165. import {ChatMessageApi, ChatMessageSendVO, ChatMessageVO} from "@/api/ai/chat/message"
  166. import {formatDate} from "@/utils/formatTime"
  167. import {useClipboard} from "@vueuse/core";
  168. // 转换 markdown
  169. import {marked} from 'marked';
  170. // 代码高亮 https://highlightjs.org/
  171. import 'highlight.js/styles/vs2015.min.css';
  172. import hljs from 'highlight.js';
  173. // 自定义渲染器
  174. const renderer = {
  175. code(code, language, c) {
  176. const highlightHtml = hljs.highlight(code, {language: language, ignoreIllegals: true}).value
  177. const copyHtml = `<div id="copy" data-copy='${code}' style="position: absolute; right: 10px; top: 5px; color: #fff;cursor: pointer;">复制</div>`
  178. return `<pre>${copyHtml}<code class="hljs">${highlightHtml}</code></pre>`
  179. },
  180. };
  181. marked.use({
  182. renderer: renderer,
  183. })
  184. const conversationList = [
  185. {
  186. id: 1,
  187. title: '测试标题',
  188. avatar:
  189. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  190. },
  191. {
  192. id: 2,
  193. title: '测试对话',
  194. avatar:
  195. 'http://test.yudao.iocoder.cn/96c787a2ce88bf6d0ce3cd8b6cf5314e80e7703cd41bf4af8cd2e2909dbd6b6d.png'
  196. }
  197. ]
  198. // 初始化 copy 到粘贴板
  199. const {copy} = useClipboard();
  200. const searchName = ref('') // 查询的内容
  201. const conversationId = ref('1781604279872581648') // 对话id
  202. const conversationInProgress = ref<Boolean>() // 对话进行中
  203. conversationInProgress.value = false
  204. const conversationInAbortController = ref<any>() // 对话进行中 abort 控制器(控制 stream 对话)
  205. const prompt = ref<string>() // prompt
  206. // 判断 消息列表 滚动的位置(用于判断是否需要滚动到消息最下方)
  207. const messageContainer: any = ref(null);
  208. const isScrolling = ref(false)//用于判断用户是否在滚动
  209. /** chat message 列表 */
  210. // defineOptions({ name: 'chatMessageList' })
  211. const list = ref<ChatMessageVO[]>([]) // 列表的数据
  212. const changeConversation = (conversation) => {
  213. console.log(conversation)
  214. conversationId.value = conversation.id
  215. // TODO 芋艿:待实现
  216. }
  217. const updateConversationTitle = (conversation) => {
  218. console.log(conversation)
  219. // TODO 芋艿:待实现
  220. }
  221. const deleteConversationTitle = (conversation) => {
  222. console.log(conversation)
  223. // TODO 芋艿:待实现
  224. }
  225. const searchConversation = () => {
  226. // TODO 芋艿:待实现
  227. }
  228. /** send */
  229. const onSend = async () => {
  230. // 进行中不允许发送
  231. if (conversationInProgress.value) {
  232. return
  233. }
  234. const content = prompt.value;
  235. // 清空输入框
  236. prompt.value = ''
  237. const requestParams = {
  238. conversationId: conversationId.value,
  239. content: content,
  240. } as unknown as ChatMessageSendVO
  241. // 添加 message
  242. const userMessage = await ChatMessageApi.add(requestParams) as unknown as ChatMessageVO;
  243. list.value.push(userMessage)
  244. // 滚动到住下面
  245. scrollToBottom();
  246. // stream
  247. await doSendStream(userMessage)
  248. //
  249. }
  250. const doSendStream = async (userMessage: ChatMessageVO) => {
  251. // 创建AbortController实例,以便中止请求
  252. conversationInAbortController.value = new AbortController()
  253. // 标记对话进行中
  254. conversationInProgress.value = true
  255. try {
  256. // 发送 event stream
  257. let isFirstMessage = true
  258. let content = ''
  259. ChatMessageApi.sendStream(userMessage.id, conversationInAbortController.value, (message) => {
  260. console.log('message', message)
  261. const data = JSON.parse(message.data) as unknown as ChatMessageVO
  262. // 如果没有内容结束链接
  263. if (data.content === '') {
  264. // 标记对话结束
  265. conversationInProgress.value = false;
  266. // 结束 stream 对话
  267. conversationInAbortController.value.abort()
  268. }
  269. // 首次返回需要添加一个 message 到页面,后面的都是更新
  270. if (isFirstMessage) {
  271. isFirstMessage = false;
  272. list.value.push(data)
  273. } else {
  274. content = content + data.content
  275. const lastMessage = list.value[list.value.length - 1];
  276. lastMessage.content = marked(content) as unknown as string
  277. list.value[list.value - 1] = lastMessage
  278. }
  279. // 滚动到最下面
  280. scrollToBottom();
  281. }, (error) => {
  282. console.log('error', error)
  283. // 标记对话结束
  284. conversationInProgress.value = false;
  285. // 结束 stream 对话
  286. conversationInAbortController.value.abort()
  287. }, () => {
  288. console.log('close')
  289. // 标记对话结束
  290. conversationInProgress.value = false;
  291. // 结束 stream 对话
  292. conversationInAbortController.value.abort()
  293. })
  294. } finally {
  295. }
  296. }
  297. /** 查询列表 */
  298. const messageList = async () => {
  299. try {
  300. // 获取列表数据
  301. const res = await ChatMessageApi.messageList(conversationId.value)
  302. // 处理 markdown
  303. // marked(this.markdownText)
  304. res.map(item => {
  305. // item.content = marked(item.content)
  306. if (item.type !== 'user') {
  307. item.content = marked(item.content)
  308. }
  309. })
  310. list.value = res;
  311. // 滚动到最下面
  312. scrollToBottom();
  313. } finally {
  314. }
  315. }
  316. function scrollToBottom() {
  317. nextTick(() => {
  318. //注意要使用nexttick以免获取不到dom
  319. console.log('isScrolling.value', isScrolling.value)
  320. if (!isScrolling.value) {
  321. messageContainer.value.scrollTop = messageContainer.value.scrollHeight - messageContainer.value.offsetHeight
  322. }
  323. })
  324. }
  325. function handleScroll() {
  326. const scrollContainer = messageContainer.value
  327. const scrollTop = scrollContainer.scrollTop
  328. const scrollHeight = scrollContainer.scrollHeight
  329. const offsetHeight = scrollContainer.offsetHeight
  330. if (scrollTop + offsetHeight < scrollHeight) {
  331. // 用户开始滚动并在最底部之上,取消保持在最底部的效果
  332. isScrolling.value = true
  333. } else {
  334. // 用户停止滚动并滚动到最底部,开启保持到最底部的效果
  335. isScrolling.value = false
  336. }
  337. }
  338. function noCopy(content) {
  339. copy(content)
  340. ElMessage({
  341. message: '复制成功!',
  342. type: 'success',
  343. })
  344. }
  345. const onDelete = async (id) => {
  346. // 删除 message
  347. await ChatMessageApi.delete(id)
  348. ElMessage({
  349. message: '删除成功!',
  350. type: 'success',
  351. })
  352. // tip:如果 stream 进行中的 message,就需要调用 controller 结束
  353. stopStream()
  354. // 重新获取 message 列表
  355. await messageList();
  356. }
  357. const stopStream = async () => {
  358. // tip:如果 stream 进行中的 message,就需要调用 controller 结束
  359. if (conversationInAbortController.value) {
  360. conversationInAbortController.value.abort()
  361. }
  362. // 设置为 false
  363. conversationInProgress.value = false
  364. }
  365. /** 初始化 **/
  366. onMounted(async () => {
  367. // 获取列表数据
  368. messageList();
  369. // scrollToBottom();
  370. // await nextTick
  371. // 监听滚动事件,判断用户滚动状态
  372. messageContainer.value.addEventListener('scroll', handleScroll)
  373. // 添加 copy 监听
  374. messageContainer.value.addEventListener('click', (e: any) => {
  375. console.log(e)
  376. if (e.target.id === 'copy') {
  377. copy(e.target?.dataset?.copy)
  378. ElMessage({
  379. message: '复制成功!',
  380. type: 'success',
  381. })
  382. }
  383. })
  384. // marked.use({
  385. // async: false,
  386. // pedantic: false,
  387. // gfm: true,
  388. // tokenizer: new Tokenizer(),
  389. // renderer: renderer,
  390. // });
  391. })
  392. </script>
  393. <style lang="scss" scoped>
  394. .ai-layout {
  395. // TODO @范 这里height不能 100% 先这样临时处理
  396. position: absolute;
  397. flex: 1;
  398. top: 0;
  399. left: 0;
  400. height: 100%;
  401. width: 100%;
  402. //padding: 15px 15px;
  403. }
  404. .conversation-container {
  405. position: relative;
  406. display: flex;
  407. flex-direction: column;
  408. justify-content: space-between;
  409. padding: 0 10px;
  410. padding-top: 10px;
  411. .btn-new-conversation {
  412. padding: 18px 0;
  413. }
  414. .search-input {
  415. margin-top: 20px;
  416. }
  417. .conversation-list {
  418. margin-top: 20px;
  419. .conversation {
  420. display: flex;
  421. flex-direction: row;
  422. justify-content: space-between;
  423. flex: 1;
  424. padding: 0 5px;
  425. margin-top: 10px;
  426. cursor: pointer;
  427. border-radius: 5px;
  428. align-items: center;
  429. line-height: 30px;
  430. &.active {
  431. background-color: #e6e6e6;
  432. .button {
  433. display: inline-block;
  434. }
  435. }
  436. .title-wrapper {
  437. display: flex;
  438. flex-direction: row;
  439. align-items: center;
  440. }
  441. .title {
  442. padding: 5px 10px;
  443. max-width: 220px;
  444. font-size: 14px;
  445. overflow: hidden;
  446. white-space: nowrap;
  447. text-overflow: ellipsis;
  448. }
  449. .avatar {
  450. width: 28px;
  451. height: 28px;
  452. display: flex;
  453. flex-direction: row;
  454. justify-items: center;
  455. }
  456. // 对话编辑、删除
  457. .button-wrapper {
  458. right: 2px;
  459. display: flex;
  460. flex-direction: row;
  461. justify-items: center;
  462. color: #606266;
  463. .el-icon {
  464. margin-right: 5px;
  465. }
  466. }
  467. }
  468. }
  469. // 角色仓库、清空未设置对话
  470. .tool-box {
  471. line-height: 35px;
  472. display: flex;
  473. justify-content: space-between;
  474. align-items: center;
  475. color: var(--el-text-color);
  476. > div {
  477. display: flex;
  478. align-items: center;
  479. color: #606266;
  480. padding: 0;
  481. margin: 0;
  482. > span {
  483. margin-left: 5px;
  484. }
  485. }
  486. }
  487. }
  488. // 头部
  489. .detail-container {
  490. background: #ffffff;
  491. .header {
  492. display: flex;
  493. flex-direction: row;
  494. align-items: center;
  495. justify-content: space-between;
  496. background: #fbfbfb;
  497. box-shadow: 0 0 0 0 #dcdfe6;
  498. .title {
  499. font-size: 18px;
  500. font-weight: bold;
  501. }
  502. }
  503. }
  504. // main 容器
  505. .main-container {
  506. margin: 0;
  507. padding: 0;
  508. position: relative;
  509. }
  510. .message-container {
  511. position: absolute;
  512. top: 0;
  513. bottom: 0;
  514. left: 0;
  515. right: 0;
  516. //width: 100%;
  517. //height: 100%;
  518. overflow-y: scroll;
  519. padding: 0 15px;
  520. }
  521. // 中间
  522. .chat-list {
  523. display: flex;
  524. flex-direction: column;
  525. overflow-y: hidden;
  526. .message-item {
  527. margin-top: 50px;
  528. }
  529. .left-message {
  530. display: flex;
  531. flex-direction: row;
  532. }
  533. .right-message {
  534. display: flex;
  535. flex-direction: row-reverse;
  536. justify-content: flex-start;
  537. }
  538. .avatar {
  539. //height: 170px;
  540. //width: 170px;
  541. }
  542. .message {
  543. display: flex;
  544. flex-direction: column;
  545. text-align: left;
  546. margin: 0 15px;
  547. .time {
  548. text-align: left;
  549. line-height: 30px;
  550. }
  551. .left-text-container {
  552. display: flex;
  553. flex-direction: column;
  554. overflow-wrap: break-word;
  555. background-color: rgba(228, 228, 228, 0.80);
  556. box-shadow: 0 0 0 1px rgba(228, 228, 228, 0.80);
  557. border-radius: 10px;
  558. padding: 10px 10px 5px 10px;
  559. .left-text {
  560. color: #393939;
  561. font-size: 0.95rem;
  562. }
  563. }
  564. .right-text-container {
  565. display: flex;
  566. flex-direction: row-reverse;
  567. .right-text {
  568. font-size: 0.95rem;
  569. color: #FFF;
  570. display: inline;
  571. background-color: #267fff;
  572. color: #FFF;
  573. box-shadow: 0 0 0 1px #267fff;
  574. border-radius: 10px;
  575. padding: 10px;
  576. width: auto;
  577. overflow-wrap: break-word;
  578. }
  579. }
  580. .left-btns, .right-btns {
  581. display: flex;
  582. flex-direction: row;
  583. margin-top: 8px;
  584. }
  585. }
  586. // 复制、删除按钮
  587. .btn-cus {
  588. display: flex;
  589. background-color: transparent;
  590. align-items: center;
  591. .btn-image {
  592. height: 20px;
  593. margin-right: 5px;
  594. }
  595. .btn-cus-text {
  596. color: #757575;
  597. }
  598. }
  599. .btn-cus:hover {
  600. cursor: pointer;
  601. }
  602. .btn-cus:focus {
  603. background-color: #8c939d;
  604. }
  605. }
  606. // 底部
  607. .footer-container {
  608. display: flex;
  609. flex-direction: column;
  610. height: auto;
  611. margin: 0;
  612. padding: 0;
  613. .prompt-from {
  614. display: flex;
  615. flex-direction: column;
  616. height: auto;
  617. border: 1px solid #e3e3e3;
  618. border-radius: 10px;
  619. margin: 20px 20px;
  620. padding: 9px 10px;
  621. }
  622. .prompt-input {
  623. height: 80px;
  624. //box-shadow: none;
  625. border: none;
  626. box-sizing: border-box;
  627. resize: none;
  628. padding: 0px 2px;
  629. //padding: 5px 5px;
  630. overflow: hidden;
  631. }
  632. .prompt-input:focus {
  633. outline: none;
  634. }
  635. .prompt-btns {
  636. display: flex;
  637. justify-content: space-between;
  638. padding-bottom: 0px;
  639. padding-top: 5px;
  640. }
  641. }
  642. </style>
  643. <style lang="scss">
  644. .markdown-view {
  645. font-family: PingFang SC;
  646. font-size: 0.95rem;
  647. font-weight: 400;
  648. line-height: 1.6rem;
  649. letter-spacing: 0em;
  650. text-align: left;
  651. color: #3B3E55;
  652. max-width: 100%;
  653. pre {
  654. position: relative;
  655. }
  656. pre code.hljs {
  657. width: auto;
  658. }
  659. code.hljs {
  660. border-radius: 6px;
  661. padding-top: 20px;
  662. width: auto;
  663. @media screen and (min-width: 1536px) {
  664. width: 960px;
  665. }
  666. @media screen and (max-width: 1536px) and (min-width: 1024px) {
  667. width: calc(100vw - 400px - 64px - 32px * 2);
  668. }
  669. @media screen and (max-width: 1024px) and (min-width: 768px) {
  670. width: calc(100vw - 32px * 2);
  671. }
  672. @media screen and (max-width: 768px) {
  673. width: calc(100vw - 16px * 2);
  674. }
  675. }
  676. p,
  677. code.hljs {
  678. margin-bottom: 16px;
  679. }
  680. p {
  681. margin-bottom: 1rem !important;
  682. }
  683. /* 标题通用格式 */
  684. h1,
  685. h2,
  686. h3,
  687. h4,
  688. h5,
  689. h6 {
  690. color: var(--color-G900);
  691. margin: 24px 0 8px;
  692. font-weight: 600;
  693. }
  694. h1 {
  695. font-size: 22px;
  696. line-height: 32px;
  697. }
  698. h2 {
  699. font-size: 20px;
  700. line-height: 30px;
  701. }
  702. h3 {
  703. font-size: 18px;
  704. line-height: 28px;
  705. }
  706. h4 {
  707. font-size: 16px;
  708. line-height: 26px;
  709. }
  710. h5 {
  711. font-size: 16px;
  712. line-height: 24px;
  713. }
  714. h6 {
  715. font-size: 16px;
  716. line-height: 24px;
  717. }
  718. /* 列表(有序,无序) */
  719. ul,
  720. ol {
  721. margin: 0 0 8px 0;
  722. padding: 0;
  723. font-size: 16px;
  724. line-height: 24px;
  725. color: #3b3e55; // var(--color-CG600);
  726. }
  727. li {
  728. margin: 4px 0 0 20px;
  729. margin-bottom: 1rem;
  730. }
  731. ol > li {
  732. list-style-type: decimal;
  733. margin-bottom: 1rem;
  734. // 表达式,修复有序列表序号展示不全的问题
  735. // &:nth-child(n + 10) {
  736. // margin-left: 30px;
  737. // }
  738. // &:nth-child(n + 100) {
  739. // margin-left: 30px;
  740. // }
  741. }
  742. ul > li {
  743. list-style-type: disc;
  744. font-size: 16px;
  745. line-height: 24px;
  746. margin-right: 11px;
  747. margin-bottom: 1rem;
  748. color: #3b3e55; // var(--color-G900);
  749. }
  750. ol ul,
  751. ol ul > li,
  752. ul ul,
  753. ul ul li {
  754. // list-style: circle;
  755. font-size: 16px;
  756. list-style: none;
  757. margin-left: 6px;
  758. margin-bottom: 1rem;
  759. }
  760. ul ul ul,
  761. ul ul ul li,
  762. ol ol,
  763. ol ol > li,
  764. ol ul ul,
  765. ol ul ul > li,
  766. ul ol,
  767. ul ol > li {
  768. list-style: square;
  769. }
  770. }
  771. </style>