From f4117e0f67b577e02a57098ccbfbb9a80484034f Mon Sep 17 00:00:00 2001 From: callmeyan Date: Mon, 23 Dec 2024 23:02:15 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=96=B0=E9=97=BB=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/article/edit-modal.tsx | 20 +++++++++++++-- src/components/icons/index.tsx | 4 +-- .../news/components/button-push2video.tsx | 25 +++++++++++-------- src/pages/news/components/style.module.scss | 2 +- src/pages/news/edit.tsx | 2 +- src/pages/video/index.tsx | 19 ++++++++++++-- src/types/api.d.ts | 2 +- 7 files changed, 55 insertions(+), 19 deletions(-) diff --git a/src/components/article/edit-modal.tsx b/src/components/article/edit-modal.tsx index d5434a1..b08d151 100644 --- a/src/components/article/edit-modal.tsx +++ b/src/components/article/edit-modal.tsx @@ -4,6 +4,8 @@ import {useEffect, useState} from "react"; import {useSetState} from "ahooks"; import * as article from "@/service/api/article.ts"; import {regenerate} from "@/service/api/video.ts"; +import {push2video} from "@/service/api/article.ts"; +import {showErrorToast, showToast} from "@/components/message.ts"; type Props = { id?: number; @@ -67,7 +69,8 @@ export default function ArticleEditModal(props: Props) { const [title, setTitle] = useState('') const [state, setState] = useSetState({ - ...DEFAULT_STATE + ...DEFAULT_STATE, + generating:false }) // 保存数据 const handleSave = () => { @@ -90,6 +93,19 @@ export default function ArticleEditModal(props: Props) { setState({loading: false}) }); } + const handlePush2Video = () =>{ + if(!props.id || state.generating) return; + setState({generating:true}) + push2video([props.id]).then(() => { + showToast('推流成功', 'success') + // navigate('/create?state=push-success',{ + // state: 'push-success' + // }) + // props.onSuccess?.() + }).catch(showErrorToast).finally(()=>{ + setState({generating:false}) + }) + } useEffect(() => { setState({...DEFAULT_STATE}) if (typeof (props.id) != 'undefined') { @@ -142,7 +158,7 @@ export default function ArticleEditModal(props: Props) {
- {props.type == 'news' ? : null} + {props.type == 'news' && props.id > 0 ? : null}
diff --git a/src/components/icons/index.tsx b/src/components/icons/index.tsx index dbdeb44..893d6d1 100644 --- a/src/components/icons/index.tsx +++ b/src/components/icons/index.tsx @@ -124,7 +124,7 @@ export const IconAdd = ({style, className}: IconProps) => ( export const IconLocked = ({style, className}: IconProps) => ( - @@ -133,7 +133,7 @@ export const IconLocked = ({style, className}: IconProps) => ( export const IconUnlock = ({style, className}: IconProps) => ( - diff --git a/src/pages/news/components/button-push2video.tsx b/src/pages/news/components/button-push2video.tsx index ce7377b..d840959 100644 --- a/src/pages/news/components/button-push2video.tsx +++ b/src/pages/news/components/button-push2video.tsx @@ -1,32 +1,37 @@ -import { Modal} from "antd"; import React, {useState} from "react"; import {showErrorToast, showToast} from "@/components/message.ts"; import {push2video} from "@/service/api/article.ts"; import {IconArrowRight} from "@/components/icons"; +import {useNavigate} from "react-router-dom"; export default function ButtonPush2Video(props: { ids: Id[]; onSuccess?: () => void; }) { const [loading, setLoading] = useState(false) + const navigate = useNavigate() const handlePush = () => { setLoading(true) push2video(props.ids).then(() => { - showToast('一键推流成功,已成功推入数字人视频生成,请前往数字人视频生成页面查看!', 'success') - props.onSuccess?.() + showToast('推流成功', 'success') + navigate('/create?state=push-success',{ + state: 'push-success' + }) + // props.onSuccess?.() }).catch(showErrorToast).finally(() => { setLoading(false) }) } const onPushClick = () => { - if(loading) return; + if (loading) return; if (props.ids.length === 0) { showToast('请选择要开播的新闻', 'warning') return } - Modal.confirm({ - title: '操作提示', - content: '是否确定一键开播选中新闻?', - onOk: handlePush - }) + // Modal.confirm({ + // title: '操作提示', + // content: '是否确定一键开播选中新闻?', + // onOk: handlePush + // }) + handlePush(); } return (
@@ -35,7 +40,7 @@ export default function ButtonPush2Video(props: { ids: Id[]; onSuccess?: () => v className='bg-[#4096ff] hover:bg-blue-600 text-white' onClick={onPushClick} > - 生成视频 + {loading?'推送中...':'生成视频'}
diff --git a/src/pages/news/components/style.module.scss b/src/pages/news/components/style.module.scss index 71cdfda..239bbc7 100644 --- a/src/pages/news/components/style.module.scss +++ b/src/pages/news/components/style.module.scss @@ -62,7 +62,7 @@ } } .source{ - width: 150px; + width: 180px; } .count-picture,.count-words{ width: 120px; diff --git a/src/pages/news/edit.tsx b/src/pages/news/edit.tsx index d5138c1..b03b57c 100644 --- a/src/pages/news/edit.tsx +++ b/src/pages/news/edit.tsx @@ -115,7 +115,7 @@ export default function NewEdit() {
-
{item.data_source_name}
+
{item.media_name}-{item.column_name}
{item.img_num}
diff --git a/src/pages/video/index.tsx b/src/pages/video/index.tsx index 6b29fb6..08fcabe 100644 --- a/src/pages/video/index.tsx +++ b/src/pages/video/index.tsx @@ -15,9 +15,11 @@ import ButtonPush2Room from "@/pages/video/components/button-push2room.tsx"; import ButtonToTop from "@/components/scoller/button-to-top.tsx"; import InfiniteScroller, {InfiniteScrollerRef} from "@/components/scoller/infinite-scroller.tsx"; import {IconDelete} from "@/components/icons"; +import {useLocation} from "react-router-dom"; export default function VideoIndex() { const [editId, setEditId] = useState(-1) + const loc = useLocation() const [videoData, setVideoData] = useState([]) const [modal, contextHolder] = Modal.useModal() const player = useRef(null) @@ -25,7 +27,8 @@ export default function VideoIndex() { const [state, setState] = useSetState({ checkedAll: false, playingIndex: -1, - showToTop: false + showToTop: false, + showStatePos: false }) const [checkedIdArray, setCheckedIdArray] = useState([]) @@ -81,6 +84,18 @@ export default function VideoIndex() { //return videoData.reduce((sum, v) => sum + Math.ceil(v.duration / 1000), 0); }, [videoData,state.playingIndex]) + useEffect(()=>{ + if(loc.state == 'push-success' && !state.showStatePos && videoData.length && scrollerRef.current){ + const generatingItem = document.querySelector(`.list-item-state-${VideoStatus.Generating}`) + if(generatingItem){ + generatingItem.scrollIntoView({behavior: 'smooth'}) + setState({showStatePos: true}) + } + } + },[videoData,scrollerRef]) + + + return (
{contextHolder}
@@ -155,7 +170,7 @@ export default function VideoIndex() { type={'create'} active={state.playingIndex == index} checked={checkedIdArray.includes(v.id)} - className={`list-item-${index} mt-3 mb-2`} + className={`list-item-${index} mt-3 mb-2 list-item-state-${v.status}`} onCheckedChange={(checked) => { setCheckedIdArray(idArray => { const newArr = checked ? idArray.concat(v.id) : idArray.filter(id => id != v.id); diff --git a/src/types/api.d.ts b/src/types/api.d.ts index 5edd1ce..4d0fada 100644 --- a/src/types/api.d.ts +++ b/src/types/api.d.ts @@ -60,7 +60,7 @@ interface BasicArticleInfo { summary: string; publish_time: string; media_name: string; - data_source_name?: string; + column_name?: string; img_num?: number; content_word_count?: number; media_id: number;