feat 优化
This commit is contained in:
@@ -189,7 +189,7 @@ watch(
|
|||||||
(newNotices) => {
|
(newNotices) => {
|
||||||
const filteredNotices = [...newNotices].map(parseNoticeItem);
|
const filteredNotices = [...newNotices].map(parseNoticeItem);
|
||||||
newsList.value = filteredNotices;
|
newsList.value = filteredNotices;
|
||||||
console.log('监听消息队列', newsList.value);
|
// console.log('监听消息队列', newsList.value);
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -122,22 +122,23 @@ export const initHls = (monitorVideoUrl, monitorVideoRef, isDialogVisible?: () =
|
|||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case Hls.ErrorTypes.NETWORK_ERROR:
|
case Hls.ErrorTypes.NETWORK_ERROR:
|
||||||
if (data.details === 'manifestLoadError' || data.details === 'manifestLoadTimeOut') {
|
if (data.details === 'manifestLoadError' || data.details === 'manifestLoadTimeOut') {
|
||||||
console.error('网络错误');
|
//console.error('网络错误');
|
||||||
|
ElMessage.error('网络错误,请检查网络连接');
|
||||||
// if (onStall) {
|
// if (onStall) {
|
||||||
// onStall();
|
// onStall();
|
||||||
// }
|
// }
|
||||||
hls.startLoad();
|
hls.startLoad();
|
||||||
} else {
|
} else {
|
||||||
console.warn('[HLS] 网络错误,自动恢复...');
|
ElMessage.error('[HLS] 网络错误,自动恢复...');
|
||||||
hls.startLoad();
|
hls.startLoad();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hls.ErrorTypes.MEDIA_ERROR:
|
case Hls.ErrorTypes.MEDIA_ERROR:
|
||||||
console.warn('[HLS] 媒体解码错误,尝试恢复...');
|
ElMessage.error('[HLS] 媒体解码错误,尝试恢复...');
|
||||||
hls.recoverMediaError();
|
hls.recoverMediaError();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.error('[HLS] 不可恢复的错误,销毁实例');
|
ElMessage.error('[HLS] 不可恢复的错误,销毁实例');
|
||||||
state.destroyed = true;
|
state.destroyed = true;
|
||||||
stopLiveSync(state);
|
stopLiveSync(state);
|
||||||
hls.destroy();
|
hls.destroy();
|
||||||
@@ -152,18 +153,18 @@ export const initHls = (monitorVideoUrl, monitorVideoRef, isDialogVisible?: () =
|
|||||||
case Hls.ErrorTypes.NETWORK_ERROR:
|
case Hls.ErrorTypes.NETWORK_ERROR:
|
||||||
// 分片加载失败等 → 重新加载
|
// 分片加载失败等 → 重新加载
|
||||||
if (data.details === 'fragLoadError' || data.details === 'fragLoadTimeOut') {
|
if (data.details === 'fragLoadError' || data.details === 'fragLoadTimeOut') {
|
||||||
console.warn(`[HLS] 分片加载问题 (${data.details}),第 ${state.consecutiveFailures} 次失败,尝试恢复...`);
|
ElMessage.error(`[HLS] 分片加载问题 (${data.details}),第 ${state.consecutiveFailures} 次失败,尝试恢复...`);
|
||||||
hls.startLoad(hls.currentLevel);
|
hls.startLoad(hls.currentLevel);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Hls.ErrorTypes.MEDIA_ERROR:
|
case Hls.ErrorTypes.MEDIA_ERROR:
|
||||||
if (data.details === 'bufferAppendError' || data.details === 'bufferFullError') {
|
if (data.details === 'bufferAppendError' || data.details === 'bufferFullError') {
|
||||||
console.warn(`[HLS] 缓冲区问题 (${data.details}),尝试恢复...`);
|
ElMessage.error(`[HLS] 缓冲区问题 (${data.details}),尝试恢复...`);
|
||||||
hls.recoverMediaError();
|
hls.recoverMediaError();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn(`[HLS] 非致命错误: ${data.type} - ${data.details}`);
|
ElMessage.error(`[HLS] 非致命错误: ${data.type} - ${data.details}`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,7 +177,7 @@ export const initHls = (monitorVideoUrl, monitorVideoRef, isDialogVisible?: () =
|
|||||||
state.stallTimer = setInterval(() => {
|
state.stallTimer = setInterval(() => {
|
||||||
if (state.destroyed || !onStall) return;
|
if (state.destroyed || !onStall) return;
|
||||||
if (state.consecutiveFailures >= 3) {
|
if (state.consecutiveFailures >= 3) {
|
||||||
console.warn(`[HLS] 连续 ${state.consecutiveFailures} 次加载失败,触发自动刷新`);
|
ElMessage.error(`[HLS] 连续 ${state.consecutiveFailures} 次加载失败,触发自动刷新`);
|
||||||
state.consecutiveFailures = 0;
|
state.consecutiveFailures = 0;
|
||||||
onStall();
|
onStall();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user