Просмотр исходного кода

fix(video): 禁用海康监控非核心异常提示

- 禁用性能不足、断流、流结束和播放器异常页面提示
- 禁用操作状态类提示并保留控制台日志
- 保留核心监控、设备和控制异常提示
- 补充监控目录加载异常日志
Zimo 4 дней назад
Родитель
Сommit
c0433d0f44
1 измененных файлов с 91 добавлено и 22 удалено
  1. 91 22
      src/views/pms/video_center/haikang/index.vue

+ 91 - 22
src/views/pms/video_center/haikang/index.vue

@@ -594,8 +594,9 @@ async function loadRootTree(searchKeyword = '', requestId = ++treeRequestId) {
     const root = treeData.value[0]
     expandedKeys.value = !searchKeyword && root?.nodeType === 'region' ? [root.indexCode] : []
     treeVersion.value += 1
-  } catch {
+  } catch (error) {
     if (componentUnmounted || requestId !== treeRequestId) return
+    console.error('海康监控目录加载失败', error)
     treeData.value = []
   } finally {
     if (!componentUnmounted && requestId === treeRequestId) treeLoading.value = false
@@ -621,7 +622,11 @@ const loadTreeNode: LoadFunction = async (node, resolve, reject) => {
 
   try {
     resolve(await HikvisionApi.getTreeNodes(data.indexCode))
-  } catch {
+  } catch (error) {
+    console.error('海康监控子区域加载失败', {
+      regionIndexCode: data.indexCode,
+      error
+    })
     reject()
   }
 }
@@ -692,7 +697,9 @@ function initPlayer(): Promise<HikvisionPlayerInstance> {
           clearWindowSoundState(windowIndex)
           void stopWindowTalk(windowIndex)
           void stopWindowZoom(windowIndex)
-          showPreviewError(`监控画面已中断(${interruptTime} 秒未收到码流)`)
+          const message = `监控画面已中断(${interruptTime} 秒未收到码流)`
+          console.warn('海康监控异常提示已禁用', { windowIndex, message })
+          // showPreviewError(message)
         },
         StreamEnd: (windowIndex) => {
           // 用户主动关闭时由 stopWindowPreview 统一清理,不显示“画面已结束”的异常提示。
@@ -708,11 +715,18 @@ function initPlayer(): Promise<HikvisionPlayerInstance> {
           void stopWindowTalk(windowIndex)
           void stopWindowZoom(windowIndex)
           clearWindowPreview(windowIndex)
-          showPreviewError('监控画面已结束')
+          console.warn('海康监控异常提示已禁用', {
+            windowIndex,
+            message: '监控画面已结束'
+          })
+          // showPreviewError('监控画面已结束')
         },
         performanceLack: () => {
-          // SDK 已经完成性能判断,页面只负责给出短暂提示,不自行推断设备性能。
-          showPreviewError('当前设备性能不足,监控画面可能卡顿')
+          // SDK 已经完成性能判断,页面只记录控制台,不自行推断设备性能或弹出提示。
+          console.warn('海康监控异常提示已禁用', {
+            message: '当前设备性能不足,监控画面可能卡顿'
+          })
+          // showPreviewError('当前设备性能不足,监控画面可能卡顿')
         },
         pluginErrorHandler: (windowIndex, errorCode, error) => {
           console.error('H5player 播放器错误', errorCode, error)
@@ -729,7 +743,8 @@ function initPlayer(): Promise<HikvisionPlayerInstance> {
             void stopWindowZoom(windowIndex)
             clearWindowPreview(windowIndex)
           }
-          showPreviewError(`播放器异常(${errorCode})`)
+          // 播放器异常保留控制台日志,但不再向页面弹出提示。
+          // showPreviewError(`播放器异常(${errorCode})`)
         },
         talkPluginErrorHandler: (errorCode, error) => {
           console.error('H5player 对讲错误', errorCode, error)
@@ -769,7 +784,10 @@ async function playCameraPreview(
   windowIndex = activeWindowIndex.value
 ) {
   if (stopAllLoading.value || splitControlLoading.value) {
-    showPreviewError('播放器正在切换状态,请稍后再选择监控点')
+    console.warn('海康监控操作提示已禁用', {
+      message: '播放器正在切换状态,请稍后再选择监控点'
+    })
+    // showPreviewError('播放器正在切换状态,请稍后再选择监控点')
     return
   }
 
@@ -905,11 +923,23 @@ async function captureWindowPicture(windowIndex: number, notify = true): Promise
     previewLoadingWindowIndexes.value.includes(windowIndex) ||
     !previewWindowIndexes.value.includes(windowIndex)
   ) {
-    if (notify) showPreviewError('请等待监控画面首帧显示后再抓图')
+    if (notify) {
+      console.warn('海康监控操作提示已禁用', {
+        windowIndex,
+        message: '请等待监控画面首帧显示后再抓图'
+      })
+      // showPreviewError('请等待监控画面首帧显示后再抓图')
+    }
     return false
   }
   if (interruptedWindowIndexes.value.includes(windowIndex)) {
-    if (notify) showPreviewError('监控画面已中断,暂时无法抓图')
+    if (notify) {
+      console.warn('海康监控操作提示已禁用', {
+        windowIndex,
+        message: '监控画面已中断,暂时无法抓图'
+      })
+      // showPreviewError('监控画面已中断,暂时无法抓图')
+    }
     return false
   }
   if (capturingWindowIndexes.has(windowIndex)) return false
@@ -938,7 +968,10 @@ async function captureAllWindowPictures() {
       previewWindowCameras.value[windowIndex] && previewWindowIndexes.value.includes(windowIndex)
   )
   if (!previewingWindowIndexes.length) {
-    ElMessage.warning('当前没有可抓图的监控画面')
+    console.warn('海康监控操作提示已禁用', {
+      message: '当前没有可抓图的监控画面'
+    })
+    // ElMessage.warning('当前没有可抓图的监控画面')
     return
   }
 
@@ -977,7 +1010,13 @@ async function toggleWindowSound(windowIndex: number, notify = true): Promise<bo
       !previewWindowIndexes.value.includes(windowIndex) ||
       interruptedWindowIndexes.value.includes(windowIndex))
   ) {
-    if (notify) showPreviewError('请等待监控画面正常显示后再开启声音')
+    if (notify) {
+      console.warn('海康监控操作提示已禁用', {
+        windowIndex,
+        message: '请等待监控画面正常显示后再开启声音'
+      })
+      // showPreviewError('请等待监控画面正常显示后再开启声音')
+    }
     return false
   }
 
@@ -1026,7 +1065,10 @@ async function toggleGlobalSound() {
   )
   const windowIndex = targetWindowIndex ?? fallbackWindowIndex
   if (windowIndex === undefined) {
-    ElMessage.warning('当前没有可开启声音的监控画面')
+    console.warn('海康监控操作提示已禁用', {
+      message: '当前没有可开启声音的监控画面'
+    })
+    // ElMessage.warning('当前没有可开启声音的监控画面')
     return
   }
   await toggleWindowSound(windowIndex)
@@ -1072,7 +1114,10 @@ async function toggleWindowTalk(windowIndex: number) {
   const currentPlayer = player
   if (!camera || !currentPlayer) return
   if (!window.isSecureContext) {
-    showPreviewError('对讲功能仅支持 HTTPS 安全环境')
+    console.warn('海康监控操作提示已禁用', {
+      message: '对讲功能仅支持 HTTPS 安全环境'
+    })
+    // showPreviewError('对讲功能仅支持 HTTPS 安全环境')
     return
   }
   if (
@@ -1080,7 +1125,11 @@ async function toggleWindowTalk(windowIndex: number) {
     !previewWindowIndexes.value.includes(windowIndex) ||
     interruptedWindowIndexes.value.includes(windowIndex)
   ) {
-    showPreviewError('请等待监控画面正常显示后再开启对讲')
+    console.warn('海康监控操作提示已禁用', {
+      windowIndex,
+      message: '请等待监控画面正常显示后再开启对讲'
+    })
+    // showPreviewError('请等待监控画面正常显示后再开启对讲')
     return
   }
 
@@ -1150,7 +1199,10 @@ async function toggleWindowZoom(windowIndex: number) {
   const currentPlayer = player
   if (!currentPlayer) return
   if (!window.isSecureContext) {
-    showPreviewError('电子放大仅支持 HTTPS 安全环境')
+    console.warn('海康监控操作提示已禁用', {
+      message: '电子放大仅支持 HTTPS 安全环境'
+    })
+    // showPreviewError('电子放大仅支持 HTTPS 安全环境')
     return
   }
   if (
@@ -1158,7 +1210,11 @@ async function toggleWindowZoom(windowIndex: number) {
     !previewWindowIndexes.value.includes(windowIndex) ||
     interruptedWindowIndexes.value.includes(windowIndex)
   ) {
-    showPreviewError('请等待监控画面正常显示后再开启电子放大')
+    console.warn('海康监控操作提示已禁用', {
+      windowIndex,
+      message: '请等待监控画面正常显示后再开启电子放大'
+    })
+    // showPreviewError('请等待监控画面正常显示后再开启电子放大')
     return
   }
 
@@ -1220,7 +1276,10 @@ async function handleSplitChange(count: SplitCount, columns: HikvisionSplitColum
   splitPopoverVisible.value = false
   if (splitControlLoading.value || currentSplitCount.value === count) return
   if (stopAllLoading.value) {
-    showPreviewError('正在关闭全部监控画面,请稍后切换分屏')
+    console.warn('海康监控操作提示已禁用', {
+      message: '正在关闭全部监控画面,请稍后切换分屏'
+    })
+    // showPreviewError('正在关闭全部监控画面,请稍后切换分屏')
     return
   }
 
@@ -1361,7 +1420,10 @@ function schedulePlayerResize() {
 async function stopAllPreviews() {
   if (stopAllLoading.value) return
   if (splitControlLoading.value) {
-    showPreviewError('正在切换分屏,请稍后关闭全部画面')
+    console.warn('海康监控操作提示已禁用', {
+      message: '正在切换分屏,请稍后关闭全部画面'
+    })
+    // showPreviewError('正在切换分屏,请稍后关闭全部画面')
     return
   }
 
@@ -1441,7 +1503,9 @@ async function handlePlayerDoubleClick() {
     singleFullscreenWindowIndex.value = undefined
     syncSingleWindowPlayerLayout()
     console.error('切换单视口全屏失败', error)
-    showPreviewError(error instanceof Error ? error.message : '切换单视口全屏失败')
+    const message = error instanceof Error ? error.message : '切换单视口全屏失败'
+    console.warn('海康监控操作提示已禁用', { message, error })
+    // showPreviewError(message)
   } finally {
     fullscreenControlLoading.value = false
   }
@@ -1452,7 +1516,10 @@ async function toggleFullscreen() {
 
   const videoStage = videoStageRef.value
   if (!videoStage) {
-    showPreviewError('视频区域尚未加载完成')
+    console.warn('海康监控操作提示已禁用', {
+      message: '视频区域尚未加载完成'
+    })
+    // showPreviewError('视频区域尚未加载完成')
     return
   }
 
@@ -1469,7 +1536,9 @@ async function toggleFullscreen() {
     }
   } catch (error) {
     console.error('切换监控全屏失败', error)
-    showPreviewError(error instanceof Error ? error.message : '切换全屏失败')
+    const message = error instanceof Error ? error.message : '切换全屏失败'
+    console.warn('海康监控操作提示已禁用', { message, error })
+    // showPreviewError(message)
   } finally {
     fullscreenControlLoading.value = false
   }