yanjinhui
10 天以前 c5de0d98241f8c8349fa38851b77efcfc61e4d26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { VNode, createVNode, render } from 'vue'
import VideoPlayer from './src/VideoPlayer.vue'
import { isClient } from '@/utils/is'
import { VideoPlayerViewer } from '@/components/VideoPlayerViewer'
import { toAnyString } from '@/utils'
 
export { VideoPlayer }
 
let instance: Nullable<VNode> = null
 
export function createVideoViewer(options: { url: string; poster?: string; show?: boolean }) {
  if (!isClient) return
  const { url, poster } = options
 
  const propsData: Partial<{ url: string; poster?: string; show?: boolean; id?: string }> = {}
  const container = document.createElement('div')
  const id = toAnyString()
  container.id = id
  propsData.url = url
  propsData.poster = poster
  propsData.show = true
  propsData.id = id
 
  document.body.appendChild(container)
  instance = createVNode(VideoPlayerViewer, propsData)
  render(instance, container)
}