yanghao 6 дней назад
Родитель
Сommit
d9d5bdbd98
1 измененных файлов с 12 добавлено и 61 удалено
  1. 12 61
      src/views/pms/video_center/sip/splitview.vue

+ 12 - 61
src/views/pms/video_center/sip/splitview.vue

@@ -91,6 +91,7 @@
               :key="`empty-${i}`"
               :class="availableChannels.length > 0 ? 'play-box' : ''"
               :style="availableChannels.length > 0 ? liveStyle : ''"
+              @click="handleEmpty(i)"
             >
               <div
                 v-if="availableChannels.length > 0"
@@ -175,62 +176,6 @@ const liveStyle = computed(() => {
   return style
 })
 
-// const loadAdditionalChannelsForSplit = async (newSplit, oldSplit) => {
-//   loading.value = true
-//   try {
-//     // 获取当前已经加载的通道数量
-//     const currentlyLoaded = Math.min(oldSplit, availableChannels.value.length)
-//     const toBeLoaded = Math.min(newSplit, availableChannels.value.length)
-
-//     // 准备所有需要加载的通道
-//     const channelsToLoad = []
-//     for (let i = currentlyLoaded; i < toBeLoaded; i++) {
-//       const channelData = availableChannels.value[i]
-
-//       // 检查是否已有缓存的播放地址
-//       if (channelData._playUrl) {
-//         // 使用缓存的地址(立即设置,不需要等待)
-//         setPlayUrl(channelData._playUrl, i)
-//       } else {
-//         // 需要获取的通道
-//         channelsToLoad.push({
-//           index: i,
-//           channelData: channelData,
-//           playData: {
-//             deviceSipId: channelData.deviceId,
-//             channelSipId: channelData.basicData?.channelSipId || channelData.id,
-//             name: channelData.name || `通道${i + 1}`,
-//             ...channelData.basicData
-//           }
-//         })
-//       }
-//     }
-
-//     // 并发执行所有请求(使用 Promise.all)
-//     const requests = channelsToLoad.map(({ playData, index, channelData }) =>
-//       sendDevicePush(playData, index)
-//         .then(() => {
-//           // 缓存获取到的地址
-//           if (videoUrl.value[index]) {
-//             channelData._playUrl = videoUrl.value[index]
-//           }
-//         })
-//         .catch((error) => {
-//           console.error(`加载通道${index + 1}失败:`, error)
-//           // 标记该通道加载失败,可以在UI上显示错误状态
-//           channelData._loadError = true
-//         })
-//     )
-
-//     // 等待所有请求完成(或部分完成)
-//     await Promise.allSettled(requests)
-//   } catch (error) {
-//     console.error('加载新增通道出错:', error)
-//   } finally {
-//     loading.value = false
-//   }
-// }
-
 const loadAdditionalChannelsForSplit = async (newSplit, oldSplit) => {
   loading.value = true
   try {
@@ -374,6 +319,7 @@ const destroy = (idx) => {
 const currentDevice = ref(null) // 存储当前选中的设备信息
 // 点击事件
 let playerInfo = ref([])
+
 const clickEvent = async (data) => {
   // 情况1:点击的是设备节点 (type === 0)
   if (data.type === 0) {
@@ -400,10 +346,6 @@ const clickEvent = async (data) => {
         playerInfo.value.push(channel)
       })
 
-      console.log('playerInfo>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', playerInfo.value)
-      console.log('availableChannels>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', availableChannels.value)
-      console.log('videourl**************************', videoUrl.value)
-
       if (!cameraChannels || cameraChannels.length === 0) {
         console.warn('该设备下没有可用的摄像头通道')
         // 清空所有播放器
@@ -422,7 +364,8 @@ const clickEvent = async (data) => {
   }
   // 情况2:点击的是具体的通道节点,保持原有逻辑不变
   else if (data.userData?.channelSipId) {
-    sendDevicePush(data.userData)
+    playerIdx.value = 0
+    await sendDevicePush(data.userData)
   }
 }
 
@@ -494,6 +437,7 @@ const sendDevicePush = async (itemData, targetIndex = null) => {
 let playInfoRes = ref('')
 // 设置播放URL
 const setPlayUrl = (url, idx) => {
+  console.log('设置播放URL:', url, '索引:', idx)
   // 确保数组长度足够
   while (videoUrl.value.length <= idx) {
     videoUrl.value.push('')
@@ -516,6 +460,13 @@ const checkPlayByParam = () => {
   }
 }
 
+const handleEmpty = (i) => {
+  // playerIdx.value = availableChannels.value.length + i - 1
+  // if (availableChannels.value.length > 0) {
+  //   playerIdx.value = 0 // 设置为第一个播放器
+  // }
+}
+
 // 截图处理
 const shot = (e) => {
   var base64ToBlob = function (code) {