diff --git a/src/assets/core.scss b/src/assets/core.scss index 29ace40..4042e25 100644 --- a/src/assets/core.scss +++ b/src/assets/core.scss @@ -550,4 +550,11 @@ } } } +} + +.modal-count-normal { + color:rgba(87, 148, 247, 1); +} +.modal-count-warning { + color:rgba(255, 0, 4, 0.85); } \ No newline at end of file diff --git a/src/i18n/translations/en-US.json b/src/i18n/translations/en-US.json index d19667e..1f5588d 100644 --- a/src/i18n/translations/en-US.json +++ b/src/i18n/translations/en-US.json @@ -152,5 +152,18 @@ "title_generated_time": "Time stamp", "title_operation": "", "title_thumb": "Cover" + }, + "modal": { + "warning": "Warning", + "push_article": { + "content_normal": "{{count}} news are selected, do you want to transfer them into videos?", + "content_normal_single": "{{count}} news is selected. Do you want to transfer it to a video?", + "content_error": "{{count}} news are selected, and metahuman contents are too short in the news below. Do you want to transfer them to videos?", + "content_error_single": "{{count}} news is selected, and the metahuman content is too short in this news. Do you want to transfer it to a video?", + "error_title": "Abnormal news", + "action_cancel": "Cancel", + "action_skip": "Skip the news", + "action_all": "Still generating" + } } } \ No newline at end of file diff --git a/src/i18n/translations/zh-CN.json b/src/i18n/translations/zh-CN.json index a81d41e..2c171e3 100644 --- a/src/i18n/translations/zh-CN.json +++ b/src/i18n/translations/zh-CN.json @@ -152,5 +152,18 @@ "title_generated_time": "生成时间", "title_operation": "操作", "title_thumb": "缩略图" + }, + "modal": { + "warning": "操作提示", + "push_article": { + "content_normal": "已选中{{count}}条新闻,是否全部生成?", + "content_normal_single": "已选中{{count}}条新闻,是否生成?", + "content_error": "已选中{{count}}条新闻,{{error_count}}条新闻数字人播报字数过少,是否生成全部{{count}}条视频?", + "content_error_single": "已选中{{count}}条新闻,{{error_count}}条新闻数字人播报字数过少,是否生成全部{{count}}条视频?", + "error_title": "异常新闻", + "action_cancel": "全部取消", + "action_skip": "跳过异常新闻", + "action_all": "全部生成" + } } } \ 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 1ab32df..0970865 100644 --- a/src/pages/news/components/button-push2video.tsx +++ b/src/pages/news/components/button-push2video.tsx @@ -1,18 +1,44 @@ 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 {Modal, Space, Button} from "antd"; import {useNavigate} from "react-router-dom"; import {useTranslation} from "react-i18next"; +import {useSetState} from "ahooks"; +import {showErrorToast, showToast} from "@/components/message.ts"; +import {push2video} from "@/service/api/article.ts"; +import {IconArrowRight, IconWarningCircle} from "@/components/icons"; -export default function ButtonPush2Video(props: { ids: Id[]; onSuccess?: () => void; }) { +export enum ProcessResult { + All, + Skip, + Cancel +} + +type PushVideoProps = { + ids: Id[]; + articles?: ListArticleItem[]; + onResult?: (result: ProcessResult, errorIds: Id[]) => void; +} +export default function ButtonPush2Video(props: PushVideoProps) { const [loading, setLoading] = useState(false) + const [state, setState] = useSetState<{ + modalVisible?: boolean; + errorTitle?: string[]; + errorIds: Id[] + }>({ + errorIds: [] + }) const {t} = useTranslation() const navigate = useNavigate() - const handlePush = () => { + const handlePush = (action: ProcessResult) => { setLoading(true) - push2video(props.ids).then(() => { + const skip = action === ProcessResult.Skip && state.errorIds.length > 0 + const ids = !skip ? props.ids : props.ids.filter(id => !state.errorIds.includes(id)); + push2video(ids).then(() => { + if (skip) { + props.onResult?.(ProcessResult.Skip, state.errorIds || []) + return; + } showToast(t('news.push_stream_success'), 'success') navigate('/create?state=push-success', { state: 'push-success' @@ -22,18 +48,64 @@ export default function ButtonPush2Video(props: { ids: Id[]; onSuccess?: () => v setLoading(false) }) } + // double check 25-02-15 https://pu7y37y121.feishu.cn/docx/FwRrddAFWotRZlxgbr5cP7b6nud + // 1.normal 数字人播报部分有内容,不少于50字;或者数字人播报部分无内容 + // 2.error 数字人播报部分有内容,但是少于50字 + const checkArticleContent = () => { + const errors: string[] = [], ids: Id[] = []; + + props.articles?.filter(s => { + return props.ids.includes(s.id) && (s.metahuman_text && s.metahuman_text.length < 50) + }).forEach(s => { + errors.push(s.title) + ids.push(s.id) + }) + return {errors, ids} + } + const onPushClick = () => { if (loading) return; if (props.ids.length === 0) { showToast(t('news.push_stream_empty'), 'warning') return } - // Modal.confirm({ - // title: '操作提示', - // content: '是否确定一键开播选中新闻?', - // onOk: handlePush + // check article content + const result = checkArticleContent() + setState({modalVisible: true, errorTitle: result.errors, errorIds: result.ids}) + // + // const instance = modal.confirm({ + // title:
{t('modal.warning')}
, + // wrapClassName: 'root-modal-confirm', + // centered: true, + // width: 440, + // icon: , + // content:
+ //
+ // {t( + // errors && errors.length > 0 + // ? (props.ids.length == 1 ? 'modal.push_article.content_error_single' : 'modal.push_article.content_error') + // : (props.ids.length == 1 ? 'modal.push_article.content_normal_single' : 'modal.push_article.content_normal'), + // {count: props.ids.length, error_count: errors?.length})} + //
+ // {errors && errors.length > 0 &&
+ //
{t('modal.push_article.error_title')}:
+ //
+ // {errors.map(s =>
{s}
)} + //
+ //
} + //
, + // footer:
+ // + // + // + // + // + //
, // }) - handlePush(); + // handlePush(); } return (
@@ -45,6 +117,51 @@ export default function ButtonPush2Video(props: { ids: Id[]; onSuccess?: () => v {loading ? t('news.push_streaming') : t('news.generate_video')} + +
+
+
{t('modal.warning')}
+
+
+
+
+
0 + ? (props.ids.length == 1 ? 'modal.push_article.content_error_single' : 'modal.push_article.content_error') + : (props.ids.length == 1 ? 'modal.push_article.content_normal_single' : 'modal.push_article.content_normal'), + {count: props.ids.length, error_count: state.errorTitle?.length}) + }}> +
+ {state.errorTitle && state.errorTitle.length > 0 && +
+
{t('modal.push_article.error_title')}:
+
+ {state.errorTitle.map(s =>
{s}
)} +
+
} +
+
+
+ + + {state.errorIds?.length > 0 && } + + +
+
) } \ No newline at end of file diff --git a/src/pages/news/edit.tsx b/src/pages/news/edit.tsx index 33f9d3c..e18f23c 100644 --- a/src/pages/news/edit.tsx +++ b/src/pages/news/edit.tsx @@ -6,7 +6,7 @@ import {formatTime} from "@/util/strings.ts"; import ArticleEditModal from "@/components/article/edit-modal.tsx"; import {deleteByIds, getList} from "@/service/api/article.ts"; import EditSearchForm from "@/pages/news/components/edit-search-form.tsx"; -import ButtonPush2Video from "@/pages/news/components/button-push2video.tsx"; +import ButtonPush2Video, {ProcessResult} from "@/pages/news/components/button-push2video.tsx"; import styles from './components/style.module.scss' import InfiniteScroller, {InfiniteScrollerRef} from "@/components/scoller/infinite-scroller.tsx"; @@ -73,6 +73,12 @@ export default function NewEdit() { showToast(t('delete_success'), 'success') }).catch(showErrorToast) } + const handlePushProcessResult = (result: ProcessResult,errorIds: Id[])=>{ + if(result == ProcessResult.Skip){ + // 跳过 + setSelectedRowKeys(errorIds) + } + } return (
@@ -157,7 +163,7 @@ export default function NewEdit() {
})} -
+
@@ -165,7 +171,7 @@ export default function NewEdit() {
scrollerRef.current?.scrollToPosition(0)}/> {selectedRowKeys?.length > 0 && } - +