AIDevelop.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  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. <!-- 课程标题 -->
  101. <div class="small-title">
  102. <span>{{ course.courseName }}</span>
  103. </div>
  104. <!-- 视频组件 -->
  105. <VideoPlayer v-if="course.courseContentType === 'video'"
  106. :contentType="course.courseContentType"
  107. :videoPath="course.courseVideoPath"
  108. :courseId="course.id || ''"
  109. :typeId="typeId"
  110. :courseConfigList="course.courseConfigList || []"
  111. :allIndices="flattenMenuItems()"
  112. :currentIndex="course.key || ''"
  113. @timeUpdate="handleVideoTimeUpdate"
  114. @videoEnded="handleVideoEnded"
  115. @switchVideo="handleSelect"
  116. />
  117. <!-- 图片 -->
  118. <ImageView v-if="course.courseContentType === 'image'" :imagePath="course.courseImagePath" altText="课程图片"></ImageView>
  119. <!-- PPT -->
  120. <PptView v-if="course.courseContentType === 'ppt'" :pptPath="course.pptPath" ref="pptRef"></PptView>
  121. <!-- 视频切换按钮 - 始终显示 -->
  122. <div class="video-switch">
  123. <div class="caret-left" @click="playPreviousVideo">
  124. <el-button type="warning" round>
  125. <img :src="leftImg" alt="Left" />上一节</el-button
  126. >
  127. </div>
  128. <div class="caret-right" @click="playNextVideo">
  129. <el-button type="warning" round
  130. >下一节<img :src="rightImg" alt="Right" />
  131. </el-button>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <!-- 弹框组件 -->
  137. <DialogComponents
  138. :questionDialogVisible="questionDialogVisible"
  139. :currentQuestion="courseConfig"
  140. :gradeId="gradeId"
  141. :typeId="typeId"
  142. :courseId="course.id || ''"
  143. @closeQuestionDialog="closeQuestionDialog"
  144. @submitAnswer="handleSubmitAnswer"
  145. />
  146. </div>
  147. </template>
  148. <script setup>
  149. import { ref, onMounted, onBeforeUnmount, computed } from 'vue'
  150. import { useRoute, useRouter } from 'vue-router'
  151. import { Expand, Fold, Memo } from '@element-plus/icons-vue'
  152. import { Search, ArrowLeftBold } from '@element-plus/icons-vue'
  153. import { ElMessage, ElMessageBox, ElNotification, valueEquals } from 'element-plus'
  154. import classImages from '@/assets/icon/class.png'
  155. import { ClassType } from '@/api/class.js'
  156. import { Message } from '@/utils/message/Message.js'
  157. import { saveRecord } from '@/api/personalized/index.js'
  158. // 导入全局状态
  159. import { globalState } from '@/utils/globalState.js'
  160. // 导入图标
  161. import leftImg from '@/assets/icon/backward.png'
  162. import rightImg from '@/assets/icon/f-backward.png'
  163. // 导入新创建的组件
  164. import VideoPlayer from '@/components/videopage/VideoPlayer.vue'
  165. import DialogComponents from '@/components/videopage/DialogComponents.vue'
  166. import PptView from "@/components/PPT/PptView.vue";
  167. import ImageView from '@/components/Image/ImageView.vue'
  168. const router = useRouter() // 获取当前路由对象
  169. const route = useRoute()
  170. // 添加按钮显示状态
  171. const buttonVisible = ref(false)
  172. // 添加抽屉显示状态
  173. const drawerVisible = ref(false)
  174. // 渲染页面标题
  175. const boxIconTitle = ref('')
  176. // 课程集合数据
  177. const courseList = ref([])
  178. //当前课程
  179. const course = ref({})
  180. // 菜单数据
  181. const menuItems = ref([])
  182. // 课程集合数据
  183. const videoPathMap = ref({})
  184. // 已观看课程ID列表
  185. const watchedCourseIds = ref([])
  186. // 试题弹框显示状态
  187. const questionDialogVisible = ref(false)
  188. // 当前显示的试题
  189. const courseConfig = ref({})
  190. // 搜索框
  191. const SearchInput = ref('')
  192. // 年级id
  193. const gradeId = ref('')
  194. // 课程大纲id
  195. const typeId = ref('')
  196. // 课程小节id
  197. const courseId = ref('')
  198. //课程小节字典
  199. const menuDict = ref({
  200. 1: '课前回顾',
  201. 2: '课程引入',
  202. 3: '知识讲解',
  203. 4: '趣味实操',
  204. 5: '课程总结'
  205. })
  206. // 切换抽屉显示状态的函数
  207. const toggleDrawer = () => {
  208. drawerVisible.value = !drawerVisible.value
  209. }
  210. // 返回上一页
  211. const goBack = () => {
  212. router.go(-1)
  213. }
  214. // 菜单打开和关闭的处理函数
  215. const handleOpen = () => {}
  216. const handleClose = () => {}
  217. // 菜单选择的处理函数
  218. const handleSelect = index => {
  219. //测试账号禁用视频
  220. if (disableVideo(index)) return
  221. // 根据索引切换视频
  222. if (videoPathMap.value[index]) {
  223. course.value = videoPathMap.value[index]
  224. courseId.value = course.value.id
  225. // 切换标题后,关闭抽屉
  226. drawerVisible.value = false
  227. } else {
  228. //视频不存在
  229. Message().notifyWarning('视频不存在!', true)
  230. }
  231. }
  232. // 展平所有菜单项索引
  233. const flattenMenuItems = () => {
  234. const indices = []
  235. const traverse = items => {
  236. for (const item of items) {
  237. if (!item.children) {
  238. indices.push(item.key)
  239. } else {
  240. traverse(item.children)
  241. }
  242. }
  243. }
  244. traverse(menuItems.value)
  245. return indices
  246. }
  247. // 播放上一个视频
  248. const playPreviousVideo = () => {
  249. const allIndices = flattenMenuItems()
  250. const currentIndexInList = allIndices.indexOf(course.value.key)
  251. if (currentIndexInList > 0) {
  252. const previousIndex = allIndices[currentIndexInList - 1]
  253. handleSelect(previousIndex)
  254. }
  255. }
  256. // 播放下一个视频
  257. const playNextVideo = () => {
  258. const allIndices = flattenMenuItems()
  259. const currentIndexInList = allIndices.indexOf(course.value.key)
  260. if (currentIndexInList !== -1 && currentIndexInList < allIndices.length - 1) {
  261. const nextIndex = allIndices[currentIndexInList + 1]
  262. handleSelect(nextIndex)
  263. }
  264. }
  265. // 播放下一个视频
  266. const handleVideoEnded = () => {
  267. // 记录当前视频ID为已观看
  268. if (
  269. course.value &&
  270. course.value.id &&
  271. !watchedCourseIds.value.includes(course.value.id)
  272. ) {
  273. watchedCourseIds.value.push(course.value.id)
  274. localStorage.setItem(
  275. 'watchedCourseIds',
  276. JSON.stringify(watchedCourseIds.value)
  277. )
  278. }
  279. // 如果是图片类型,不需要自动播放下一个
  280. if (course.value.courseContentType === 'video') {
  281. const allIndices = flattenMenuItems()
  282. const currentIndexInList = allIndices.indexOf(course.value.key)
  283. if (currentIndexInList !== -1 && currentIndexInList < allIndices.length - 1) {
  284. const nextIndex = allIndices[currentIndexInList + 1]
  285. handleSelect(nextIndex)
  286. }
  287. }
  288. const allIndices = flattenMenuItems()
  289. const currentIndexInList = allIndices.indexOf(course.value.key)
  290. if (currentIndexInList !== -1 && currentIndexInList < allIndices.length - 1) {
  291. const nextIndex = allIndices[currentIndexInList + 1]
  292. handleSelect(nextIndex)
  293. }
  294. }
  295. // 禁用视频
  296. const disableVideo = (index = course.value.key) => {
  297. if (localStorage.getItem('userName') === 'aiTest' && gradeId.value === "1") {
  298. let dis = Number(index.substring(index.indexOf("-") + 1));
  299. if (dis > 5) {
  300. //提示禁用
  301. Message().notifyWarning('您的账号并未开放此课程!', true)
  302. return true
  303. }
  304. }
  305. // if (localStorage.getItem('userName') === 'aiDemo') {
  306. // let dis = Number(index.substring(index.indexOf("-") + 1));
  307. // if (dis > 4) {
  308. // //提示禁用
  309. // Message().notifyWarning('您的账号并未开放此课程!', true)
  310. // return true
  311. // }
  312. // }
  313. return false
  314. }
  315. // 处理视频时间更新事件
  316. const handleVideoTimeUpdate = ({ currentTime, progressPercentage, courseConfig: config }) => {
  317. if (config) {
  318. questionDialogVisible.value = true
  319. courseConfig.value = config
  320. // 保存试题进度
  321. const saveQuestProgress = async () =>{
  322. try {
  323. // 确保courseId已经设置
  324. if (!courseId.value && typeId.value) {
  325. const courseRes = await ClassType(typeId.value)
  326. if (courseRes.data && courseRes.data.length > 0) {
  327. courseId.value = course.value && course.value.id ? course.value.id : courseRes.data[0].id
  328. }
  329. }
  330. if (config.id) {
  331. // 保存弹窗问题进度
  332. await saveRecord({
  333. brpNjId: gradeId.value,
  334. brpCtId: typeId.value,
  335. brpCourseConfigId: config.id,
  336. brpCourseId: courseId.value,
  337. brpType: 'courseQuest',
  338. brpProgress: progressPercentage
  339. })
  340. } else {
  341. console.error('无法保存试题进度: 试题id不存在')
  342. }
  343. }catch(error){
  344. console.error(`保存试题进度失败:`, error)
  345. }
  346. }
  347. // 调用异步函数
  348. saveQuestProgress()
  349. }
  350. }
  351. // 关闭试题弹框
  352. const closeQuestionDialog = () => {
  353. questionDialogVisible.value = false
  354. }
  355. // 提交答案
  356. const handleSubmitAnswer = ({ selectedOption }) => {
  357. questionDialogVisible.value = false
  358. }
  359. // 搜索
  360. const querySearch = (queryString, cb) => {
  361. const sections = getAllCourseSections()
  362. const results = queryString
  363. ? sections.filter(section =>
  364. section.title.toLowerCase().includes(queryString.toLowerCase())
  365. )
  366. : sections
  367. cb(results)
  368. }
  369. const filteredTitles = computed(() => {
  370. const sections = getAllCourseSections()
  371. if (!SearchInput.value) {
  372. return sections
  373. }
  374. return sections.filter(section =>
  375. section.title.toLowerCase().includes(SearchInput.value.toLowerCase())
  376. )
  377. })
  378. const handleSearchSelect = item => {
  379. handleSelect(item.key)
  380. // 清空输入框
  381. SearchInput.value = ''
  382. }
  383. // 课程小节数据提取
  384. const getAllCourseSections = () => {
  385. let sections = []
  386. const traverse = items => {
  387. items.forEach(item => {
  388. if (item.children) {
  389. traverse(item.children)
  390. } else {
  391. sections.push({ title: item.title, key: item.key })
  392. }
  393. })
  394. }
  395. traverse(menuItems.value)
  396. return sections
  397. }
  398. // 渲染 课程数据结构 以及 视频
  399. onMounted(async () => {
  400. const typeIdParam = router.currentRoute.value.query.typeId
  401. if (typeIdParam) {
  402. typeId.value = typeIdParam
  403. try {
  404. // 取接口课程数据
  405. const res = await ClassType(typeIdParam)
  406. courseList.value = res.data
  407. // 初始化已观看课程ID
  408. const savedWatchedIds = localStorage.getItem('watchedCourseIds')
  409. if (savedWatchedIds) {
  410. watchedCourseIds.value = JSON.parse(savedWatchedIds)
  411. }
  412. //课程数据
  413. let topName = '';
  414. courseList.value.forEach((courseTemp, index) => {
  415. let menuIndex = courseTemp.courseLabel + '-' + (index + 1)
  416. //大节
  417. let menu = {
  418. key: menuIndex,
  419. index: menuIndex,
  420. title: courseTemp.courseName
  421. }
  422. // 手动修改第一个课程为image类型用于测试
  423. // if (index === 0) {
  424. // // courseTemp.courseContentType = 'ppt';
  425. // // courseTemp.pptPath = 'http://59.110.91.129:8088/admin-api/infra/file/29/get/20250820/ppt_1755654972861.pptx';
  426. // courseTemp.courseContentType = 'image';
  427. // courseTemp.courseImagePath = 'http://59.110.91.129:8088/admin-api/infra/file/4/get/20250715/one_1752549934393.png,http://59.110.91.129:8088/admin-api/infra/file/29/get/20250722/666_1753151547130.png';
  428. // // 可选:修改课程名称以便识别
  429. // courseTemp.courseName = '测试';
  430. // }
  431. if (topName === courseTemp.courseLabel) {
  432. let topMenu = menuItems.value[menuItems.value.length - 1]
  433. let topMenuChildren = topMenu.children;
  434. if (topMenuChildren) {
  435. topMenuChildren.push(menu)
  436. } else {
  437. menu = {
  438. key: menuIndex,
  439. index: menuIndex,
  440. title: menuDict.value[courseTemp.courseLabel],
  441. children: [
  442. {
  443. key: topMenu.key,
  444. index: topMenu.index,
  445. title: topMenu.title,
  446. },
  447. {
  448. key: menuIndex,
  449. index: menuIndex,
  450. title: courseTemp.courseName
  451. }
  452. ]
  453. }
  454. menuItems.value[menuItems.value.length-1] = menu
  455. }
  456. }else{
  457. menuItems.value.push(menu)
  458. }
  459. topName = courseTemp.courseLabel
  460. courseTemp['key'] = menuIndex
  461. videoPathMap.value[menuIndex] = courseTemp
  462. //确定默认课程
  463. if (index === 0) {
  464. course.value = courseTemp
  465. courseId.value = courseTemp.id
  466. }
  467. })
  468. } catch (error) {
  469. console.error('获取课程数据失败:', error)
  470. }
  471. }
  472. const title = router.currentRoute.value.query.typeName
  473. if (title) {
  474. boxIconTitle.value = String(title)
  475. }
  476. // 初始化年级ID
  477. gradeId.value = globalState.initGradeId()
  478. })
  479. onBeforeUnmount(() => {
  480. // 组件卸载时的清理
  481. })
  482. </script>
  483. <style scoped lang="scss">
  484. @use 'sass:math';
  485. @use 'sass:color'; // 引入 color 模块
  486. // 定义rpx转换函数
  487. @function rpx($px) {
  488. @return math.div($px, 750) * 100vw;
  489. }
  490. // 定义儿童风格的蓝紫色调
  491. $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
  492. $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
  493. $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
  494. $light-color: #ffffff; // 浅色背景:淡紫色
  495. $text-color: #483d8b; // 文本颜色:靛蓝色
  496. // 视频切换按钮样式
  497. .video-switch {
  498. width: 100%;
  499. display: flex;
  500. margin-top: rpx(5);
  501. margin-bottom: rpx(15);
  502. justify-content: center;
  503. }
  504. .caret-right,
  505. .caret-left {
  506. width: rpx(50);
  507. margin: 0 rpx(20);
  508. margin: auto;
  509. display: flex;
  510. justify-content: center;
  511. }
  512. .caret-left ::v-deep(.el-button.is-round),
  513. .caret-right ::v-deep(.el-button.is-round) {
  514. width: rpx(50);
  515. height: rpx(15);
  516. color: white;
  517. font-size: rpx(7);
  518. border-radius: none;
  519. border: 1px white solid;
  520. background-color: rgb(255, 255, 255, 0.5);
  521. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  522. }
  523. .caret-right img,
  524. .caret-left img {
  525. width: rpx(12);
  526. }
  527. .default-messages {
  528. margin-top: rpx(-10);
  529. margin-bottom: rpx(5);
  530. }
  531. /* 添加过渡样式 */
  532. .drawer-slide-enter-active,
  533. .drawer-slide-leave-active {
  534. transition: all 0.3s ease;
  535. }
  536. .drawer-slide-enter-from,
  537. .drawer-slide-leave-to {
  538. transform: translateX(-100%);
  539. opacity: 0;
  540. }
  541. .home-container ::v-deep(.el-drawer__body) {
  542. width: rpx(135);
  543. height: 100%;
  544. position: relative;
  545. background: linear-gradient(to bottom, #001169, #8a78d0);
  546. }
  547. .content-box {
  548. flex: 1;
  549. height: 100%;
  550. display: flex;
  551. flex-direction: column; /* 子元素上下排列 */
  552. background: linear-gradient(to bottom, #001169, #8a78d0);
  553. }
  554. .icon-expand {
  555. width: rpx(8);
  556. height: rpx(35);
  557. border-top-right-radius: rpx(5);
  558. border-bottom-right-radius: rpx(5);
  559. z-index: 9999;
  560. position: absolute;
  561. top: 50%;
  562. transform: translateY(-50%);
  563. cursor: pointer; // 添加鼠标指针样式
  564. clip-path: polygon(0 0, 100% 15%, 100% 85%, 0 100%);
  565. display: flex;
  566. justify-content: center;
  567. align-items: center;
  568. transition: all 0.3s ease;
  569. }
  570. .icon-expand .vertical-lines {
  571. color: #8a78d0;
  572. font-size: rpx(10);
  573. }
  574. .home-container {
  575. position: fixed;
  576. top: 0;
  577. left: 0;
  578. right: 0;
  579. bottom: 0;
  580. background: linear-gradient(to bottom, #001169, #b4a8e1);
  581. display: flex;
  582. }
  583. .el-row {
  584. margin: auto;
  585. margin-top: rpx(20);
  586. }
  587. .tac ::v-deep(.el-menu) {
  588. background-color: transparent;
  589. border: none;
  590. width: 100%;
  591. margin-top: rpx(8);
  592. }
  593. /* 取消点击后的蓝色字体 el-sub-menu__title*/
  594. .tac ::v-deep(.el-menu-item.is-active),
  595. .tac ::v-deep(.el-sub-menu__title.is-active) {
  596. color: white;
  597. }
  598. // 取消鼠标悬浮颜色
  599. .tac ::v-deep(.el-sub-menu__title) {
  600. width: rpx(130);
  601. height: rpx(20);
  602. margin-bottom: rpx(5);
  603. border-radius: rpx(6);
  604. // 添加flex布局使标题和图标两端对齐
  605. display: flex;
  606. justify-content: space-between;
  607. align-items: center;
  608. }
  609. .el-menu ::v-deep(.el-sub-menu__title:hover),
  610. .el-menu ::v-deep(.el-sub-menu__title:focus),
  611. .el-menu ::v-deep(.el-sub-menu__title:active) {
  612. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  613. background-color: transparent;
  614. }
  615. // 添加二级标题折叠图标样式
  616. ::v-deep(.el-sub-menu__icon-arrow) {
  617. color: white;
  618. font-size: rpx(10); // 增大图标尺寸
  619. margin-left: auto; // 将图标推到右侧
  620. margin-top: rpx(-5);
  621. display: block;
  622. width: rpx(16); // 确保有明确宽度
  623. }
  624. // 鼠标悬停时的图标样式
  625. .el-menu ::v-deep(.el-sub-menu__title:hover .el-sub-menu__icon-arrow) {
  626. color: black; // 与悬停状态的文字颜色保持一致
  627. }
  628. .el-menu ::v-deep(.el-icon svg) {
  629. font-size: rpx(9);
  630. }
  631. .mb-2 {
  632. color: white;
  633. font-size: rpx(9);
  634. }
  635. .mb-2 img {
  636. width: rpx(10);
  637. height: rpx(10);
  638. vertical-align: middle;
  639. margin-top: rpx(-2);
  640. }
  641. .el-menu-item {
  642. width: rpx(100);
  643. height: rpx(20);
  644. margin-bottom: rpx(5);
  645. border-radius: rpx(6);
  646. color: white;
  647. font-size: rpx(8);
  648. }
  649. .el-menu ::v-deep(.el-sub-menu__title) {
  650. color: white;
  651. width: rpx(100);
  652. height: rpx(20);
  653. margin-bottom: rpx(5);
  654. font-size: rpx(8);
  655. }
  656. .el-menu ::v-deep(.el-sub-menu__title:hover),
  657. .el-menu ::v-deep(.el-sub-menu__title:focus),
  658. .el-menu ::v-deep(.el-sub-menu__title:active) {
  659. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  660. color: black;
  661. }
  662. .el-menu ::v-deep(.el-menu-item:hover),
  663. .el-menu ::v-deep(.el-menu-item:focus),
  664. .el-menu ::v-deep(.el-menu-item:active) {
  665. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  666. color: black;
  667. font-size: rpx(8);
  668. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  669. }
  670. .el-menu .el-menu-item.is-active {
  671. background: linear-gradient(to bottom, #fee78a, #ffce1b);
  672. color: black;
  673. font-size: rpx(8);
  674. box-shadow: 0 4px 8px rgba(3, 3, 3, 0.3);
  675. }
  676. .drawer-box {
  677. position: absolute;
  678. display: flex;
  679. align-items: center;
  680. height: 100%;
  681. width: 80%;
  682. }
  683. .drawer-box .toggle-button {
  684. width: rpx(10);
  685. height: rpx(50);
  686. font-size: rpx(7);
  687. background-color: rgba(17, 23, 29, 0.2);
  688. border: none;
  689. position: relative;
  690. writing-mode: vertical-lr; // 文字垂直排列,从左到右
  691. text-orientation: upright; // 文字保持正立
  692. }
  693. .toggle-button:hover {
  694. left: 0;
  695. }
  696. .toggle-button.is-active,
  697. .toggle-button:active,
  698. .toggle-button:focus {
  699. background-color: rgba(165, 209, 247, 0.8);
  700. color: white;
  701. border: none; // 移除点击时的边框
  702. outline: none; // 移除点击时的外边框
  703. }
  704. .box-1 {
  705. width: 100%;
  706. // height: rpx(50);
  707. margin-top: rpx(10);
  708. display: flex;
  709. justify-content: center;
  710. align-items: center;
  711. box-sizing: border-box;
  712. font-size: rpx(15); // 默认字体大小
  713. }
  714. .inner-box {
  715. height: 100%;
  716. display: flex;
  717. justify-content: center;
  718. align-items: center;
  719. font-size: rpx(16); // 默认字体大小
  720. }
  721. .left-box {
  722. position: relative;
  723. justify-content: flex-start;
  724. align-items: flex-start;
  725. flex: 1; // 设置左侧盒子占比为 2
  726. cursor: pointer; // 添加鼠标指针样式
  727. }
  728. .box-icon {
  729. width: 100%;
  730. height: 100%;
  731. flex: 1;
  732. display: flex; // 添加 flex 布局
  733. align-items: center; // 垂直居中
  734. color: white; // 设置图标颜色为白色
  735. padding-left: rpx(15);
  736. font-size: rpx(10); // 设置图标大小,可按需调整
  737. }
  738. .box-icon .left-icon {
  739. margin-left: rpx(10);
  740. margin-right: rpx(5); // 设置图标和文字之间的间距 ;
  741. }
  742. .left-box span {
  743. position: absolute;
  744. font-size: rpx(11); // 默认字体大小
  745. color: white;
  746. }
  747. .right-box {
  748. flex: 1;
  749. position: relative; // 添加相对定位;
  750. }
  751. .top-right-box {
  752. position: absolute; // 添加绝对定位
  753. // margin-top: rpx(9); // 调整上边距离
  754. margin-left: rpx(260); // 调整右边距离
  755. width: rpx(100); // 设置盒子宽度,可按需调整
  756. // height: 60px; // 设置盒子高度,可按需调整
  757. margin-right: rpx(20);
  758. display: flex;
  759. justify-content: flex-end;
  760. }
  761. .top-right-box {
  762. ::v-deep(.el-input__wrapper) {
  763. height: rpx(15);
  764. font-size: rpx(6);
  765. background-color: rgb(255, 255, 255, 0.5);
  766. border-radius: rpx(12);
  767. border: white 1px solid;
  768. color: white;
  769. }
  770. ::v-deep(.el-input__icon) {
  771. color: white; // 设置输入框图标颜色为白色
  772. }
  773. // 添加占位符样式
  774. ::v-deep(.el-input__inner::placeholder) {
  775. color: white;
  776. }
  777. // 添加输入框文字颜色样式
  778. ::v-deep(.el-input__inner) {
  779. color: black;
  780. }
  781. }
  782. // 搜索框
  783. .search-input {
  784. width: rpx(100);
  785. height: rpx(15);
  786. font-size: rpx(7);
  787. }
  788. .box-2 {
  789. width: 100%;
  790. flex: 1;
  791. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  792. box-sizing: border-box;
  793. // display: flex; // 确保子元素水平排列
  794. flex-wrap: wrap; // 允许子元素换行;
  795. align-content: center; // 顶部对齐;
  796. cursor: pointer; // 添加鼠标指针样式
  797. }
  798. .small-title {
  799. width: 100%;
  800. // margin-top: rpx(-20);
  801. height: rpx(20);
  802. color: white;
  803. font-size: rpx(10);
  804. justify-content: center; //使子元素水平居中
  805. }
  806. // 图片容器样式
  807. .image-container {
  808. width: 100%;
  809. display: flex;
  810. justify-content: center;
  811. align-items: center;
  812. // padding: rpx(20) 0;
  813. }
  814. // 图片样式
  815. .course-image {
  816. max-width: 70%;
  817. max-height: rpx(400);
  818. object-fit: contain;
  819. border-radius: rpx(12);
  820. box-shadow: 0 rpx(10) rpx(20) rgba(0, 0, 0, 0.1);
  821. }
  822. // 儿童风格试题弹框样式
  823. .child-dialog {
  824. .el-dialog__header {
  825. display: none; // 隐藏原有的标题栏
  826. }
  827. .el-dialog__body {
  828. padding: rpx(20);
  829. position: relative;
  830. }
  831. .el-dialog__footer {
  832. border-top: none;
  833. padding: rpx(10) rpx(20);
  834. text-align: center;
  835. margin-top: auto; // 使底部按钮位于底部
  836. }
  837. .el-dialog__wrapper {
  838. // 修改半透明背景色
  839. background-color: rgba(0, 0, 0, 0.6);
  840. }
  841. .el-dialog {
  842. border: none;
  843. border-radius: rpx(20);
  844. background: linear-gradient(
  845. 135deg,
  846. $light-color,
  847. #d8bfd8
  848. ); // 柔和的蓝紫色渐变
  849. overflow: hidden;
  850. display: flex; // 添加 flex 布局
  851. flex-direction: column; // 设置垂直布局
  852. min-height: 0; // 防止子元素溢出
  853. // 添加装饰元素
  854. &::before {
  855. content: '';
  856. position: absolute;
  857. top: 0;
  858. left: 0;
  859. width: 100%;
  860. height: rpx(10);
  861. background: linear-gradient(90deg, $secondary-color, $accent-color);
  862. }
  863. }
  864. }
  865. // 问题标题样式
  866. .question-title {
  867. padding: rpx(15);
  868. border-radius: rpx(12);
  869. margin-bottom: rpx(20);
  870. color: #483d8b;
  871. font-weight: bold;
  872. font-size: rpx(12);
  873. position: relative;
  874. display: flex;
  875. // align-items: center;
  876. .question-icon {
  877. background-color: $accent-color;
  878. color: white;
  879. width: rpx(24);
  880. height: rpx(24);
  881. border-radius: 50%;
  882. display: flex;
  883. align-items: center;
  884. justify-content: center;
  885. margin-right: rpx(10);
  886. font-weight: bold;
  887. box-shadow: 0 rpx(2) rpx(5) rgba($accent-color, 0.3);
  888. }
  889. }
  890. // 选项容器样式
  891. .options-container {
  892. margin-bottom: rpx(20);
  893. }
  894. // 问题选项样式
  895. .question-option {
  896. margin: rpx(8) 0;
  897. padding: rpx(10) rpx(15);
  898. border-radius: rpx(12);
  899. border: rpx(1) solid rgba($primary-color, 0.3);
  900. transition: all 0.3s ease;
  901. display: flex;
  902. align-items: center;
  903. background-color: white;
  904. box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.05);
  905. ::v-deep(.el-radio__label) {
  906. color: $text-color;
  907. margin-left: rpx(8);
  908. flex: 1;
  909. text-align: left;
  910. // 增大字体大小
  911. font-size: rpx(12);
  912. }
  913. // 选中时的样式变化
  914. .el-radio__input.is-checked + .el-radio__label {
  915. font-weight: bold;
  916. color: $accent-color;
  917. }
  918. &:hover {
  919. background-color: rgba($primary-color, 0.05);
  920. border-color: rgba($primary-color, 0.5);
  921. transform: translateY(-rpx(1));
  922. }
  923. }
  924. // 暂无选项样式
  925. .no-options {
  926. color: rgba($text-color, 0.7);
  927. text-align: center;
  928. padding: rpx(20);
  929. font-size: rpx(12);
  930. }
  931. // 底部按钮样式
  932. .child-button {
  933. min-width: rpx(80);
  934. height: rpx(30);
  935. border-radius: rpx(8);
  936. font-size: rpx(12);
  937. font-weight: 500;
  938. transition: all 0.3s ease;
  939. box-shadow: 0 rpx(2) rpx(8) rgba(0, 0, 0, 0.1);
  940. &.confirm {
  941. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  942. border: none;
  943. border-right: 15px;
  944. color: white;
  945. &:hover {
  946. background: linear-gradient(
  947. to bottom,
  948. color.adjust(#ab81ff, $lightness: -5%),
  949. color.adjust(#8559dc, $lightness: -5%)
  950. );
  951. transform: translateY(-rpx(1));
  952. color: white;
  953. }
  954. }
  955. &.cancel {
  956. background: white;
  957. border: rpx(1) solid rgba($primary-color, 0.3);
  958. color: $text-color;
  959. &:hover {
  960. background: rgba($primary-color, 0.05);
  961. border-color: rgba($primary-color, 0.5);
  962. transform: translateY(-rpx(1));
  963. }
  964. }
  965. }
  966. // AI对话图标样式
  967. .ai-icon-container {
  968. position: absolute;
  969. bottom: rpx(20);
  970. right: rpx(20);
  971. display: flex;
  972. flex-direction: column;
  973. align-items: center;
  974. cursor: pointer;
  975. transition: all 0.3s ease;
  976. &:hover {
  977. transform: translateY(-rpx(2));
  978. }
  979. .ai-icon {
  980. width: rpx(30);
  981. height: rpx(30);
  982. margin-bottom: rpx(0);
  983. filter: drop-shadow(0 rpx(2) rpx(4) rgba($primary-color, 0.3));
  984. // 添加过渡动画
  985. transition: transform 0.3s ease;
  986. }
  987. // 悬浮时放大效果
  988. .ai-icon:hover {
  989. transform: scale(1.5);
  990. }
  991. .ai-text {
  992. color: $text-color;
  993. font-size: rpx(8);
  994. background-color: rgba(255, 255, 255, 0.7);
  995. padding: rpx(2) rpx(5);
  996. border-radius: rpx(5);
  997. }
  998. }
  999. // AI消息样式
  1000. .ai-message {
  1001. display: flex;
  1002. align-items: flex-start;
  1003. margin-bottom: rpx(15);
  1004. .ai-avatar {
  1005. width: rpx(30);
  1006. height: rpx(30);
  1007. border-radius: 50%;
  1008. margin-right: rpx(10);
  1009. background-color: $primary-color;
  1010. padding: rpx(5);
  1011. // box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.2);
  1012. }
  1013. .ai-text-content {
  1014. background-color: $light-color;
  1015. padding: rpx(8) rpx(12);
  1016. border-radius: rpx(10);
  1017. font-size: rpx(10);
  1018. color: $text-color;
  1019. max-width: 80%;
  1020. // box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1021. }
  1022. }
  1023. // 用户输入框样式
  1024. .user-input {
  1025. ::v-deep(.el-input__wrapper) {
  1026. height: rpx(23);
  1027. border-top-left-radius: rpx(5);
  1028. border-bottom-left-radius: rpx(5);
  1029. border-color: rgba($primary-color, 0.3);
  1030. &:focus-within {
  1031. box-shadow: 0 0 0 rpx(1) rgba($primary-color, 0.5);
  1032. }
  1033. }
  1034. ::v-deep(.el-input__inner) {
  1035. font-size: rpx(10);
  1036. // color: $text-color;
  1037. text-indent: 1em;
  1038. }
  1039. ::v-deep(.el-input-group__append, .el-input-group__prepend) {
  1040. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  1041. border-top-right-radius: rpx(5);
  1042. border-bottom-right-radius: rpx(5);
  1043. color: white;
  1044. font-size: rpx(9);
  1045. }
  1046. }
  1047. /* 定义淡入和缩放动画 */
  1048. .fade-scale-enter-active,
  1049. .fade-scale-leave-active {
  1050. transition: all 0.5s ease;
  1051. }
  1052. .fade-scale-enter-from,
  1053. .fade-scale-leave-to {
  1054. opacity: 0.1;
  1055. transform: scale(0.9);
  1056. }
  1057. // 自定义试题弹框背景
  1058. .child-dialog-wrapper {
  1059. position: fixed;
  1060. top: 0;
  1061. left: 0;
  1062. right: 0;
  1063. bottom: 0;
  1064. background-color: rgba(0, 0, 0, 0.6); // 半透明背景
  1065. display: flex;
  1066. justify-content: center;
  1067. align-items: center;
  1068. z-index: 1000;
  1069. }
  1070. .child-dialog {
  1071. border: none;
  1072. border-radius: rpx(15);
  1073. background: rgb(255, 255, 255, 0.8); // 柔和的蓝紫色渐变
  1074. overflow: hidden;
  1075. padding: rpx(5);
  1076. // width: 40%;
  1077. // height: 60%;
  1078. position: relative;
  1079. }
  1080. // AI对话弹框样式
  1081. .ai-dialog-wrapper {
  1082. position: fixed;
  1083. top: 0;
  1084. left: 0;
  1085. right: 0;
  1086. bottom: 0;
  1087. display: flex;
  1088. justify-content: flex-end;
  1089. align-items: center;
  1090. z-index: 1001;
  1091. pointer-events: none;
  1092. }
  1093. .ai-dialog {
  1094. border: none;
  1095. border-radius: rpx(15);
  1096. background: rgb(255, 255, 255, 0.8);
  1097. overflow: hidden;
  1098. padding: rpx(20);
  1099. width: 30%;
  1100. // 增加高度
  1101. height: 80%;
  1102. margin-right: rpx(50);
  1103. pointer-events: auto;
  1104. position: relative;
  1105. display: flex;
  1106. flex-direction: column;
  1107. &::before {
  1108. content: '';
  1109. position: absolute;
  1110. top: 0;
  1111. left: 0;
  1112. width: 100%;
  1113. height: rpx(10);
  1114. }
  1115. }
  1116. .ai-dialog-header {
  1117. position: relative;
  1118. display: flex;
  1119. justify-content: center;
  1120. align-items: center;
  1121. margin-bottom: rpx(15);
  1122. margin-top: rpx(-10);
  1123. img {
  1124. width: rpx(15);
  1125. }
  1126. h3 {
  1127. color: black;
  1128. font-size: rpx(12);
  1129. }
  1130. .close-btn {
  1131. padding: 0;
  1132. width: rpx(20);
  1133. height: rpx(20);
  1134. font-size: rpx(16);
  1135. line-height: 1;
  1136. position: absolute;
  1137. background-color: transparent;
  1138. border: none;
  1139. margin-left: rpx(200);
  1140. }
  1141. }
  1142. .ai-dialog-content {
  1143. flex: 1;
  1144. display: flex;
  1145. flex-direction: column;
  1146. }
  1147. .ai-message-history {
  1148. flex: 1;
  1149. // 当内容超出容器高度时,显示垂直滚动条
  1150. overflow-y: auto;
  1151. margin-bottom: rpx(15);
  1152. // 可以根据实际情况调整最大高度
  1153. font-size: rpx(5);
  1154. max-height: 50vh;
  1155. // padding: 5px 10px;
  1156. .message {
  1157. display: flex;
  1158. align-items: flex-start;
  1159. margin-bottom: rpx(10);
  1160. &.user {
  1161. flex-direction: row-reverse;
  1162. }
  1163. .avatar {
  1164. width: rpx(30);
  1165. height: rpx(30);
  1166. border-radius: 50%;
  1167. margin: 0 rpx(10);
  1168. }
  1169. .user {
  1170. width: 15px;
  1171. height: 15px;
  1172. }
  1173. .message-content {
  1174. background-color: #ffffff;
  1175. font-size: rpx(5);
  1176. max-width: 80%;
  1177. color: black;
  1178. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1179. }
  1180. }
  1181. // 滚动条整体样式
  1182. &::-webkit-scrollbar {
  1183. width: rpx(4); // 滚动条宽度
  1184. }
  1185. // 滚动条滑块样式
  1186. &::-webkit-scrollbar-thumb {
  1187. background-color: $primary-color; // 滑块颜色
  1188. border-radius: rpx(4); // 滑块圆角
  1189. transition: background-color 0.3s ease; // 颜色过渡效果
  1190. &:hover {
  1191. //background-color: darken($primary-color, 10%); // 悬停时滑块颜色加深
  1192. }
  1193. }
  1194. // 滚动条轨道样式
  1195. &::-webkit-scrollbar-track {
  1196. background-color: rgba($primary-color, 0.2); // 轨道颜色
  1197. border-radius: rpx(4); // 轨道圆角
  1198. }
  1199. .message {
  1200. display: flex;
  1201. align-items: flex-start;
  1202. margin-bottom: rpx(10);
  1203. &.user {
  1204. flex-direction: row-reverse;
  1205. }
  1206. .avatar {
  1207. width: rpx(30);
  1208. height: rpx(30);
  1209. border-radius: 50%;
  1210. margin: 0 rpx(10);
  1211. }
  1212. .message-content {
  1213. background-color: white;
  1214. padding: rpx(8) rpx(12);
  1215. border-radius: rpx(5);
  1216. font-size: rpx(8);
  1217. color: black;
  1218. max-width: 80%;
  1219. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  1220. }
  1221. }
  1222. }
  1223. // 优化发送按钮样式
  1224. .send-button {
  1225. //background: linear-gradient(90deg, $primary-color, $secondary-color);
  1226. border: none;
  1227. color: white;
  1228. &:hover {
  1229. //background: linear-gradient(90deg, darken($primary-color, 5%), darken($secondary-color, 5%));
  1230. }
  1231. }
  1232. </style>
  1233. <style lang="scss">
  1234. // 搜索下拉框样式
  1235. @use 'sass:math';
  1236. // 定义rpx转换函数
  1237. @function rpx($px) {
  1238. @return math.div($px, 750) * 100vw;
  1239. }
  1240. /* 消除小三角 */
  1241. .el-popper__arrow {
  1242. display: none;
  1243. }
  1244. .el-popper.is-light,
  1245. .el-dropdown__popper.el-popper {
  1246. background: transparent;
  1247. border: none;
  1248. box-shadow: none;
  1249. }
  1250. .el-dropdown__popper {
  1251. --el-dropdown-menuItem-hover-color: none;
  1252. }
  1253. .el-autocomplete-suggestion .el-scrollbar__wrap {
  1254. margin: 0 auto;
  1255. background-color: rgba(255, 255, 255, 0.7);
  1256. border: 2px solid white;
  1257. border-radius: rpx(5);
  1258. backdrop-filter: blur(rpx(5));
  1259. }
  1260. .el-autocomplete-suggestion li {
  1261. color: black;
  1262. font-size: rpx(7);
  1263. padding: rpx(5) rpx(8); // 调整下拉项内边距
  1264. }
  1265. .el-autocomplete-suggestion li:hover {
  1266. background: linear-gradient(to bottom, #ffefb0, #ffcc00);
  1267. }
  1268. </style>
  1269. <style scoped lang="scss">
  1270. @use 'sass:math';
  1271. // 定义rpx转换函数
  1272. @function rpx($px) {
  1273. @return math.div($px, 750) * 100vw;
  1274. }
  1275. .default-messages {
  1276. margin-top: rpx(-10);
  1277. margin-bottom: rpx(5);
  1278. }
  1279. </style>