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 {TopicType} 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. TopicType(typeIdParam).then(res => {
  372. if (res && res.data && Array.isArray(res.data)) {
  373. props.courseList = res.data
  374. // 保存原始API返回的数据
  375. handleParentCourseData(res.data);
  376. // 处理课程数据
  377. courseList.value = processCourseDataList(res.data);
  378. }
  379. })
  380. } catch (error) {
  381. console.error('获取课程数据失败:', error);
  382. ElMessage.error('获取课程数据失败,请稍后重试');
  383. }
  384. }
  385. // 设置页面标题和排序
  386. const title = router.currentRoute.value.query.typeName;
  387. if (title) {
  388. boxIconTitle.value = String(title);
  389. }
  390. typeSort.value = router.currentRoute.value.query.typeSort;
  391. })
  392. // 保存视频进度接口
  393. const handleSaveProgress = async (progressData) => {
  394. try {
  395. const { progress, typeId, courseId } = progressData
  396. await saveRecordBlockly({
  397. brpZtId: props.courseData.ztId,
  398. brpCtId: typeId,
  399. brpCourseId: courseId,
  400. brpType: 'course',
  401. brpProgress: progress
  402. })
  403. } catch (error) {
  404. console.error('保存视频进度失败:', error)
  405. }
  406. }
  407. // 保存bockly进度接口
  408. const saveBlocklyProgress = async () => {
  409. try {
  410. await saveRecordBlockly({
  411. brpZtId: props.courseData.ztId,
  412. brpCtId: props.courseData.bcType,
  413. brpCourseId: props.courseData.id,
  414. brpType: 'blockly',
  415. brpProgress: 100
  416. })
  417. } catch (error) {
  418. console.error('保存blockly进度失败:', error)
  419. }
  420. }
  421. </script>
  422. <style scoped lang="scss">
  423. @use 'sass:math';
  424. @use 'sass:color'; // 引入 color 模块
  425. // 定义rpx转换函数
  426. @function rpx($px) {
  427. @return math.div($px, 750) * 100vw;
  428. }
  429. // 定义儿童风格的蓝紫色调
  430. $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
  431. $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
  432. $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
  433. $light-color: #ffffff; // 浅色背景:淡紫色
  434. $text-color: #483d8b; // 文本颜色:靛蓝色
  435. // 视频切换按钮样式
  436. .video-switch {
  437. width: 100%;
  438. display: flex;
  439. margin-top: rpx(5);
  440. margin-bottom: rpx(15);
  441. justify-content: center;
  442. }
  443. .caret-right,
  444. .caret-left {
  445. width: rpx(50);
  446. margin: 0 rpx(20);
  447. margin: auto;
  448. display: flex;
  449. justify-content: center;
  450. }
  451. .caret-left ::v-deep(.el-button.is-round),
  452. .caret-right ::v-deep(.el-button.is-round) {
  453. width: rpx(50);
  454. height: rpx(15);
  455. color: white;
  456. font-size: rpx(7);
  457. border-radius: none;
  458. border: 1px white solid;
  459. background-color: rgb(255, 255, 255, 0.5);
  460. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  461. }
  462. .caret-right img,
  463. .caret-left img {
  464. width: rpx(12);
  465. }
  466. .default-messages {
  467. margin-top: rpx(-10);
  468. margin-bottom: rpx(5);
  469. }
  470. .content-box {
  471. width: 100%;
  472. height: 100%;
  473. display: flex;
  474. flex-direction: column; /* 子元素上下排列 */
  475. background-image: url('@/assets/programming/list_bg03.png');
  476. overflow-y: auto;
  477. // 滚动条整体样式
  478. &::-webkit-scrollbar {
  479. width: rpx(1); // 滚动条宽度
  480. }
  481. // 滚动条滑块样式
  482. &::-webkit-scrollbar-thumb {
  483. background-color: rgba(255, 255, 255, 0.5); // 滑块颜色
  484. border-radius: 4px; // 滑块圆角
  485. transition: background-color 0.3s ease;
  486. }
  487. // 滚动条轨道样式
  488. &::-webkit-scrollbar-track {
  489. background-color: rgba(0, 0, 0, 0.1); // 轨道颜色
  490. border-radius: 4px; // 轨道圆角
  491. }
  492. }
  493. .home-container {
  494. position: fixed;
  495. top: 0;
  496. left: 0;
  497. right: 0;
  498. bottom: 0;
  499. background-image: url('@/assets/programming/list_bg03.png');
  500. }
  501. .box-1 {
  502. width: 100%;
  503. // height: rpx(50);
  504. margin-top: rpx(10);
  505. display: flex;
  506. justify-content: center;
  507. align-items: center;
  508. box-sizing: border-box;
  509. font-size: rpx(15); // 默认字体大小
  510. }
  511. .inner-box {
  512. height: 100%;
  513. display: flex;
  514. justify-content: center;
  515. align-items: center;
  516. font-size: rpx(16); // 默认字体大小
  517. }
  518. .left-box {
  519. position: relative;
  520. justify-content: flex-start;
  521. align-items: flex-start;
  522. flex: 1; // 设置左侧盒子占比为 2
  523. cursor: pointer; // 添加鼠标指针样式
  524. }
  525. .box-icon {
  526. display: flex;
  527. align-items: center;
  528. margin-left: rpx(7);
  529. gap: 10px;
  530. padding: 10px 20px;
  531. background-color: rgba(255, 255, 255, 0.8);
  532. border-radius: 30px;
  533. backdrop-filter: blur(10px);
  534. cursor: pointer;
  535. transition: all 0.3s ease;
  536. font-size: 16px;
  537. color: #333;
  538. font-weight: 500;
  539. width: fit-content;
  540. }
  541. .box-icon:hover {
  542. background-color: rgba(255, 255, 255, 0.9);
  543. transform: translate(-3px);
  544. }
  545. .box-icon .left-icon {
  546. margin: 0;
  547. }
  548. .left-box span {
  549. position: absolute;
  550. font-size: rpx(11); // 默认字体大小
  551. color: white;
  552. }
  553. .box-2 {
  554. width: 100%;
  555. flex: 1;
  556. box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
  557. box-sizing: border-box;
  558. // display: flex; // 确保子元素水平排列
  559. flex-wrap: wrap; // 允许子元素换行;
  560. align-content: center; // 顶部对齐;
  561. cursor: pointer; // 添加鼠标指针样式
  562. }
  563. .small-title {
  564. width: 100%;
  565. // margin-top: rpx(-20);
  566. height: rpx(20);
  567. color: white;
  568. font-size: rpx(10);
  569. justify-content: center; //使子元素水平居中
  570. }
  571. // 图片容器样式
  572. .image-container {
  573. width: 100%;
  574. display: flex;
  575. justify-content: center;
  576. align-items: center;
  577. // padding: rpx(20) 0;
  578. }
  579. // 图片样式
  580. .course-image {
  581. max-width: 70%;
  582. max-height: rpx(400);
  583. object-fit: contain;
  584. border-radius: rpx(12);
  585. box-shadow: 0 rpx(10) rpx(20) rgba(0, 0, 0, 0.1);
  586. }
  587. // 儿童风格试题弹框样式
  588. .child-dialog {
  589. .el-dialog__header {
  590. display: none; // 隐藏原有的标题栏
  591. }
  592. .el-dialog__body {
  593. padding: rpx(20);
  594. position: relative;
  595. }
  596. .el-dialog__footer {
  597. border-top: none;
  598. padding: rpx(10) rpx(20);
  599. text-align: center;
  600. margin-top: auto; // 使底部按钮位于底部
  601. }
  602. .el-dialog__wrapper {
  603. // 修改半透明背景色
  604. background-color: rgba(0, 0, 0, 0.6);
  605. }
  606. .el-dialog {
  607. border: none;
  608. border-radius: rpx(20);
  609. background: linear-gradient(
  610. 135deg,
  611. $light-color,
  612. #d8bfd8
  613. ); // 柔和的蓝紫色渐变
  614. overflow: hidden;
  615. display: flex; // 添加 flex 布局
  616. flex-direction: column; // 设置垂直布局
  617. min-height: 0; // 防止子元素溢出
  618. // 添加装饰元素
  619. &::before {
  620. content: '';
  621. position: absolute;
  622. top: 0;
  623. left: 0;
  624. width: 100%;
  625. height: rpx(10);
  626. background: linear-gradient(90deg, $secondary-color, $accent-color);
  627. }
  628. }
  629. }
  630. // 问题标题样式
  631. .question-title {
  632. padding: rpx(15);
  633. border-radius: rpx(12);
  634. margin-bottom: rpx(20);
  635. color: #483d8b;
  636. font-weight: bold;
  637. font-size: rpx(12);
  638. position: relative;
  639. display: flex;
  640. .question-icon {
  641. background-color: $accent-color;
  642. color: white;
  643. width: rpx(24);
  644. height: rpx(24);
  645. border-radius: 50%;
  646. display: flex;
  647. align-items: center;
  648. justify-content: center;
  649. margin-right: rpx(10);
  650. font-weight: bold;
  651. box-shadow: 0 rpx(2) rpx(5) rgba($accent-color, 0.3);
  652. }
  653. }
  654. // 选项容器样式
  655. .options-container {
  656. margin-bottom: rpx(20);
  657. }
  658. // 问题选项样式
  659. .question-option {
  660. margin: rpx(8) 0;
  661. padding: rpx(10) rpx(15);
  662. border-radius: rpx(12);
  663. border: rpx(1) solid rgba($primary-color, 0.3);
  664. transition: all 0.3s ease;
  665. display: flex;
  666. align-items: center;
  667. background-color: white;
  668. box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.05);
  669. ::v-deep(.el-radio__label) {
  670. color: $text-color;
  671. margin-left: rpx(8);
  672. flex: 1;
  673. text-align: left;
  674. // 增大字体大小
  675. font-size: rpx(12);
  676. }
  677. // 选中时的样式变化
  678. .el-radio__input.is-checked + .el-radio__label {
  679. font-weight: bold;
  680. color: $accent-color;
  681. }
  682. &:hover {
  683. background-color: rgba($primary-color, 0.05);
  684. border-color: rgba($primary-color, 0.5);
  685. transform: translateY(-rpx(1));
  686. }
  687. }
  688. // 暂无选项样式
  689. .no-options {
  690. color: rgba($text-color, 0.7);
  691. text-align: center;
  692. padding: rpx(20);
  693. font-size: rpx(12);
  694. }
  695. // 底部按钮样式
  696. .child-button {
  697. min-width: rpx(80);
  698. height: rpx(30);
  699. border-radius: rpx(8);
  700. font-size: rpx(12);
  701. font-weight: 500;
  702. transition: all 0.3s ease;
  703. box-shadow: 0 rpx(2) rpx(8) rgba(0, 0, 0, 0.1);
  704. &.confirm {
  705. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  706. border: none;
  707. border-right: 15px;
  708. color: white;
  709. &:hover {
  710. background: linear-gradient(
  711. to bottom,
  712. color.adjust(#ab81ff, $lightness: -5%),
  713. color.adjust(#8559dc, $lightness: -5%)
  714. );
  715. transform: translateY(-rpx(1));
  716. color: white;
  717. }
  718. }
  719. &.cancel {
  720. background: white;
  721. border: rpx(1) solid rgba($primary-color, 0.3);
  722. color: $text-color;
  723. &:hover {
  724. background: rgba($primary-color, 0.05);
  725. border-color: rgba($primary-color, 0.5);
  726. transform: translateY(-rpx(1));
  727. }
  728. }
  729. }
  730. // AI对话图标样式
  731. .ai-icon-container {
  732. position: absolute;
  733. bottom: rpx(20);
  734. right: rpx(20);
  735. display: flex;
  736. flex-direction: column;
  737. align-items: center;
  738. cursor: pointer;
  739. transition: all 0.3s ease;
  740. &:hover {
  741. transform: translateY(-rpx(2));
  742. }
  743. .ai-icon {
  744. width: rpx(30);
  745. height: rpx(30);
  746. margin-bottom: rpx(0);
  747. filter: drop-shadow(0 rpx(2) rpx(4) rgba($primary-color, 0.3));
  748. // 添加过渡动画
  749. transition: transform 0.3s ease;
  750. }
  751. // 悬浮时放大效果
  752. .ai-icon:hover {
  753. transform: scale(1.5);
  754. }
  755. .ai-text {
  756. color: $text-color;
  757. font-size: rpx(8);
  758. background-color: rgba(255, 255, 255, 0.7);
  759. padding: rpx(2) rpx(5);
  760. border-radius: rpx(5);
  761. }
  762. }
  763. // AI消息样式
  764. .ai-message {
  765. display: flex;
  766. align-items: flex-start;
  767. margin-bottom: rpx(15);
  768. .ai-avatar {
  769. width: rpx(30);
  770. height: rpx(30);
  771. border-radius: 50%;
  772. margin-right: rpx(10);
  773. background-color: $primary-color;
  774. padding: rpx(5);
  775. }
  776. .ai-text-content {
  777. background-color: $light-color;
  778. padding: rpx(8) rpx(12);
  779. border-radius: rpx(10);
  780. font-size: rpx(10);
  781. color: $text-color;
  782. max-width: 80%;
  783. }
  784. }
  785. // 用户输入框样式
  786. .user-input {
  787. ::v-deep(.el-input__wrapper) {
  788. height: rpx(23);
  789. border-top-left-radius: rpx(5);
  790. border-bottom-left-radius: rpx(5);
  791. border-color: rgba($primary-color, 0.3);
  792. &:focus-within {
  793. box-shadow: 0 0 0 rpx(1) rgba($primary-color, 0.5);
  794. }
  795. }
  796. ::v-deep(.el-input__inner) {
  797. font-size: rpx(10);
  798. // color: $text-color;
  799. text-indent: 1em;
  800. }
  801. ::v-deep(.el-input-group__append, .el-input-group__prepend) {
  802. background: linear-gradient(to bottom, #ab81ff, #8559dc);
  803. border-top-right-radius: rpx(5);
  804. border-bottom-right-radius: rpx(5);
  805. color: white;
  806. font-size: rpx(9);
  807. }
  808. }
  809. /* 定义淡入和缩放动画 */
  810. .fade-scale-enter-active,
  811. .fade-scale-leave-active {
  812. transition: all 0.5s ease;
  813. }
  814. .fade-scale-enter-from,
  815. .fade-scale-leave-to {
  816. opacity: 0.1;
  817. transform: scale(0.9);
  818. }
  819. // 自定义试题弹框背景
  820. .child-dialog-wrapper {
  821. position: fixed;
  822. top: 0;
  823. left: 0;
  824. right: 0;
  825. bottom: 0;
  826. background-color: rgba(0, 0, 0, 0.6); // 半透明背景
  827. display: flex;
  828. justify-content: center;
  829. align-items: center;
  830. z-index: 1000;
  831. }
  832. .child-dialog {
  833. border: none;
  834. border-radius: rpx(15);
  835. background: rgb(255, 255, 255, 0.8); // 柔和的蓝紫色渐变
  836. overflow: hidden;
  837. padding: rpx(5);
  838. // width: 40%;
  839. // height: 60%;
  840. position: relative;
  841. }
  842. // AI对话弹框样式
  843. .ai-dialog-wrapper {
  844. position: fixed;
  845. top: 0;
  846. left: 0;
  847. right: 0;
  848. bottom: 0;
  849. display: flex;
  850. justify-content: flex-end;
  851. align-items: center;
  852. z-index: 1001;
  853. pointer-events: none;
  854. }
  855. .ai-dialog {
  856. border: none;
  857. border-radius: rpx(15);
  858. background: rgb(255, 255, 255, 0.8);
  859. overflow: hidden;
  860. padding: rpx(20);
  861. width: 30%;
  862. // 增加高度
  863. height: 80%;
  864. margin-right: rpx(50);
  865. pointer-events: auto;
  866. position: relative;
  867. display: flex;
  868. flex-direction: column;
  869. &::before {
  870. content: '';
  871. position: absolute;
  872. top: 0;
  873. left: 0;
  874. width: 100%;
  875. height: rpx(10);
  876. }
  877. }
  878. .ai-dialog-header {
  879. position: relative;
  880. display: flex;
  881. justify-content: center;
  882. align-items: center;
  883. margin-bottom: rpx(15);
  884. margin-top: rpx(-10);
  885. img {
  886. width: rpx(15);
  887. }
  888. h3 {
  889. color: black;
  890. font-size: rpx(12);
  891. }
  892. .close-btn {
  893. padding: 0;
  894. width: rpx(20);
  895. height: rpx(20);
  896. font-size: rpx(16);
  897. line-height: 1;
  898. position: absolute;
  899. background-color: transparent;
  900. border: none;
  901. margin-left: rpx(200);
  902. }
  903. }
  904. .ai-dialog-content {
  905. flex: 1;
  906. display: flex;
  907. flex-direction: column;
  908. }
  909. .ai-message-history {
  910. flex: 1;
  911. // 当内容超出容器高度时,显示垂直滚动条
  912. overflow-y: auto;
  913. margin-bottom: rpx(15);
  914. // 可以根据实际情况调整最大高度
  915. font-size: rpx(5);
  916. max-height: 50vh;
  917. .message {
  918. display: flex;
  919. align-items: flex-start;
  920. margin-bottom: rpx(10);
  921. &.user {
  922. flex-direction: row-reverse;
  923. }
  924. .avatar {
  925. width: rpx(30);
  926. height: rpx(30);
  927. border-radius: 50%;
  928. margin: 0 rpx(10);
  929. }
  930. .user {
  931. width: 15px;
  932. height: 15px;
  933. }
  934. .message-content {
  935. background-color: #ffffff;
  936. font-size: rpx(5);
  937. max-width: 80%;
  938. color: black;
  939. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  940. }
  941. }
  942. // 滚动条整体样式
  943. &::-webkit-scrollbar {
  944. width: rpx(4); // 滚动条宽度
  945. }
  946. // 滚动条滑块样式
  947. &::-webkit-scrollbar-thumb {
  948. background-color: $primary-color; // 滑块颜色
  949. border-radius: rpx(4); // 滑块圆角
  950. transition: background-color 0.3s ease; // 颜色过渡效果
  951. }
  952. // 滚动条轨道样式
  953. &::-webkit-scrollbar-track {
  954. background-color: rgba($primary-color, 0.2); // 轨道颜色
  955. border-radius: rpx(4); // 轨道圆角
  956. }
  957. .message {
  958. display: flex;
  959. align-items: flex-start;
  960. margin-bottom: rpx(10);
  961. &.user {
  962. flex-direction: row-reverse;
  963. }
  964. .avatar {
  965. width: rpx(30);
  966. height: rpx(30);
  967. border-radius: 50%;
  968. margin: 0 rpx(10);
  969. }
  970. .message-content {
  971. background-color: white;
  972. padding: rpx(8) rpx(12);
  973. border-radius: rpx(5);
  974. font-size: rpx(8);
  975. color: black;
  976. max-width: 80%;
  977. box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
  978. }
  979. }
  980. }
  981. // 优化发送按钮样式
  982. .send-button {
  983. border: none;
  984. color: white;
  985. }
  986. </style>
  987. <style scoped lang="scss">
  988. @use 'sass:math';
  989. // 定义rpx转换函数
  990. @function rpx($px) {
  991. @return math.div($px, 750) * 100vw;
  992. }
  993. .default-messages {
  994. margin-top: rpx(-10);
  995. margin-bottom: rpx(5);
  996. }
  997. .contentClass{
  998. width: 70%;
  999. height: 80%;
  1000. margin: 0 auto;
  1001. border-radius: rpx(15);
  1002. overflow: hidden;
  1003. }
  1004. </style>