feat: 更新视频播放器组件,添加章节视频功能并优化返回逻辑

This commit is contained in:
2026-04-09 16:48:57 +08:00
parent 943cc862fc
commit 17022d498a
19 changed files with 1192 additions and 1599 deletions

View File

@@ -254,9 +254,21 @@
methods: {
dataIdWatcher (newVal) {
if ( newVal ) {
this.dom = document.querySelector('.rvideo' + newVal)
this.domSlot = document.querySelector('.rvideoslot' + newVal)
this.init()
// 延迟一下再查找 DOM 元素,确保 DOM 已经渲染完成
setTimeout(() => {
this.dom = document.querySelector('.rvideo' + newVal)
this.domSlot = document.querySelector('.rvideoslot' + newVal)
// 检查 DOM 元素是否存在
if ( this.dom && this.domSlot ) {
this.init()
} else {
console.error('yb-video: DOM 元素未找到,可能渲染失败', {
dataId: newVal,
dom: this.dom,
domSlot: this.domSlot
})
}
}, 100)
}
},
async init () {
@@ -348,8 +360,9 @@
parseSrc (path) {
// #ifdef H5
const isHash = window.location.hash
const route = this.dom.getAttribute('data-route')
const pathName = isHash ? window.location.pathname : window.location.pathname.replace(route, '')
// 安全检查 this.dom 是否存在
const route = this.dom ? this.dom.getAttribute('data-route') : ''
const pathName = isHash ? window.location.pathname : window.location.pathname.replace(route || '', '')
return window.location.origin + pathName + path.substring(1)
// #endif
// #ifdef APP-VUE
@@ -455,6 +468,7 @@
isLive: params.isLive,
header: params.header,
controls: params.controls,
alwaysShowControls: params.alwaysShowControls,
height: '100%',
objectFit: params.objectFit,
crossOrigin: params.crossOrigin,
@@ -465,6 +479,7 @@
workIndex: params.workIndex,
subtitles: params.subtitles,
subtitleIndex: params.subtitleIndex,
playbackRates: params.playbackRates,
custom,
decoder: {
hls: {