ExperimentalInterface.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  1. <!-- 实验界面 -->
  2. <template>
  3. <!-- 编程课程视频页面 -->
  4. <div class="home-container">
  5. <div class="content-box">
  6. <div class="box-1">
  7. <div class="inner-box left-box">
  8. <div class="box-icon" @click="emit('closeVideo')">
  9. <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
  10. 返回
  11. </div>
  12. </div>
  13. </div>
  14. <div class="box-2">
  15. <!-- 课程标题 -->
  16. <div class="small-title">
  17. <span>{{ course.courseName }}</span>
  18. </div>
  19. <el-empty v-if="course.isDisabled"
  20. image-size="500"
  21. description="您无权查看该课程!"
  22. :image="isDisabledImage"
  23. />
  24. <template v-else>
  25. <!-- 视频组件 -->
  26. <VideoPlayer
  27. v-if="course.courseContentType === 'video'"
  28. :contentType="course.courseContentType"
  29. :videoPath="course.courseContent"
  30. :courseId="course.id || ''"
  31. :typeId="course.typeId"
  32. :courseConfigList="course.courseConfigList || []"
  33. :allIndices="flattenMenuItems()"
  34. :currentIndex="course.key || ''"
  35. @timeUpdate="handleVideoTimeUpdate"
  36. @videoEnded="handleVideoEnded"
  37. @saveProgress="handleSaveProgress"
  38. v-memo="[course.id, course.courseContentType, course.courseContent]"
  39. />
  40. <!-- 图片 -->
  41. <ImageView v-if="course.courseContentType === 'image'" :imagePath="course.courseContent" altText="课程图片"></ImageView>
  42. <!-- PPT -->
  43. <PptView v-if="course.courseContentType === 'ppt'" :pptPath="course.courseContent" ref="pptRef"></PptView>
  44. <!--文生文-->
  45. <TextToText class="contentClass" v-if="course.courseContentType === 'aiTextToText'" ref="aiTextToText"></TextToText>
  46. <!--文生图-->
  47. <TextToImage class="contentClass" v-if="course.courseContentType === 'aiTextToImage'" ref="aiTextToImage"></TextToImage>
  48. <!--图生图-->
  49. <ImageToImage class="contentClass" v-if="course.courseContentType === 'aiImageToImage'" ref="aiImageToImage"></ImageToImage>
  50. <!--图生视频-->
  51. <ImageToVideo class="contentClass" v-if="course.courseContentType === 'aiImageToVideo'" ref="aiImageToVideo"></ImageToVideo>
  52. <!--编程地图游戏-->
  53. <MapGame v-if="course.courseContentType === 'blockly'"
  54. :game-id="course.id"
  55. :map-background="course.blocklyBackground"
  56. :map-tile-size="course.blocklyTileSize"
  57. :map-start-point="course.blocklyStartPoint"
  58. :map-end-point="course.blocklyEndPoint"
  59. :map-walkable-points="course.blocklyWalkablePoints"
  60. :user-direction="course.blocklyUserDirection"
  61. :route-list="course.blocklyRouteList"
  62. :user-image="course.blocklyUserImage"
  63. :info="course.blocklyInfo"
  64. :game-title="course.courseName"
  65. :course-list="props.courseList"
  66. :blockly-special-blocks="course.blocklySpecialBlocks"
  67. :current-index="currentCourseIndex"
  68. @close-game="emit('closeVideo')"
  69. @prev-section="playPreviousVideo"
  70. @next-section="playNextVideo"
  71. @saveProgress="handleSaveProgress"
  72. v-memo="[course.id, course.courseContentType]"
  73. ></MapGame>
  74. </template>
  75. <!-- 视频切换按钮 - 始终显示 -->
  76. <div class="video-switch" :class="{'map-game-mode': course.courseContentType === 'blockly'}">
  77. <div class="caret-left" @click="playPreviousVideo">
  78. <el-button type="warning" round :disabled="currentCourseIndex === 0">
  79. <img :src="leftImg" alt="Left" />上一节</el-button
  80. >
  81. </div>
  82. <div class="caret-right" @click="playNextVideo">
  83. <el-button type="warning" round :disabled="currentCourseIndex === props.courseList.length - 1"
  84. >下一节<img :src="rightImg" alt="Right" />
  85. </el-button>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. <!-- 弹框组件 -->
  91. <DialogComponents
  92. componentType="blockly"
  93. :questionDialogVisible="questionDialogVisible"
  94. :currentQuestion="courseConfig"
  95. :gradeId="gradeId"
  96. :typeId="typeId"
  97. :courseId="course.id || ''"
  98. @closeQuestionDialog="closeQuestionDialog"
  99. @submitAnswer="handleSubmitAnswer"
  100. />
  101. </div>
  102. </template>
  103. <script setup>
  104. import { ref, onMounted, computed, onUnmounted } from 'vue'
  105. import { useRouter } from 'vue-router'
  106. import { ArrowLeftBold } from '@element-plus/icons-vue'
  107. import { ElMessage } from 'element-plus'
  108. import isDisabledImage from '@/assets/images/permission/isDisabled.png'
  109. import { ClassType } from '@/api/class.js'
  110. import { Message } from '@/utils/message/Message.js'
  111. import { saveRecordBlockly } from '@/api/personalized/index.js'
  112. // 导入图标
  113. import leftImg from '@/assets/icon/backward.png'
  114. import rightImg from '@/assets/icon/f-backward.png'
  115. // 导入新创建的组件
  116. import VideoPlayer from '@/components/videopage/VideoPlayer.vue'
  117. import DialogComponents from '@/components/videopage/DialogComponents.vue'
  118. import PptView from "@/components/PPT/PptView.vue";
  119. import ImageView from '@/components/Image/ImageView.vue'
  120. // AI实验室
  121. import TextToText from "@/components/ai/text/TextToText.vue";
  122. import TextToImage from "@/components/ai/image/TextToImage.vue";
  123. import ImageToImage from "@/components/ai/image/ImageToImage.vue";
  124. import ImageToVideo from "@/components/ai/video/ImageToVideo.vue";
  125. import MapGame from "@/components/blockly/MapGame.vue";
  126. // 根据ID获取课程列表
  127. import { getBlocklyByTypeId } from '@/api/programming/index.js'
  128. // 导入音频播放器
  129. import { useAudioPlayer } from '@/api/tts/useAudioPlayer';
  130. // 定义常量
  131. const CONSTANTS = {
  132. ANIMATION_DURATION: '0.3s',
  133. STORAGE_KEYS: {
  134. WATCHED_COURSES: 'watchedCourseIds'
  135. }
  136. }
  137. const router = useRouter() // 获取当前路由对象
  138. // 渲染页面标题
  139. const boxIconTitle = ref('')
  140. // AI组件refs
  141. const aiTextToText = ref(null)
  142. // 音频播放器实例
  143. const { stopPlayback } = useAudioPlayer();
  144. // 定义组件的props
  145. const props = defineProps({
  146. courseData: {
  147. type: Object,
  148. default: null
  149. },
  150. courseList: {
  151. type: Array,
  152. default: () => []
  153. }
  154. })
  155. // 定义emit事件
  156. const emit = defineEmits(['closeVideo'])
  157. // 课程集合数据
  158. const courseList = ref([])
  159. //当前课程 - 重新定义course来接收传递过来的数据
  160. const course = ref({})
  161. // 菜单数据
  162. const menuItems = ref([])
  163. // 已观看课程ID列表
  164. const watchedCourseIds = ref([])
  165. // 试题弹框显示状态
  166. const questionDialogVisible = ref(false)
  167. // 当前显示的试题
  168. const courseConfig = ref({})
  169. // 年级id
  170. const gradeId = ref('')
  171. // 课程大纲id
  172. const typeId = ref('')
  173. // 课程小节id
  174. const courseId = ref('')
  175. // 课程排序
  176. const typeSort = ref('')
  177. // 计算当前课程在列表中的索引
  178. const currentCourseIndex = computed(() => {
  179. if (!props.courseList || !course.value.id) return -1
  180. return props.courseList.findIndex(item => item.id === course.value.id)
  181. })
  182. // 展平所有菜单项索引
  183. const flattenMenuItems = () => {
  184. const indices = []
  185. const traverse = items => {
  186. for (const item of items) {
  187. if (!item.children) {
  188. indices.push(item.key)
  189. } else {
  190. traverse(item.children)
  191. }
  192. }
  193. }
  194. traverse(menuItems.value)
  195. return indices
  196. }
  197. // 播放上一个视频
  198. const playPreviousVideo = () => {
  199. if (props.courseList && props.courseList.length > 0) {
  200. const currentIndex = currentCourseIndex.value
  201. if (currentIndex > 0) {
  202. // 停止音频播放并清理资源
  203. stopPlayback();
  204. // 终止AI问答流并清空消息列表
  205. if (aiTextToText.value) {
  206. aiTextToText.value.stopStream();
  207. aiTextToText.value.clearMessageList();
  208. }
  209. const previousCourse = props.courseList[currentIndex - 1]
  210. // 更新当前课程数据
  211. handleParentCourseData(previousCourse)
  212. courseId.value = course.value.id
  213. // 更新标题
  214. boxIconTitle.value = course.value.courseName
  215. }
  216. }
  217. }
  218. // 播放下一个视频
  219. const playNextVideo = () => {
  220. if (props.courseList && props.courseList.length > 0) {
  221. const currentIndex = currentCourseIndex.value
  222. if (currentIndex !== -1 && currentIndex < props.courseList.length - 1) {
  223. // 停止音频播放并清理资源
  224. stopPlayback();
  225. // 终止AI问答流并清空消息列表
  226. if (aiTextToText.value) {
  227. aiTextToText.value.stopStream();
  228. aiTextToText.value.clearMessageList();
  229. }
  230. const nextCourse = props.courseList[currentIndex + 1]
  231. // 更新当前课程数据
  232. handleParentCourseData(nextCourse)
  233. courseId.value = course.value.id
  234. // 更新标题
  235. boxIconTitle.value = course.value.courseName
  236. }
  237. }
  238. }
  239. // 播放结束
  240. const handleVideoEnded = () => {
  241. // 记录当前视频ID为已观看
  242. if (
  243. course.value &&
  244. course.value.id &&
  245. !watchedCourseIds.value.includes(course.value.id)
  246. ) {
  247. watchedCourseIds.value.push(course.value.id)
  248. localStorage.setItem(
  249. CONSTANTS.STORAGE_KEYS.WATCHED_COURSES,
  250. JSON.stringify(watchedCourseIds.value)
  251. )
  252. }
  253. // 自动播放下一个
  254. // playNextVideo();
  255. }
  256. // 处理视频时间更新事件
  257. const handleVideoTimeUpdate = async ({ currentTime, progressPercentage, courseConfig: config }) => {
  258. if (config) {
  259. questionDialogVisible.value = true
  260. courseConfig.value = config
  261. // 保存试题进度
  262. try {
  263. // 确保courseId已经设置
  264. if (!courseId.value && typeId.value) {
  265. const courseRes = await ClassType(typeId.value)
  266. if (courseRes.data && courseRes.data.length > 0) {
  267. courseId.value = course.value && course.value.id ? course.value.id : courseRes.data[0].id
  268. }
  269. }
  270. if (config.id) {
  271. // 保存弹窗问题进度
  272. await saveRecordBlockly({
  273. brpZtId: props.courseData?.ztId,
  274. brpCtId: props.courseData?.acType,
  275. brpCourseConfigId: config.id,
  276. brpCourseId: courseId.value,
  277. brpType: 'courseQuest',
  278. brpProgress: 1
  279. })
  280. }
  281. } catch (error) {
  282. console.error('保存试题进度失败:', error)
  283. }
  284. }
  285. }
  286. // 关闭试题弹框
  287. const closeQuestionDialog = () => {
  288. questionDialogVisible.value = false
  289. }
  290. // 提交答案
  291. const handleSubmitAnswer = ({ selectedOption }) => {
  292. questionDialogVisible.value = false
  293. }
  294. // 处理父组件传递的课程数据
  295. const handleParentCourseData = (courseData = props.courseData) => {
  296. if (!courseData) return false
  297. // 设置返回按钮标题
  298. boxIconTitle.value = courseData.acName
  299. // 重新定义course接收传递过来的数据
  300. course.value = {
  301. id: courseData.id,
  302. courseName: courseData.acName,
  303. typeId: courseData.acType,
  304. courseContentType: courseData.acContentType,
  305. courseContent: courseData.acContent,
  306. courseConfigList: courseData.aiCourseConfigList,
  307. key: courseData.id.toString(),
  308. // blockly相关属性,用于MapGame组件
  309. blocklyBackground: courseData.aiCourseBackground,
  310. blocklyTileSize: courseData.aiCourseTileSize,
  311. blocklyStartPoint: courseData.aiCourseStartPoint,
  312. blocklyEndPoint: courseData.aiCourseEndPoint,
  313. blocklyWalkablePoints: courseData.aiCourseWalkablePoints,
  314. blocklyUserDirection: courseData.aiCourseUserDirection || 0,
  315. blocklyRouteList: courseData.aiCourseRouteList,
  316. blocklyUserImage: courseData.aiCourseUserImage,
  317. blocklyInfo: courseData.aiCourseInfo,
  318. blocklySpecialBlocks: courseData.aiCourseSpecialBlocks ? courseData.aiCourseSpecialBlocks.split(',') : [],
  319. isDisabled: courseData.isDisabled,
  320. }
  321. courseId.value = course.value.id
  322. // 如果有配置,禁用视频检查
  323. if (courseData.isDisabled) {
  324. Message().notifyWarning('您的账号并未开放此课程!', true)
  325. }
  326. return true
  327. }
  328. // 处理课程数据列表
  329. const processCourseDataList = (data) => {
  330. // 对返回的课程数据进行处理,确保ccTime为有效秒数
  331. return data.map(course => {
  332. // 检查并处理courseConfigList
  333. if (course.courseConfigList && Array.isArray(course.courseConfigList)) {
  334. // 过滤掉ccTime为0的配置项
  335. const validConfigList = course.courseConfigList.filter(config =>
  336. config.ccTime !== undefined && config.ccTime !== null && config.ccTime > 0
  337. )
  338. return {
  339. ...course,
  340. courseConfigList: validConfigList
  341. }
  342. }
  343. return course
  344. })
  345. }
  346. // 初始化已观看课程ID
  347. const initWatchedCourseIds = () => {
  348. const savedWatchedIds = localStorage.getItem(CONSTANTS.STORAGE_KEYS.WATCHED_COURSES)
  349. if (savedWatchedIds) {
  350. try {
  351. watchedCourseIds.value = JSON.parse(savedWatchedIds)
  352. } catch (error) {
  353. console.error('解析已观看课程ID失败:', error)
  354. watchedCourseIds.value = []
  355. }
  356. }
  357. }
  358. // 渲染 课程数据结构 以及 视频
  359. onMounted(async () => {
  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. const res = await getBlocklyByTypeId(typeIdParam)
  373. if (res && res.data && Array.isArray(res.data)) {
  374. // 保存原始API返回的数据
  375. handleParentCourseData(res.data[0])
  376. // 处理课程数据
  377. courseList.value = processCourseDataList(res.data)
  378. }
  379. } catch (error) {
  380. console.error('获取课程数据失败:', error)
  381. ElMessage.error('获取课程数据失败,请稍后重试')
  382. }
  383. }
  384. // 设置页面标题和排序
  385. const title = router.currentRoute.value.query.typeName
  386. if (title) {
  387. boxIconTitle.value = String(title)
  388. }
  389. typeSort.value = router.currentRoute.value.query.typeSort
  390. })
  391. // 清理函数
  392. onUnmounted(() => {
  393. // 组件卸载时清理音频资源
  394. stopPlayback();
  395. })
  396. // 保存视频/bockly进度接口
  397. const handleSaveProgress = async (type, progress) => {
  398. try {
  399. await saveRecordBlockly({
  400. brpZtId: props.courseData?.ztId,
  401. brpCtId: props.courseData?.acType,
  402. brpCourseId: course.value.id,
  403. brpType: type,
  404. brpProgress: progress
  405. })
  406. } catch (error) {
  407. console.error(`保存${type}进度失败:`, error)
  408. }
  409. }
  410. </script>
  411. <style scoped lang="scss">
  412. @use 'sass:math';
  413. @use 'sass:color'; // 引入 color 模块
  414. // 定义rpx转换函数
  415. @function rpx($px) {
  416. @return math.div($px, 750) * 100vw;
  417. }
  418. // 定义儿童风格的蓝紫色调
  419. $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
  420. $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
  421. $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
  422. $light-color: #ffffff; // 浅色背景:淡紫色
  423. $text-color: #483d8b; // 文本颜色:靛蓝色
  424. // 视频切换按钮样式
  425. .video-switch {
  426. width: 100%;
  427. display: flex;
  428. margin-top: rpx(5);
  429. margin-bottom: rpx(15);
  430. justify-content: center;
  431. }
  432. // MapGame地图模式下-上下节切换按钮-显示到右上角
  433. .video-switch.map-game-mode {
  434. position: absolute;
  435. top: rpx(5);
  436. right: rpx(2);
  437. width: auto;
  438. justify-content: flex-end;
  439. z-index: 1000;
  440. margin: rpx(10);
  441. gap: rpx(10);
  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(15);
  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>