Export VideoChangeCallback

This commit is contained in:
the1812 2022-03-15 13:02:46 +08:00
parent 49c9cd74e4
commit 226deff5c0
2 changed files with 3 additions and 8 deletions

View File

@ -1,6 +1,5 @@
import { ComponentMetadata } from '@/components/types' import { ComponentMetadata } from '@/components/types'
import { videoChange } from '@/core/observer' import { videoChange, VideoChangeCallback } from '@/core/observer'
import { select } from '@/core/spin-query'
import { createHook, isBwpVideo } from '@/core/utils' import { createHook, isBwpVideo } from '@/core/utils'
import { playerUrls } from '@/core/utils/urls' import { playerUrls } from '@/core/utils/urls'
@ -12,8 +11,7 @@ const entry = async () => {
removeCover() removeCover()
return true return true
}) })
const showCover = async () => { const showCover: VideoChangeCallback = async ({ aid }) => {
const aid = await select(() => unsafeWindow.aid)
if (!aid) { if (!aid) {
console.warn('[播放前显示封面] 未找到av号') console.warn('[播放前显示封面] 未找到av号')
return return
@ -25,9 +23,6 @@ const entry = async () => {
const { VideoInfo } = await import('@/components/video/video-info') const { VideoInfo } = await import('@/components/video/video-info')
const info = new VideoInfo(aid) const info = new VideoInfo(aid)
await info.fetchInfo() await info.fetchInfo()
// if (!(dq('video') as HTMLVideoElement).paused) {
// return
// }
document.body.style.setProperty('--cover-url', `url('${info.coverUrl}')`) document.body.style.setProperty('--cover-url', `url('${info.coverUrl}')`)
} }
videoChange(showCover) videoChange(showCover)

View File

@ -245,7 +245,7 @@ const selectCid = lodash.once(() => select(() => {
})) }))
let cidHooked = false let cidHooked = false
type VideoChangeCallback = (id: { aid: string; cid: string }) => void export type VideoChangeCallback = (id: { aid: string; cid: string }) => void
/** /**
* , resolve * , resolve
* @param callback * @param callback