AIDevelop.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550
  1. <template>
  2. <!-- AI发展历程 -->
  3. <div class="home-container">
  4. <!-- 展开收起侧边栏 -->
  5. <div
  6. class="icon-expand"
  7. :style="{
  8. backgroundColor: drawerVisible ? '#44449c' : '#7F70C840',
  9. left: drawerVisible ? '18%' : '0'
  10. }"
  11. @click="toggleDrawer"
  12. >
  13. <span
  14. class="vertical-lines"
  15. :style="{
  16. color: drawerVisible ? '#8a78d0' : 'white'
  17. }"
  18. >||</span
  19. >
  20. </div>
  21. <el-drawer
  22. v-model="drawerVisible"
  23. direction="ltr"
  24. size="18%"
  25. :with-header="false"
  26. >
  27. <!-- 添加抽屉 -->
  28. <div class="drawer-box">
  29. <el-row class="tac">
  30. <el-col :span="12">
  31. <span class="mb-2">
  32. <img :src="classImages" alt="课程小节图标" />
  33. 课程小节
  34. </span>
  35. <el-menu
  36. :default-active="course.key"
  37. @open="handleOpen"
  38. @close="handleClose"
  39. @select="handleSelect"
  40. :default-openeds="['3']"
  41. >
  42. <template v-for="item in menuItems" :key="item.key">
  43. <el-menu-item v-if="!item.children" :index="item.key">{{
  44. item.title
  45. }}</el-menu-item>
  46. <el-sub-menu v-else :index="item.key">
  47. <template #title>
  48. <span>{{ item.title }}</span>
  49. </template>
  50. <el-menu-item-group v-if="item.children">
  51. <template v-for="child in item.children" :key="child.key">
  52. <el-menu-item :index="child.key"
  53. >• {{ child.title }}</el-menu-item
  54. >
  55. </template>
  56. </el-menu-item-group>
  57. </el-sub-menu>
  58. </template>
  59. </el-menu>
  60. </el-col>
  61. </el-row>
  62. </div>
  63. </el-drawer>
  64. <div class="content-box">
  65. <div class="box-1">
  66. <div class="inner-box left-box">
  67. <div class="box-icon" @click="goBack">
  68. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  69. {{ boxIconTitle }}
  70. </div>
  71. </div>
  72. <div class="inner-box right-box">
  73. <div class="top-right-box">
  74. <el-autocomplete
  75. v-model="SearchInput"
  76. :fetch-suggestions="querySearch"
  77. placeholder="搜索"
  78. @select="handleSearchSelect"
  79. class="search-input"
  80. value-key="title"
  81. :trigger-on-focus="false"
  82. >
  83. <template #prefix>
  84. <el-icon class="el-input__icon"><search /></el-icon>
  85. </template>
  86. <template #popper-append-to-body>
  87. <el-option
  88. class="scrollbar"
  89. v-for="item in filteredTitles"
  90. :key="item.key"
  91. :label="item.title"
  92. :value="item"
  93. ></el-option>
  94. </template>
  95. </el-autocomplete>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="box-2">
  100. <!-- 课程标题 autoplay自动播放 @ended="playNextVideo"-->
  101. <div class="small-title">
  102. <span>{{ course.courseName }}</span>
  103. </div>
  104. <div class="box-video">
  105. <video
  106. class="full-box-video video-js vjs-default-skin"
  107. :src="course.courseVideoPath"
  108. controlsList="nodownload"
  109. controls
  110. @timeupdate="handleTimeUpdate"
  111. @play="checkVideoPermission"
  112. @seeked="handleSeeked"
  113. ref="videoRef"
  114. >
  115. <source :src="course.courseVideoPath" type="video/mp4" />
  116. 您的浏览器不支持视频播放。
  117. </video>
  118. </div>
  119. <!-- 添加切换视频 -->
  120. <div class="video-switch">
  121. <!-- 上一个视频 -->
  122. <div class="caret-left" @click="playPreviousVideo">
  123. <el-button type="warning" round>
  124. <img :src="leftImg" alt="Left" />
  125. 上一节</el-button
  126. >
  127. </div>
  128. <!-- 下一个视频 -->
  129. <div class="caret-right" @click="playNextVideo">
  130. <el-button type="warning" round
  131. >下一节
  132. <img :src="rightImg" alt="Right" />
  133. </el-button>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- 添加试题弹框 -->
  138. <transition name="fade-scale">
  139. <div
  140. v-show="questionDialogVisible"
  141. class="child-dialog-wrapper"
  142. @click.self="handleCloseQuestionDialog"
  143. >
  144. <div class="child-dialog">
  145. <div class="question-title">
  146. <span class="question-icon">?</span>
  147. <span v-html="courseConfig.ccQuestContent"></span>
  148. </div>
  149. <!-- 选项区域 -->
  150. <div
  151. v-if="
  152. courseConfig.ccQuestOption &&
  153. courseConfig.ccQuestOption.length > 0
  154. "
  155. class="options-container"
  156. >
  157. <div
  158. v-for="(option, index) in courseConfig.ccQuestOption"
  159. :key="index"
  160. class="question-option"
  161. >
  162. <el-radio
  163. v-model="selectedOption"
  164. :label="index"
  165. :value="option"
  166. v-cloak="(selectedOption = option)"
  167. >
  168. <span>{{ option }}</span>
  169. </el-radio>
  170. </div>
  171. </div>
  172. <div v-else class="no-options">
  173. <!-- 暂无选项 -->
  174. </div>
  175. <!-- 底部按钮 -->
  176. <div class="dialog-footer">
  177. <!-- <el-button class="child-button cancel" @click="questionDialogVisible = false; showAIDialog = false">取消</el-button>-->
  178. <el-button
  179. class="child-button confirm"
  180. @click="handleSubmitAnswer"
  181. >确定</el-button
  182. >
  183. </div>
  184. <!-- 右侧小图标 -->
  185. <div
  186. v-if="courseConfig.ccAiAnswer !== null"
  187. class="ai-icon-container"
  188. @click="handleAIClick"
  189. >
  190. <img
  191. src="@/assets/images/xiaozhi.png"
  192. alt="AI对话"
  193. class="ai-icon"
  194. />
  195. <span class="ai-text">小智智能助手</span>
  196. </div>
  197. </div>
  198. </div>
  199. </transition>
  200. <!-- AI对话弹框 -->
  201. <div
  202. v-show="showAIDialog"
  203. class="ai-dialog-wrapper"
  204. @click.self="showAIDialog = false"
  205. >
  206. <div class="ai-dialog">
  207. <div class="ai-dialog-header">
  208. <h3>
  209. <img :src="auto" alt="" />
  210. 小智智能助手
  211. </h3>
  212. <el-button @click="showAIDialog = false" class="close-btn"
  213. >×</el-button
  214. >
  215. </div>
  216. <div class="ai-dialog-content">
  217. <div class="ai-message-history">
  218. <div
  219. v-for="(message, index) in messageHistory"
  220. :key="index"
  221. :class="['message', message.type]"
  222. >
  223. <img
  224. v-if="message.type === 'user'"
  225. src="@/assets/images/user.png"
  226. class="avatar user"
  227. />
  228. <img v-else src="@/assets/images/xiaozhi.png" class="avatar" />
  229. <div class="message-content" v-html="message.content"></div>
  230. </div>
  231. </div>
  232. <el-input
  233. v-model="userMessage"
  234. placeholder="输入问题..."
  235. class="user-input"
  236. @keyup.enter="sendMessage"
  237. >
  238. <template #append class="flex flex-wrap items-center mb-4">
  239. <!-- <el-button @click="sendMessage" class="child-button confirm">发送</el-button>-->
  240. <el-button @click="sendMessage" size="large" round
  241. >发送</el-button
  242. >
  243. </template>
  244. </el-input>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </template>
  251. <script setup>
  252. import { ref, onMounted, onUnmounted, onBeforeUnmount,computed} from 'vue'
  253. import { useRouter } from 'vue-router'
  254. import videojs from 'video.js';
  255. import 'video.js/dist/video-js.css';
  256. import '@videojs/http-streaming'; // 支持HLS分片
  257. const videoPlayer = ref(null);
  258. let player = null;
  259. import {
  260. Expand,
  261. Fold,
  262. Memo
  263. } from '@element-plus/icons-vue'
  264. import { Search, ArrowLeftBold } from '@element-plus/icons-vue'
  265. import {
  266. ElMessage,
  267. ElMessageBox,
  268. ElNotification,
  269. valueEquals
  270. } from 'element-plus'
  271. import classImages from '@/assets/icon/class.png'
  272. import leftImg from '@/assets/icon/backward.png'
  273. import rightImg from '@/assets/icon/f-backward.png'
  274. import auto from '@/assets/icon/auto_awesome.png'
  275. import { ClassType } from '@/api/class.js'
  276. import { Message } from '@/utils/message/Message.js'
  277. const router = useRouter() // 获取当前路由对象
  278. // 添加按钮显示状态
  279. const buttonVisible = ref(false)
  280. // 添加抽屉显示状态
  281. const drawerVisible = ref(false)
  282. // 添加切换抽屉显示状态的函数
  283. const toggleDrawer = () => {
  284. drawerVisible.value = !drawerVisible.value
  285. }
  286. // 返回上一页
  287. const goBack = () => {
  288. router.go(-1)
  289. }
  290. // 渲染页面标题
  291. const boxIconTitle = ref('')
  292. // 课程集合数据
  293. const courseList = ref([])
  294. //当前课程
  295. const course = ref({})
  296. // 菜单数据
  297. const menuItems = ref([])
  298. // 课程集合数据
  299. const videoPathMap = ref({})
  300. //课程小节字典(需要新加接口调取字典)
  301. const menuDict = ref({
  302. "1": "课前回顾",
  303. "2": "课程引入",
  304. "3": "知识讲解",
  305. "4": "趣味实操",
  306. "5": "课程总结",
  307. })
  308. // 渲染 课程数据结构 以及 视频
  309. onMounted(async () => {
  310. const typeId = router.currentRoute.value.query.typeId
  311. if (typeId) {
  312. try {
  313. // 取接口课程数据
  314. const res = await ClassType(typeId)
  315. courseList.value = res.data
  316. //课程数据
  317. courseList.value.forEach((courseTemp,index) => {
  318. let menuIndex = courseTemp.courseLabel + '-' + (index+1);
  319. //填充大纲小节
  320. let menu = menuItems.value.find(menu => courseTemp.courseLabel === menu.index);
  321. if (menu){//小节
  322. menu.children = menu.children || [];
  323. menu.children.push({
  324. key: menuIndex,
  325. index: menuIndex,
  326. title: courseTemp.courseName
  327. })
  328. }else {//大节
  329. let temp = {
  330. key: menuIndex,
  331. index: courseTemp.courseLabel,
  332. title: menuDict.value[courseTemp.courseLabel]
  333. }
  334. if (courseTemp.courseLabel === "3"){
  335. temp.children = [{
  336. key: menuIndex,
  337. index: menuIndex,
  338. title: courseTemp.courseName
  339. }]
  340. }
  341. menuItems.value.push(temp)
  342. }
  343. courseTemp["key"] = menuIndex;
  344. videoPathMap.value[menuIndex] = courseTemp
  345. //确定默认课程
  346. if (index === 0) {
  347. course.value = courseTemp;
  348. }
  349. })
  350. } catch (error) {
  351. console.error('获取课程数据失败:', error)
  352. }
  353. }
  354. const title = router.currentRoute.value.query.typeName
  355. if (title) {
  356. boxIconTitle.value = String(title)
  357. }
  358. // 在视频元素上添加时间更新事件监听
  359. if (videoRef.value) {
  360. videoRef.value.addEventListener('timeupdate', handleTimeUpdate)
  361. }
  362. })
  363. // 菜单打开和关闭的处理函数
  364. const handleOpen = () => {}
  365. const handleClose = () => {}
  366. // 菜单选择的处理函数
  367. const handleSelect = index => {
  368. //测试账号禁用视频
  369. if (disableVideo(index))return;
  370. const findTitle = items => {
  371. for (const item of items) {
  372. if (item.key === index) {
  373. return item.title
  374. }
  375. if (item.children) {
  376. const result = findTitle(item.children)
  377. if (result) {
  378. return result
  379. }
  380. }
  381. }
  382. return null
  383. }
  384. // 根据索引切换视频,使用新的 videoPathMap
  385. if (videoPathMap.value[index]) {
  386. course.value = videoPathMap.value[index]
  387. // 切换标题后,关闭抽屉
  388. drawerVisible.value = false
  389. }else {
  390. //视频不存在
  391. Message().notifyWarning('视频不存在!', true);
  392. }
  393. //测试账号禁用视频
  394. if (disableVideo()) return
  395. }
  396. // 展平所有菜单项索引
  397. const flattenMenuItems = () => {
  398. const indices = []
  399. const traverse = items => {
  400. for (const item of items) {
  401. if (!item.children) {
  402. indices.push(item.key)
  403. } else {
  404. traverse(item.children)
  405. }
  406. }
  407. }
  408. traverse(menuItems.value)
  409. return indices
  410. }
  411. // 播放下一个视频
  412. const playNextVideo = () => {
  413. //测试账号禁用视频
  414. if (disableVideo())return;
  415. const allIndices = flattenMenuItems()
  416. const currentIndexInList = allIndices.indexOf(course.value.key)
  417. if (currentIndexInList !== -1 && currentIndexInList < allIndices.length - 1) {
  418. const nextIndex = allIndices[currentIndexInList + 1]
  419. handleSelect(nextIndex)
  420. // 切换视频后自动播放
  421. if (videoRef.value) {
  422. videoRef.value.addEventListener('loadedmetadata', tryPlayVideo, {
  423. once: true
  424. })
  425. }
  426. }
  427. // 重置
  428. pausedIndices.value = [];
  429. userMessage.value = ''
  430. messageHistory.value = []
  431. }
  432. // 切换视频
  433. // 播放上一个视频
  434. const playPreviousVideo = () => {
  435. //测试账号禁用视频
  436. if (disableVideo())return;
  437. const allIndices = flattenMenuItems()
  438. const currentIndexInList = allIndices.indexOf(course.value.key)
  439. if (currentIndexInList > 0) {
  440. const previousIndex = allIndices[currentIndexInList - 1]
  441. handleSelect(previousIndex)
  442. // 切换视频后自动播放
  443. if (videoRef.value) {
  444. videoRef.value.addEventListener('loadedmetadata', tryPlayVideo, {
  445. once: true
  446. })
  447. }
  448. }
  449. }
  450. // 尝试播放视频,处理浏览器自动播放限制
  451. const tryPlayVideo = () => {
  452. //测试账号禁用视频
  453. if (disableVideo())return;
  454. const playPromise = videoRef.value.play()
  455. if (playPromise !== undefined) {
  456. playPromise.catch(error => {
  457. console.error('视频播放失败,可能是浏览器自动播放限制:', error)
  458. })
  459. }
  460. player = videojs(videoPlayer.value, {
  461. controls: true,
  462. sources: [
  463. {
  464. src: course.value.courseVideoPath,
  465. type: 'video/mp4'
  466. }
  467. ],
  468. preload:'metadata' // 仅加载元数据,避免预加载整个文件
  469. });
  470. }
  471. // 检查视频播放权限
  472. const checkVideoPermission = () => {
  473. if (disableVideo() || questionDialogVisible.value) {
  474. if (videoRef.value) {
  475. videoRef.value.pause()
  476. }
  477. }
  478. };
  479. //禁用视频
  480. const disableVideo = (index = course.value.key) => {
  481. let dis = ["3-7","3-8","3-9","3-10","3-11","3-12","3-13","4-14","5-15"]
  482. if (localStorage.getItem('userName') === "aiTest" &&
  483. dis.indexOf(index) !== -1) {
  484. if (videoRef.value) {
  485. // 记录当前播放时间
  486. videoRef.value.pause()
  487. // 阻止用户跳转到新的时间点,将播放时间重置为之前的时间
  488. videoRef.value.currentTime = 0;
  489. }
  490. //提示禁用// 显示消息框
  491. Message().notifyWarning('您的账号并未开放此课程!', true);
  492. return true;
  493. }
  494. return false;
  495. }
  496. // 视频 ref
  497. const videoRef = ref(null)
  498. // 记录已经暂停过的时间点索引
  499. let pausedIndices = ref([])
  500. // 试题弹框显示状态
  501. const questionDialogVisible = ref(false)
  502. // 当前显示的试题
  503. const courseConfig = ref({})
  504. // 用户选择的选项
  505. const selectedOption = ref(null)
  506. // AI对话弹出框显示状态
  507. let showAIDialog = ref(false)
  508. // 用户输入的消息
  509. let userMessage = ref('')
  510. // 消息历史记录
  511. let messageHistory = ref([])
  512. // 处理视频时间更新事件
  513. const handleTimeUpdate = () => {
  514. //测试账号禁用视频
  515. if (!videoRef.value) return
  516. const currentTime = parseInt(videoRef.value.currentTime)
  517. if (!course.value.courseConfigList) return
  518. course.value.courseConfigList.forEach(courseCofig => {
  519. //暂停时间
  520. let time = courseCofig.ccTime
  521. // 检查是否到达时间点且还未暂停过
  522. if (currentTime === time && !pausedIndices.value.includes(time) ) {
  523. videoRef.value.pause()
  524. //记录暂停时间
  525. pausedIndices.value.push(currentTime)
  526. // 显示对应的问题
  527. if (courseCofig.ccQuestContent) {
  528. questionDialogVisible.value = true
  529. courseConfig.value = courseCofig
  530. //解析选项
  531. if (courseCofig.ccQuestOption) {
  532. courseConfig.courseQuestion = courseCofig.ccQuestOption.split(',')
  533. }
  534. }
  535. }
  536. })
  537. }
  538. // 视频完成拖动进度条时触发的方法
  539. const handleSeeked = () => {
  540. pausedIndices.value = [];
  541. }
  542. // 关闭试题弹框
  543. const handleCloseQuestionDialog = () => {
  544. questionDialogVisible.value = false
  545. // 继续播放视频
  546. videoRef.value.play()
  547. }
  548. // 提交答案
  549. const handleSubmitAnswer = () => {
  550. // 这里可以添加答案验证逻辑
  551. questionDialogVisible.value = false
  552. // 继续播放视频
  553. videoRef.value.play()
  554. selectedOption.value = null
  555. }
  556. // 发送消息
  557. const sendMessage = async () => {
  558. if (userMessage.value.trim()) {
  559. // 添加用户消息到历史记录
  560. messageHistory.value.push({
  561. type: 'user',
  562. content: userMessage.value
  563. })
  564. // 模拟 AI 回复
  565. const aiResponse = await simulateAIResponse(userMessage.value)
  566. messageHistory.value.push({
  567. type: 'ai',
  568. content: aiResponse
  569. })
  570. // 清空输入框
  571. userMessage.value = ''
  572. }
  573. }
  574. // 处理 AI 助手点击事件
  575. const handleAIClick = () => {
  576. // 清空输入框
  577. messageHistory = ref([])
  578. if (courseConfig.value.ccQuestContent) {
  579. userMessage.value = courseConfig.value.ccQuestContent
  580. sendMessage()
  581. userMessage.value = ''
  582. }
  583. showAIDialog.value = true
  584. }
  585. // 模拟 AI 回复
  586. const simulateAIResponse = question => {
  587. return new Promise(resolve => {
  588. setTimeout(() => {
  589. if (courseConfig.value.ccAiAnswer) {
  590. resolve(courseConfig.value.ccAiAnswer)
  591. return
  592. }
  593. // 若未匹配到自定义回复,给出默认回复
  594. resolve(`您的问题是:${question},这是 AI 的回复示例。`)
  595. }, 1000)
  596. })
  597. }
  598. // 关闭AI对话弹出框
  599. const handleCloseAIDialog = () => {
  600. showAIDialog.value = false
  601. }
  602. // 搜索框
  603. const SearchInput = ref('')
  604. // 添加搜索建议查询方法
  605. const querySearch = (queryString, cb) => {
  606. const sections = getAllCourseSections();
  607. const results = queryString
  608. ? sections.filter(section =>
  609. section.title.toLowerCase().includes(queryString.toLowerCase())
  610. )
  611. : sections;
  612. cb(results);
  613. };
  614. const filteredTitles = computed(() => {
  615. const sections = getAllCourseSections();
  616. if (!SearchInput.value) {
  617. return sections;
  618. }
  619. return sections.filter(section =>
  620. section.title.toLowerCase().includes(SearchInput.value.toLowerCase())
  621. );
  622. });
  623. const handleSearchSelect = (item) => {
  624. handleSelect(item.key);
  625. // 添加以下代码清空输入框
  626. SearchInput.value = '';
  627. };
  628. // 添加课程小节数据提取方法
  629. const getAllCourseSections = () => {
  630. let sections = [];
  631. const traverse = (items) => {
  632. items.forEach(item => {
  633. if (item.children) {
  634. traverse(item.children);
  635. } else {
  636. sections.push({ title: item.title, key: item.key });
  637. }
  638. });
  639. };
  640. traverse(menuItems.value);
  641. return sections;
  642. };
  643. </script>
  644. <style scoped lang="scss">
  645. @use 'sass:math';
  646. @use 'sass:color'; // 引入 color 模块
  647. // 定义rpx转换函数
  648. @function rpx($px) {
  649. @return math.div($px, 750) * 100vw;
  650. }
  651. // 定义儿童风格的蓝紫色调
  652. $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
  653. $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
  654. $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
  655. $light-color: #ffffff; // 浅色背景:淡紫色
  656. $text-color: #483d8b; // 文本颜色:靛蓝色
  657. /* 添加过渡样式 */
  658. .drawer-slide-enter-active,
  659. .drawer-slide-leave-active {
  660. transition: all 0.3s ease;
  661. }
  662. .drawer-slide-enter-from,
  663. .drawer-slide-leave-to {
  664. transform: translateX(-100%);
  665. opacity: 0;
  666. }
  667. .home-container ::v-deep(.el-drawer__body) {
  668. width: rpx(135);
  669. height: 100%;
  670. position: relative;
  671. background: linear-gradient(to bottom, #001169, #8a78d0);
  672. }
  673. .content-box {
  674. flex: 1;
  675. height: 100%;
  676. display: flex;
  677. flex-direction: column; /* 子元素上下排列 */
  678. background: linear-gradient(to bottom, #001169, #8a78d0);
  679. }
  680. .icon-expand {
  681. width: rpx(8);
  682. height: rpx(35);
  683. border-top-right-radius: rpx(5);
  684. border-bottom-right-radius: rpx(5);
  685. z-index: 9999;
  686. position: absolute;
  687. top: 50%;
  688. left: 18%;
  689. transform: translateY(-50%);
  690. cursor: pointer; // 添加鼠标指针样式
  691. clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  692. display: flex;
  693. justify-content: center;
  694. align-items: center;
  695. transition: all 0.3s ease;
  696. }
  697. .icon-expand .vertical-lines {
  698. color: #8a78d0;
  699. font-size: rpx(10);
  700. }
  701. .home-container {
  702. position: fixed;
  703. top: 0;
  704. left: 0;
  705. right: 0;
  706. bottom: 0;
  707. background: linear-gradient(to bottom, #001169, #b4a8e1);
  708. display: flex;
  709. }
  710. .el-row {
  711. margin: auto;
  712. margin-top: rpx(20);
  713. }
  714. .tac ::v-deep(.el-menu) {
  715. background-color: transparent;
  716. border: none;
  717. width: 100%;
  718. margin-top: rpx(8);
  719. }
  720. /* 取消点击后的蓝色字体 el-sub-menu__title*/
  721. .tac ::v-deep(.el-menu-item.is-active),
  722. .tac ::v-deep(.el-sub-menu__title.is-active) {
  723. color: white;
  724. }
  725. // 取消鼠标悬浮颜色
  726. .tac ::v-deep(.el-sub-menu__title) {
  727. width: rpx(130);
  728. height: rpx(20);
  729. margin-bottom: rpx(5);
  730. border-radius: rpx(6);
  731. // 添加flex布局使标题和图标两端对齐
  732. display: flex;
  733. justify-content: space-between;
  734. align-items: center;
  735. }
  736. .el-menu ::v-deep(.el-sub-menu__title:hover),
  737. .el-menu ::v-deep(.el-sub-menu__title:focus),
  738. .el-menu ::v-deep(.el-sub-menu__title:active) {
  739. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  740. background-color: transparent;
  741. }
  742. // 添加二级标题折叠图标样式
  743. ::v-deep(.el-sub-menu__icon-arrow) {
  744. color: white;
  745. font-size: rpx(10); // 增大图标尺寸
  746. margin-left: auto; // 将图标推到右侧
  747. margin-top: rpx(-5);
  748. display: block;
  749. width: rpx(16); // 确保有明确宽度
  750. }
  751. // 鼠标悬停时的图标样式
  752. .el-menu ::v-deep(.el-sub-menu__title:hover .el-sub-menu__icon-arrow) {
  753. color: black; // 与悬停状态的文字颜色保持一致
  754. }
  755. .el-menu ::v-deep(.el-icon svg) {
  756. font-size: rpx(9);
  757. }
  758. .mb-2 {
  759. color: white;
  760. font-size: rpx(9);
  761. }
  762. .mb-2 img {
  763. width: rpx(10);
  764. height: rpx(10);
  765. vertical-align: middle;
  766. margin-top: rpx(-2);
  767. }
  768. .el-menu-item {
  769. width: rpx(100);
  770. height: rpx(20);
  771. margin-bottom: rpx(5);
  772. border-radius: rpx(6);
  773. color: white;
  774. font-size: rpx(8);
  775. }
  776. .el-menu ::v-deep(.el-sub-menu__title) {
  777. color: white;
  778. width: rpx(100);
  779. height: rpx(20);
  780. margin-bottom: rpx(5);
  781. font-size: rpx(8);
  782. }
  783. .el-menu ::v-deep(.el-sub-menu__title:hover),
  784. .el-menu ::v-deep(.el-sub-menu__title:focus),
  785. .el-menu ::v-deep(.el-sub-menu__title:active) {
  786. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  787. color: black;
  788. }
  789. .el-menu ::v-deep(.el-menu-item:hover),
  790. .el-menu ::v-deep(.el-menu-item:focus),
  791. .el-menu ::v-deep(.el-menu-item:active) {
  792. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  793. color: black;
  794. font-size: rpx(8);
  795. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  796. }
  797. .el-menu .el-menu-item.is-active {
  798. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  799. color: black;
  800. font-size: rpx(8);
  801. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  802. }
  803. .drawer-box {
  804. position: absolute;
  805. display: flex;
  806. align-items: center;
  807. height: 100%;
  808. width: 80%;
  809. }
  810. .drawer-box .toggle-button {
  811. width: rpx(10);
  812. height: rpx(50);
  813. font-size: rpx(7);
  814. background-color: rgba(17, 23, 29, 0.2);
  815. border: none;
  816. position: relative;
  817. writing-mode: vertical-lr; // 文字垂直排列,从左到右
  818. text-orientation: upright; // 文字保持正立
  819. }
  820. .toggle-button:hover {
  821. left: 0;
  822. }
  823. .toggle-button.is-active,
  824. .toggle-button:active,
  825. .toggle-button:focus {
  826. background-color: rgba(165, 209, 247, 0.8);
  827. color: white;
  828. border: none; // 移除点击时的边框
  829. outline: none; // 移除点击时的外边框
  830. }
  831. .box-1 {
  832. width: 100%;
  833. height: rpx(50);
  834. margin-top: rpx(10);
  835. display: flex;
  836. justify-content: center;
  837. align-items: center;
  838. box-sizing: border-box;
  839. font-size: rpx(15); // 默认字体大小
  840. }
  841. .inner-box {
  842. height: 100%;
  843. display: flex;
  844. justify-content: center;
  845. align-items: center;
  846. font-size: rpx(16); // 默认字体大小
  847. }
  848. .left-box {
  849. position: relative;
  850. justify-content: flex-start;
  851. align-items: flex-start;
  852. flex: 1; // 设置左侧盒子占比为 2
  853. cursor: pointer; // 添加鼠标指针样式
  854. }
  855. .box-icon {
  856. width: 100%;
  857. height: 100%;
  858. flex: 1;
  859. display: flex; // 添加 flex 布局
  860. align-items: center; // 垂直居中
  861. color: white; // 设置图标颜色为白色
  862. padding-left: rpx(15);
  863. font-size: rpx(10); // 设置图标大小,可按需调整
  864. }
  865. .box-icon .left-icon {
  866. margin-left: rpx(10);
  867. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  868. }
  869. .left-box span {
  870. position: absolute;
  871. font-size: rpx(11); // 默认字体大小
  872. color: white;
  873. }
  874. .right-box {
  875. flex: 1;
  876. position: relative; // 添加相对定位;
  877. }
  878. .top-right-box {
  879. position: absolute; // 添加绝对定位
  880. // margin-top: rpx(9); // 调整上边距离
  881. margin-left: rpx(260); // 调整右边距离
  882. width: rpx(100); // 设置盒子宽度,可按需调整
  883. // height: 60px; // 设置盒子高度,可按需调整
  884. display: flex;
  885. justify-content: flex-end;
  886. }
  887. .top-right-box {
  888. ::v-deep(.el-input__wrapper) {
  889. height: rpx(15);
  890. font-size: rpx(6);
  891. background-color: rgb(255, 255, 255, 0.5);
  892. border-radius: rpx(12);
  893. border: white 1px solid;
  894. color: white;
  895. }
  896. ::v-deep(.el-input__icon) {
  897. color: white; // 设置输入框图标颜色为白色
  898. }
  899. // 添加占位符样式
  900. ::v-deep(.el-input__inner::placeholder) {
  901. color: white;
  902. }
  903. // 添加输入框文字颜色样式
  904. ::v-deep(.el-input__inner) {
  905. color: black;
  906. }
  907. }
  908. // 搜索框
  909. .search-input {
  910. width: rpx(100);
  911. height: rpx(15);
  912. font-size: rpx(7);
  913. }
  914. .box-2 {
  915. width: 100%;
  916. flex: 1;
  917. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  918. box-sizing: border-box;
  919. display: flex; // 确保子元素水平排列
  920. flex-wrap: wrap; // 允许子元素换行;
  921. align-content: center; // 顶部对齐;
  922. cursor: pointer; // 添加鼠标指针样式
  923. }
  924. .box-video {
  925. width: 100%;
  926. height: rpx(300);
  927. video.full-box-video {
  928. height: rpx(280);
  929. width: 67%;
  930. margin: 0 auto;
  931. border-radius: rpx(12);
  932. object-fit: cover;
  933. }
  934. }
  935. /* 隐藏 Chrome 视频控件的渐变背景等默认样式 */
  936. video::-webkit-media-controls-panel {
  937. background: transparent !important; /* 去掉背景渐变,设为透明 */
  938. }
  939. .small-title {
  940. width: 100%;
  941. margin-top: rpx(-20);
  942. height: rpx(20);
  943. color: white;
  944. font-size: rpx(10);
  945. justify-content: center; //使子元素水平居中
  946. }
  947. .video-switch {
  948. width: 100%;
  949. // height: rpx(50);
  950. display: flex;
  951. margin-top: rpx(-20);
  952. // background-color: saddlebrown;
  953. }
  954. .caret-right,
  955. .caret-left {
  956. width: rpx(50);
  957. margin: auto;
  958. display: flex;
  959. margin-top: rpx(5);
  960. margin-bottom: rpx(15);
  961. }
  962. .caret-left ::v-deep(.el-button.is-round),
  963. .caret-right ::v-deep(.el-button.is-round) {
  964. width: rpx(50);
  965. height: rpx(15);
  966. color: white;
  967. font-size: rpx(7);
  968. border-radius: none;
  969. border: 1px white solid;
  970. background-color: rgb(255, 255, 255, 0.5); // 进度条背景颜色,调浅为半透明白色
  971. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  972. }
  973. .caret-right img,
  974. .caret-left img {
  975. width: rpx(12);
  976. }
  977. // 儿童风格试题弹框样式
  978. .child-dialog {
  979. .el-dialog__header {
  980. display: none; // 隐藏原有的标题栏
  981. }
  982. .el-dialog__body {
  983. padding: rpx(20);
  984. position: relative;
  985. }
  986. .el-dialog__footer {
  987. border-top: none;
  988. padding: rpx(10) rpx(20);
  989. text-align: center;
  990. margin-top: auto; // 使底部按钮位于底部
  991. }
  992. .el-dialog__wrapper {
  993. // 修改半透明背景色
  994. background-color: rgba(0, 0, 0, 0.6);
  995. }
  996. .el-dialog {
  997. border: none;
  998. border-radius: rpx(20);
  999. background: linear-gradient(
  1000. 135deg,
  1001. $light-color,
  1002. #d8bfd8
  1003. ); // 柔和的蓝紫色渐变
  1004. overflow: hidden;
  1005. display: flex; // 添加 flex 布局
  1006. flex-direction: column; // 设置垂直布局
  1007. min-height: 0; // 防止子元素溢出
  1008. // 添加装饰元素
  1009. &::before {
  1010. content: '';
  1011. position: absolute;
  1012. top: 0;
  1013. left: 0;
  1014. width: 100%;
  1015. height: rpx(10);
  1016. background: linear-gradient(90deg, $secondary-color, $accent-color);
  1017. }
  1018. }
  1019. }
  1020. // 问题标题样式
  1021. .question-title {
  1022. padding: rpx(15);
  1023. border-radius: rpx(12);
  1024. margin-bottom: rpx(20);
  1025. color: #483d8b;
  1026. font-weight: bold;
  1027. font-size: rpx(12);
  1028. position: relative;
  1029. display: flex;
  1030. // align-items: center;
  1031. .question-icon {
  1032. background-color: $accent-color;
  1033. color: white;
  1034. width: rpx(24);
  1035. height: rpx(24);
  1036. border-radius: 50%;
  1037. display: flex;
  1038. align-items: center;
  1039. justify-content: center;
  1040. margin-right: rpx(10);
  1041. font-weight: bold;
  1042. box-shadow: 0 rpx(2) rpx(5) rgba($accent-color, 0.3);
  1043. }
  1044. }
  1045. // 选项容器样式
  1046. .options-container {
  1047. margin-bottom: rpx(20);
  1048. }
  1049. // 问题选项样式
  1050. .question-option {
  1051. margin: rpx(8) 0;
  1052. padding: rpx(10) rpx(15);
  1053. border-radius: rpx(12);
  1054. border: rpx(1) solid rgba($primary-color, 0.3);
  1055. transition: all 0.3s ease;
  1056. display: flex;
  1057. align-items: center;
  1058. background-color: white;
  1059. box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.05);
  1060. ::v-deep(.el-radio__label) {
  1061. color: $text-color;
  1062. margin-left: rpx(8);
  1063. flex: 1;
  1064. text-align: left;
  1065. // 增大字体大小
  1066. font-size: rpx(12);
  1067. }
  1068. // 选中时的样式变化
  1069. .el-radio__input.is-checked + .el-radio__label {
  1070. font-weight: bold;
  1071. color: $accent-color;
  1072. }
  1073. &:hover {
  1074. background-color: rgba($primary-color, 0.05);
  1075. border-color: rgba($primary-color, 0.5);
  1076. transform: translateY(-rpx(1));
  1077. }
  1078. }
  1079. // 暂无选项样式
  1080. .no-options {
  1081. color: rgba($text-color, 0.7);
  1082. text-align: center;
  1083. padding: rpx(20);
  1084. font-size: rpx(12);
  1085. }
  1086. // 底部按钮样式
  1087. .child-button {
  1088. min-width: rpx(80);
  1089. height: rpx(30);
  1090. border-radius: rpx(8);
  1091. font-size: rpx(12);
  1092. font-weight: 500;
  1093. transition: all 0.3s ease;
  1094. box-shadow: 0 rpx(2) rpx(8) rgba(0, 0, 0, 0.1);
  1095. &.confirm {
  1096. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  1097. border: none;
  1098. border-right: 15px;
  1099. color: white;
  1100. &:hover {
  1101. background: linear-gradient(
  1102. to bottom,
  1103. color.adjust(#ab81ff, $lightness: -5%),
  1104. color.adjust(#8559dc, $lightness: -5%)
  1105. );
  1106. transform: translateY(-rpx(1));
  1107. color: white;
  1108. }
  1109. }
  1110. &.cancel {
  1111. background: white;
  1112. border: rpx(1) solid rgba($primary-color, 0.3);
  1113. color: $text-color;
  1114. &:hover {
  1115. background: rgba($primary-color, 0.05);
  1116. border-color: rgba($primary-color, 0.5);
  1117. transform: translateY(-rpx(1));
  1118. }
  1119. }
  1120. }
  1121. // AI对话图标样式
  1122. .ai-icon-container {
  1123. position: absolute;
  1124. bottom: rpx(20);
  1125. right: rpx(20);
  1126. display: flex;
  1127. flex-direction: column;
  1128. align-items: center;
  1129. cursor: pointer;
  1130. transition: all 0.3s ease;
  1131. &:hover {
  1132. transform: translateY(-rpx(2));
  1133. }
  1134. .ai-icon {
  1135. width: rpx(30);
  1136. height: rpx(30);
  1137. margin-bottom: rpx(0);
  1138. filter: drop-shadow(0 rpx(2) rpx(4) rgba($primary-color, 0.3));
  1139. // 添加过渡动画
  1140. transition: transform 0.3s ease;
  1141. }
  1142. // 悬浮时放大效果
  1143. .ai-icon:hover {
  1144. transform: scale(1.5);
  1145. }
  1146. .ai-text {
  1147. color: $text-color;
  1148. font-size: rpx(8);
  1149. background-color: rgba(255, 255, 255, 0.7);
  1150. padding: rpx(2) rpx(5);
  1151. border-radius: rpx(5);
  1152. }
  1153. }
  1154. // AI消息样式
  1155. .ai-message {
  1156. display: flex;
  1157. align-items: flex-start;
  1158. margin-bottom: rpx(15);
  1159. .ai-avatar {
  1160. width: rpx(30);
  1161. height: rpx(30);
  1162. border-radius: 50%;
  1163. margin-right: rpx(10);
  1164. background-color: $primary-color;
  1165. padding: rpx(5);
  1166. // box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.2);
  1167. }
  1168. .ai-text-content {
  1169. background-color: $light-color;
  1170. padding: rpx(8) rpx(12);
  1171. border-radius: rpx(10);
  1172. font-size: rpx(10);
  1173. color: $text-color;
  1174. max-width: 80%;
  1175. // box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1176. }
  1177. }
  1178. // 用户输入框样式
  1179. .user-input {
  1180. ::v-deep(.el-input__wrapper) {
  1181. height: rpx(23);
  1182. border-top-left-radius: rpx(5);
  1183. border-bottom-left-radius: rpx(5);
  1184. border-color: rgba($primary-color, 0.3);
  1185. &:focus-within {
  1186. box-shadow: 0 0 0 rpx(1) rgba($primary-color, 0.5);
  1187. }
  1188. }
  1189. ::v-deep(.el-input__inner) {
  1190. font-size: rpx(10);
  1191. // color: $text-color;
  1192. text-indent: 1em;
  1193. }
  1194. ::v-deep(.el-input-group__append, .el-input-group__prepend) {
  1195. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  1196. border-top-right-radius: rpx(5);
  1197. border-bottom-right-radius: rpx(5);
  1198. color: white;
  1199. font-size: rpx(9);
  1200. }
  1201. }
  1202. /* 定义淡入和缩放动画 */
  1203. .fade-scale-enter-active,
  1204. .fade-scale-leave-active {
  1205. transition: all 0.5s ease;
  1206. }
  1207. .fade-scale-enter-from,
  1208. .fade-scale-leave-to {
  1209. opacity: 0.1;
  1210. transform: scale(0.9);
  1211. }
  1212. // 自定义试题弹框背景
  1213. .child-dialog-wrapper {
  1214. position: fixed;
  1215. top: 0;
  1216. left: 0;
  1217. right: 0;
  1218. bottom: 0;
  1219. background-color: rgba(0, 0, 0, 0.6); // 半透明背景
  1220. display: flex;
  1221. justify-content: center;
  1222. align-items: center;
  1223. z-index: 1000;
  1224. }
  1225. .child-dialog {
  1226. border: none;
  1227. border-radius: rpx(15);
  1228. background: rgb(255, 255, 255, 0.8); // 柔和的蓝紫色渐变
  1229. overflow: hidden;
  1230. padding: rpx(15);
  1231. width: 40%;
  1232. // height: 60%;
  1233. position: relative;
  1234. }
  1235. // AI对话弹框样式
  1236. .ai-dialog-wrapper {
  1237. position: fixed;
  1238. top: 0;
  1239. left: 0;
  1240. right: 0;
  1241. bottom: 0;
  1242. display: flex;
  1243. justify-content: flex-end;
  1244. align-items: center;
  1245. z-index: 1001;
  1246. pointer-events: none;
  1247. }
  1248. .ai-dialog {
  1249. border: none;
  1250. border-radius: rpx(15);
  1251. background: rgb(255, 255, 255, 0.8);
  1252. overflow: hidden;
  1253. padding: rpx(20);
  1254. width: 30%;
  1255. // 增加高度
  1256. height: 80%;
  1257. margin-right: rpx(50);
  1258. pointer-events: auto;
  1259. position: relative;
  1260. display: flex;
  1261. flex-direction: column;
  1262. &::before {
  1263. content: '';
  1264. position: absolute;
  1265. top: 0;
  1266. left: 0;
  1267. width: 100%;
  1268. height: rpx(10);
  1269. }
  1270. }
  1271. .ai-dialog-header {
  1272. position: relative;
  1273. display: flex;
  1274. justify-content: center;
  1275. align-items: center;
  1276. margin-bottom: rpx(15);
  1277. margin-top: rpx(-10);
  1278. img {
  1279. width: rpx(15);
  1280. }
  1281. h3 {
  1282. color: black;
  1283. font-size: rpx(12);
  1284. }
  1285. .close-btn {
  1286. padding: 0;
  1287. width: rpx(20);
  1288. height: rpx(20);
  1289. font-size: rpx(16);
  1290. line-height: 1;
  1291. position: absolute;
  1292. background-color: transparent;
  1293. border: none;
  1294. margin-left: rpx(200);
  1295. }
  1296. }
  1297. .ai-dialog-content {
  1298. flex: 1;
  1299. display: flex;
  1300. flex-direction: column;
  1301. }
  1302. .ai-message-history {
  1303. flex: 1;
  1304. // 当内容超出容器高度时,显示垂直滚动条
  1305. overflow-y: auto;
  1306. margin-bottom: rpx(15);
  1307. // 可以根据实际情况调整最大高度
  1308. max-height: 50vh;
  1309. // padding: 5px 10px;
  1310. .message {
  1311. display: flex;
  1312. align-items: flex-start;
  1313. margin-bottom: rpx(10);
  1314. &.user {
  1315. flex-direction: row-reverse;
  1316. }
  1317. .avatar {
  1318. width: rpx(30);
  1319. height: rpx(30);
  1320. border-radius: 50%;
  1321. margin: 0 rpx(10);
  1322. }
  1323. .user {
  1324. width: 15px;
  1325. height: 15px;
  1326. }
  1327. .message-content {
  1328. background-color: #ffffff;
  1329. font-size: rpx(10);
  1330. max-width: 80%;
  1331. color: black;
  1332. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1333. }
  1334. }
  1335. // 滚动条整体样式
  1336. &::-webkit-scrollbar {
  1337. width: rpx(4); // 滚动条宽度
  1338. }
  1339. // 滚动条滑块样式
  1340. &::-webkit-scrollbar-thumb {
  1341. background-color: $primary-color; // 滑块颜色
  1342. border-radius: rpx(4); // 滑块圆角
  1343. transition: background-color 0.3s ease; // 颜色过渡效果
  1344. &:hover {
  1345. //background-color: darken($primary-color, 10%); // 悬停时滑块颜色加深
  1346. }
  1347. }
  1348. // 滚动条轨道样式
  1349. &::-webkit-scrollbar-track {
  1350. background-color: rgba($primary-color, 0.2); // 轨道颜色
  1351. border-radius: rpx(4); // 轨道圆角
  1352. }
  1353. .message {
  1354. display: flex;
  1355. align-items: flex-start;
  1356. margin-bottom: rpx(10);
  1357. &.user {
  1358. flex-direction: row-reverse;
  1359. }
  1360. .avatar {
  1361. width: rpx(30);
  1362. height: rpx(30);
  1363. border-radius: 50%;
  1364. margin: 0 rpx(10);
  1365. }
  1366. .message-content {
  1367. background-color: white;
  1368. padding: rpx(8) rpx(12);
  1369. border-radius: rpx(5);
  1370. font-size: rpx(10);
  1371. color: black;
  1372. max-width: 80%;
  1373. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1374. }
  1375. }
  1376. }
  1377. // 优化发送按钮样式
  1378. .send-button {
  1379. //background: linear-gradient(90deg, $primary-color, $secondary-color);
  1380. border: none;
  1381. color: white;
  1382. &:hover {
  1383. //background: linear-gradient(90deg, darken($primary-color, 5%), darken($secondary-color, 5%));
  1384. }
  1385. }
  1386. </style>
  1387. <style lang="scss">
  1388. // 搜索下拉框样式
  1389. @use 'sass:math';
  1390. // 定义rpx转换函数
  1391. @function rpx($px) {
  1392. @return math.div($px, 750) * 100vw;
  1393. }
  1394. /* 消除小三角 */
  1395. .el-popper__arrow {
  1396. display: none;
  1397. }
  1398. .el-popper.is-light,
  1399. .el-dropdown__popper.el-popper {
  1400. background: transparent;
  1401. border: none;
  1402. box-shadow: none;
  1403. }
  1404. .el-dropdown__popper {
  1405. --el-dropdown-menuItem-hover-color: none;
  1406. }
  1407. .el-autocomplete-suggestion .el-scrollbar__wrap {
  1408. margin: 0 auto;
  1409. background-color: rgba(255, 255, 255, 0.7);
  1410. border: 2px solid white;
  1411. border-radius: rpx(5);
  1412. backdrop-filter: blur(rpx(5));
  1413. }
  1414. .el-autocomplete-suggestion li {
  1415. color: black;
  1416. font-size: rpx(7);
  1417. padding: rpx(5) rpx(8); // 调整下拉项内边距
  1418. }
  1419. .el-autocomplete-suggestion li:hover {
  1420. background: linear-gradient(to bottom, #ffefb0, #ffcc00);
  1421. }
  1422. </style>