mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-05 12:29:44 +08:00
refactor(video): rename Video component to VideoPlayer and pass video prop
Update VideoPanel to use VideoPlayer component instead of Video and accept video as a prop
This commit is contained in:
parent
4cf4c1e946
commit
85c8d5fca2
@ -3,24 +3,24 @@ import { loggerService } from '@logger'
|
|||||||
import { useAddOpenAIVideo } from '@renderer/hooks/video/useOpenAIVideos'
|
import { useAddOpenAIVideo } from '@renderer/hooks/video/useOpenAIVideos'
|
||||||
import { createVideo } from '@renderer/services/ApiService'
|
import { createVideo } from '@renderer/services/ApiService'
|
||||||
import { Provider } from '@renderer/types'
|
import { Provider } from '@renderer/types'
|
||||||
|
import { Video } from '@renderer/types/video'
|
||||||
import { ArrowUp } from 'lucide-react'
|
import { ArrowUp } from 'lucide-react'
|
||||||
import { useCallback, useState } from 'react'
|
import { useCallback, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
import { Video } from './Video'
|
import { VideoPlayer } from './VideoPlayer'
|
||||||
|
|
||||||
export type VideoPanelProps = {
|
export type VideoPanelProps = {
|
||||||
provider: Provider
|
provider: Provider
|
||||||
|
video?: Video
|
||||||
}
|
}
|
||||||
|
|
||||||
const logger = loggerService.withContext('VideoPanel')
|
const logger = loggerService.withContext('VideoPanel')
|
||||||
|
|
||||||
export const VideoPanel = ({ provider }: VideoPanelProps) => {
|
export const VideoPanel = ({ provider, video }: VideoPanelProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [prompt, setPrompt] = useState('')
|
const [prompt, setPrompt] = useState('')
|
||||||
const addOpenAIVideo = useAddOpenAIVideo(provider.id)
|
const addOpenAIVideo = useAddOpenAIVideo(provider.id)
|
||||||
// TODO: get video job from api
|
|
||||||
const video = { success: false, data: undefined }
|
|
||||||
|
|
||||||
const sendRequest = useCallback(async () => {
|
const sendRequest = useCallback(async () => {
|
||||||
const result = await createVideo({
|
const result = await createVideo({
|
||||||
@ -44,7 +44,7 @@ export const VideoPanel = ({ provider }: VideoPanelProps) => {
|
|||||||
<div className="flex flex-1 flex-col p-2">
|
<div className="flex flex-1 flex-col p-2">
|
||||||
<div className="m-8 flex-1">
|
<div className="m-8 flex-1">
|
||||||
<Skeleton className="h-full w-full rounded-2xl" classNames={{ content: 'h-full w-full' }} isLoaded={true}>
|
<Skeleton className="h-full w-full rounded-2xl" classNames={{ content: 'h-full w-full' }} isLoaded={true}>
|
||||||
<Video video={video.data} />
|
<VideoPlayer video={video} />
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
|
import { Video } from '@renderer/types/video'
|
||||||
import { CircleXIcon } from 'lucide-react'
|
import { CircleXIcon } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export interface VideoProps {
|
export interface VideoProps {
|
||||||
video: null | undefined
|
video?: Video | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Video = ({ video }: VideoProps) => {
|
export const VideoPlayer = ({ video }: VideoProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full items-center justify-center rounded-2xl bg-foreground-200">
|
<div className="flex h-full w-full items-center justify-center rounded-2xl bg-foreground-200">
|
||||||
Loading…
Reference in New Issue
Block a user