shuisheng hace 1 año
padre
commit
26bae5cff9
Se han modificado 3 ficheros con 15 adiciones y 5 borrados
  1. 9 0
      src/utils/google-ad.ts
  2. 3 2
      src/views/home/index.vue
  3. 3 3
      src/views/pull/index.vue

+ 9 - 0
src/utils/google-ad.ts

@@ -0,0 +1,9 @@
+export const initAdsbygoogle = () => {
+  // @ts-ignore
+  if (!window.adsbygoogle) {
+    // @ts-ignore
+    window.adsbygoogle = [];
+  }
+  // @ts-ignore
+  window.adsbygoogle.push({});
+};

+ 3 - 2
src/views/home/index.vue

@@ -246,6 +246,7 @@ import {
   LiveRoomTypeEnum,
   LiveRoomUseCDNEnum,
 } from '@/types/ILiveRoom';
+import { initAdsbygoogle } from '@/utils/google-ad';
 
 const route = useRoute();
 const router = useRouter();
@@ -286,9 +287,9 @@ const rootMargin = {
   left: 0,
   right: 0,
 };
+
 onMounted(() => {
-  //  @ts-ignore
-  (adsbygoogle = window.adsbygoogle || []).push({});
+  initAdsbygoogle();
   const intersectionObserver = new IntersectionObserver(
     (entries) => {
       entries.forEach((item) => {

+ 3 - 3
src/views/pull/index.vue

@@ -481,6 +481,7 @@ import { useUserStore } from '@/store/user';
 import { LiveRoomTypeEnum } from '@/types/ILiveRoom';
 import { WsDisableSpeakingType, WsMsgTypeEnum } from '@/types/websocket';
 import { formatMoney, formatTimeHour, handleUserMedia } from '@/utils';
+import { initAdsbygoogle } from '@/utils/google-ad';
 import { NODE_ENV } from 'script/constant';
 
 import RechargeCpt from './recharge/index.vue';
@@ -551,8 +552,7 @@ const rtcLoss = computed(() => {
 });
 
 onMounted(() => {
-  // @ts-ignore
-  (adsbygoogle = window.adsbygoogle || []).push({});
+  initAdsbygoogle();
   appStore.videoControls.fps = true;
   appStore.videoControls.fullMode = true;
   appStore.videoControls.kbs = true;
@@ -619,7 +619,7 @@ async function handleBilibil() {
     console.log(flv?.data?.data?.durl?.[0].url, 'flv');
     console.log(hls?.data?.data?.durl?.[0].url, 'hls');
     roomLiving.value = true;
-    appStore.liveLine = LiveLineEnum.flv;
+    appStore.liveLine = LiveLineEnum.hls;
     anchorInfo.value = {
       avatar: roomInfo?.data?.data?.user_cover,
       username: roomInfo?.data?.data?.title,