@@ -12,8 +12,8 @@ import {
1212} from "@ant-design/pro-components" ;
1313import { COL_SCROLL_STYLE , PRO_FORM_PROPS , SEGMENTED_PROPS } from "@/constant" ;
1414import { useAppConfig } from "@/app/store" ;
15- import { Alert , Col , Divider , message , Segmented } from "antd" ;
16- import { KelingAI , KelingApiTypes } from "@/app/providers/keling-ai " ;
15+ import { Alert , Col , Divider , message , Segmented , SegmentedProps } from "antd" ;
16+ import { Kling , KlingApiTypes } from "@/app/providers/kling " ;
1717import { RenderSubmitter } from "../render" ;
1818
1919const MODE_OPTIONS = [
@@ -26,13 +26,20 @@ const DURATION_OPTIONS = [
2626 { label : "10s" , value : "10" } ,
2727] ;
2828
29+ const TASK_TYPE_OPTIONS = [
30+ { label : "文生视频" , value : "text2video" } ,
31+ { label : "图生视频" , value : "image2video" } ,
32+ // { label: "图片生成", value: "generations", disabled: true },
33+ { label : "任务查询" , value : "queryTask" } ,
34+ ] ;
35+
2936const MODEL_OPTIONS = [ { label : "kling-v1" , value : "kling-v1" } ] ;
3037
31- const KelingPage = ( ) => {
38+ const KlingPage = ( ) => {
3239 const appConfig = useAppConfig ( ) ;
33- const api = new KelingAI ( "sk-sFplfAcnWY3sFCCs02Ac93Ce9cEf4984A7EdF93e70969c18" ) ;
40+ const api = new Kling ( "sk-sFplfAcnWY3sFCCs02Ac93Ce9cEf4984A7EdF93e70969c18" ) ;
3441
35- const [ taskType , setTaskType ] = useState < "text2video" | "image2video" | "queryTask" > ( "text2video" ) ;
42+ const [ taskType , setTaskType ] = useState ( "text2video" ) ;
3643 const [ klingText2VideoForm ] = ProForm . useForm ( ) ;
3744 const [ klingImage2VideoForm ] = ProForm . useForm ( ) ;
3845 const [ klingQueryTaskForm ] = ProForm . useForm ( ) ;
@@ -42,7 +49,7 @@ const KelingPage = () => {
4249
4350 const Text2VideoForm = ( props : {
4451 form : ProFormInstance ;
45- api : KelingAI ;
52+ api : Kling ;
4653 updateTask : ( data : any [ ] ) => void ;
4754 updateError : ( error : any ) => void ;
4855 } ) => {
@@ -53,7 +60,7 @@ const KelingPage = () => {
5360 const [ abortController , setAbortController ] = useState < AbortController | null > ( null ) ;
5461 const [ submitting , setSubmitting ] = useState ( false ) ;
5562 return (
56- < ProForm < KelingApiTypes [ "generateText2VideoTask" ] [ "req" ] >
63+ < ProForm < KlingApiTypes [ "generateText2VideoTask" ] [ "req" ] >
5764 { ...PRO_FORM_PROPS }
5865 form = { props . form }
5966 initialValues = { {
@@ -100,25 +107,14 @@ const KelingPage = () => {
100107 < ProFormTextArea
101108 name = { "prompt" }
102109 label = { "Prompt" }
103- rules = { [
104- { required : true } ,
105- {
106- type : "string" ,
107- max : 2500 ,
108- } ,
109- ] }
110+ rules = { [ { required : true } , { type : "string" , max : 2500 } ] }
110111 fieldProps = { { autoSize : { minRows : 3 } } }
111112 tooltip = { "正向文本提示" }
112113 />
113114 < ProFormTextArea
114115 name = { "negative_prompt" }
115116 label = { "Negative Prompt" }
116- rules = { [
117- {
118- type : "string" ,
119- max : 2500 ,
120- } ,
121- ] }
117+ rules = { [ { type : "string" , max : 2500 } ] }
122118 fieldProps = { { autoSize : { minRows : 2 } } }
123119 tooltip = { "负向文本提示,用于排除不需要的元素或风格" }
124120 />
@@ -128,13 +124,7 @@ const KelingPage = () => {
128124 min = { 0 }
129125 max = { 1 }
130126 step = { 0.01 }
131- marks = { {
132- 0 : "0" ,
133- 0.25 : "0.25" ,
134- 0.5 : "0.5" ,
135- 0.75 : "0.75" ,
136- 1 : "1" ,
137- } }
127+ marks = { { 0 : "0" , 0.25 : "0.25" , 0.5 : "0.5" , 0.75 : "0.75" , 1 : "1" } }
138128 tooltip = { "生成视频的自由度,值越大,模型自由度越小,与用户输入的提示词相关性越强" }
139129 />
140130
@@ -152,26 +142,11 @@ const KelingPage = () => {
152142 name = { [ "camera_control" , "type" ] }
153143 label = { "Type" }
154144 options = { [
155- {
156- label : "Simple" ,
157- value : "simple" ,
158- } ,
159- {
160- label : "Down Back" ,
161- value : "down_back" ,
162- } ,
163- {
164- label : "Forward Up" ,
165- value : "forward_up" ,
166- } ,
167- {
168- label : "Right Turn Forward" ,
169- value : "right_turn_forward" ,
170- } ,
171- {
172- label : "Left Turn Forward" ,
173- value : "left_turn_forward" ,
174- } ,
145+ { label : "Simple" , value : "simple" } ,
146+ { label : "Down Back" , value : "down_back" } ,
147+ { label : "Forward Up" , value : "forward_up" } ,
148+ { label : "Right Turn Forward" , value : "right_turn_forward" } ,
149+ { label : "Left Turn Forward" , value : "left_turn_forward" } ,
175150 ] }
176151 tooltip = {
177152 < >
@@ -312,7 +287,7 @@ const KelingPage = () => {
312287
313288 const Image2VideoForm = ( props : {
314289 form : ProFormInstance ;
315- api : KelingAI ;
290+ api : Kling ;
316291 updateTask : ( data : any [ ] ) => void ;
317292 updateError : ( error : any ) => void ;
318293 } ) => {
@@ -341,7 +316,7 @@ const KelingPage = () => {
341316 } ;
342317
343318 return (
344- < ProForm < KelingApiTypes [ "generateImage2VideoTask" ] [ "req" ] >
319+ < ProForm < KlingApiTypes [ "generateImage2VideoTask" ] [ "req" ] >
345320 { ...PRO_FORM_PROPS }
346321 form = { props . form }
347322 initialValues = { {
@@ -442,14 +417,14 @@ const KelingPage = () => {
442417
443418 const QueryTaskForm = ( props : {
444419 form : ProFormInstance ;
445- api : KelingAI ;
420+ api : Kling ;
446421 updateTask : ( data : any [ ] ) => void ;
447422 updateError : ( error : any ) => void ;
448423 } ) => {
449424 const [ abortController , setAbortController ] = useState < AbortController | null > ( null ) ;
450425 const [ submitting , setSubmitting ] = useState ( false ) ;
451426 return (
452- < ProForm < KelingApiTypes [ "queryTask" ] [ "endpoint_params" ] >
427+ < ProForm < KlingApiTypes [ "queryTask" ] [ "endpoint_params" ] >
453428 { ...PRO_FORM_PROPS }
454429 form = { props . form }
455430 initialValues = { {
@@ -485,21 +460,19 @@ const KelingPage = () => {
485460 >
486461 < ProFormRadio . Group
487462 name = { "action" }
488- // label={"Action"}
489463 label = { "目标类型" }
490- options = { [ "images" , "videos" ] }
464+ options = { [
465+ { label : "视频" , value : "videos" } ,
466+ { label : "图片" , value : "images" , disabled : true } ,
467+ ] }
491468 />
492469 < ProFormRadio . Group
493470 name = { "action2" }
494- // label={"Action2"}
495471 label = { "任务类型" }
496472 options = { [
497- // { label: "生成", value: "generations" },
498- // { label: "视频", value: "text2video" },
499- // { label: "图片", value: "image2video" },
500- "generations" ,
501- "text2video" ,
502- "image2video" ,
473+ { label : "文生视频" , value : "text2video" } ,
474+ { label : "图生视频" , value : "image2video" } ,
475+ { label : "图片生成" , value : "generations" , disabled : true } ,
503476 ] }
504477 />
505478 < ProFormText name = { "task_id" } label = { "任务ID" } rules = { [ { required : true } , { type : "string" } ] } />
@@ -509,26 +482,8 @@ const KelingPage = () => {
509482
510483 return (
511484 < >
512- < Col flex = "340px" style = { COL_SCROLL_STYLE } >
513- < Segmented
514- { ...SEGMENTED_PROPS }
515- options = { [
516- {
517- label : "文生视频" ,
518- value : "text2video" ,
519- } ,
520- {
521- label : "图生视频" ,
522- value : "image2video" ,
523- } ,
524- {
525- label : "任务查询" ,
526- value : "queryTask" ,
527- } ,
528- ] }
529- value = { taskType }
530- onChange = { setTaskType }
531- />
485+ < Col flex = "360px" style = { COL_SCROLL_STYLE } >
486+ < Segmented { ...SEGMENTED_PROPS } options = { TASK_TYPE_OPTIONS } value = { taskType } onChange = { setTaskType } />
532487 { taskType === "text2video" && (
533488 < Text2VideoForm form = { klingText2VideoForm } api = { api } updateTask = { setTaskData } updateError = { setErrorData } />
534489 ) }
@@ -548,4 +503,4 @@ const KelingPage = () => {
548503 ) ;
549504} ;
550505
551- export default KelingPage ;
506+ export default KlingPage ;
0 commit comments