- {editable ?<>
+ {editable ? <>
-
+
批量删除
- >:
-
+ > :
+
}
@@ -86,7 +170,7 @@ export default function LiveIndex() {
video={v}
index={index + 1}
id={v.id}
- active={index == 0}
+ active={state.activeId == v.id}
key={index}
onCheckedChange={(checked) => {
setCheckedIdArray(idArray => {
diff --git a/src/pages/live/style.module.scss b/src/pages/live/style.module.scss
new file mode 100644
index 0000000..5ba3fb7
--- /dev/null
+++ b/src/pages/live/style.module.scss
@@ -0,0 +1,3 @@
+.videoListContainer{
+
+}
\ No newline at end of file
diff --git a/src/pages/news/components/button-push2video.tsx b/src/pages/news/components/button-push2video.tsx
index c391851..42904e8 100644
--- a/src/pages/news/components/button-push2video.tsx
+++ b/src/pages/news/components/button-push2video.tsx
@@ -1,26 +1,26 @@
import {Button, Modal} from "antd";
import React, {useState} from "react";
-import {showToast} from "@/components/message.ts";
-import {push2article} from "@/service/api/news.ts";
+import {showErrorToast, showToast} from "@/components/message.ts";
+import {push2video} from "@/service/api/article.ts";
-export default function ButtonPush2Video(props: { ids: Id[]}){
- const [loading,setLoading] = useState(false)
- const handlePush = ()=>{
+export default function ButtonPush2Video(props: { ids: Id[] }) {
+ const [loading, setLoading] = useState(false)
+ const handlePush = () => {
setLoading(true)
- push2article(props.ids).then(()=>{
+ push2video(props.ids).then(() => {
showToast('一键推流成功,已成功推入数字人视频生成,请前往数字人视频生成页面查看!', 'success')
- }).finally(()=>{
+ }).catch(showErrorToast).finally(() => {
setLoading(false)
})
}
- const onPushClick = ()=>{
+ const onPushClick = () => {
if (props.ids.length === 0) {
showToast('请选择要开播的新闻', 'warning')
return
}
Modal.confirm({
- title:'操作提示',
+ title: '操作提示',
content: '是否确定一键开播选中新闻?',
onOk: handlePush
})
diff --git a/src/pages/news/index.tsx b/src/pages/news/index.tsx
index 8a8720c..19a2d2c 100644
--- a/src/pages/news/index.tsx
+++ b/src/pages/news/index.tsx
@@ -95,7 +95,7 @@ export default function NewsIndex() {
{
handleViewNewsDetail(item.id)
- }}>{item.id}{item.title}
+ }}>{item.title}
{item.internal_article_id > 0 &&
已加入编辑界面
}
diff --git a/src/pages/video/components/button-push2room.tsx b/src/pages/video/components/button-push2room.tsx
new file mode 100644
index 0000000..ff069fe
--- /dev/null
+++ b/src/pages/video/components/button-push2room.tsx
@@ -0,0 +1,31 @@
+import {Button, Modal} from "antd";
+import React, {useState} from "react";
+import {showErrorToast, showToast} from "@/components/message.ts";
+import {push2room} from "@/service/api/video.ts";
+
+
+export default function ButtonPush2Room(props: { ids: Id[]}){
+ const [loading,setLoading] = useState(false)
+ const handlePush = ()=>{
+ setLoading(true)
+ push2room(props.ids).then(()=>{
+ showToast('一键推流成功,已推流至数字人直播间,请前往数字人直播间页面查看!', 'success')
+ }).catch(showErrorToast).finally(()=>{
+ setLoading(false)
+ })
+ }
+ const onPushClick = ()=>{
+ if (props.ids.length === 0) {
+ showToast('请选择要推流的新闻', 'warning')
+ return
+ }
+ Modal.confirm({
+ title:'操作提示',
+ content: '是否确定一键推流选中新闻视频??',
+ onOk: handlePush
+ })
+ }
+ return (
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/create/index.tsx b/src/pages/video/index.tsx
similarity index 81%
rename from src/pages/create/index.tsx
rename to src/pages/video/index.tsx
index bb2f43b..985e2f7 100644
--- a/src/pages/create/index.tsx
+++ b/src/pages/video/index.tsx
@@ -1,7 +1,5 @@
-import {Button, message, Modal} from "antd";
-import React, {useEffect, useRef, useState} from "react";
-
-import {ArticleGroupList, MockVideoDataList} from "@/_local/mock-data";
+import {message, Modal} from "antd";
+import React, {useEffect, useMemo, useRef, useState} from "react";
import {DndContext} from "@dnd-kit/core";
import {arrayMove, SortableContext} from "@dnd-kit/sortable";
import {VideoListItem} from "@/components/video/video-list-item.tsx";
@@ -10,19 +8,18 @@ import {useSetState} from "ahooks";
import {CheckCircleFilled} from "@ant-design/icons";
import {clsx} from "clsx";
import {getList} from "@/service/api/video.ts";
+import {formatDuration} from "@/util/strings.ts";
+import ButtonPush2Room from "@/pages/video/components/button-push2room.tsx";
-export default function CreateIndex() {
- const [editNews, setEditNews] = useSetState<{
- title?: string;
- groups?: ArticleContentGroup[];
- }>({})
+export default function VideoIndex() {
+ const [editId, setEditId] = useState(-1)
const [videoData, setVideoData] = useState
([])
useEffect(() => {
- getList({}).then((ret) => {
- setVideoData(ret.list)
+ getList().then((ret) => {
+ setVideoData(ret.list || [])
})
}, [])
@@ -63,13 +60,19 @@ export default function CreateIndex() {
})
}
+ const totalDuration = useMemo(() => {
+ if(!videoData || videoData.length == 0) return 0;
+ // 计算总时长
+ return videoData.reduce((sum, v) => sum + v.duration, 0);
+ }, [videoData])
+
return (
{contextHolder}
- 视频时长: 00:00:29
+ 视频时长: {formatDuration(totalDuration)}
批量删除
@@ -99,6 +102,7 @@ export default function CreateIndex() {
}
}}>
+
{videoData.map((v, index) => (
playVideo(v)}
onEdit={() => {
- setEditNews({title: v.title, groups: [...ArticleGroupList]})
+ setEditId(v.article_id)
}}
editable
/>))}
-
+
-
)
}
\ No newline at end of file
diff --git a/src/routes/routes.tsx b/src/routes/routes.tsx
index d2a2dc2..9ae6fdd 100644
--- a/src/routes/routes.tsx
+++ b/src/routes/routes.tsx
@@ -1,7 +1,7 @@
import {RouteObject} from "react-router-dom";
import ErrorBoundary from "@/routes/error.tsx";
import UserAuth from "@/pages/user";
-import CreateIndex from "@/pages/create";
+import CreateIndex from "../pages/video";
import LibraryIndex from "@/pages/library";
import LiveIndex from "@/pages/live";
import NewsIndex from "@/pages/news";
diff --git a/src/service/api/article.ts b/src/service/api/article.ts
index 7fb948c..cf3b9ef 100644
--- a/src/service/api/article.ts
+++ b/src/service/api/article.ts
@@ -22,12 +22,13 @@ export function getById(id: Id) {
}
export function save(title: string, content_group: BlockContent[][], id: number) {
- return post<{ content: string }>({
- url: '/spider/article',
- data: {
- title,
- content_group,
- id
- }
+ return post<{ content: string }>(id && id > 0 ? '/article/modify' : '/article/create/new', {
+ title,
+ content_group,
+ id
})
+}
+
+export function push2video(article_ids: Id[]) {
+ return post('/article/push2video', {article_ids})
}
\ No newline at end of file
diff --git a/src/service/api/live.ts b/src/service/api/live.ts
new file mode 100644
index 0000000..36b58d2
--- /dev/null
+++ b/src/service/api/live.ts
@@ -0,0 +1,20 @@
+import {post} from "@/service/request.ts";
+
+export function playState() {
+ return post<{
+ id: number;
+ start_time?: number;
+ }>({url: '/room/playing'})
+}
+
+export function getList() {
+ return post