shuisheng 2 vuotta sitten
vanhempi
sitoutus
fe06653073

+ 5 - 0
src/App.vue

@@ -12,7 +12,10 @@ import { useUserStore } from '@/store/user';
 import { getLastBuildDate, setLastBuildDate } from '@/utils/localStorage/app';
 import { getToken } from '@/utils/localStorage/user';
 
+import { usePiniaCacheStore } from './store/cache';
+
 const { appInfo } = useCheckUpdate();
+const cacheStore = usePiniaCacheStore();
 const userStore = useUserStore();
 
 function handleUpdate() {
@@ -26,6 +29,8 @@ function handleUpdate() {
 onMounted(() => {
   handleUpdate();
   loginMessage();
+  cacheStore.setMuted(true);
+  cacheStore.setVolume(0);
   const token = getToken();
   if (token) {
     userStore.setToken(token);

+ 5 - 1
src/components/VideoControls/index.vue

@@ -12,7 +12,7 @@
       </div>
       <div
         class="refresh"
-        @click="emits('refresh')"
+        @click="debounceRefresh"
       >
         <n-icon size="25">
           <RefreshSharp></RefreshSharp>
@@ -108,6 +108,7 @@ import {
   VolumeHighOutline,
   VolumeMuteOutline,
 } from '@vicons/ionicons5';
+import { debounce } from 'billd-utils';
 import { ref } from 'vue';
 
 import { LiveLineEnum, LiveRoomTypeEnum } from '@/interface';
@@ -123,6 +124,9 @@ withDefaults(
 
 const emits = defineEmits(['refresh']);
 
+const debounceRefresh = debounce(() => {
+  emits('refresh');
+}, 500);
 const cacheStore = usePiniaCacheStore();
 const appStore = useAppStore();
 const showLine = ref(false);

+ 0 - 8
src/hooks/use-pull.ts

@@ -326,14 +326,6 @@ export function usePull() {
 
   function addVideo() {
     sidebarList.value.push({ socketId: mySocketId.value });
-    // nextTick(() => {
-    //   liveUserList.value.forEach((item) => {
-    //     const socketId = item.id;
-    //     if (socketId === mySocketId.value) {
-    //       remoteVideoRef.value[mySocketId.value].srcObject = localStream.value;
-    //     }
-    //   });
-    // });
   }
 
   function keydownDanmu(event: KeyboardEvent) {

+ 14 - 3
src/views/h5/room/index.vue

@@ -50,7 +50,11 @@
       >
         点击播放
       </div>
-      <VideoControls v-else></VideoControls>
+      <VideoControls
+        v-else
+        :resolution="videoHeight"
+        @refresh="handleRefresh"
+      ></VideoControls>
     </div>
     <div class="danmu-list">
       <div class="title">弹幕专区</div>
@@ -133,6 +137,8 @@ const {
   initPull,
   keydownDanmu,
   sendDanmu,
+  closeRtc,
+  closeWs,
   autoplayVal,
   videoLoading,
   damuList,
@@ -140,8 +146,7 @@ const {
   roomLiving,
   anchorInfo,
   remoteVideo,
-  closeRtc,
-  closeWs,
+  videoHeight,
 } = usePull();
 
 watch(
@@ -168,6 +173,12 @@ watch(
   }
 );
 
+function handleRefresh() {
+  if (appStore.liveRoomInfo) {
+    handlePlay(appStore.liveRoomInfo);
+  }
+}
+
 async function getLiveRoomInfo() {
   try {
     videoLoading.value = true;

+ 12 - 2
src/views/pull/index.vue

@@ -52,7 +52,10 @@
             class="media-list"
             :class="{ item: appStore.allTrack.length > 1 }"
           ></div>
-          <VideoControls :resolution="videoHeight"></VideoControls>
+          <VideoControls
+            :resolution="videoHeight"
+            @refresh="handleRefresh"
+          ></VideoControls>
         </div>
       </div>
 
@@ -208,9 +211,10 @@ const {
   initPull,
   closeWs,
   closeRtc,
-  mySocketId,
   keydownDanmu,
   sendDanmu,
+  handlePlay,
+  mySocketId,
   videoHeight,
   videoLoading,
   remoteVideo,
@@ -258,6 +262,12 @@ function handlePay() {
   window.$message.info('敬请期待~');
 }
 
+function handleRefresh() {
+  if (appStore.liveRoomInfo) {
+    handlePlay(appStore.liveRoomInfo);
+  }
+}
+
 async function getGoodsList() {
   try {
     giftLoading.value = true;