| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122 |
- <template>
- <!-- 编程课程视频页面 -->
- <div class="home-container">
- <div class="content-box">
- <div class="box-1">
- <div class="inner-box left-box">
- <div class="box-icon" @click="emit('closeVideo')">
- <el-icon class="left-icon"><ArrowLeftBold /></el-icon>
- 返回
- </div>
- </div>
- </div>
- <div class="box-2">
- <!-- 课程标题 -->
- <div class="small-title">
- <span>{{ course.courseName }}</span>
- </div>
- <el-empty v-if="isDisabled"
- image-size="500"
- description="您无权查看该课程!"
- :image="isDisabledImage"
- />
- <template v-else>
- <!-- 视频组件 -->
- <VideoPlayer
- v-if="course.courseContentType === 'video'"
- :contentType="course.courseContentType"
- :videoPath="course.courseContent"
- :courseId="course.id || ''"
- :typeId="course.typeId"
- :courseConfigList="course.courseConfigList || []"
- :allIndices="flattenMenuItems()"
- :currentIndex="course.key || ''"
- @timeUpdate="handleVideoTimeUpdate"
- @videoEnded="handleVideoEnded"
- @saveProgress="handleSaveProgress"
- />
- <!-- 图片 -->
- <ImageView v-if="course.courseContentType === 'image'" :imagePath="course.courseContent" altText="课程图片"></ImageView>
- <!-- PPT -->
- <PptView v-if="course.courseContentType === 'ppt'" :pptPath="course.courseContent" ref="pptRef"></PptView>
- <!--文生文-->
- <TextToText class="contentClass" v-if="course.courseContentType === 'aiTextToText'" ref="aiTextToText"></TextToText>
- <!--文生图-->
- <TextToImage class="contentClass" v-if="course.courseContentType === 'aiTextToImage'" ref="aiTextToImage"></TextToImage>
- <!--图生图-->
- <ImageToImage class="contentClass" v-if="course.courseContentType === 'aiImageToImage'" ref="aiImageToImage"></ImageToImage>
- <!--图生视频-->
- <ImageToVideo class="contentClass" v-if="course.courseContentType === 'aiImageToVideo'" ref="aiImageToVideo"></ImageToVideo>
-
- <!--编程地图游戏-->
- <MapGame v-if="course.courseContentType === 'blockly'"
- :game-id="course.id"
- :map-background="course.blocklyBackground"
- :map-tile-size="course.blocklyTileSize"
- :map-start-point="course.blocklyStartPoint"
- :map-end-point="course.blocklyEndPoint"
- :map-walkable-points="course.blocklyWalkablePoints"
- :user-direction="course.blocklyUserDirection"
- :user-image="course.blocklyUserImage"
- :info="course.blocklyInfo"
- :game-title="course.courseName"
- :course-list="props.courseList"
- :blockly-special-blocks="course.blocklySpecialBlocks"
- :current-index="props.courseList.findIndex(item => item.id === course.id)"
- @close-game="emit('closeVideo')"
- @prev-section="playPreviousVideo"
- @next-section="playNextVideo"
- @saveProgress="handleSaveProgress"
- ></MapGame>
- </template>
- <!-- 视频切换按钮 - 始终显示 -->
- <div class="video-switch">
- <div class="caret-left" @click="playPreviousVideo">
- <el-button type="warning" round :disabled="props.courseList.findIndex(item => item.id === course.id) === 0">
- <img :src="leftImg" alt="Left" />上一节</el-button
- >
- </div>
- <div class="caret-right" @click="playNextVideo">
- <el-button type="warning" round :disabled="props.courseList.findIndex(item => item.id === course.id) === props.courseList.length - 1"
- >下一节<img :src="rightImg" alt="Right" />
- </el-button>
- </div>
- </div>
- </div>
- </div>
- <!-- 弹框组件 -->
- <DialogComponents
- componentType="blockly"
- :questionDialogVisible="questionDialogVisible"
- :currentQuestion="courseConfig"
- :gradeId="gradeId"
- :typeId="typeId"
- :courseId="course.id || ''"
- @closeQuestionDialog="closeQuestionDialog"
- @submitAnswer="handleSubmitAnswer"
- />
- </div>
- </template>
- <script setup>
- import { ref, onMounted, computed } from 'vue'
- import { useRouter } from 'vue-router'
- import { ArrowLeftBold } from '@element-plus/icons-vue'
- import { ElMessage } from 'element-plus'
- import isDisabledImage from '@/assets/images/permission/isDisabled.png'
- import { ClassType } from '@/api/class.js'
- import { Message } from '@/utils/message/Message.js'
- import { saveRecordBlockly } from '@/api/personalized/index.js'
- // 导入全局状态
- import { globalState } from '@/utils/globalState.js'
- // 导入图标
- import leftImg from '@/assets/icon/backward.png'
- import rightImg from '@/assets/icon/f-backward.png'
- // 导入新创建的组件
- import VideoPlayer from '@/components/videopage/VideoPlayer.vue'
- import DialogComponents from '@/components/videopage/DialogComponents.vue'
- import PptView from "@/components/PPT/PptView.vue";
- import ImageView from '@/components/Image/ImageView.vue'
- // AI实验室
- import TextToText from "@/components/ai/text/TextToText.vue";
- import TextToImage from "@/components/ai/image/TextToImage.vue";
- import ImageToImage from "@/components/ai/image/ImageToImage.vue";
- import ImageToVideo from "@/components/ai/video/ImageToVideo.vue";
- import MapGame from "@/components/blockly/MapGame.vue";
- import {getBlocklyByTypeId} from "@/api/programming/index.js";
- const router = useRouter() // 获取当前路由对象
- // 渲染页面标题
- const boxIconTitle = ref('')
- // 定义组件的props
- const props = defineProps({
- courseData: {
- type: Object,
- default: null
- },
- courseList: {
- type: Array,
- default: () => []
- }
- })
- // 定义emit事件
- const emit = defineEmits(['closeVideo'])
- // 课程集合数据
- const courseList = ref([])
- //当前课程 - 重新定义course来接收传递过来的数据
- const course = ref({})
- // 菜单数据
- const menuItems = ref([])
- // 课程集合数据
- const videoPathMap = ref({})
- // 已观看课程ID列表
- const watchedCourseIds = ref([])
- // 试题弹框显示状态
- const questionDialogVisible = ref(false)
- // 当前显示的试题
- const courseConfig = ref({})
- // 年级id
- const gradeId = ref('')
- // 课程大纲id
- const typeId = ref('')
- // 课程小节id
- const courseId = ref('')
- // 课程排序
- const typeSort = ref('')
- // 课程权限
- const blocklyDataScope = ref([])
- // 测试账号禁用视频
- const isDisabled = ref(false)
- // 展平所有菜单项索引
- const flattenMenuItems = () => {
- const indices = []
- const traverse = items => {
- for (const item of items) {
- if (!item.children) {
- indices.push(item.key)
- } else {
- traverse(item.children)
- }
- }
- }
- traverse(menuItems.value)
- return indices
- }
- // 播放上一个视频
- const playPreviousVideo = () => {
- if (props.courseList && props.courseList.length > 0) {
- const currentIndex = props.courseList.findIndex(item => item.id === course.value.id)
- if (currentIndex > 0) {
- const previousCourse = props.courseList[currentIndex - 1]
- // 更新当前课程数据
- handleParentCourseData(previousCourse)
- courseId.value = course.value.id;
- // 更新标题
- boxIconTitle.value = course.value.courseName;
- // 禁用视频检查
- disableVideo(course.value.key);
- }
- }
- }
- // 播放下一个视频
- const playNextVideo = () => {
- if (props.courseList && props.courseList.length > 0) {
- const currentIndex = props.courseList.findIndex(item => item.id === course.value.id)
- if (currentIndex !== -1 && currentIndex < props.courseList.length - 1) {
- const nextCourse = props.courseList[currentIndex + 1]
- // 更新当前课程数据
- handleParentCourseData(nextCourse)
- courseId.value = course.value.id;
- // 更新标题
- boxIconTitle.value = course.value.courseName;
- // 禁用视频检查
- disableVideo(course.value.key);
- }
- }
- }
- // 播放结束
- const handleVideoEnded = () => {
- // 记录当前视频ID为已观看
- if (
- course.value &&
- course.value.id &&
- !watchedCourseIds.value.includes(course.value.id)
- ) {
- watchedCourseIds.value.push(course.value.id)
- localStorage.setItem(
- 'watchedCourseIds',
- JSON.stringify(watchedCourseIds.value)
- )
- }
- // 自动播放下一个
- // playNextVideo();
- }
- // 禁用视频
- const disableVideo = (index = course.value.key) => {
- // 未配置课程权限,不禁用视频
- if (!blocklyDataScope.value || blocklyDataScope.value.length === 0) {
- return false
- }
- //配置了课程权限,且视频id不在权限列表中
- isDisabled.value = !blocklyDataScope.value.some(item => Number(item) === videoPathMap.value[index].id)
- if (isDisabled.value) {
- Message().notifyWarning('您的账号并未开放此课程!', true)
- return isDisabled.value;
- }
- return isDisabled.value;
- }
- // 处理视频时间更新事件
- const handleVideoTimeUpdate = ({ currentTime, progressPercentage, courseConfig: config }) => {
- if (config) {
- questionDialogVisible.value = true
- courseConfig.value = config
- // 保存试题进度
- const saveQuestProgress = async () =>{
- try {
- // 确保courseId已经设置
- if (!courseId.value && typeId.value) {
- const courseRes = await ClassType(typeId.value)
- if (courseRes.data && courseRes.data.length > 0) {
- courseId.value = course.value && course.value.id ? course.value.id : courseRes.data[0].id
- }
- }
- if (config.id) {
- // 保存弹窗问题进度
- await saveRecordBlockly({
- brpZtId: props.courseData.ztId,
- brpCtId: props.courseData.bcType,
- brpCourseConfigId: config.id,
- brpCourseId: courseId.value,
- brpType: 'courseQuest',
- brpProgress: 1
- })
- } else {
- console.error('无法保存试题进度: 试题id不存在')
- }
- }catch(error){
- console.error(`保存试题进度失败:`, error)
- }
- }
- // 调用异步函数
- saveQuestProgress()
- }
- }
- // 关闭试题弹框
- const closeQuestionDialog = () => {
- questionDialogVisible.value = false
- }
- // 提交答案
- const handleSubmitAnswer = ({ selectedOption }) => {
- questionDialogVisible.value = false
- }
- // 初始化课程数据范围
- const initCourseDataScope = () => {
- const scope = localStorage.getItem("blocklyDataScope");
- if (scope) {
- blocklyDataScope.value = scope.split(",");
- }
- };
- // 处理父组件传递的课程数据
- const handleParentCourseData = (courseData = props.courseData) => {
- if (!courseData) return false;
- // 设置返回按钮标题
- boxIconTitle.value = courseData.bcName;
- // 重新定义course接收传递过来的数据
- course.value = {
- id: courseData.id,
- courseName: courseData.bcName,
- typeId: courseData.bcType,
- courseContentType: courseData.bcContentType,
- courseContent: courseData.bcContent,
- courseConfigList: courseData.blocklyConfigList,
- key: courseData.id.toString(),
- // blockly相关属性,用于MapGame组件
- blocklyBackground: courseData.blocklyBackground,
- blocklyTileSize: courseData.blocklyTileSize,
- blocklyStartPoint: courseData.blocklyStartPoint,
- blocklyEndPoint: courseData.blocklyEndPoint,
- blocklyWalkablePoints: courseData.blocklyWalkablePoints,
- blocklyUserDirection: courseData.blocklyUserDirection || 0,
- blocklyUserImage: courseData.blocklyUserImage,
- blocklyInfo: courseData.blocklyInfo,
- blocklySpecialBlocks: courseData.blocklySpecialBlocks ? courseData.blocklySpecialBlocks.split(',') : [],
- };
- courseId.value = course.value.id;
- // 如果有配置,禁用视频检查
- if (!disableVideo(course.value.key)) {
- console.log('课程已加载:', course.value);
- }
- return true;
- };
- // 处理课程数据列表
- const processCourseDataList = (data) => {
- // 对返回的课程数据进行处理,确保ccTime为有效秒数
- return data.map(course => {
- // 检查并处理courseConfigList
- if (course.courseConfigList && Array.isArray(course.courseConfigList)) {
- // 过滤掉ccTime为0的配置项
- const validConfigList = course.courseConfigList.filter(config =>
- config.ccTime !== undefined && config.ccTime !== null && config.ccTime > 0
- );
- return {
- ...course,
- courseConfigList: validConfigList
- };
- }
- return course;
- });
- };
- // 初始化已观看课程ID
- const initWatchedCourseIds = () => {
- const savedWatchedIds = localStorage.getItem('watchedCourseIds');
- if (savedWatchedIds) {
- try {
- watchedCourseIds.value = JSON.parse(savedWatchedIds);
- } catch (error) {
- console.error('解析已观看课程ID失败:', error);
- watchedCourseIds.value = [];
- }
- }
- };
- // 渲染 课程数据结构 以及 视频
- onMounted(async () => {
- // 初始化课程数据范围
- initCourseDataScope();
- // 初始化已观看课程ID
- initWatchedCourseIds();
- // 检查是否有从父组件传递的courseData
- if (handleParentCourseData()) {
- return;
- }
- // 从路由参数获取typeId
- const typeIdParam = router.currentRoute.value.query.typeId;
- if (typeIdParam) {
- typeId.value = typeIdParam;
- try {
- // 获取课程列表
- getBlocklyByTypeId(typeIdParam).then(res => {
- if (res && res.data && Array.isArray(res.data)) {
- props.courseList = res.data
- // 保存原始API返回的数据
- handleParentCourseData(res.data);
- // 处理课程数据
- courseList.value = processCourseDataList(res.data);
- }
- })
- } catch (error) {
- console.error('获取课程数据失败:', error);
- ElMessage.error('获取课程数据失败,请稍后重试');
- }
- }
- // 设置页面标题和排序
- const title = router.currentRoute.value.query.typeName;
- if (title) {
- boxIconTitle.value = String(title);
- }
- typeSort.value = router.currentRoute.value.query.typeSort;
- })
- // 保存视频/bockly进度接口
- const handleSaveProgress = async (type, progress) => {
- try {
- await saveRecordBlockly({
- brpZtId: props.courseData.ztId,
- brpCtId: props.courseData.bcType,
- brpCourseId: course.value.id,
- brpType: type,
- brpProgress: progress
- })
- } catch (error) {
- console.error(`保存${type}进度失败:`, error)
- }
- }
- </script>
- <style scoped lang="scss">
- @use 'sass:math';
- @use 'sass:color'; // 引入 color 模块
- // 定义rpx转换函数
- @function rpx($px) {
- @return math.div($px, 750) * 100vw;
- }
- // 定义儿童风格的蓝紫色调
- $primary-color: rgba(106, 90, 205, 0.52); // 主色调:蓝紫色
- $secondary-color: rgba(147, 112, 219, 0.66); // 辅助色:亮蓝紫色
- $accent-color: rgb(133, 89, 220); // 强调色:暗蓝紫色
- $light-color: #ffffff; // 浅色背景:淡紫色
- $text-color: #483d8b; // 文本颜色:靛蓝色
- // 视频切换按钮样式
- .video-switch {
- width: 100%;
- display: flex;
- margin-top: rpx(5);
- margin-bottom: rpx(15);
- justify-content: center;
- }
- .caret-right,
- .caret-left {
- width: rpx(50);
- margin: 0 rpx(20);
- margin: auto;
- display: flex;
- justify-content: center;
- }
- .caret-left ::v-deep(.el-button.is-round),
- .caret-right ::v-deep(.el-button.is-round) {
- width: rpx(50);
- height: rpx(15);
- color: white;
- font-size: rpx(7);
- border-radius: none;
- border: 1px white solid;
- background-color: rgb(255, 255, 255, 0.5);
- box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
- }
- .caret-right img,
- .caret-left img {
- width: rpx(12);
- }
- .default-messages {
- margin-top: rpx(-10);
- margin-bottom: rpx(5);
- }
- .content-box {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column; /* 子元素上下排列 */
- background-image: url('@/assets/programming/list_bg03.png');
- overflow-y: auto;
- // 滚动条整体样式
- &::-webkit-scrollbar {
- width: rpx(1); // 滚动条宽度
- }
- // 滚动条滑块样式
- &::-webkit-scrollbar-thumb {
- background-color: rgba(255, 255, 255, 0.5); // 滑块颜色
- border-radius: 4px; // 滑块圆角
- transition: background-color 0.3s ease;
- }
- // 滚动条轨道样式
- &::-webkit-scrollbar-track {
- background-color: rgba(0, 0, 0, 0.1); // 轨道颜色
- border-radius: 4px; // 轨道圆角
- }
- }
- .home-container {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-image: url('@/assets/programming/list_bg03.png');
- }
- .box-1 {
- width: 100%;
- // height: rpx(50);
- margin-top: rpx(10);
- display: flex;
- justify-content: center;
- align-items: center;
- box-sizing: border-box;
- font-size: rpx(15); // 默认字体大小
- }
- .inner-box {
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: rpx(16); // 默认字体大小
- }
- .left-box {
- position: relative;
- justify-content: flex-start;
- align-items: flex-start;
- flex: 1; // 设置左侧盒子占比为 2
- cursor: pointer; // 添加鼠标指针样式
- }
- .box-icon {
- display: flex;
- align-items: center;
- margin-left: rpx(7);
- gap: 10px;
- padding: 10px 20px;
- background-color: rgba(255, 255, 255, 0.8);
- border-radius: 30px;
- backdrop-filter: blur(10px);
- cursor: pointer;
- transition: all 0.3s ease;
- font-size: 16px;
- color: #333;
- font-weight: 500;
- width: fit-content;
- }
- .box-icon:hover {
- background-color: rgba(255, 255, 255, 0.9);
- transform: translate(-3px);
- }
- .box-icon .left-icon {
- margin: 0;
- }
- .left-box span {
- position: absolute;
- font-size: rpx(11); // 默认字体大小
- color: white;
- }
- .box-2 {
- width: 100%;
- flex: 1;
- box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
- box-sizing: border-box;
- // display: flex; // 确保子元素水平排列
- flex-wrap: wrap; // 允许子元素换行;
- align-content: center; // 顶部对齐;
- cursor: pointer; // 添加鼠标指针样式
- }
- .small-title {
- width: 100%;
- // margin-top: rpx(-20);
- height: rpx(20);
- color: white;
- font-size: rpx(10);
- justify-content: center; //使子元素水平居中
- }
- // 图片容器样式
- .image-container {
- width: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- // padding: rpx(20) 0;
- }
- // 图片样式
- .course-image {
- max-width: 70%;
- max-height: rpx(400);
- object-fit: contain;
- border-radius: rpx(12);
- box-shadow: 0 rpx(10) rpx(20) rgba(0, 0, 0, 0.1);
- }
- // 儿童风格试题弹框样式
- .child-dialog {
- .el-dialog__header {
- display: none; // 隐藏原有的标题栏
- }
- .el-dialog__body {
- padding: rpx(20);
- position: relative;
- }
- .el-dialog__footer {
- border-top: none;
- padding: rpx(10) rpx(20);
- text-align: center;
- margin-top: auto; // 使底部按钮位于底部
- }
- .el-dialog__wrapper {
- // 修改半透明背景色
- background-color: rgba(0, 0, 0, 0.6);
- }
- .el-dialog {
- border: none;
- border-radius: rpx(20);
- background: linear-gradient(
- 135deg,
- $light-color,
- #d8bfd8
- ); // 柔和的蓝紫色渐变
- overflow: hidden;
- display: flex; // 添加 flex 布局
- flex-direction: column; // 设置垂直布局
- min-height: 0; // 防止子元素溢出
- // 添加装饰元素
- &::before {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: rpx(10);
- background: linear-gradient(90deg, $secondary-color, $accent-color);
- }
- }
- }
- // 问题标题样式
- .question-title {
- padding: rpx(15);
- border-radius: rpx(12);
- margin-bottom: rpx(20);
- color: #483d8b;
- font-weight: bold;
- font-size: rpx(12);
- position: relative;
- display: flex;
- .question-icon {
- background-color: $accent-color;
- color: white;
- width: rpx(24);
- height: rpx(24);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: rpx(10);
- font-weight: bold;
- box-shadow: 0 rpx(2) rpx(5) rgba($accent-color, 0.3);
- }
- }
- // 选项容器样式
- .options-container {
- margin-bottom: rpx(20);
- }
- // 问题选项样式
- .question-option {
- margin: rpx(8) 0;
- padding: rpx(10) rpx(15);
- border-radius: rpx(12);
- border: rpx(1) solid rgba($primary-color, 0.3);
- transition: all 0.3s ease;
- display: flex;
- align-items: center;
- background-color: white;
- box-shadow: 0 rpx(2) rpx(5) rgba($primary-color, 0.05);
- ::v-deep(.el-radio__label) {
- color: $text-color;
- margin-left: rpx(8);
- flex: 1;
- text-align: left;
- // 增大字体大小
- font-size: rpx(12);
- }
- // 选中时的样式变化
- .el-radio__input.is-checked + .el-radio__label {
- font-weight: bold;
- color: $accent-color;
- }
- &:hover {
- background-color: rgba($primary-color, 0.05);
- border-color: rgba($primary-color, 0.5);
- transform: translateY(-rpx(1));
- }
- }
- // 暂无选项样式
- .no-options {
- color: rgba($text-color, 0.7);
- text-align: center;
- padding: rpx(20);
- font-size: rpx(12);
- }
- // 底部按钮样式
- .child-button {
- min-width: rpx(80);
- height: rpx(30);
- border-radius: rpx(8);
- font-size: rpx(12);
- font-weight: 500;
- transition: all 0.3s ease;
- box-shadow: 0 rpx(2) rpx(8) rgba(0, 0, 0, 0.1);
- &.confirm {
- background: linear-gradient(to bottom, #ab81ff, #8559dc);
- border: none;
- border-right: 15px;
- color: white;
- &:hover {
- background: linear-gradient(
- to bottom,
- color.adjust(#ab81ff, $lightness: -5%),
- color.adjust(#8559dc, $lightness: -5%)
- );
- transform: translateY(-rpx(1));
- color: white;
- }
- }
- &.cancel {
- background: white;
- border: rpx(1) solid rgba($primary-color, 0.3);
- color: $text-color;
- &:hover {
- background: rgba($primary-color, 0.05);
- border-color: rgba($primary-color, 0.5);
- transform: translateY(-rpx(1));
- }
- }
- }
- // AI对话图标样式
- .ai-icon-container {
- position: absolute;
- bottom: rpx(20);
- right: rpx(20);
- display: flex;
- flex-direction: column;
- align-items: center;
- cursor: pointer;
- transition: all 0.3s ease;
- &:hover {
- transform: translateY(-rpx(2));
- }
- .ai-icon {
- width: rpx(30);
- height: rpx(30);
- margin-bottom: rpx(0);
- filter: drop-shadow(0 rpx(2) rpx(4) rgba($primary-color, 0.3));
- // 添加过渡动画
- transition: transform 0.3s ease;
- }
- // 悬浮时放大效果
- .ai-icon:hover {
- transform: scale(1.5);
- }
- .ai-text {
- color: $text-color;
- font-size: rpx(8);
- background-color: rgba(255, 255, 255, 0.7);
- padding: rpx(2) rpx(5);
- border-radius: rpx(5);
- }
- }
- // AI消息样式
- .ai-message {
- display: flex;
- align-items: flex-start;
- margin-bottom: rpx(15);
- .ai-avatar {
- width: rpx(30);
- height: rpx(30);
- border-radius: 50%;
- margin-right: rpx(10);
- background-color: $primary-color;
- padding: rpx(5);
- }
- .ai-text-content {
- background-color: $light-color;
- padding: rpx(8) rpx(12);
- border-radius: rpx(10);
- font-size: rpx(10);
- color: $text-color;
- max-width: 80%;
- }
- }
- // 用户输入框样式
- .user-input {
- ::v-deep(.el-input__wrapper) {
- height: rpx(23);
- border-top-left-radius: rpx(5);
- border-bottom-left-radius: rpx(5);
- border-color: rgba($primary-color, 0.3);
- &:focus-within {
- box-shadow: 0 0 0 rpx(1) rgba($primary-color, 0.5);
- }
- }
- ::v-deep(.el-input__inner) {
- font-size: rpx(10);
- // color: $text-color;
- text-indent: 1em;
- }
- ::v-deep(.el-input-group__append, .el-input-group__prepend) {
- background: linear-gradient(to bottom, #ab81ff, #8559dc);
- border-top-right-radius: rpx(5);
- border-bottom-right-radius: rpx(5);
- color: white;
- font-size: rpx(9);
- }
- }
- /* 定义淡入和缩放动画 */
- .fade-scale-enter-active,
- .fade-scale-leave-active {
- transition: all 0.5s ease;
- }
- .fade-scale-enter-from,
- .fade-scale-leave-to {
- opacity: 0.1;
- transform: scale(0.9);
- }
- // 自定义试题弹框背景
- .child-dialog-wrapper {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.6); // 半透明背景
- display: flex;
- justify-content: center;
- align-items: center;
- z-index: 1000;
- }
- .child-dialog {
- border: none;
- border-radius: rpx(15);
- background: rgb(255, 255, 255, 0.8); // 柔和的蓝紫色渐变
- overflow: hidden;
- padding: rpx(5);
- // width: 40%;
- // height: 60%;
- position: relative;
- }
- // AI对话弹框样式
- .ai-dialog-wrapper {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- display: flex;
- justify-content: flex-end;
- align-items: center;
- z-index: 1001;
- pointer-events: none;
- }
- .ai-dialog {
- border: none;
- border-radius: rpx(15);
- background: rgb(255, 255, 255, 0.8);
- overflow: hidden;
- padding: rpx(20);
- width: 30%;
- // 增加高度
- height: 80%;
- margin-right: rpx(50);
- pointer-events: auto;
- position: relative;
- display: flex;
- flex-direction: column;
- &::before {
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: rpx(10);
- }
- }
- .ai-dialog-header {
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-bottom: rpx(15);
- margin-top: rpx(-10);
- img {
- width: rpx(15);
- }
- h3 {
- color: black;
- font-size: rpx(12);
- }
- .close-btn {
- padding: 0;
- width: rpx(20);
- height: rpx(20);
- font-size: rpx(16);
- line-height: 1;
- position: absolute;
- background-color: transparent;
- border: none;
- margin-left: rpx(200);
- }
- }
- .ai-dialog-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .ai-message-history {
- flex: 1;
- // 当内容超出容器高度时,显示垂直滚动条
- overflow-y: auto;
- margin-bottom: rpx(15);
- // 可以根据实际情况调整最大高度
- font-size: rpx(5);
- max-height: 50vh;
- .message {
- display: flex;
- align-items: flex-start;
- margin-bottom: rpx(10);
- &.user {
- flex-direction: row-reverse;
- }
- .avatar {
- width: rpx(30);
- height: rpx(30);
- border-radius: 50%;
- margin: 0 rpx(10);
- }
- .user {
- width: 15px;
- height: 15px;
- }
- .message-content {
- background-color: #ffffff;
- font-size: rpx(5);
- max-width: 80%;
- color: black;
- box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
- }
- }
- // 滚动条整体样式
- &::-webkit-scrollbar {
- width: rpx(4); // 滚动条宽度
- }
- // 滚动条滑块样式
- &::-webkit-scrollbar-thumb {
- background-color: $primary-color; // 滑块颜色
- border-radius: rpx(4); // 滑块圆角
- transition: background-color 0.3s ease; // 颜色过渡效果
- }
- // 滚动条轨道样式
- &::-webkit-scrollbar-track {
- background-color: rgba($primary-color, 0.2); // 轨道颜色
- border-radius: rpx(4); // 轨道圆角
- }
- .message {
- display: flex;
- align-items: flex-start;
- margin-bottom: rpx(10);
- &.user {
- flex-direction: row-reverse;
- }
- .avatar {
- width: rpx(30);
- height: rpx(30);
- border-radius: 50%;
- margin: 0 rpx(10);
- }
- .message-content {
- background-color: white;
- padding: rpx(8) rpx(12);
- border-radius: rpx(5);
- font-size: rpx(8);
- color: black;
- max-width: 80%;
- box-shadow: 0 rpx(1) rpx(3) rgba(0, 0, 0, 0.05);
- }
- }
- }
- // 优化发送按钮样式
- .send-button {
- border: none;
- color: white;
- }
- </style>
- <style scoped lang="scss">
- @use 'sass:math';
- // 定义rpx转换函数
- @function rpx($px) {
- @return math.div($px, 750) * 100vw;
- }
- .default-messages {
- margin-top: rpx(-10);
- margin-bottom: rpx(5);
- }
- .contentClass{
- width: 70%;
- height: 80%;
- margin: 0 auto;
- border-radius: rpx(15);
- overflow: hidden;
- }
- </style>
|