|
|
@@ -22,6 +22,7 @@
|
|
|
@open="handleOpen"
|
|
|
@close="handleClose"
|
|
|
@select="handleSelect"
|
|
|
+ :default-openeds="['1']"
|
|
|
>
|
|
|
<template v-for="item in menuItems" :key="item.index">
|
|
|
<el-menu-item v-if="!item.children" :index="item.index">{{
|
|
|
@@ -68,7 +69,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="box-2">
|
|
|
- <!-- 课程标题 autoplay自动播放-->
|
|
|
+ <!-- 课程标题 autoplay自动播放 @ended="playNextVideo"-->
|
|
|
<div class="small-title">
|
|
|
<span>{{ smallTitle }}</span>
|
|
|
</div>
|
|
|
@@ -76,14 +77,23 @@
|
|
|
class="full-box-video"
|
|
|
:src="videoSrc"
|
|
|
controls
|
|
|
- autoplay
|
|
|
- @ended="playNextVideo"
|
|
|
@timeupdate="handleTimeUpdate"
|
|
|
ref="videoRef"
|
|
|
>
|
|
|
<source :src="videoSrc" type="video/mp4" />
|
|
|
您的浏览器不支持视频播放。
|
|
|
</video>
|
|
|
+ <!-- 添加切换视频 -->
|
|
|
+ <div class="video-switch">
|
|
|
+ <!-- 上一个视频 -->
|
|
|
+ <div class="caret-left" @click="playPreviousVideo">
|
|
|
+ <el-icon class="caret-left-icon"><CaretLeft /></el-icon>
|
|
|
+ </div>
|
|
|
+ <!-- 下一个视频 -->
|
|
|
+ <div class="caret-right" @click="playNextVideo">
|
|
|
+ <el-icon class="caret-right-icon"><CaretRight /></el-icon>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -91,7 +101,7 @@
|
|
|
<script setup>
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
-import { ArrowDown, ArrowRightBold } from '@element-plus/icons-vue'
|
|
|
+import { ArrowDown, ArrowRightBold, CaretRight,CaretLeft } from '@element-plus/icons-vue'
|
|
|
import { Search, ArrowLeftBold } from '@element-plus/icons-vue'
|
|
|
import { valueEquals } from 'element-plus'
|
|
|
// 引入视频
|
|
|
@@ -244,9 +254,19 @@ const playNextVideo = () => {
|
|
|
pausedIndices = ref([])
|
|
|
}
|
|
|
|
|
|
-// 视频 ref
|
|
|
-const videoRef = ref(null)
|
|
|
+// 切换视频
|
|
|
+// 播放上一个视频
|
|
|
+const playPreviousVideo = () => {
|
|
|
+ const allIndices = flattenMenuItems()
|
|
|
+ const currentIndexInList = allIndices.indexOf(currentIndex.value)
|
|
|
+ if (currentIndexInList > 0) {
|
|
|
+ const previousIndex = allIndices[currentIndexInList - 1]
|
|
|
+ handleSelect(previousIndex)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
+// 视频 ref
|
|
|
+const videoRef = ref(null)
|
|
|
// 定义每个视频对应的暂停时间
|
|
|
const videoPauseTimes = {
|
|
|
[video4]: [1],
|
|
|
@@ -254,15 +274,11 @@ const videoPauseTimes = {
|
|
|
[video9]: [2],
|
|
|
[video12]: [1]
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
// 处理视频时间更新事件
|
|
|
const handleTimeUpdate = () => {
|
|
|
if (!videoRef.value) return
|
|
|
-
|
|
|
const currentTime = videoRef.value.currentTime
|
|
|
const currentPauseTimes = videoPauseTimes[videoSrc.value]
|
|
|
-
|
|
|
if (currentPauseTimes) {
|
|
|
currentPauseTimes.forEach((time, index) => {
|
|
|
// 检查是否到达时间点且还未暂停过
|
|
|
@@ -273,6 +289,7 @@ const handleTimeUpdate = () => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
@@ -287,7 +304,7 @@ const handleTimeUpdate = () => {
|
|
|
left: 0;
|
|
|
right: 0;
|
|
|
bottom: 0;
|
|
|
- background: linear-gradient(to bottom, #08105e, #8271c8);
|
|
|
+ background: linear-gradient(to bottom, #001169, #B4A8E1);
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
gap: rpx(0);
|
|
|
@@ -393,12 +410,13 @@ const handleTimeUpdate = () => {
|
|
|
|
|
|
.box-1 {
|
|
|
width: 100%;
|
|
|
- flex: 0.3;
|
|
|
+ height: rpx(50);
|
|
|
+ // margin-top: rpx(10);
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
box-sizing: border-box;
|
|
|
- font-size: rpx(16); // 默认字体大小
|
|
|
+ font-size: rpx(15); // 默认字体大小
|
|
|
}
|
|
|
|
|
|
.inner-box {
|
|
|
@@ -415,7 +433,6 @@ const handleTimeUpdate = () => {
|
|
|
align-items: flex-start;
|
|
|
flex: 1; // 设置左侧盒子占比为 2
|
|
|
cursor: pointer; // 添加鼠标指针样式
|
|
|
- // margin-top: rpx(20);
|
|
|
}
|
|
|
.box-icon {
|
|
|
width: 100%;
|
|
|
@@ -434,14 +451,12 @@ const handleTimeUpdate = () => {
|
|
|
|
|
|
.left-box span {
|
|
|
position: absolute;
|
|
|
- // top: 20px;
|
|
|
- // left: 20px;
|
|
|
font-size: rpx(11); // 默认字体大小
|
|
|
color: white;
|
|
|
}
|
|
|
|
|
|
.right-box {
|
|
|
- flex: 2;
|
|
|
+ flex: 1;
|
|
|
position: relative; // 添加相对定位;
|
|
|
}
|
|
|
.top-right-box {
|
|
|
@@ -479,22 +494,22 @@ const handleTimeUpdate = () => {
|
|
|
}
|
|
|
.box-2 {
|
|
|
width: 100%;
|
|
|
- flex: 2;
|
|
|
+ flex: 1;
|
|
|
box-shadow: 0 4px 8px rgba(202, 52, 52, 0.1);
|
|
|
box-sizing: border-box;
|
|
|
- // padding: 0 rpx(30); // 添加左右内边距
|
|
|
+ // padding: rpx(-20) rpx(20); // 添加左右内边距
|
|
|
display: flex; // 确保子元素水平排列
|
|
|
flex-wrap: wrap; // 允许子元素换行;
|
|
|
align-content: center; // 顶部对齐;
|
|
|
cursor: pointer; // 添加鼠标指针样式
|
|
|
video.full-box-video {
|
|
|
- width: 85%;
|
|
|
- height: 90%;
|
|
|
- margin: auto;
|
|
|
+ width: rpx(550);
|
|
|
+ height: rpx(250);
|
|
|
+ margin: 0 auto;
|
|
|
border-radius: rpx(12);
|
|
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
|
|
|
object-fit: cover;
|
|
|
- background-color: #000;
|
|
|
+ // object-fit: contain;
|
|
|
}
|
|
|
}
|
|
|
.small-title {
|
|
|
@@ -505,4 +520,24 @@ const handleTimeUpdate = () => {
|
|
|
font-size: rpx(10);
|
|
|
justify-content: center; //使子元素水平居中
|
|
|
}
|
|
|
+.video-switch {
|
|
|
+ width: 100%;
|
|
|
+ // height: rpx(50);
|
|
|
+ display: flex;
|
|
|
+ margin-top: rpx(10);
|
|
|
+ // background-color: saddlebrown;
|
|
|
+}
|
|
|
+.caret-right,
|
|
|
+.caret-left{
|
|
|
+ width: rpx(20);
|
|
|
+ height: rpx(20);
|
|
|
+ margin: auto;
|
|
|
+ border-radius: rpx(50);
|
|
|
+ border: 2px solid white;
|
|
|
+}
|
|
|
+.caret-right-icon,
|
|
|
+.caret-left-icon{
|
|
|
+ font-size: rpx(20);
|
|
|
+ color: white;
|
|
|
+}
|
|
|
</style>
|