From 226deff5c08f7c68627dada6ac94219bbbe6aae1 Mon Sep 17 00:00:00 2001 From: the1812 Date: Tue, 15 Mar 2022 13:02:46 +0800 Subject: [PATCH] Export VideoChangeCallback --- registry/lib/components/video/player/show-cover/index.ts | 9 ++------- src/core/observer.ts | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/registry/lib/components/video/player/show-cover/index.ts b/registry/lib/components/video/player/show-cover/index.ts index ec0b462bf..e113346ad 100644 --- a/registry/lib/components/video/player/show-cover/index.ts +++ b/registry/lib/components/video/player/show-cover/index.ts @@ -1,6 +1,5 @@ import { ComponentMetadata } from '@/components/types' -import { videoChange } from '@/core/observer' -import { select } from '@/core/spin-query' +import { videoChange, VideoChangeCallback } from '@/core/observer' import { createHook, isBwpVideo } from '@/core/utils' import { playerUrls } from '@/core/utils/urls' @@ -12,8 +11,7 @@ const entry = async () => { removeCover() return true }) - const showCover = async () => { - const aid = await select(() => unsafeWindow.aid) + const showCover: VideoChangeCallback = async ({ aid }) => { if (!aid) { console.warn('[播放前显示封面] 未找到av号') return @@ -25,9 +23,6 @@ const entry = async () => { const { VideoInfo } = await import('@/components/video/video-info') const info = new VideoInfo(aid) await info.fetchInfo() - // if (!(dq('video') as HTMLVideoElement).paused) { - // return - // } document.body.style.setProperty('--cover-url', `url('${info.coverUrl}')`) } videoChange(showCover) diff --git a/src/core/observer.ts b/src/core/observer.ts index fdb3e4226..5461599cf 100644 --- a/src/core/observer.ts +++ b/src/core/observer.ts @@ -245,7 +245,7 @@ const selectCid = lodash.once(() => select(() => { })) let cidHooked = false -type VideoChangeCallback = (id: { aid: string; cid: string }) => void +export type VideoChangeCallback = (id: { aid: string; cid: string }) => void /** * 监听视频的变化, 等待视频加载并开始监听后 resolve * @param callback 回调函数