Skip to content

Commit 36dcc78

Browse files
committed
kling
1 parent 74bfe58 commit 36dcc78

2 files changed

Lines changed: 82 additions & 39 deletions

File tree

app/pages/Kling.tsx

Lines changed: 81 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ import {
1313
} from "@ant-design/pro-components";
1414
import { COL_SCROLL_STYLE, PRO_FORM_PROPS, SEGMENTED_PROPS } from "@/constant";
1515
import { useAppConfig } from "@/app/store";
16-
import { Alert, Col, Divider, App, Segmented, Descriptions, Button, Space } from "antd";
16+
import { Alert, Col, Divider, App, Segmented, Descriptions, Button, Space, Popconfirm } from "antd";
1717
import { Kling, KlingApiTypes, KlingTask } from "@/app/providers/kling";
1818
import { renderCode, RenderSubmitter } from "../render";
1919
import { beforeUpload, safeJsonStringify } from "../utils";
20+
import { ascetic } from "react-syntax-highlighter/dist/esm/styles/hljs";
2021

2122
const MODE_OPTIONS = [
2223
{ label: "Std-标准模式(高性能)", value: "std" },
@@ -688,7 +689,42 @@ const KlingPage = () => {
688689
copyable: true,
689690
},
690691
{
691-
title: "请求信息",
692+
title: "任务状态",
693+
dataIndex: ["latest_task_info", "task_status"],
694+
valueEnum: {
695+
processing: { text: "Processing", status: "Processing" },
696+
submitted: { text: "Submitted", status: "Processing" },
697+
succeed: { text: "Succeed", status: "Success" },
698+
failed: { text: "Failed", status: "Error" },
699+
},
700+
},
701+
{
702+
title: "创建时间",
703+
dataIndex: ["latest_task_info", "created_at"],
704+
valueType: "dateTime",
705+
},
706+
{
707+
title: "更新时间",
708+
dataIndex: ["latest_task_info", "updated_at"],
709+
valueType: "dateTime",
710+
},
711+
{
712+
title: "视频预览",
713+
render: (_, record) => {
714+
if (record?.latest_task_info?.task_result?.videos?.[0]?.url) {
715+
return (
716+
<video
717+
src={record.latest_task_info.task_result.videos[0].url}
718+
controls
719+
style={{ maxWidth: 300, maxHeight: 200 }}
720+
/>
721+
);
722+
}
723+
return null;
724+
},
725+
},
726+
{
727+
title: "操作",
692728
render: (_, record) => {
693729
return (
694730
<Space>
@@ -715,7 +751,7 @@ const KlingPage = () => {
715751
});
716752
}}
717753
>
718-
原始
754+
原始请求
719755
</Button>
720756
<Button
721757
size={"small"}
@@ -740,47 +776,53 @@ const KlingPage = () => {
740776
});
741777
}}
742778
>
743-
最新
779+
最新请求
744780
</Button>
781+
<Button
782+
key={"query"}
783+
size={"small"}
784+
onClick={async () => {
785+
const hide = message.loading({
786+
content: "正在更新",
787+
key: `message-${record.id}`,
788+
duration: 0,
789+
});
790+
const taskId = record?.latest_task_info?.task_id;
791+
if (!taskId) {
792+
hide();
793+
message.error({ content: "任务ID不存在", key: `message-${record.id}` });
794+
return;
795+
}
796+
const res = await api.callApi({
797+
callKey: "queryTask",
798+
endpoint_params: {
799+
action: "videos",
800+
action2: "text2video",
801+
task_id: record?.latest_task_info?.task_id,
802+
},
803+
signal: undefined,
804+
});
805+
updateTaskData(api.updateTask(res, record));
806+
hide();
807+
message.success({ content: "更新成功!", key: `message-${record.id}` });
808+
}}
809+
>
810+
更新任务
811+
</Button>
812+
<Popconfirm
813+
title="确定删除任务?"
814+
onConfirm={() => {
815+
setTaskData((prev) => prev.filter((_, i) => i !== index));
816+
}}
817+
>
818+
<Button size={"small"} danger>
819+
删除任务
820+
</Button>
821+
</Popconfirm>
745822
</Space>
746823
);
747824
},
748825
},
749-
{
750-
title: "任务状态",
751-
dataIndex: ["latest_task_info", "task_status"],
752-
valueEnum: {
753-
processing: { text: "Processing", status: "Processing" },
754-
submitted: { text: "Submitted", status: "Processing" },
755-
succeed: { text: "Succeed", status: "Success" },
756-
failed: { text: "Failed", status: "Error" },
757-
},
758-
},
759-
{
760-
title: "创建时间",
761-
dataIndex: ["latest_task_info", "created_at"],
762-
valueType: "dateTime",
763-
},
764-
{
765-
title: "更新时间",
766-
dataIndex: ["latest_task_info", "updated_at"],
767-
valueType: "dateTime",
768-
},
769-
{
770-
title: "预览",
771-
render: (_, record) => {
772-
if (record?.latest_task_info?.task_result?.videos?.[0]?.url) {
773-
return (
774-
<video
775-
src={record.latest_task_info.task_result.videos[0].url}
776-
controls
777-
style={{ maxWidth: 320, maxHeight: 240 }}
778-
/>
779-
);
780-
}
781-
return null;
782-
},
783-
},
784826
]}
785827
/>
786828
))}

app/providers/kling/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ export class Kling implements AIProvider {
482482
* 更新任务
483483
* @param task 任务
484484
* @param originalTask 原始任务,如果传入,则更新任务信息,否则创建新任务
485+
* @returns 更新后的任务
485486
*/
486487
updateTask(
487488
res: MakeApiRequestResult<

0 commit comments

Comments
 (0)