mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 06:19:05 +08:00
fix(video): handle undefined video case and add new video button
Add fallback for undefined video case in VideoPanel to clear prompt params Add PlusIcon button in VideoList to allow creating new videos by setting activeVideoId to undefined
This commit is contained in:
parent
942c239d14
commit
7bde37680e
@ -2,10 +2,14 @@ import { cn, Progress, Spinner } from '@heroui/react'
|
|||||||
import { mockVideos } from '@renderer/config/models/video'
|
import { mockVideos } from '@renderer/config/models/video'
|
||||||
import { useVideos } from '@renderer/hooks/video/useVideos'
|
import { useVideos } from '@renderer/hooks/video/useVideos'
|
||||||
import { Video } from '@renderer/types'
|
import { Video } from '@renderer/types'
|
||||||
import { CheckCircleIcon, CircleXIcon, ClockIcon, DownloadIcon } from 'lucide-react'
|
import { CheckCircleIcon, CircleXIcon, ClockIcon, DownloadIcon, PlusIcon } from 'lucide-react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export type VideoListProps = { providerId: string; activeVideoId?: string; setActiveVideoId: (id: string) => void }
|
export type VideoListProps = {
|
||||||
|
providerId: string
|
||||||
|
activeVideoId?: string
|
||||||
|
setActiveVideoId: (id: string | undefined) => void
|
||||||
|
}
|
||||||
|
|
||||||
export const VideoList = ({ providerId, activeVideoId, setActiveVideoId }: VideoListProps) => {
|
export const VideoList = ({ providerId, activeVideoId, setActiveVideoId }: VideoListProps) => {
|
||||||
const { videos } = useVideos(providerId)
|
const { videos } = useVideos(providerId)
|
||||||
@ -15,6 +19,11 @@ export const VideoList = ({ providerId, activeVideoId, setActiveVideoId }: Video
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-40 space-y-3 overflow-auto p-2">
|
<div className="w-40 space-y-3 overflow-auto p-2">
|
||||||
|
<div
|
||||||
|
className="group relative flex aspect-square cursor-pointer items-center justify-center overflow-hidden rounded-xl border-2 transition-all hover:scale-105 hover:shadow-lg"
|
||||||
|
onClick={() => setActiveVideoId(undefined)}>
|
||||||
|
<PlusIcon size={24} />
|
||||||
|
</div>
|
||||||
{displayVideos.map((video) => (
|
{displayVideos.map((video) => (
|
||||||
<VideoListItem
|
<VideoListItem
|
||||||
key={video.id}
|
key={video.id}
|
||||||
|
|||||||
@ -39,6 +39,8 @@ export const VideoPanel = ({ provider, video, params, updateParams }: VideoPanel
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (video) {
|
if (video) {
|
||||||
updateParams({ params: { prompt: video.prompt } })
|
updateParams({ params: { prompt: video.prompt } })
|
||||||
|
} else {
|
||||||
|
updateParams({ params: { prompt: undefined } })
|
||||||
}
|
}
|
||||||
}, [updateParams, video])
|
}, [updateParams, video])
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user