AIDevelop.vue 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181
  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','5']"
  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" @play="checkVideoPermission" :controlsList="[nodownload]"-->
  101. <div class="small-title">
  102. <span>{{ course.courseName }}</span>
  103. </div>
  104. <div class="box-video">
  105. <Vue3VideoPlay
  106. class="full-box-video"
  107. :src="course.courseVideoPath"
  108. :controls="false"
  109. @timeupdate="handleTimeUpdate"
  110. @seeked="handleSeeked"
  111. @ended="handleVideoEnded"
  112. ref="videoRef"
  113. />
  114. </div>
  115. <!-- 添加切换视频 -->
  116. <div class="video-switch">
  117. <!-- 上一个视频 -->
  118. <div class="caret-left" @click="playPreviousVideo">
  119. <el-button type="warning" round>
  120. <img :src="leftImg" alt="Left" />
  121. 上一节</el-button
  122. >
  123. </div>
  124. <!-- 下一个视频 -->
  125. <div class="caret-right" @click="playNextVideo">
  126. <el-button type="warning" round
  127. >下一节
  128. <img :src="rightImg" alt="Right" />
  129. </el-button>
  130. </div>
  131. </div>
  132. </div>
  133. <!-- 添加试题弹框 -->
  134. <transition name="fade-scale">
  135. <div
  136. v-show="questionDialogVisible"
  137. class="child-dialog-wrapper"
  138. @click.self="handleCloseQuestionDialog"
  139. >
  140. <div class="child-dialog">
  141. <div class="question-title">
  142. <span class="question-icon">?</span>
  143. <span v-html="courseConfig.ccQuestContent"></span>
  144. </div>
  145. <!-- 选项区域 -->
  146. <div
  147. v-if="
  148. courseConfig.ccQuestOption &&
  149. courseConfig.ccQuestOption.length > 0
  150. "
  151. class="options-container"
  152. >
  153. <div
  154. v-for="(option, index) in courseConfig.ccQuestOption"
  155. :key="index"
  156. class="question-option"
  157. >
  158. <el-radio
  159. v-model="selectedOption"
  160. :label="index"
  161. :value="option"
  162. v-cloak="(selectedOption = option)"
  163. >
  164. <span>{{ option }}</span>
  165. </el-radio>
  166. </div>
  167. </div>
  168. <div v-else class="no-options">
  169. <!-- 暂无选项 -->
  170. </div>
  171. <!-- 底部按钮 -->
  172. <div class="dialog-footer">
  173. <!-- <el-button class="child-button cancel" @click="questionDialogVisible = false; showAIDialog = false">取消</el-button>-->
  174. <el-button
  175. class="child-button confirm"
  176. @click="handleSubmitAnswer"
  177. >确定</el-button
  178. >
  179. </div>
  180. <!-- 右侧小图标 -->
  181. <div
  182. v-if="courseConfig.ccAiAnswer !== null"
  183. class="ai-icon-container"
  184. @click="handleAIClick"
  185. >
  186. <img
  187. src="@/assets/images/xiaozhi.png"
  188. alt="AI对话"
  189. class="ai-icon"
  190. />
  191. <span class="ai-text">小智智能助手</span>
  192. </div>
  193. </div>
  194. </div>
  195. </transition>
  196. <!-- AI对话弹框 -->
  197. <div
  198. v-show="showAIDialog"
  199. class="ai-dialog-wrapper"
  200. @click.self="showAIDialog = false"
  201. >
  202. <div class="ai-dialog">
  203. <div class="ai-dialog-header">
  204. <h3>
  205. <img :src="auto" alt="" />
  206. 小智智能助手
  207. </h3>
  208. <el-button @click="showAIDialog = false" class="close-btn"
  209. >×</el-button
  210. >
  211. </div>
  212. <div class="ai-dialog-content">
  213. <div class="ai-message-history">
  214. <div
  215. v-for="(message, index) in messageList"
  216. :key="index"
  217. :class="['message', message.type]"
  218. >
  219. <img
  220. v-if="message.type === 'user'"
  221. src="@/assets/images/user.png"
  222. class="avatar user"
  223. />
  224. <img v-else src="@/assets/images/xiaozhi.png" class="avatar" />
  225. <div
  226. class="message-content"
  227. v-if="message.type === 'user'"
  228. v-html="message.content"
  229. ></div>
  230. <div class="message-content" v-else>
  231. <MarkdownView class="left-text" :content="message.content" />
  232. </div>
  233. </div>
  234. </div>
  235. <!-- 弹框默认消息 -->
  236. <DefaultMessage
  237. class="default-messages"
  238. :category="'ai_develop'"
  239. :questTip="
  240. course.courseConfigList && course.courseConfigList[0]
  241. ? course.courseConfigList[0].ccAiQuestTip
  242. : ''
  243. "
  244. @select-message="handleSelectMessage"
  245. />
  246. <el-input
  247. v-model="prompt"
  248. placeholder="输入问题..."
  249. class="user-input"
  250. @keyup.enter="handleSendByKeydown"
  251. >
  252. <template #append class="flex flex-wrap items-center mb-4">
  253. <el-button @click="handleSendByButton" size="large" round
  254. >发送</el-button
  255. >
  256. </template>
  257. </el-input>
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. </template>
  264. <script setup>
  265. import { ref, onMounted, onUnmounted, onBeforeUnmount, computed } from 'vue'
  266. import { useRoute, useRouter } from 'vue-router'
  267. // import videojs from 'video.js'
  268. // import 'video.js/dist/video-js.css'
  269. import '@videojs/http-streaming' // 支持HLS分片
  270. import "vue3-video-play/dist/style.css";
  271. import { videoPlay as Vue3VideoPlay } from "vue3-video-play";
  272. // 导入hls.js以支持m3u8格式
  273. import Hls from 'hls.js'
  274. const videoPlayer = ref(null)
  275. let player = null
  276. import { Expand, Fold, Memo } from '@element-plus/icons-vue'
  277. import { Search, ArrowLeftBold } from '@element-plus/icons-vue'
  278. import {
  279. ElMessage,
  280. ElMessageBox,
  281. ElNotification,
  282. valueEquals
  283. } from 'element-plus'
  284. import classImages from '@/assets/icon/class.png'
  285. import leftImg from '@/assets/icon/backward.png'
  286. import rightImg from '@/assets/icon/f-backward.png'
  287. import auto from '@/assets/icon/auto_awesome.png'
  288. import { ClassType } from '@/api/class.js'
  289. import { Message } from '@/utils/message/Message.js'
  290. import { saveRecord } from '@/api/personalized/index.js'
  291. import DefaultMessage from '@/components/DefaultMessage/index.vue'
  292. import { CreateDialogue, sendChatMessageStream } from '@/api/questions.js'
  293. import { teacherList } from '@/api/teachers.js'
  294. import MarkdownView from '@/components/MarkdownView/index.vue'
  295. // 导入全局状态
  296. import { globalState } from '@/utils/globalState.js'
  297. // 处理选择的默认消息
  298. const handleSelectMessage = message => {
  299. prompt.value = message
  300. }
  301. const router = useRouter() // 获取当前路由对象
  302. // 添加按钮显示状态
  303. const buttonVisible = ref(false)
  304. // 添加抽屉显示状态
  305. const drawerVisible = ref(false)
  306. // 添加切换抽屉显示状态的函数
  307. const toggleDrawer = () => {
  308. drawerVisible.value = !drawerVisible.value
  309. }
  310. // 返回上一页
  311. const goBack = () => {
  312. router.go(-1)
  313. }
  314. // 渲染页面标题
  315. const boxIconTitle = ref('')
  316. // 课程集合数据
  317. const courseList = ref([])
  318. //当前课程
  319. const course = ref({})
  320. // 菜单数据
  321. const menuItems = ref([])
  322. // 课程集合数据
  323. const videoPathMap = ref({})
  324. // 已观看课程ID列表
  325. const watchedCourseIds = ref([])
  326. //课程小节字典(需要新加接口调取字典)
  327. const menuDict = ref({
  328. 1: '课前回顾',
  329. 2: '课程引入',
  330. 3: '知识讲解',
  331. 4: '趣味实操',
  332. 5: '课程总结'
  333. })
  334. // 渲染 课程数据结构 以及 视频
  335. onMounted(async () => {
  336. const typeId = router.currentRoute.value.query.typeId
  337. if (typeId) {
  338. try {
  339. // 取接口课程数据
  340. const res = await ClassType(typeId)
  341. console.log(res);
  342. courseList.value = res.data
  343. // 初始化已观看课程ID
  344. const savedWatchedIds = localStorage.getItem('watchedCourseIds')
  345. if (savedWatchedIds) {
  346. watchedCourseIds.value = JSON.parse(savedWatchedIds)
  347. }
  348. //课程数据
  349. let topName = '';
  350. courseList.value.forEach((courseTemp, index) => {
  351. let menuIndex = courseTemp.courseLabel + '-' + (index + 1)
  352. //大节
  353. let menu = {
  354. key: menuIndex,
  355. index: menuIndex,
  356. title: courseTemp.courseName
  357. }
  358. if (topName === courseTemp.courseLabel) {
  359. let topMenu = menuItems.value[menuItems.value.length - 1]
  360. let topMenuChildren = topMenu.children;
  361. if (topMenuChildren) {
  362. topMenuChildren.push(menu)
  363. } else {
  364. menu = {
  365. key: menuIndex,
  366. index: menuIndex,
  367. title: menuDict.value[courseTemp.courseLabel],
  368. children: [
  369. {
  370. key: topMenu.key,
  371. index: topMenu.index,
  372. title: topMenu.title,
  373. },
  374. {
  375. key: menuIndex,
  376. index: menuIndex,
  377. title: courseTemp.courseName
  378. }
  379. ]
  380. }
  381. menuItems.value[menuItems.value.length-1] = menu
  382. }
  383. }else{
  384. menuItems.value.push(menu)
  385. }
  386. topName = courseTemp.courseLabel
  387. courseTemp['key'] = menuIndex
  388. videoPathMap.value[menuIndex] = courseTemp
  389. //确定默认课程
  390. if (index === 0) {
  391. course.value = courseTemp
  392. }
  393. })
  394. } catch (error) {
  395. console.error('获取课程数据失败:', error)
  396. }
  397. }
  398. const title = router.currentRoute.value.query.typeName
  399. if (title) {
  400. boxIconTitle.value = String(title)
  401. }
  402. // // 在视频元素上添加时间更新事件监听
  403. // if (videoRef.value) {
  404. // videoRef.value.addEventListener('timeupdate', handleTimeUpdate)
  405. // }
  406. })
  407. onBeforeUnmount(() => {
  408. if (player) {
  409. player.dispose()
  410. player = null
  411. }
  412. if (hlsRef.value) {
  413. hlsRef.value.destroy()
  414. hlsRef.value = null
  415. }
  416. })
  417. // 菜单打开和关闭的处理函数
  418. const handleOpen = () => {}
  419. const handleClose = () => {}
  420. // 菜单选择的处理函数
  421. const handleSelect = index => {
  422. //测试账号禁用视频
  423. if (disableVideo(index)) return
  424. const findTitle = items => {
  425. for (const item of items) {
  426. if (item.key === index) {
  427. return item.title
  428. }
  429. if (item.children) {
  430. const result = findTitle(item.children)
  431. if (result) {
  432. return result
  433. }
  434. }
  435. }
  436. return null
  437. }
  438. // 根据索引切换视频,使用新的 videoPathMap
  439. if (videoPathMap.value[index]) {
  440. course.value = videoPathMap.value[index]
  441. courseId.value = course.value.id
  442. // 切换标题后,关闭抽屉
  443. drawerVisible.value = false
  444. } else {
  445. //视频不存在
  446. Message().notifyWarning('视频不存在!', true)
  447. }
  448. //测试账号禁用视频
  449. if (disableVideo()) return
  450. }
  451. // 展平所有菜单项索引
  452. const flattenMenuItems = () => {
  453. const indices = []
  454. const traverse = items => {
  455. for (const item of items) {
  456. if (!item.children) {
  457. indices.push(item.key)
  458. } else {
  459. traverse(item.children)
  460. }
  461. }
  462. }
  463. traverse(menuItems.value)
  464. return indices
  465. }
  466. // 播放下一个视频
  467. const playNextVideo = () => {
  468. //测试账号禁用视频
  469. if (disableVideo()) return
  470. // 记录当前视频ID为已观看
  471. if (
  472. course.value &&
  473. course.value.id &&
  474. !watchedCourseIds.value.includes(course.value.id)
  475. ) {
  476. watchedCourseIds.value.push(course.value.id)
  477. localStorage.setItem(
  478. 'watchedCourseIds',
  479. JSON.stringify(watchedCourseIds.value)
  480. )
  481. }
  482. const allIndices = flattenMenuItems()
  483. const currentIndexInList = allIndices.indexOf(course.value.key)
  484. if (currentIndexInList !== -1 && currentIndexInList < allIndices.length - 1) {
  485. const nextIndex = allIndices[currentIndexInList + 1]
  486. handleSelect(nextIndex)
  487. // 切换视频后自动播放
  488. setTimeout(() => {
  489. tryPlayVideo()
  490. }, 500)
  491. }
  492. // 重置
  493. pausedIndices.value = []
  494. prompt.value = ''
  495. messageList.value = []
  496. }
  497. // 切换视频
  498. // 播放上一个视频
  499. const playPreviousVideo = () => {
  500. //测试账号禁用视频
  501. if (disableVideo()) return
  502. const allIndices = flattenMenuItems()
  503. const currentIndexInList = allIndices.indexOf(course.value.key)
  504. if (currentIndexInList > 0) {
  505. const previousIndex = allIndices[currentIndexInList - 1]
  506. handleSelect(previousIndex)
  507. // 切换视频后自动播放
  508. setTimeout(() => {
  509. tryPlayVideo()
  510. }, 500)
  511. }
  512. }
  513. // 尝试播放视频,处理浏览器自动播放限制
  514. const tryPlayVideo = () => {
  515. // 测试账号禁用视频
  516. if (disableVideo()) return
  517. // 判断视频格式是否为m3u8
  518. const isM3u8 = course.value.courseVideoPath && course.value.courseVideoPath.endsWith('.m3u8')
  519. // 确保videoRef存在
  520. if (!videoRef.value) {
  521. console.error('视频元素未找到')
  522. return
  523. }
  524. const playPromise = videoRef.value.play()
  525. if (playPromise !== undefined) {
  526. playPromise.catch(error => {
  527. console.error('视频播放失败,可能是浏览器自动播放限制:', error)
  528. })
  529. }
  530. // 初始化video.js播放器
  531. if (videoPlayer.value) {
  532. // 销毁旧的播放器实例(如果存在)
  533. if (player) {
  534. player.dispose()
  535. }
  536. player = videojs(videoPlayer.value, {
  537. controls: true,
  538. sources: [
  539. {
  540. src: course.value.courseVideoPath,
  541. type: isM3u8 ? 'application/x-mpegURL' : 'video/mp4'
  542. }
  543. ],
  544. preload: 'metadata' // 仅加载元数据,避免预加载整个文件
  545. })
  546. // 如果是m3u8格式,启用HLS支持
  547. if (isM3u8 && !hlsRef.value) {
  548. // 检查是否已加载hls.js插件
  549. if (videojs.getPlugin('hls')) {
  550. hlsRef.value = player.hls()
  551. } else {
  552. console.warn('video.js HLS插件未加载,可能无法正常播放m3u8格式视频')
  553. // 尝试使用hls.js直接播放
  554. if (Hls.isSupported()) {
  555. hlsRef.value = new Hls()
  556. hlsRef.value.loadSource(course.value.courseVideoPath)
  557. hlsRef.value.attachMedia(videoRef.value)
  558. }
  559. }
  560. }
  561. }
  562. }
  563. //禁用视频
  564. const disableVideo = (index = course.value.key) => {
  565. let dis = [
  566. '3-7',
  567. '3-8',
  568. '3-9',
  569. '3-10',
  570. '3-11',
  571. '3-12',
  572. '3-13',
  573. '4-14',
  574. '5-15'
  575. ]
  576. if (
  577. localStorage.getItem('userName') === 'aiTest' &&
  578. dis.indexOf(index) !== -1
  579. ) {
  580. if (videoRef.value) {
  581. // 记录当前播放时间
  582. videoRef.value.pause()
  583. // 阻止用户跳转到新的时间点,将播放时间重置为之前的时间
  584. videoRef.value.currentTime = 0
  585. }
  586. //提示禁用// 显示消息框
  587. Message().notifyWarning('您的账号并未开放此课程!', true)
  588. return true
  589. }
  590. return false
  591. }
  592. // 视频 ref
  593. const videoRef = ref(null)
  594. // HLS实例
  595. const hlsRef = ref(null)
  596. // 记录已经暂停过的时间点索引
  597. let pausedIndices = ref([])
  598. // 试题弹框显示状态
  599. const questionDialogVisible = ref(false)
  600. // 当前显示的试题
  601. const courseConfig = ref({})
  602. // 用户选择的选项
  603. const selectedOption = ref(null)
  604. // 记录已经保存的进度百分比
  605. const savedProgress = ref([])
  606. // 节流时间间隔(毫秒)
  607. const THROTTLE_TIME = 5000
  608. // 上次播放进度
  609. const lastPlayProgress = ref(0)
  610. // 定义进度数组
  611. const targetProgresses = [10, 50, 100]
  612. // AI对话弹出框显示状态
  613. let showAIDialog = ref(false)
  614. // 消息历史记录
  615. // let messageList = ref([])
  616. // 年级id
  617. const gradeId = ref('')
  618. // 课程大纲id
  619. const typeId = ref('')
  620. // 课程小节id
  621. const courseId = ref('')
  622. // AI问答次数
  623. const aiQuestionCount = ref(0)
  624. // 定义节流函数
  625. const throttle = (fn, delay) => {
  626. let lastCall = 0
  627. return function(...args) {
  628. const now = Date.now()
  629. if (now - lastCall >= delay) {
  630. lastCall = now
  631. return fn.apply(this, args)
  632. }
  633. }
  634. }
  635. // 保存进度(带节流)
  636. const saveProgress = throttle(async (progress, currentTime) => {
  637. try {
  638. // 保存到localStorage,下次加载视频续播
  639. localStorage.setItem(`videoProgress_${courseId.value}`, JSON.stringify({
  640. progress: progress,
  641. currentTime: currentTime,
  642. timestamp: Date.now()
  643. }))
  644. // 获取课程小节id
  645. if (typeId.value) {
  646. const courseRes = await ClassType(typeId.value)
  647. if (courseRes.data && courseRes.data.length > 0) {
  648. // 使用选中的课程id
  649. if (course.value && course.value.id) {
  650. courseId.value = course.value.id
  651. } else {
  652. // 如果没有选中的课程,默认使用第一个课程id
  653. courseId.value = courseRes.data[0].id
  654. }
  655. }
  656. }
  657. // 保存视频进度接口
  658. await saveRecord({
  659. brpNjId: gradeId.value,
  660. brpCtId: typeId.value,
  661. brpCourseId: courseId.value,
  662. brpType: 'course',
  663. brpProgress: progress
  664. })
  665. savedProgress.value.push(progress)
  666. } catch (error) {
  667. console.error(`保存进度失败:`, error)
  668. }
  669. }, THROTTLE_TIME)
  670. // 处理视频时间更新事件
  671. const handleTimeUpdate = (ev) => {
  672. // 测试账号禁用视频
  673. if (!videoRef.value) return
  674. const currentTime = parseInt(ev.target.currentTime)
  675. const duration = videoRef.value.duration || 0
  676. const progressPercentage = duration > 0 ? Math.round((currentTime / duration) * 100) : 0
  677. // 更新最后播放进度
  678. lastPlayProgress.value = progressPercentage
  679. // 检查是否达到目标进度点且尚未保存
  680. targetProgresses.some(target => {
  681. const isNearTarget = Math.abs(progressPercentage - target) <= 2
  682. const isNotSaved = !savedProgress.value.includes(target)
  683. if (isNearTarget && isNotSaved) {
  684. // 保存目标进度
  685. saveProgress(target, currentTime)
  686. return true
  687. }
  688. return false
  689. })
  690. // 使用节流保存进度
  691. saveProgress(progressPercentage, currentTime)
  692. if (!course.value.courseConfigList) return
  693. course.value.courseConfigList.forEach(courseCofig => {
  694. //暂停时间
  695. let time = courseCofig.ccTime
  696. // 检查是否到达时间点且还未暂停过
  697. if (currentTime === time && !pausedIndices.value.includes(time)) {
  698. videoRef.value.pause()
  699. // 记录暂停时间
  700. pausedIndices.value.push(currentTime)
  701. // 视频弹框显示对应的问题
  702. if (courseCofig.ccQuestContent) {
  703. questionDialogVisible.value = true
  704. courseConfig.value = courseCofig
  705. // 解析选项
  706. if (courseCofig.ccQuestOption) {
  707. courseConfig.courseQuestion = courseCofig.ccQuestOption.split(',')
  708. }
  709. // 添加试题进度
  710. const saveQuestProgress = async () =>{
  711. try {
  712. // 确保courseId已经设置
  713. if (!courseId.value && typeId.value) {
  714. const courseRes = await ClassType(typeId.value)
  715. if (courseRes.data && courseRes.data.length > 0) {
  716. courseId.value = course.value && course.value.id ? course.value.id : courseRes.data[0].id
  717. }
  718. }
  719. if (courseCofig.id) {
  720. // 保存弹窗问题进度
  721. await saveRecord({
  722. brpNjId: gradeId.value,
  723. brpCtId: typeId.value,
  724. brpCourseConfigId: courseCofig.id,
  725. brpCourseId: courseId.value,
  726. brpType: 'courseQuest',
  727. brpProgress: progressPercentage
  728. })
  729. } else {
  730. console.error('无法保存试题进度: 试题id不存在')
  731. }
  732. }catch(error){
  733. console.error(`保存试题进度失败:`, error)
  734. }
  735. }
  736. // 调用异步函数
  737. saveQuestProgress()
  738. }
  739. }
  740. })
  741. }
  742. // 在视频加载完成后设置上次播放进度
  743. const setLastPlayPosition = () => {
  744. if (!videoRef.value) return
  745. try {
  746. const savedData = localStorage.getItem(`videoProgress_${courseId.value}`)
  747. if (savedData) {
  748. const { currentTime, progress } = JSON.parse(savedData)
  749. if (currentTime && !isNaN(currentTime)) {
  750. videoRef.value.currentTime = currentTime
  751. lastPlayProgress.value = progress
  752. }
  753. }
  754. } catch (error) {
  755. console.error('读取上次播放进度失败:', error)
  756. }
  757. }
  758. // 视频完成拖动进度条时触发的方法
  759. const handleSeeked = () => {
  760. pausedIndices.value = []
  761. }
  762. // 关闭试题弹框
  763. const handleCloseQuestionDialog = () => {
  764. questionDialogVisible.value = false
  765. // 继续播放视频
  766. videoRef.value.play()
  767. }
  768. // 提交答案
  769. const handleSubmitAnswer = () => {
  770. // 这里可以添加答案验证逻辑
  771. questionDialogVisible.value = false
  772. // 继续播放视频
  773. videoRef.value.play()
  774. selectedOption.value = null
  775. }
  776. // 发送消息
  777. const sendMessage = async () => {
  778. if (prompt.value.trim()) {
  779. // 添加用户消息到历史记录
  780. messageList.value.push({
  781. type: 'user',
  782. content: prompt.value
  783. })
  784. // 模拟 AI 回复
  785. const aiResponse = await simulateAIResponse(prompt.value)
  786. messageList.value.push({
  787. type: 'ai',
  788. content: aiResponse
  789. })
  790. activeMessageList.value = messageList.value
  791. // 清空输入框
  792. prompt.value = ''
  793. }
  794. }
  795. // 处理 AI 助手点击事件
  796. const handleAIClick = () => {
  797. // 清空输入框
  798. messageList.value = []
  799. if (courseConfig.value.ccQuestContent) {
  800. prompt.value = courseConfig.value.ccQuestContent
  801. sendMessage()
  802. prompt.value = ''
  803. }
  804. showAIDialog.value = true
  805. //创建对话
  806. createAiChart()
  807. }
  808. // 模拟 AI 回复
  809. const simulateAIResponse = question => {
  810. return new Promise(resolve => {
  811. setTimeout(() => {
  812. if (courseConfig.value.ccAiAnswer) {
  813. resolve(courseConfig.value.ccAiAnswer)
  814. return
  815. }
  816. // 若未匹配到自定义回复,给出默认回复
  817. resolve(`您的问题是:${question},这是 AI 的回复示例。`)
  818. }, 1000)
  819. })
  820. }
  821. // 关闭AI对话弹出框
  822. const handleCloseAIDialog = () => {
  823. showAIDialog.value = false
  824. }
  825. // 搜索框
  826. const SearchInput = ref('')
  827. // 添加搜索建议查询方法
  828. const querySearch = (queryString, cb) => {
  829. const sections = getAllCourseSections()
  830. const results = queryString
  831. ? sections.filter(section =>
  832. section.title.toLowerCase().includes(queryString.toLowerCase())
  833. )
  834. : sections
  835. cb(results)
  836. }
  837. const filteredTitles = computed(() => {
  838. const sections = getAllCourseSections()
  839. if (!SearchInput.value) {
  840. return sections
  841. }
  842. return sections.filter(section =>
  843. section.title.toLowerCase().includes(SearchInput.value.toLowerCase())
  844. )
  845. })
  846. const handleSearchSelect = item => {
  847. handleSelect(item.key)
  848. // 添加以下代码清空输入框
  849. SearchInput.value = ''
  850. }
  851. // 添加课程小节数据提取方法
  852. const getAllCourseSections = () => {
  853. let sections = []
  854. const traverse = items => {
  855. items.forEach(item => {
  856. if (item.children) {
  857. traverse(item.children)
  858. } else {
  859. sections.push({ title: item.title, key: item.key })
  860. }
  861. })
  862. }
  863. traverse(menuItems.value)
  864. return sections
  865. }
  866. // =========== 【聊天对话】小智ai ===========
  867. // 数字人接口
  868. const route = useRoute()
  869. const grade = ref('')
  870. const xZAiData = ref({})
  871. const getXzAi = async () => {
  872. try {
  873. grade.value = route.query.grade || localStorage.getItem('selectedGrade')
  874. // 获取小学低年级AI数据
  875. const juniorAIRes = await teacherList({ category: grade.value + 'AI' })
  876. const aiPerson = juniorAIRes.data.list.find(
  877. person => person.name === '小智'
  878. )
  879. if (aiPerson) {
  880. xZAiData.value = {
  881. id: aiPerson.id,
  882. name: aiPerson.name,
  883. image: aiPerson.model2dPath,
  884. message: aiPerson.systemMessage,
  885. default: aiPerson.questTip
  886. }
  887. } else {
  888. console.warn('未找到名为小智的数据')
  889. }
  890. } catch (error) {
  891. console.error('获取年级AI数据失败:', error)
  892. }
  893. }
  894. // =========== 【聊天对话】对话相关 ===========
  895. // 聊天对话
  896. const activeConversationModelPath = ref(null) // 选中的对话编号
  897. const activeConversationId = ref(null) // 选中的对话编号
  898. const activeConversation = ref(null) // 选中的 Conversation
  899. const conversationInProgress = ref(false) // 对话是否正在进行中。目前只有【发送】消息时,会更新为 true,避免切换对话、删除对话等操作,导致 stream 中断
  900. // 消息列表
  901. const messageRef = ref()
  902. const activeMessageList = ref([]) // 选中对话的消息列表
  903. // 消息滚动
  904. const textSpeed = ref(50) // Typing speed in milliseconds
  905. const textRoleRunning = ref(false) // Typing speed in milliseconds
  906. // 发送消息输入框
  907. const isComposing = ref(false) // 判断用户是否在输入
  908. const conversationInAbortController = ref() // 对话进行中 abort 控制器(控制 stream 对话)
  909. const inputTimeout = ref() // 处理输入中回车的定时器
  910. const prompt = ref() // prompt
  911. const enableContext = ref(true) // 是否开启上下文
  912. // 接收 Stream 消息
  913. const receiveMessageFullText = ref('')
  914. const receiveMessageDisplayedText = ref('')
  915. //创建对话
  916. const createAiChart = async () => {
  917. // 先获取数字人接口
  918. await getXzAi()
  919. // 智能问答
  920. CreateDialogue({ roleId: xZAiData.value.id })
  921. .then(res => {
  922. // console.log('创建会话:', res)
  923. activeConversationId.value = res.data
  924. })
  925. .catch(error => {
  926. console.error('请求出错:', error)
  927. })
  928. await getConversation(xZAiData.value.id)
  929. }
  930. // =========== 【聊天对话】相关 ===========
  931. /** 获取对话信息 */
  932. const getConversation = async id => {
  933. if (!id) {
  934. return
  935. }
  936. const conversation = ref({})
  937. if (!conversation) {
  938. return
  939. }
  940. conversation.systemMessage = xZAiData.value.message
  941. activeConversation.value = conversation
  942. activeConversationModelPath.value = xZAiData.value.image
  943. }
  944. // =========== 【发送消息】相关 ===========
  945. /** 处理来自 keydown 的发送消息 */
  946. const handleSendByKeydown = async event => {
  947. // 判断用户是否在输入
  948. if (isComposing.value) {
  949. return
  950. }
  951. // 进行中不允许发送
  952. if (conversationInProgress.value) {
  953. return
  954. }
  955. const content = prompt.value?.trim()
  956. if (event.key === 'Enter') {
  957. if (event.shiftKey) {
  958. // 插入换行
  959. prompt.value += '\r\n'
  960. event.preventDefault() // 防止默认的换行行为
  961. } else {
  962. // 发送消息
  963. await doSendMessage(content)
  964. event.preventDefault() // 防止默认的提交行为
  965. }
  966. }
  967. }
  968. onMounted(() => {
  969. // 获取本地存储中的值
  970. gradeId.value = globalState.initGradeId()
  971. typeId.value = localStorage.getItem('typeId') || ''
  972. // 视频相关初始化
  973. initVideoProgress()
  974. })
  975. const initVideoProgress = () => {
  976. // 延迟设置上次播放进度,确保视频已加载
  977. setTimeout(() => {
  978. setLastPlayPosition()
  979. }, 1000)
  980. // 检查是否已有保存的进度点
  981. const savedData = localStorage.getItem(`videoProgress_${courseId.value}`)
  982. if (savedData) {
  983. try {
  984. const { progress } = JSON.parse(savedData)
  985. if (progress >= 10) savedProgress.value.push(10)
  986. if (progress >= 50) savedProgress.value.push(50)
  987. if (progress >= 100) savedProgress.value.push(100)
  988. } catch (error) {
  989. console.error('解析保存的进度失败:', error)
  990. }
  991. }
  992. }
  993. // 添加视频结束事件处理
  994. const handleVideoEnded = () => {
  995. // 视频结束时保存100%进度
  996. if (!savedProgress.value.includes(100)) {
  997. saveProgress(100, videoRef.value.duration)
  998. }
  999. }
  1000. /** 处理来自【发送】按钮的发送消息 */
  1001. const handleSendByButton = () => {
  1002. doSendMessage(prompt.value?.trim())
  1003. }
  1004. /** 处理 prompt 输入变化 */
  1005. const handlePromptInput = event => {
  1006. // 非输入法 输入设置为 true
  1007. if (!isComposing.value) {
  1008. // 回车 event data 是 null
  1009. if (event.data == null) {
  1010. return
  1011. }
  1012. isComposing.value = true
  1013. }
  1014. // 清理定时器
  1015. if (inputTimeout.value) {
  1016. clearTimeout(inputTimeout.value)
  1017. }
  1018. // 重置定时器
  1019. inputTimeout.value = setTimeout(() => {
  1020. isComposing.value = false
  1021. }, 400)
  1022. }
  1023. // TODO注:是不是可以通过 @keydown.enter、@keydown.shift.enter 来实现,回车发送、shift+回车换行;主要看看,是不是可以简化 isComposing 相关的逻辑
  1024. const onCompositionstart = () => {
  1025. isComposing.value = true
  1026. }
  1027. const onCompositionend = () => {
  1028. setTimeout(() => {
  1029. isComposing.value = false
  1030. }, 200)
  1031. }
  1032. /** 真正执行【发送】消息操作 */
  1033. const doSendMessage = async content => {
  1034. // 校验
  1035. if (content.length < 1) {
  1036. console.error('发送失败,原因:内容为空!')
  1037. return
  1038. }
  1039. if (activeConversationId.value == null) {
  1040. console.error('还没创建对话,不能发送!')
  1041. return
  1042. }
  1043. // 增加问答次数
  1044. aiQuestionCount.value++
  1045. // 保存AI问答次数
  1046. try {
  1047. await saveRecord({
  1048. brpNjId: gradeId.value,
  1049. brpType: 'aiCount',
  1050. brpProgress: aiQuestionCount.value
  1051. })
  1052. } catch (error) {
  1053. console.error('保存AI问答次数失败:', error)
  1054. }
  1055. // 清空输入框
  1056. prompt.value = ''
  1057. // 执行发送
  1058. await doSendMessageStream({
  1059. conversationId: activeConversationId.value,
  1060. content: content
  1061. })
  1062. }
  1063. /** 真正执行【发送】消息操作 */
  1064. const doSendMessageStream = async userMessage => {
  1065. // 创建 AbortController 实例,以便中止请求
  1066. conversationInAbortController.value = new AbortController()
  1067. // 标记对话进行中
  1068. conversationInProgress.value = true
  1069. // 设置为空
  1070. receiveMessageFullText.value = ''
  1071. try {
  1072. // 1.1 先添加两个假数据,等 stream 返回再替换
  1073. activeMessageList.value.push({
  1074. id: -1,
  1075. conversationId: activeConversationId.value,
  1076. type: 'user',
  1077. content: userMessage.content,
  1078. createTime: new Date()
  1079. })
  1080. activeMessageList.value.push({
  1081. id: -2,
  1082. conversationId: activeConversationId.value,
  1083. type: 'assistant',
  1084. content: '思考中...',
  1085. createTime: new Date()
  1086. })
  1087. // 1.3 开始滚动
  1088. textRoll()
  1089. // 2. 发送 event stream
  1090. let isFirstChunk = true // 是否是第一个 chunk 消息段
  1091. await sendChatMessageStream(
  1092. userMessage.conversationId,
  1093. userMessage.content,
  1094. conversationInAbortController.value,
  1095. enableContext.value,
  1096. async res => {
  1097. const { code, data, msg } = JSON.parse(res.data)
  1098. if (code !== 0) {
  1099. console.log(`对话异常! ${msg}`)
  1100. return
  1101. }
  1102. // 如果内容为空,就不处理。
  1103. // if (data.receive.content === '') {
  1104. // return
  1105. // }
  1106. receiveMessageFullText.value =
  1107. receiveMessageFullText.value + data.receive.content
  1108. // 首次返回需要添加一个 message 到页面,后面的都是更新
  1109. if (isFirstChunk) {
  1110. isFirstChunk = false
  1111. // 弹出两个假数据
  1112. activeMessageList.value.pop()
  1113. activeMessageList.value.pop()
  1114. // 更新返回的数据
  1115. activeMessageList.value.push(data.send)
  1116. activeMessageList.value.push(data.receive)
  1117. }
  1118. },
  1119. error => {
  1120. console.log(`对话异常! ${error}`)
  1121. stopStream()
  1122. // 需要抛出异常,禁止重试
  1123. throw error
  1124. },
  1125. () => {
  1126. stopStream()
  1127. }
  1128. )
  1129. } catch {}
  1130. }
  1131. /** 停止 stream 流式调用 */
  1132. const stopStream = async () => {
  1133. // tip:如果 stream 进行中的 message,就需要调用 controller 结束
  1134. if (conversationInAbortController.value) {
  1135. conversationInAbortController.value.abort()
  1136. }
  1137. // 设置为 false
  1138. conversationInProgress.value = false
  1139. }
  1140. /**
  1141. * 消息列表
  1142. *
  1143. * 和 {@link #getMessageList()} 的差异是,把 systemMessage 考虑进去
  1144. */
  1145. const messageList = ref([])
  1146. // ============== 【消息滚动】相关 =============
  1147. /** 滚动到 message 底部 */
  1148. const scrollToBottom = async isIgnore => {
  1149. // if (messageRef.value) {
  1150. // messageRef.value.scrollToBottom(isIgnore)
  1151. // }
  1152. }
  1153. /** 自提滚动效果 */
  1154. const textRoll = async () => {
  1155. let index = 0
  1156. try {
  1157. // 只能执行一次
  1158. if (textRoleRunning.value) {
  1159. return
  1160. }
  1161. // 设置状态
  1162. textRoleRunning.value = true
  1163. receiveMessageDisplayedText.value = ''
  1164. const task = async () => {
  1165. // 调整速度
  1166. const diff =
  1167. (receiveMessageFullText.value.length -
  1168. receiveMessageDisplayedText.value.length) /
  1169. 10
  1170. if (diff > 5) {
  1171. textSpeed.value = 10
  1172. } else if (diff > 2) {
  1173. textSpeed.value = 30
  1174. } else if (diff > 1.5) {
  1175. textSpeed.value = 50
  1176. } else {
  1177. textSpeed.value = 100
  1178. }
  1179. // 对话结束,就按 30 的速度
  1180. if (!conversationInProgress.value) {
  1181. textSpeed.value = 10
  1182. }
  1183. if (index < receiveMessageFullText.value.length) {
  1184. receiveMessageDisplayedText.value += receiveMessageFullText.value[index]
  1185. index++
  1186. // 更新 message
  1187. const lastMessage =
  1188. activeMessageList.value[activeMessageList.value.length - 1]
  1189. lastMessage.content = receiveMessageDisplayedText.value
  1190. // 滚动到住下面
  1191. await scrollToBottom()
  1192. // 重新设置任务
  1193. timer = setTimeout(task, textSpeed.value)
  1194. } else {
  1195. // 不是对话中可以结束
  1196. if (!conversationInProgress.value) {
  1197. textRoleRunning.value = false
  1198. clearTimeout(timer)
  1199. } else {
  1200. // 重新设置任务
  1201. timer = setTimeout(task, textSpeed.value)
  1202. }
  1203. }
  1204. }
  1205. let timer = setTimeout(task, textSpeed.value)
  1206. } catch {}
  1207. }
  1208. </script>
  1209. <style scoped lang="scss">
  1210. @use 'sass:math';
  1211. @use 'sass:color'; // 引入 color 模块
  1212. // 定义rpx转换函数
  1213. @function rpx($px) {
  1214. @return math.div($px, 750) * 100vw;
  1215. }
  1216. // 定义儿童风格的蓝紫色调
  1217. $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
  1218. $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
  1219. $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
  1220. $light-color: #ffffff; // 浅色背景:淡紫色
  1221. $text-color: #483d8b; // 文本颜色:靛蓝色
  1222. /* 添加过渡样式 */
  1223. .drawer-slide-enter-active,
  1224. .drawer-slide-leave-active {
  1225. transition: all 0.3s ease;
  1226. }
  1227. .drawer-slide-enter-from,
  1228. .drawer-slide-leave-to {
  1229. transform: translateX(-100%);
  1230. opacity: 0;
  1231. }
  1232. .home-container ::v-deep(.el-drawer__body) {
  1233. width: rpx(135);
  1234. height: 100%;
  1235. position: relative;
  1236. background: linear-gradient(to bottom, #001169, #8a78d0);
  1237. }
  1238. .content-box {
  1239. flex: 1;
  1240. height: 100%;
  1241. display: flex;
  1242. flex-direction: column; /* 子元素上下排列 */
  1243. background: linear-gradient(to bottom, #001169, #8a78d0);
  1244. }
  1245. .icon-expand {
  1246. width: rpx(8);
  1247. height: rpx(35);
  1248. border-top-right-radius: rpx(5);
  1249. border-bottom-right-radius: rpx(5);
  1250. z-index: 9999;
  1251. position: absolute;
  1252. top: 50%;
  1253. left: 18%;
  1254. transform: translateY(-50%);
  1255. cursor: pointer; // 添加鼠标指针样式
  1256. clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  1257. display: flex;
  1258. justify-content: center;
  1259. align-items: center;
  1260. transition: all 0.3s ease;
  1261. }
  1262. .icon-expand .vertical-lines {
  1263. color: #8a78d0;
  1264. font-size: rpx(10);
  1265. }
  1266. .home-container {
  1267. position: fixed;
  1268. top: 0;
  1269. left: 0;
  1270. right: 0;
  1271. bottom: 0;
  1272. background: linear-gradient(to bottom, #001169, #b4a8e1);
  1273. display: flex;
  1274. }
  1275. .el-row {
  1276. margin: auto;
  1277. margin-top: rpx(20);
  1278. }
  1279. .tac ::v-deep(.el-menu) {
  1280. background-color: transparent;
  1281. border: none;
  1282. width: 100%;
  1283. margin-top: rpx(8);
  1284. }
  1285. /* 取消点击后的蓝色字体 el-sub-menu__title*/
  1286. .tac ::v-deep(.el-menu-item.is-active),
  1287. .tac ::v-deep(.el-sub-menu__title.is-active) {
  1288. color: white;
  1289. }
  1290. // 取消鼠标悬浮颜色
  1291. .tac ::v-deep(.el-sub-menu__title) {
  1292. width: rpx(130);
  1293. height: rpx(20);
  1294. margin-bottom: rpx(5);
  1295. border-radius: rpx(6);
  1296. // 添加flex布局使标题和图标两端对齐
  1297. display: flex;
  1298. justify-content: space-between;
  1299. align-items: center;
  1300. }
  1301. .el-menu ::v-deep(.el-sub-menu__title:hover),
  1302. .el-menu ::v-deep(.el-sub-menu__title:focus),
  1303. .el-menu ::v-deep(.el-sub-menu__title:active) {
  1304. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  1305. background-color: transparent;
  1306. }
  1307. // 添加二级标题折叠图标样式
  1308. ::v-deep(.el-sub-menu__icon-arrow) {
  1309. color: white;
  1310. font-size: rpx(10); // 增大图标尺寸
  1311. margin-left: auto; // 将图标推到右侧
  1312. margin-top: rpx(-5);
  1313. display: block;
  1314. width: rpx(16); // 确保有明确宽度
  1315. }
  1316. // 鼠标悬停时的图标样式
  1317. .el-menu ::v-deep(.el-sub-menu__title:hover .el-sub-menu__icon-arrow) {
  1318. color: black; // 与悬停状态的文字颜色保持一致
  1319. }
  1320. .el-menu ::v-deep(.el-icon svg) {
  1321. font-size: rpx(9);
  1322. }
  1323. .mb-2 {
  1324. color: white;
  1325. font-size: rpx(9);
  1326. }
  1327. .mb-2 img {
  1328. width: rpx(10);
  1329. height: rpx(10);
  1330. vertical-align: middle;
  1331. margin-top: rpx(-2);
  1332. }
  1333. .el-menu-item {
  1334. width: rpx(100);
  1335. height: rpx(20);
  1336. margin-bottom: rpx(5);
  1337. border-radius: rpx(6);
  1338. color: white;
  1339. font-size: rpx(8);
  1340. }
  1341. .el-menu ::v-deep(.el-sub-menu__title) {
  1342. color: white;
  1343. width: rpx(100);
  1344. height: rpx(20);
  1345. margin-bottom: rpx(5);
  1346. font-size: rpx(8);
  1347. }
  1348. .el-menu ::v-deep(.el-sub-menu__title:hover),
  1349. .el-menu ::v-deep(.el-sub-menu__title:focus),
  1350. .el-menu ::v-deep(.el-sub-menu__title:active) {
  1351. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  1352. color: black;
  1353. }
  1354. .el-menu ::v-deep(.el-menu-item:hover),
  1355. .el-menu ::v-deep(.el-menu-item:focus),
  1356. .el-menu ::v-deep(.el-menu-item:active) {
  1357. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  1358. color: black;
  1359. font-size: rpx(8);
  1360. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  1361. }
  1362. .el-menu .el-menu-item.is-active {
  1363. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  1364. color: black;
  1365. font-size: rpx(8);
  1366. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  1367. }
  1368. .drawer-box {
  1369. position: absolute;
  1370. display: flex;
  1371. align-items: center;
  1372. height: 100%;
  1373. width: 80%;
  1374. }
  1375. .drawer-box .toggle-button {
  1376. width: rpx(10);
  1377. height: rpx(50);
  1378. font-size: rpx(7);
  1379. background-color: rgba(17, 23, 29, 0.2);
  1380. border: none;
  1381. position: relative;
  1382. writing-mode: vertical-lr; // 文字垂直排列,从左到右
  1383. text-orientation: upright; // 文字保持正立
  1384. }
  1385. .toggle-button:hover {
  1386. left: 0;
  1387. }
  1388. .toggle-button.is-active,
  1389. .toggle-button:active,
  1390. .toggle-button:focus {
  1391. background-color: rgba(165, 209, 247, 0.8);
  1392. color: white;
  1393. border: none; // 移除点击时的边框
  1394. outline: none; // 移除点击时的外边框
  1395. }
  1396. .box-1 {
  1397. width: 100%;
  1398. // height: rpx(50);
  1399. margin-top: rpx(10);
  1400. display: flex;
  1401. justify-content: center;
  1402. align-items: center;
  1403. box-sizing: border-box;
  1404. font-size: rpx(15); // 默认字体大小
  1405. }
  1406. .inner-box {
  1407. height: 100%;
  1408. display: flex;
  1409. justify-content: center;
  1410. align-items: center;
  1411. font-size: rpx(16); // 默认字体大小
  1412. }
  1413. .left-box {
  1414. position: relative;
  1415. justify-content: flex-start;
  1416. align-items: flex-start;
  1417. flex: 1; // 设置左侧盒子占比为 2
  1418. cursor: pointer; // 添加鼠标指针样式
  1419. }
  1420. .box-icon {
  1421. width: 100%;
  1422. height: 100%;
  1423. flex: 1;
  1424. display: flex; // 添加 flex 布局
  1425. align-items: center; // 垂直居中
  1426. color: white; // 设置图标颜色为白色
  1427. padding-left: rpx(15);
  1428. font-size: rpx(10); // 设置图标大小,可按需调整
  1429. }
  1430. .box-icon .left-icon {
  1431. margin-left: rpx(10);
  1432. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  1433. }
  1434. .left-box span {
  1435. position: absolute;
  1436. font-size: rpx(11); // 默认字体大小
  1437. color: white;
  1438. }
  1439. .right-box {
  1440. flex: 1;
  1441. position: relative; // 添加相对定位;
  1442. }
  1443. .top-right-box {
  1444. position: absolute; // 添加绝对定位
  1445. // margin-top: rpx(9); // 调整上边距离
  1446. margin-left: rpx(260); // 调整右边距离
  1447. width: rpx(100); // 设置盒子宽度,可按需调整
  1448. // height: 60px; // 设置盒子高度,可按需调整
  1449. margin-right: rpx(20);
  1450. display: flex;
  1451. justify-content: flex-end;
  1452. }
  1453. .top-right-box {
  1454. ::v-deep(.el-input__wrapper) {
  1455. height: rpx(15);
  1456. font-size: rpx(6);
  1457. background-color: rgb(255, 255, 255, 0.5);
  1458. border-radius: rpx(12);
  1459. border: white 1px solid;
  1460. color: white;
  1461. }
  1462. ::v-deep(.el-input__icon) {
  1463. color: white; // 设置输入框图标颜色为白色
  1464. }
  1465. // 添加占位符样式
  1466. ::v-deep(.el-input__inner::placeholder) {
  1467. color: white;
  1468. }
  1469. // 添加输入框文字颜色样式
  1470. ::v-deep(.el-input__inner) {
  1471. color: black;
  1472. }
  1473. }
  1474. // 搜索框
  1475. .search-input {
  1476. width: rpx(100);
  1477. height: rpx(15);
  1478. font-size: rpx(7);
  1479. }
  1480. .box-2 {
  1481. width: 100%;
  1482. flex: 1;
  1483. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  1484. box-sizing: border-box;
  1485. display: flex; // 确保子元素水平排列
  1486. flex-wrap: wrap; // 允许子元素换行;
  1487. align-content: center; // 顶部对齐;
  1488. cursor: pointer; // 添加鼠标指针样式
  1489. }
  1490. .box-video {
  1491. width: 100%;
  1492. height: rpx(300);
  1493. display: flex;
  1494. justify-content: center;
  1495. align-items: center;
  1496. // video.full-box-video {
  1497. // height: rpx(280);
  1498. // width: 67%;
  1499. // margin: 0 auto;
  1500. // border-radius: rpx(12);
  1501. // object-fit: cover;
  1502. // }
  1503. .d-player-wrap{
  1504. height: rpx(289);
  1505. width: 68.5%;
  1506. border-radius: rpx(12);
  1507. object-fit: cover;
  1508. }
  1509. }
  1510. /* 隐藏 Chrome 视频控件的渐变背景等默认样式 */
  1511. video::-webkit-media-controls-panel {
  1512. background: transparent !important; /* 去掉背景渐变,设为透明 */
  1513. }
  1514. .small-title {
  1515. width: 100%;
  1516. // margin-top: rpx(-20);
  1517. height: rpx(20);
  1518. color: white;
  1519. font-size: rpx(10);
  1520. justify-content: center; //使子元素水平居中
  1521. }
  1522. .video-switch {
  1523. width: 100%;
  1524. // height: rpx(50);
  1525. display: flex;
  1526. // margin-top: rpx(-20);
  1527. // background-color: saddlebrown;
  1528. }
  1529. .caret-right,
  1530. .caret-left {
  1531. width: rpx(50);
  1532. margin: auto;
  1533. display: flex;
  1534. margin-top: rpx(5);
  1535. margin-bottom: rpx(15);
  1536. }
  1537. .caret-left ::v-deep(.el-button.is-round),
  1538. .caret-right ::v-deep(.el-button.is-round) {
  1539. width: rpx(50);
  1540. height: rpx(15);
  1541. color: white;
  1542. font-size: rpx(7);
  1543. border-radius: none;
  1544. border: 1px white solid;
  1545. background-color: rgb(255, 255, 255, 0.5); // 进度条背景颜色,调浅为半透明白色
  1546. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  1547. }
  1548. .caret-right img,
  1549. .caret-left img {
  1550. width: rpx(12);
  1551. }
  1552. // 儿童风格试题弹框样式
  1553. .child-dialog {
  1554. .el-dialog__header {
  1555. display: none; // 隐藏原有的标题栏
  1556. }
  1557. .el-dialog__body {
  1558. padding: rpx(20);
  1559. position: relative;
  1560. }
  1561. .el-dialog__footer {
  1562. border-top: none;
  1563. padding: rpx(10) rpx(20);
  1564. text-align: center;
  1565. margin-top: auto; // 使底部按钮位于底部
  1566. }
  1567. .el-dialog__wrapper {
  1568. // 修改半透明背景色
  1569. background-color: rgba(0, 0, 0, 0.6);
  1570. }
  1571. .el-dialog {
  1572. border: none;
  1573. border-radius: rpx(20);
  1574. background: linear-gradient(
  1575. 135deg,
  1576. $light-color,
  1577. #d8bfd8
  1578. ); // 柔和的蓝紫色渐变
  1579. overflow: hidden;
  1580. display: flex; // 添加 flex 布局
  1581. flex-direction: column; // 设置垂直布局
  1582. min-height: 0; // 防止子元素溢出
  1583. // 添加装饰元素
  1584. &::before {
  1585. content: '';
  1586. position: absolute;
  1587. top: 0;
  1588. left: 0;
  1589. width: 100%;
  1590. height: rpx(10);
  1591. background: linear-gradient(90deg, $secondary-color, $accent-color);
  1592. }
  1593. }
  1594. }
  1595. // 问题标题样式
  1596. .question-title {
  1597. padding: rpx(15);
  1598. border-radius: rpx(12);
  1599. margin-bottom: rpx(20);
  1600. color: #483d8b;
  1601. font-weight: bold;
  1602. font-size: rpx(12);
  1603. position: relative;
  1604. display: flex;
  1605. // align-items: center;
  1606. .question-icon {
  1607. background-color: $accent-color;
  1608. color: white;
  1609. width: rpx(24);
  1610. height: rpx(24);
  1611. border-radius: 50%;
  1612. display: flex;
  1613. align-items: center;
  1614. justify-content: center;
  1615. margin-right: rpx(10);
  1616. font-weight: bold;
  1617. box-shadow: 0 rpx(2) rpx(5) rgba($accent-color, 0.3);
  1618. }
  1619. }
  1620. // 选项容器样式
  1621. .options-container {
  1622. margin-bottom: rpx(20);
  1623. }
  1624. // 问题选项样式
  1625. .question-option {
  1626. margin: rpx(8) 0;
  1627. padding: rpx(10) rpx(15);
  1628. border-radius: rpx(12);
  1629. border: rpx(1) solid rgba($primary-color, 0.3);
  1630. transition: all 0.3s ease;
  1631. display: flex;
  1632. align-items: center;
  1633. background-color: white;
  1634. box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.05);
  1635. ::v-deep(.el-radio__label) {
  1636. color: $text-color;
  1637. margin-left: rpx(8);
  1638. flex: 1;
  1639. text-align: left;
  1640. // 增大字体大小
  1641. font-size: rpx(12);
  1642. }
  1643. // 选中时的样式变化
  1644. .el-radio__input.is-checked + .el-radio__label {
  1645. font-weight: bold;
  1646. color: $accent-color;
  1647. }
  1648. &:hover {
  1649. background-color: rgba($primary-color, 0.05);
  1650. border-color: rgba($primary-color, 0.5);
  1651. transform: translateY(-rpx(1));
  1652. }
  1653. }
  1654. // 暂无选项样式
  1655. .no-options {
  1656. color: rgba($text-color, 0.7);
  1657. text-align: center;
  1658. padding: rpx(20);
  1659. font-size: rpx(12);
  1660. }
  1661. // 底部按钮样式
  1662. .child-button {
  1663. min-width: rpx(80);
  1664. height: rpx(30);
  1665. border-radius: rpx(8);
  1666. font-size: rpx(12);
  1667. font-weight: 500;
  1668. transition: all 0.3s ease;
  1669. box-shadow: 0 rpx(2) rpx(8) rgba(0, 0, 0, 0.1);
  1670. &.confirm {
  1671. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  1672. border: none;
  1673. border-right: 15px;
  1674. color: white;
  1675. &:hover {
  1676. background: linear-gradient(
  1677. to bottom,
  1678. color.adjust(#ab81ff, $lightness: -5%),
  1679. color.adjust(#8559dc, $lightness: -5%)
  1680. );
  1681. transform: translateY(-rpx(1));
  1682. color: white;
  1683. }
  1684. }
  1685. &.cancel {
  1686. background: white;
  1687. border: rpx(1) solid rgba($primary-color, 0.3);
  1688. color: $text-color;
  1689. &:hover {
  1690. background: rgba($primary-color, 0.05);
  1691. border-color: rgba($primary-color, 0.5);
  1692. transform: translateY(-rpx(1));
  1693. }
  1694. }
  1695. }
  1696. // AI对话图标样式
  1697. .ai-icon-container {
  1698. position: absolute;
  1699. bottom: rpx(20);
  1700. right: rpx(20);
  1701. display: flex;
  1702. flex-direction: column;
  1703. align-items: center;
  1704. cursor: pointer;
  1705. transition: all 0.3s ease;
  1706. &:hover {
  1707. transform: translateY(-rpx(2));
  1708. }
  1709. .ai-icon {
  1710. width: rpx(30);
  1711. height: rpx(30);
  1712. margin-bottom: rpx(0);
  1713. filter: drop-shadow(0 rpx(2) rpx(4) rgba($primary-color, 0.3));
  1714. // 添加过渡动画
  1715. transition: transform 0.3s ease;
  1716. }
  1717. // 悬浮时放大效果
  1718. .ai-icon:hover {
  1719. transform: scale(1.5);
  1720. }
  1721. .ai-text {
  1722. color: $text-color;
  1723. font-size: rpx(8);
  1724. background-color: rgba(255, 255, 255, 0.7);
  1725. padding: rpx(2) rpx(5);
  1726. border-radius: rpx(5);
  1727. }
  1728. }
  1729. // AI消息样式
  1730. .ai-message {
  1731. display: flex;
  1732. align-items: flex-start;
  1733. margin-bottom: rpx(15);
  1734. .ai-avatar {
  1735. width: rpx(30);
  1736. height: rpx(30);
  1737. border-radius: 50%;
  1738. margin-right: rpx(10);
  1739. background-color: $primary-color;
  1740. padding: rpx(5);
  1741. // box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.2);
  1742. }
  1743. .ai-text-content {
  1744. background-color: $light-color;
  1745. padding: rpx(8) rpx(12);
  1746. border-radius: rpx(10);
  1747. font-size: rpx(10);
  1748. color: $text-color;
  1749. max-width: 80%;
  1750. // box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1751. }
  1752. }
  1753. // 用户输入框样式
  1754. .user-input {
  1755. ::v-deep(.el-input__wrapper) {
  1756. height: rpx(23);
  1757. border-top-left-radius: rpx(5);
  1758. border-bottom-left-radius: rpx(5);
  1759. border-color: rgba($primary-color, 0.3);
  1760. &:focus-within {
  1761. box-shadow: 0 0 0 rpx(1) rgba($primary-color, 0.5);
  1762. }
  1763. }
  1764. ::v-deep(.el-input__inner) {
  1765. font-size: rpx(10);
  1766. // color: $text-color;
  1767. text-indent: 1em;
  1768. }
  1769. ::v-deep(.el-input-group__append, .el-input-group__prepend) {
  1770. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  1771. border-top-right-radius: rpx(5);
  1772. border-bottom-right-radius: rpx(5);
  1773. color: white;
  1774. font-size: rpx(9);
  1775. }
  1776. }
  1777. /* 定义淡入和缩放动画 */
  1778. .fade-scale-enter-active,
  1779. .fade-scale-leave-active {
  1780. transition: all 0.5s ease;
  1781. }
  1782. .fade-scale-enter-from,
  1783. .fade-scale-leave-to {
  1784. opacity: 0.1;
  1785. transform: scale(0.9);
  1786. }
  1787. // 自定义试题弹框背景
  1788. .child-dialog-wrapper {
  1789. position: fixed;
  1790. top: 0;
  1791. left: 0;
  1792. right: 0;
  1793. bottom: 0;
  1794. background-color: rgba(0, 0, 0, 0.6); // 半透明背景
  1795. display: flex;
  1796. justify-content: center;
  1797. align-items: center;
  1798. z-index: 1000;
  1799. }
  1800. .child-dialog {
  1801. border: none;
  1802. border-radius: rpx(15);
  1803. background: rgb(255, 255, 255, 0.8); // 柔和的蓝紫色渐变
  1804. overflow: hidden;
  1805. padding: rpx(5);
  1806. // width: 40%;
  1807. // height: 60%;
  1808. position: relative;
  1809. }
  1810. // AI对话弹框样式
  1811. .ai-dialog-wrapper {
  1812. position: fixed;
  1813. top: 0;
  1814. left: 0;
  1815. right: 0;
  1816. bottom: 0;
  1817. display: flex;
  1818. justify-content: flex-end;
  1819. align-items: center;
  1820. z-index: 1001;
  1821. pointer-events: none;
  1822. }
  1823. .ai-dialog {
  1824. border: none;
  1825. border-radius: rpx(15);
  1826. background: rgb(255, 255, 255, 0.8);
  1827. overflow: hidden;
  1828. padding: rpx(20);
  1829. width: 30%;
  1830. // 增加高度
  1831. height: 80%;
  1832. margin-right: rpx(50);
  1833. pointer-events: auto;
  1834. position: relative;
  1835. display: flex;
  1836. flex-direction: column;
  1837. &::before {
  1838. content: '';
  1839. position: absolute;
  1840. top: 0;
  1841. left: 0;
  1842. width: 100%;
  1843. height: rpx(10);
  1844. }
  1845. }
  1846. .ai-dialog-header {
  1847. position: relative;
  1848. display: flex;
  1849. justify-content: center;
  1850. align-items: center;
  1851. margin-bottom: rpx(15);
  1852. margin-top: rpx(-10);
  1853. img {
  1854. width: rpx(15);
  1855. }
  1856. h3 {
  1857. color: black;
  1858. font-size: rpx(12);
  1859. }
  1860. .close-btn {
  1861. padding: 0;
  1862. width: rpx(20);
  1863. height: rpx(20);
  1864. font-size: rpx(16);
  1865. line-height: 1;
  1866. position: absolute;
  1867. background-color: transparent;
  1868. border: none;
  1869. margin-left: rpx(200);
  1870. }
  1871. }
  1872. .ai-dialog-content {
  1873. flex: 1;
  1874. display: flex;
  1875. flex-direction: column;
  1876. }
  1877. .ai-message-history {
  1878. flex: 1;
  1879. // 当内容超出容器高度时,显示垂直滚动条
  1880. overflow-y: auto;
  1881. margin-bottom: rpx(15);
  1882. // 可以根据实际情况调整最大高度
  1883. font-size: rpx(5);
  1884. max-height: 50vh;
  1885. // padding: 5px 10px;
  1886. .message {
  1887. display: flex;
  1888. align-items: flex-start;
  1889. margin-bottom: rpx(10);
  1890. &.user {
  1891. flex-direction: row-reverse;
  1892. }
  1893. .avatar {
  1894. width: rpx(30);
  1895. height: rpx(30);
  1896. border-radius: 50%;
  1897. margin: 0 rpx(10);
  1898. }
  1899. .user {
  1900. width: 15px;
  1901. height: 15px;
  1902. }
  1903. .message-content {
  1904. background-color: #ffffff;
  1905. font-size: rpx(5);
  1906. max-width: 80%;
  1907. color: black;
  1908. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1909. }
  1910. }
  1911. // 滚动条整体样式
  1912. &::-webkit-scrollbar {
  1913. width: rpx(4); // 滚动条宽度
  1914. }
  1915. // 滚动条滑块样式
  1916. &::-webkit-scrollbar-thumb {
  1917. background-color: $primary-color; // 滑块颜色
  1918. border-radius: rpx(4); // 滑块圆角
  1919. transition: background-color 0.3s ease; // 颜色过渡效果
  1920. &:hover {
  1921. //background-color: darken($primary-color, 10%); // 悬停时滑块颜色加深
  1922. }
  1923. }
  1924. // 滚动条轨道样式
  1925. &::-webkit-scrollbar-track {
  1926. background-color: rgba($primary-color, 0.2); // 轨道颜色
  1927. border-radius: rpx(4); // 轨道圆角
  1928. }
  1929. .message {
  1930. display: flex;
  1931. align-items: flex-start;
  1932. margin-bottom: rpx(10);
  1933. &.user {
  1934. flex-direction: row-reverse;
  1935. }
  1936. .avatar {
  1937. width: rpx(30);
  1938. height: rpx(30);
  1939. border-radius: 50%;
  1940. margin: 0 rpx(10);
  1941. }
  1942. .message-content {
  1943. background-color: white;
  1944. padding: rpx(8) rpx(12);
  1945. border-radius: rpx(5);
  1946. font-size: rpx(8);
  1947. color: black;
  1948. max-width: 80%;
  1949. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1950. }
  1951. }
  1952. }
  1953. // 优化发送按钮样式
  1954. .send-button {
  1955. //background: linear-gradient(90deg, $primary-color, $secondary-color);
  1956. border: none;
  1957. color: white;
  1958. &:hover {
  1959. //background: linear-gradient(90deg, darken($primary-color, 5%), darken($secondary-color, 5%));
  1960. }
  1961. }
  1962. </style>
  1963. <style lang="scss">
  1964. // 搜索下拉框样式
  1965. @use 'sass:math';
  1966. // 定义rpx转换函数
  1967. @function rpx($px) {
  1968. @return math.div($px, 750) * 100vw;
  1969. }
  1970. /* 消除小三角 */
  1971. .el-popper__arrow {
  1972. display: none;
  1973. }
  1974. .el-popper.is-light,
  1975. .el-dropdown__popper.el-popper {
  1976. background: transparent;
  1977. border: none;
  1978. box-shadow: none;
  1979. }
  1980. .el-dropdown__popper {
  1981. --el-dropdown-menuItem-hover-color: none;
  1982. }
  1983. .el-autocomplete-suggestion .el-scrollbar__wrap {
  1984. margin: 0 auto;
  1985. background-color: rgba(255, 255, 255, 0.7);
  1986. border: 2px solid white;
  1987. border-radius: rpx(5);
  1988. backdrop-filter: blur(rpx(5));
  1989. }
  1990. .el-autocomplete-suggestion li {
  1991. color: black;
  1992. font-size: rpx(7);
  1993. padding: rpx(5) rpx(8); // 调整下拉项内边距
  1994. }
  1995. .el-autocomplete-suggestion li:hover {
  1996. background: linear-gradient(to bottom, #ffefb0, #ffcc00);
  1997. }
  1998. </style>
  1999. <style scoped lang="scss">
  2000. @use 'sass:math';
  2001. // 定义rpx转换函数
  2002. @function rpx($px) {
  2003. @return math.div($px, 750) * 100vw;
  2004. }
  2005. .default-messages {
  2006. margin-top: rpx(-10);
  2007. margin-bottom: rpx(5);
  2008. }
  2009. </style>