Interface.vue 27 KB

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