mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 21:42:27 +08:00
feat(video): add name and providerId fields to video types
Add required name and providerId fields to video interfaces and update all related implementations including mock data and hook usage. This ensures consistent video object structure across the application.
This commit is contained in:
parent
41041fa296
commit
b68a0ffaba
@ -14,6 +14,8 @@ export const mockVideos: Video[] = [
|
||||
prompt: 'A beautiful sunset over the ocean with waves crashing',
|
||||
thumbnail: 'https://picsum.photos/200/200?random=1',
|
||||
fileId: 'file-001',
|
||||
providerId: 'openai',
|
||||
name: 'video-001',
|
||||
metadata: {
|
||||
id: 'video-001',
|
||||
object: 'video',
|
||||
@ -35,6 +37,8 @@ export const mockVideos: Video[] = [
|
||||
status: 'in_progress',
|
||||
prompt: 'A cat playing with a ball of yarn in slow motion',
|
||||
progress: 65,
|
||||
providerId: 'openai',
|
||||
name: 'video-002',
|
||||
metadata: {
|
||||
id: 'video-002',
|
||||
object: 'video',
|
||||
@ -55,6 +59,8 @@ export const mockVideos: Video[] = [
|
||||
type: 'openai',
|
||||
status: 'queued',
|
||||
prompt: 'Time-lapse of flowers blooming in a garden',
|
||||
providerId: 'openai',
|
||||
name: 'video-003',
|
||||
metadata: {
|
||||
id: 'video-003',
|
||||
object: 'video',
|
||||
@ -77,6 +83,8 @@ export const mockVideos: Video[] = [
|
||||
status: 'downloading',
|
||||
progress: 80,
|
||||
thumbnail: 'https://picsum.photos/200/200?random=4',
|
||||
providerId: 'openai',
|
||||
name: 'video-004',
|
||||
metadata: {
|
||||
id: 'video-004',
|
||||
object: 'video',
|
||||
@ -98,6 +106,8 @@ export const mockVideos: Video[] = [
|
||||
status: 'failed',
|
||||
error: { code: '400', message: 'Video generation failed' },
|
||||
prompt: 'Mountain landscape with snow peaks and forest',
|
||||
providerId: 'openai',
|
||||
name: 'video-005',
|
||||
metadata: {
|
||||
id: 'video-005',
|
||||
object: 'video',
|
||||
@ -119,6 +129,8 @@ export const mockVideos: Video[] = [
|
||||
status: 'completed',
|
||||
thumbnail: 'https://picsum.photos/200/200?random=6',
|
||||
prompt: 'City street at night with neon lights reflecting on wet pavement',
|
||||
providerId: 'openai',
|
||||
name: 'video-006',
|
||||
metadata: {
|
||||
id: 'video-006',
|
||||
object: 'video',
|
||||
|
||||
@ -12,6 +12,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
|
||||
case 'queued':
|
||||
addVideo({
|
||||
id: video.id,
|
||||
name: video.id,
|
||||
providerId,
|
||||
status: video.status,
|
||||
type: 'openai',
|
||||
metadata: video,
|
||||
@ -21,6 +23,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
|
||||
case 'in_progress':
|
||||
addVideo({
|
||||
id: video.id,
|
||||
name: video.id,
|
||||
providerId,
|
||||
status: 'in_progress',
|
||||
type: 'openai',
|
||||
progress: video.progress,
|
||||
@ -31,6 +35,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
|
||||
case 'completed':
|
||||
addVideo({
|
||||
id: video.id,
|
||||
name: video.id,
|
||||
providerId,
|
||||
status: 'completed',
|
||||
type: 'openai',
|
||||
metadata: video,
|
||||
@ -41,6 +47,8 @@ export const useAddOpenAIVideo = (providerId: string) => {
|
||||
case 'failed':
|
||||
addVideo({
|
||||
id: video.id,
|
||||
name: video.id,
|
||||
providerId,
|
||||
status: 'failed',
|
||||
type: 'openai',
|
||||
error: video.error,
|
||||
|
||||
@ -7,8 +7,11 @@ export type VideoEndpointType = 'openai'
|
||||
export type VideoStatus = 'queued' | 'in_progress' | 'completed' | 'downloading' | 'downloaded' | 'failed'
|
||||
|
||||
interface VideoBase {
|
||||
id: string
|
||||
type: VideoEndpointType
|
||||
readonly id: string
|
||||
readonly type: VideoEndpointType
|
||||
name: string
|
||||
readonly providerId: string
|
||||
prompt: string
|
||||
/**
|
||||
* Represents the possible states of a video generation or download process.
|
||||
*
|
||||
@ -19,45 +22,44 @@ interface VideoBase {
|
||||
* - `downloaded`: The video has been fully downloaded and is available locally.
|
||||
* - `failed`: The video task encountered an error and could not be completed.
|
||||
*/
|
||||
status: VideoStatus
|
||||
prompt: string
|
||||
readonly status: VideoStatus
|
||||
}
|
||||
|
||||
interface OpenAIVideoBase {
|
||||
type: 'openai'
|
||||
readonly type: 'openai'
|
||||
metadata: OpenAI.Videos.Video
|
||||
}
|
||||
|
||||
export interface VideoQueued extends VideoBase {
|
||||
status: 'queued'
|
||||
readonly status: 'queued'
|
||||
}
|
||||
|
||||
export interface VideoInProgress extends VideoBase {
|
||||
status: 'in_progress'
|
||||
readonly status: 'in_progress'
|
||||
/** integer percent */
|
||||
progress: number
|
||||
}
|
||||
export interface VideoCompleted extends VideoBase {
|
||||
status: 'completed'
|
||||
readonly status: 'completed'
|
||||
/** When generation completed, firstly try to retrieve thumbnail. */
|
||||
thumbnail: string | null
|
||||
}
|
||||
|
||||
export interface VideoDownloading extends VideoBase {
|
||||
status: 'downloading'
|
||||
readonly status: 'downloading'
|
||||
thumbnail: string
|
||||
/** integer percent */
|
||||
progress: number
|
||||
}
|
||||
export interface VideoDownloaded extends VideoBase {
|
||||
status: 'downloaded'
|
||||
readonly status: 'downloaded'
|
||||
thumbnail: string
|
||||
/** Managed by fileManager */
|
||||
fileId: string
|
||||
}
|
||||
|
||||
export interface VideoFailedBase extends VideoBase {
|
||||
status: 'failed'
|
||||
readonly status: 'failed'
|
||||
error: unknown
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user