Interface.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  1. <template>
  2. <!-- 编程课程视频页面 -->
  3. <div class="home-container">
  4. <div class="content-box">
  5. <div class="box-1">
  6. <div class="inner-box left-box">
  7. <div class="box-icon" @click="emit('closeVideo')">
  8. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  9. 返回
  10. </div>
  11. </div>
  12. </div>
  13. <div class="box-2">
  14. <!-- 课程标题 -->
  15. <div class="small-title">
  16. <span>{{ course.courseName }}</span>
  17. </div>
  18. <el-empty v-if="isDisabled"
  19. image-size="500"
  20. description="您无权查看该课程!"
  21. :image="isDisabledImage"
  22. />
  23. <template v-else>
  24. <!-- 视频组件 -->
  25. <VideoPlayer
  26. v-if="course.courseContentType === 'video'"
  27. :contentType="course.courseContentType"
  28. :videoPath="course.courseVideoPath"
  29. :courseId="course.id || ''"
  30. :typeId="course.typeId"
  31. :courseConfigList="course.courseConfigList || []"
  32. :allIndices="flattenMenuItems()"
  33. :currentIndex="course.key || ''"
  34. @timeUpdate="handleVideoTimeUpdate"
  35. @videoEnded="handleVideoEnded"
  36. @saveProgress="handleSaveProgress"
  37. />
  38. <!-- 图片 -->
  39. <ImageView v-if="course.courseContentType === 'image'" :imagePath="course.courseImagePath" altText="课程图片"></ImageView>
  40. <!-- PPT -->
  41. <PptView v-if="course.courseContentType === 'ppt'" :pptPath="course.pptPath" ref="pptRef"></PptView>
  42. <!--文生文-->
  43. <TextToText class="contentClass" v-if="course.courseContentType === 'aiTextToText'" ref="aiTextToText"></TextToText>
  44. <!--文生图-->
  45. <TextToImage class="contentClass" v-if="course.courseContentType === 'aiTextToImage'" ref="aiTextToImage"></TextToImage>
  46. <!--图生图-->
  47. <ImageToImage class="contentClass" v-if="course.courseContentType === 'aiImageToImage'" ref="aiImageToImage"></ImageToImage>
  48. <!--图生视频-->
  49. <ImageToVideo class="contentClass" v-if="course.courseContentType === 'aiImageToVideo'" ref="aiImageToVideo"></ImageToVideo>
  50. <!--编程地图游戏-->
  51. <MapGame v-if="course.courseContentType === 'blockly'"
  52. :game-id="course.id"
  53. :map-background="course.blocklyBackground"
  54. :map-tile-size="course.blocklyTileSize"
  55. :map-start-point="course.blocklyStartPoint"
  56. :map-end-point="course.blocklyEndPoint"
  57. :map-walkable-points="course.blocklyWalkablePoints"
  58. :user-direction="course.blocklyUserDirection"
  59. :user-image="course.blocklyUserImage"
  60. :info="course.blocklyInfo"
  61. :game-title="course.courseName"
  62. :course-list="props.courseList"
  63. :current-index="props.courseList.findIndex(item => item.id === course.id)"
  64. @close-game="emit('closeVideo')"
  65. @prev-section="playPreviousVideo"
  66. @next-section="playNextVideo"
  67. @saveProgress="saveBlocklyProgress"
  68. ></MapGame>
  69. </template>
  70. <!-- 视频切换按钮 - 始终显示 -->
  71. <div class="video-switch">
  72. <div class="caret-left" @click="playPreviousVideo">
  73. <el-button type="warning" round :disabled="props.courseList.findIndex(item => item.id === course.id) === 0">
  74. <img :src="leftImg" alt="Left" />上一节</el-button
  75. >
  76. </div>
  77. <div class="caret-right" @click="playNextVideo">
  78. <el-button type="warning" round :disabled="props.courseList.findIndex(item => item.id === course.id) === props.courseList.length - 1"
  79. >下一节<img :src="rightImg" alt="Right" />
  80. </el-button>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <!-- 弹框组件 -->
  86. <DialogComponents
  87. componentType="blockly"
  88. :questionDialogVisible="questionDialogVisible"
  89. :currentQuestion="courseConfig"
  90. :gradeId="gradeId"
  91. :typeId="typeId"
  92. :courseId="course.id || ''"
  93. @closeQuestionDialog="closeQuestionDialog"
  94. @submitAnswer="handleSubmitAnswer"
  95. />
  96. </div>
  97. </template>
  98. <script setup>
  99. import { ref, onMounted, computed } from 'vue'
  100. import { useRouter } from 'vue-router'
  101. import { ArrowLeftBold } from '@element-plus/icons-vue'
  102. import { ElMessage } from 'element-plus'
  103. import isDisabledImage from '@/assets/images/permission/isDisabled.png'
  104. import { ClassType } from '@/api/class.js'
  105. import { Message } from '@/utils/message/Message.js'
  106. import { saveRecordBlockly } from '@/api/personalized/index.js'
  107. // 导入全局状态
  108. import { globalState } from '@/utils/globalState.js'
  109. // 导入图标
  110. import leftImg from '@/assets/icon/backward.png'
  111. import rightImg from '@/assets/icon/f-backward.png'
  112. // 导入新创建的组件
  113. import VideoPlayer from '@/components/videopage/VideoPlayer.vue'
  114. import DialogComponents from '@/components/videopage/DialogComponents.vue'
  115. import PptView from "@/components/PPT/PptView.vue";
  116. import ImageView from '@/components/Image/ImageView.vue'
  117. // AI实验室
  118. import TextToText from "@/components/ai/text/TextToText.vue";
  119. import TextToImage from "@/components/ai/image/TextToImage.vue";
  120. import ImageToImage from "@/components/ai/image/ImageToImage.vue";
  121. import ImageToVideo from "@/components/ai/video/ImageToVideo.vue";
  122. import MapGame from "@/components/blockly/MapGame.vue";
  123. import {getBlocklyByTypeId} from "@/api/programming/index.js";
  124. const router = useRouter() // 获取当前路由对象
  125. // 渲染页面标题
  126. const boxIconTitle = ref('')
  127. // 定义组件的props
  128. const props = defineProps({
  129. courseData: {
  130. type: Object,
  131. default: null
  132. },
  133. courseList: {
  134. type: Array,
  135. default: () => []
  136. }
  137. })
  138. // 定义emit事件
  139. const emit = defineEmits(['closeVideo'])
  140. // 课程集合数据
  141. const courseList = ref([])
  142. //当前课程 - 重新定义course来接收传递过来的数据
  143. const course = ref({})
  144. // 菜单数据
  145. const menuItems = ref([])
  146. // 课程集合数据
  147. const videoPathMap = ref({})
  148. // 已观看课程ID列表
  149. const watchedCourseIds = ref([])
  150. // 试题弹框显示状态
  151. const questionDialogVisible = ref(false)
  152. // 当前显示的试题
  153. const courseConfig = ref({})
  154. // 年级id
  155. const gradeId = ref('')
  156. // 课程大纲id
  157. const typeId = ref('')
  158. // 课程小节id
  159. const courseId = ref('')
  160. // 课程排序
  161. const typeSort = ref('')
  162. // 课程权限
  163. const blocklyDataScope = ref([])
  164. // 测试账号禁用视频
  165. const isDisabled = ref(false)
  166. // 展平所有菜单项索引
  167. const flattenMenuItems = () => {
  168. const indices = []
  169. const traverse = items => {
  170. for (const item of items) {
  171. if (!item.children) {
  172. indices.push(item.key)
  173. } else {
  174. traverse(item.children)
  175. }
  176. }
  177. }
  178. traverse(menuItems.value)
  179. return indices
  180. }
  181. // 播放上一个视频
  182. const playPreviousVideo = () => {
  183. if (props.courseList && props.courseList.length > 0) {
  184. const currentIndex = props.courseList.findIndex(item => item.id === course.value.id)
  185. if (currentIndex > 0) {
  186. const previousCourse = props.courseList[currentIndex - 1]
  187. // 更新当前课程数据
  188. handleParentCourseData(previousCourse)
  189. courseId.value = course.value.id;
  190. // 更新标题
  191. boxIconTitle.value = course.value.courseName;
  192. // 禁用视频检查
  193. disableVideo(course.value.key);
  194. }
  195. }
  196. }
  197. // 播放下一个视频
  198. const playNextVideo = () => {
  199. if (props.courseList && props.courseList.length > 0) {
  200. const currentIndex = props.courseList.findIndex(item => item.id === course.value.id)
  201. if (currentIndex !== -1 && currentIndex < props.courseList.length - 1) {
  202. const nextCourse = props.courseList[currentIndex + 1]
  203. // 更新当前课程数据
  204. handleParentCourseData(nextCourse)
  205. courseId.value = course.value.id;
  206. // 更新标题
  207. boxIconTitle.value = course.value.courseName;
  208. // 禁用视频检查
  209. disableVideo(course.value.key);
  210. }
  211. }
  212. }
  213. // 播放结束
  214. const handleVideoEnded = () => {
  215. // 记录当前视频ID为已观看
  216. if (
  217. course.value &&
  218. course.value.id &&
  219. !watchedCourseIds.value.includes(course.value.id)
  220. ) {
  221. watchedCourseIds.value.push(course.value.id)
  222. localStorage.setItem(
  223. 'watchedCourseIds',
  224. JSON.stringify(watchedCourseIds.value)
  225. )
  226. }
  227. // 自动播放下一个
  228. playNextVideo();
  229. }
  230. // 禁用视频
  231. const disableVideo = (index = course.value.key) => {
  232. // 未配置课程权限,不禁用视频
  233. if (!blocklyDataScope.value || blocklyDataScope.value.length === 0) {
  234. return false
  235. }
  236. //配置了课程权限,且视频id不在权限列表中
  237. isDisabled.value = !blocklyDataScope.value.some(item => Number(item) === videoPathMap.value[index].id)
  238. if (isDisabled.value) {
  239. Message().notifyWarning('您的账号并未开放此课程!', true)
  240. return isDisabled.value;
  241. }
  242. return isDisabled.value;
  243. }
  244. // 处理视频时间更新事件
  245. const handleVideoTimeUpdate = ({ currentTime, progressPercentage, courseConfig: config }) => {
  246. if (config) {
  247. questionDialogVisible.value = true
  248. courseConfig.value = config
  249. // 保存试题进度
  250. const saveQuestProgress = async () =>{
  251. try {
  252. // 确保courseId已经设置
  253. if (!courseId.value && typeId.value) {
  254. const courseRes = await ClassType(typeId.value)
  255. if (courseRes.data && courseRes.data.length > 0) {
  256. courseId.value = course.value && course.value.id ? course.value.id : courseRes.data[0].id
  257. }
  258. }
  259. if (config.id) {
  260. // 保存弹窗问题进度
  261. await saveRecordBlockly({
  262. brpZtId: props.courseData.ztId,
  263. brpCtId: props.courseData.bcType,
  264. brpCourseConfigId: config.id,
  265. brpCourseId: courseId.value,
  266. brpType: 'courseQuest',
  267. brpProgress: 1
  268. })
  269. } else {
  270. console.error('无法保存试题进度: 试题id不存在')
  271. }
  272. }catch(error){
  273. console.error(`保存试题进度失败:`, error)
  274. }
  275. }
  276. // 调用异步函数
  277. saveQuestProgress()
  278. }
  279. }
  280. // 关闭试题弹框
  281. const closeQuestionDialog = () => {
  282. questionDialogVisible.value = false
  283. }
  284. // 提交答案
  285. const handleSubmitAnswer = ({ selectedOption }) => {
  286. questionDialogVisible.value = false
  287. }
  288. // 初始化课程数据范围
  289. const initCourseDataScope = () => {
  290. const scope = localStorage.getItem("blocklyDataScope");
  291. if (scope) {
  292. blocklyDataScope.value = scope.split(",");
  293. }
  294. };
  295. // 处理父组件传递的课程数据
  296. const handleParentCourseData = (courseData = props.courseData) => {
  297. if (!courseData) return false;
  298. // 设置返回按钮标题
  299. boxIconTitle.value = courseData.bcName;
  300. // 重新定义course接收传递过来的数据
  301. course.value = {
  302. id: courseData.id,
  303. courseName: courseData.bcName,
  304. typeId: courseData.bcType,
  305. courseContentType: courseData.bcContentType,
  306. courseVideoPath: courseData.bcContent,
  307. courseConfigList: courseData.blocklyConfigList,
  308. key: courseData.id.toString(),
  309. // blockly相关属性,用于MapGame组件
  310. blocklyBackground: courseData.blocklyBackground,
  311. blocklyTileSize: courseData.blocklyTileSize,
  312. blocklyStartPoint: courseData.blocklyStartPoint,
  313. blocklyEndPoint: courseData.blocklyEndPoint,
  314. blocklyWalkablePoints: courseData.blocklyWalkablePoints,
  315. blocklyUserDirection: courseData.blocklyUserDirection || 0,
  316. blocklyUserImage: courseData.blocklyUserImage,
  317. blocklyInfo: courseData.blocklyInfo
  318. };
  319. courseId.value = course.value.id;
  320. // 如果有配置,禁用视频检查
  321. if (!disableVideo(course.value.key)) {
  322. console.log('课程已加载:', course.value);
  323. }
  324. return true;
  325. };
  326. // 处理课程数据列表
  327. const processCourseDataList = (data) => {
  328. // 对返回的课程数据进行处理,确保ccTime为有效秒数
  329. return data.map(course => {
  330. // 检查并处理courseConfigList
  331. if (course.courseConfigList && Array.isArray(course.courseConfigList)) {
  332. // 过滤掉ccTime为0的配置项
  333. const validConfigList = course.courseConfigList.filter(config =>
  334. config.ccTime !== undefined && config.ccTime !== null && config.ccTime > 0
  335. );
  336. return {
  337. ...course,
  338. courseConfigList: validConfigList
  339. };
  340. }
  341. return course;
  342. });
  343. };
  344. // 初始化已观看课程ID
  345. const initWatchedCourseIds = () => {
  346. const savedWatchedIds = localStorage.getItem('watchedCourseIds');
  347. if (savedWatchedIds) {
  348. try {
  349. watchedCourseIds.value = JSON.parse(savedWatchedIds);
  350. } catch (error) {
  351. console.error('解析已观看课程ID失败:', error);
  352. watchedCourseIds.value = [];
  353. }
  354. }
  355. };
  356. // 渲染 课程数据结构 以及 视频
  357. onMounted(async () => {
  358. // 初始化课程数据范围
  359. initCourseDataScope();
  360. // 初始化已观看课程ID
  361. initWatchedCourseIds();
  362. // 检查是否有从父组件传递的courseData
  363. if (handleParentCourseData()) {
  364. return;
  365. }
  366. // 从路由参数获取typeId
  367. const typeIdParam = router.currentRoute.value.query.typeId;
  368. if (typeIdParam) {
  369. typeId.value = typeIdParam;
  370. try {
  371. // 获取课程列表
  372. getBlocklyByTypeId(typeIdParam).then(res => {
  373. if (res && res.data && Array.isArray(res.data)) {
  374. props.courseList = res.data
  375. // 保存原始API返回的数据
  376. handleParentCourseData(res.data);
  377. // 处理课程数据
  378. courseList.value = processCourseDataList(res.data);
  379. }
  380. })
  381. } catch (error) {
  382. console.error('获取课程数据失败:', error);
  383. ElMessage.error('获取课程数据失败,请稍后重试');
  384. }
  385. }
  386. // 设置页面标题和排序
  387. const title = router.currentRoute.value.query.typeName;
  388. if (title) {
  389. boxIconTitle.value = String(title);
  390. }
  391. typeSort.value = router.currentRoute.value.query.typeSort;
  392. })
  393. // 保存视频进度接口
  394. const handleSaveProgress = async (progressData) => {
  395. try {
  396. const { progress, typeId, courseId } = progressData
  397. await saveRecordBlockly({
  398. brpZtId: props.courseData.ztId,
  399. brpCtId: typeId,
  400. brpCourseId: courseId,
  401. brpType: 'course',
  402. brpProgress: progress
  403. })
  404. } catch (error) {
  405. console.error('保存视频进度失败:', error)
  406. }
  407. }
  408. // 保存bockly进度接口
  409. const saveBlocklyProgress = async () => {
  410. try {
  411. await saveRecordBlockly({
  412. brpZtId: props.courseData.ztId,
  413. brpCtId: props.courseData.bcType,
  414. brpCourseId: props.courseData.id,
  415. brpType: 'blockly',
  416. brpProgress: 300
  417. })
  418. } catch (error) {
  419. console.error('保存blockly进度失败:', error)
  420. }
  421. }
  422. </script>
  423. <style scoped lang="scss">
  424. @use 'sass:math';
  425. @use 'sass:color'; // 引入 color 模块
  426. // 定义rpx转换函数
  427. @function rpx($px) {
  428. @return math.div($px, 750) * 100vw;
  429. }
  430. // 定义儿童风格的蓝紫色调
  431. $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
  432. $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
  433. $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
  434. $light-color: #ffffff; // 浅色背景:淡紫色
  435. $text-color: #483d8b; // 文本颜色:靛蓝色
  436. // 视频切换按钮样式
  437. .video-switch {
  438. width: 100%;
  439. display: flex;
  440. margin-top: rpx(5);
  441. margin-bottom: rpx(15);
  442. justify-content: center;
  443. }
  444. .caret-right,
  445. .caret-left {
  446. width: rpx(50);
  447. margin: 0 rpx(20);
  448. margin: auto;
  449. display: flex;
  450. justify-content: center;
  451. }
  452. .caret-left ::v-deep(.el-button.is-round),
  453. .caret-right ::v-deep(.el-button.is-round) {
  454. width: rpx(50);
  455. height: rpx(15);
  456. color: white;
  457. font-size: rpx(7);
  458. border-radius: none;
  459. border: 1px white solid;
  460. background-color: rgb(255, 255, 255, 0.5);
  461. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  462. }
  463. .caret-right img,
  464. .caret-left img {
  465. width: rpx(12);
  466. }
  467. .default-messages {
  468. margin-top: rpx(-10);
  469. margin-bottom: rpx(5);
  470. }
  471. .content-box {
  472. width: 100%;
  473. height: 100%;
  474. display: flex;
  475. flex-direction: column; /* 子元素上下排列 */
  476. background-image: url('@/assets/programming/list_bg03.png');
  477. overflow-y: auto;
  478. // 滚动条整体样式
  479. &::-webkit-scrollbar {
  480. width: rpx(1); // 滚动条宽度
  481. }
  482. // 滚动条滑块样式
  483. &::-webkit-scrollbar-thumb {
  484. background-color: rgba(255, 255, 255, 0.5); // 滑块颜色
  485. border-radius: 4px; // 滑块圆角
  486. transition: background-color 0.3s ease;
  487. }
  488. // 滚动条轨道样式
  489. &::-webkit-scrollbar-track {
  490. background-color: rgba(0, 0, 0, 0.1); // 轨道颜色
  491. border-radius: 4px; // 轨道圆角
  492. }
  493. }
  494. .home-container {
  495. position: fixed;
  496. top: 0;
  497. left: 0;
  498. right: 0;
  499. bottom: 0;
  500. background-image: url('@/assets/programming/list_bg03.png');
  501. }
  502. .box-1 {
  503. width: 100%;
  504. // height: rpx(50);
  505. margin-top: rpx(10);
  506. display: flex;
  507. justify-content: center;
  508. align-items: center;
  509. box-sizing: border-box;
  510. font-size: rpx(15); // 默认字体大小
  511. }
  512. .inner-box {
  513. height: 100%;
  514. display: flex;
  515. justify-content: center;
  516. align-items: center;
  517. font-size: rpx(16); // 默认字体大小
  518. }
  519. .left-box {
  520. position: relative;
  521. justify-content: flex-start;
  522. align-items: flex-start;
  523. flex: 1; // 设置左侧盒子占比为 2
  524. cursor: pointer; // 添加鼠标指针样式
  525. }
  526. .box-icon {
  527. display: flex;
  528. align-items: center;
  529. margin-left: rpx(7);
  530. gap: 10px;
  531. padding: 10px 20px;
  532. background-color: rgba(255, 255, 255, 0.8);
  533. border-radius: 30px;
  534. backdrop-filter: blur(10px);
  535. cursor: pointer;
  536. transition: all 0.3s ease;
  537. font-size: 16px;
  538. color: #333;
  539. font-weight: 500;
  540. width: fit-content;
  541. }
  542. .box-icon:hover {
  543. background-color: rgba(255, 255, 255, 0.9);
  544. transform: translate(-3px);
  545. }
  546. .box-icon .left-icon {
  547. margin: 0;
  548. }
  549. .left-box span {
  550. position: absolute;
  551. font-size: rpx(11); // 默认字体大小
  552. color: white;
  553. }
  554. .box-2 {
  555. width: 100%;
  556. flex: 1;
  557. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  558. box-sizing: border-box;
  559. // display: flex; // 确保子元素水平排列
  560. flex-wrap: wrap; // 允许子元素换行;
  561. align-content: center; // 顶部对齐;
  562. cursor: pointer; // 添加鼠标指针样式
  563. }
  564. .small-title {
  565. width: 100%;
  566. // margin-top: rpx(-20);
  567. height: rpx(20);
  568. color: white;
  569. font-size: rpx(10);
  570. justify-content: center; //使子元素水平居中
  571. }
  572. // 图片容器样式
  573. .image-container {
  574. width: 100%;
  575. display: flex;
  576. justify-content: center;
  577. align-items: center;
  578. // padding: rpx(20) 0;
  579. }
  580. // 图片样式
  581. .course-image {
  582. max-width: 70%;
  583. max-height: rpx(400);
  584. object-fit: contain;
  585. border-radius: rpx(12);
  586. box-shadow: 0 rpx(10) rpx(20) rgba(0, 0, 0, 0.1);
  587. }
  588. // 儿童风格试题弹框样式
  589. .child-dialog {
  590. .el-dialog__header {
  591. display: none; // 隐藏原有的标题栏
  592. }
  593. .el-dialog__body {
  594. padding: rpx(20);
  595. position: relative;
  596. }
  597. .el-dialog__footer {
  598. border-top: none;
  599. padding: rpx(10) rpx(20);
  600. text-align: center;
  601. margin-top: auto; // 使底部按钮位于底部
  602. }
  603. .el-dialog__wrapper {
  604. // 修改半透明背景色
  605. background-color: rgba(0, 0, 0, 0.6);
  606. }
  607. .el-dialog {
  608. border: none;
  609. border-radius: rpx(20);
  610. background: linear-gradient(
  611. 135deg,
  612. $light-color,
  613. #d8bfd8
  614. ); // 柔和的蓝紫色渐变
  615. overflow: hidden;
  616. display: flex; // 添加 flex 布局
  617. flex-direction: column; // 设置垂直布局
  618. min-height: 0; // 防止子元素溢出
  619. // 添加装饰元素
  620. &::before {
  621. content: '';
  622. position: absolute;
  623. top: 0;
  624. left: 0;
  625. width: 100%;
  626. height: rpx(10);
  627. background: linear-gradient(90deg, $secondary-color, $accent-color);
  628. }
  629. }
  630. }
  631. // 问题标题样式
  632. .question-title {
  633. padding: rpx(15);
  634. border-radius: rpx(12);
  635. margin-bottom: rpx(20);
  636. color: #483d8b;
  637. font-weight: bold;
  638. font-size: rpx(12);
  639. position: relative;
  640. display: flex;
  641. .question-icon {
  642. background-color: $accent-color;
  643. color: white;
  644. width: rpx(24);
  645. height: rpx(24);
  646. border-radius: 50%;
  647. display: flex;
  648. align-items: center;
  649. justify-content: center;
  650. margin-right: rpx(10);
  651. font-weight: bold;
  652. box-shadow: 0 rpx(2) rpx(5) rgba($accent-color, 0.3);
  653. }
  654. }
  655. // 选项容器样式
  656. .options-container {
  657. margin-bottom: rpx(20);
  658. }
  659. // 问题选项样式
  660. .question-option {
  661. margin: rpx(8) 0;
  662. padding: rpx(10) rpx(15);
  663. border-radius: rpx(12);
  664. border: rpx(1) solid rgba($primary-color, 0.3);
  665. transition: all 0.3s ease;
  666. display: flex;
  667. align-items: center;
  668. background-color: white;
  669. box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.05);
  670. ::v-deep(.el-radio__label) {
  671. color: $text-color;
  672. margin-left: rpx(8);
  673. flex: 1;
  674. text-align: left;
  675. // 增大字体大小
  676. font-size: rpx(12);
  677. }
  678. // 选中时的样式变化
  679. .el-radio__input.is-checked + .el-radio__label {
  680. font-weight: bold;
  681. color: $accent-color;
  682. }
  683. &:hover {
  684. background-color: rgba($primary-color, 0.05);
  685. border-color: rgba($primary-color, 0.5);
  686. transform: translateY(-rpx(1));
  687. }
  688. }
  689. // 暂无选项样式
  690. .no-options {
  691. color: rgba($text-color, 0.7);
  692. text-align: center;
  693. padding: rpx(20);
  694. font-size: rpx(12);
  695. }
  696. // 底部按钮样式
  697. .child-button {
  698. min-width: rpx(80);
  699. height: rpx(30);
  700. border-radius: rpx(8);
  701. font-size: rpx(12);
  702. font-weight: 500;
  703. transition: all 0.3s ease;
  704. box-shadow: 0 rpx(2) rpx(8) rgba(0, 0, 0, 0.1);
  705. &.confirm {
  706. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  707. border: none;
  708. border-right: 15px;
  709. color: white;
  710. &:hover {
  711. background: linear-gradient(
  712. to bottom,
  713. color.adjust(#ab81ff, $lightness: -5%),
  714. color.adjust(#8559dc, $lightness: -5%)
  715. );
  716. transform: translateY(-rpx(1));
  717. color: white;
  718. }
  719. }
  720. &.cancel {
  721. background: white;
  722. border: rpx(1) solid rgba($primary-color, 0.3);
  723. color: $text-color;
  724. &:hover {
  725. background: rgba($primary-color, 0.05);
  726. border-color: rgba($primary-color, 0.5);
  727. transform: translateY(-rpx(1));
  728. }
  729. }
  730. }
  731. // AI对话图标样式
  732. .ai-icon-container {
  733. position: absolute;
  734. bottom: rpx(20);
  735. right: rpx(20);
  736. display: flex;
  737. flex-direction: column;
  738. align-items: center;
  739. cursor: pointer;
  740. transition: all 0.3s ease;
  741. &:hover {
  742. transform: translateY(-rpx(2));
  743. }
  744. .ai-icon {
  745. width: rpx(30);
  746. height: rpx(30);
  747. margin-bottom: rpx(0);
  748. filter: drop-shadow(0 rpx(2) rpx(4) rgba($primary-color, 0.3));
  749. // 添加过渡动画
  750. transition: transform 0.3s ease;
  751. }
  752. // 悬浮时放大效果
  753. .ai-icon:hover {
  754. transform: scale(1.5);
  755. }
  756. .ai-text {
  757. color: $text-color;
  758. font-size: rpx(8);
  759. background-color: rgba(255, 255, 255, 0.7);
  760. padding: rpx(2) rpx(5);
  761. border-radius: rpx(5);
  762. }
  763. }
  764. // AI消息样式
  765. .ai-message {
  766. display: flex;
  767. align-items: flex-start;
  768. margin-bottom: rpx(15);
  769. .ai-avatar {
  770. width: rpx(30);
  771. height: rpx(30);
  772. border-radius: 50%;
  773. margin-right: rpx(10);
  774. background-color: $primary-color;
  775. padding: rpx(5);
  776. }
  777. .ai-text-content {
  778. background-color: $light-color;
  779. padding: rpx(8) rpx(12);
  780. border-radius: rpx(10);
  781. font-size: rpx(10);
  782. color: $text-color;
  783. max-width: 80%;
  784. }
  785. }
  786. // 用户输入框样式
  787. .user-input {
  788. ::v-deep(.el-input__wrapper) {
  789. height: rpx(23);
  790. border-top-left-radius: rpx(5);
  791. border-bottom-left-radius: rpx(5);
  792. border-color: rgba($primary-color, 0.3);
  793. &:focus-within {
  794. box-shadow: 0 0 0 rpx(1) rgba($primary-color, 0.5);
  795. }
  796. }
  797. ::v-deep(.el-input__inner) {
  798. font-size: rpx(10);
  799. // color: $text-color;
  800. text-indent: 1em;
  801. }
  802. ::v-deep(.el-input-group__append, .el-input-group__prepend) {
  803. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  804. border-top-right-radius: rpx(5);
  805. border-bottom-right-radius: rpx(5);
  806. color: white;
  807. font-size: rpx(9);
  808. }
  809. }
  810. /* 定义淡入和缩放动画 */
  811. .fade-scale-enter-active,
  812. .fade-scale-leave-active {
  813. transition: all 0.5s ease;
  814. }
  815. .fade-scale-enter-from,
  816. .fade-scale-leave-to {
  817. opacity: 0.1;
  818. transform: scale(0.9);
  819. }
  820. // 自定义试题弹框背景
  821. .child-dialog-wrapper {
  822. position: fixed;
  823. top: 0;
  824. left: 0;
  825. right: 0;
  826. bottom: 0;
  827. background-color: rgba(0, 0, 0, 0.6); // 半透明背景
  828. display: flex;
  829. justify-content: center;
  830. align-items: center;
  831. z-index: 1000;
  832. }
  833. .child-dialog {
  834. border: none;
  835. border-radius: rpx(15);
  836. background: rgb(255, 255, 255, 0.8); // 柔和的蓝紫色渐变
  837. overflow: hidden;
  838. padding: rpx(5);
  839. // width: 40%;
  840. // height: 60%;
  841. position: relative;
  842. }
  843. // AI对话弹框样式
  844. .ai-dialog-wrapper {
  845. position: fixed;
  846. top: 0;
  847. left: 0;
  848. right: 0;
  849. bottom: 0;
  850. display: flex;
  851. justify-content: flex-end;
  852. align-items: center;
  853. z-index: 1001;
  854. pointer-events: none;
  855. }
  856. .ai-dialog {
  857. border: none;
  858. border-radius: rpx(15);
  859. background: rgb(255, 255, 255, 0.8);
  860. overflow: hidden;
  861. padding: rpx(20);
  862. width: 30%;
  863. // 增加高度
  864. height: 80%;
  865. margin-right: rpx(50);
  866. pointer-events: auto;
  867. position: relative;
  868. display: flex;
  869. flex-direction: column;
  870. &::before {
  871. content: '';
  872. position: absolute;
  873. top: 0;
  874. left: 0;
  875. width: 100%;
  876. height: rpx(10);
  877. }
  878. }
  879. .ai-dialog-header {
  880. position: relative;
  881. display: flex;
  882. justify-content: center;
  883. align-items: center;
  884. margin-bottom: rpx(15);
  885. margin-top: rpx(-10);
  886. img {
  887. width: rpx(15);
  888. }
  889. h3 {
  890. color: black;
  891. font-size: rpx(12);
  892. }
  893. .close-btn {
  894. padding: 0;
  895. width: rpx(20);
  896. height: rpx(20);
  897. font-size: rpx(16);
  898. line-height: 1;
  899. position: absolute;
  900. background-color: transparent;
  901. border: none;
  902. margin-left: rpx(200);
  903. }
  904. }
  905. .ai-dialog-content {
  906. flex: 1;
  907. display: flex;
  908. flex-direction: column;
  909. }
  910. .ai-message-history {
  911. flex: 1;
  912. // 当内容超出容器高度时,显示垂直滚动条
  913. overflow-y: auto;
  914. margin-bottom: rpx(15);
  915. // 可以根据实际情况调整最大高度
  916. font-size: rpx(5);
  917. max-height: 50vh;
  918. .message {
  919. display: flex;
  920. align-items: flex-start;
  921. margin-bottom: rpx(10);
  922. &.user {
  923. flex-direction: row-reverse;
  924. }
  925. .avatar {
  926. width: rpx(30);
  927. height: rpx(30);
  928. border-radius: 50%;
  929. margin: 0 rpx(10);
  930. }
  931. .user {
  932. width: 15px;
  933. height: 15px;
  934. }
  935. .message-content {
  936. background-color: #ffffff;
  937. font-size: rpx(5);
  938. max-width: 80%;
  939. color: black;
  940. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  941. }
  942. }
  943. // 滚动条整体样式
  944. &::-webkit-scrollbar {
  945. width: rpx(4); // 滚动条宽度
  946. }
  947. // 滚动条滑块样式
  948. &::-webkit-scrollbar-thumb {
  949. background-color: $primary-color; // 滑块颜色
  950. border-radius: rpx(4); // 滑块圆角
  951. transition: background-color 0.3s ease; // 颜色过渡效果
  952. }
  953. // 滚动条轨道样式
  954. &::-webkit-scrollbar-track {
  955. background-color: rgba($primary-color, 0.2); // 轨道颜色
  956. border-radius: rpx(4); // 轨道圆角
  957. }
  958. .message {
  959. display: flex;
  960. align-items: flex-start;
  961. margin-bottom: rpx(10);
  962. &.user {
  963. flex-direction: row-reverse;
  964. }
  965. .avatar {
  966. width: rpx(30);
  967. height: rpx(30);
  968. border-radius: 50%;
  969. margin: 0 rpx(10);
  970. }
  971. .message-content {
  972. background-color: white;
  973. padding: rpx(8) rpx(12);
  974. border-radius: rpx(5);
  975. font-size: rpx(8);
  976. color: black;
  977. max-width: 80%;
  978. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  979. }
  980. }
  981. }
  982. // 优化发送按钮样式
  983. .send-button {
  984. border: none;
  985. color: white;
  986. }
  987. </style>
  988. <style scoped lang="scss">
  989. @use 'sass:math';
  990. // 定义rpx转换函数
  991. @function rpx($px) {
  992. @return math.div($px, 750) * 100vw;
  993. }
  994. .default-messages {
  995. margin-top: rpx(-10);
  996. margin-bottom: rpx(5);
  997. }
  998. .contentClass{
  999. width: 70%;
  1000. height: 80%;
  1001. margin: 0 auto;
  1002. border-radius: rpx(15);
  1003. overflow: hidden;
  1004. }
  1005. </style>