diff --git a/src/components/article/edit-modal.tsx b/src/components/article/edit-modal.tsx index fe399a7..9f0c29f 100644 --- a/src/components/article/edit-modal.tsx +++ b/src/components/article/edit-modal.tsx @@ -86,14 +86,14 @@ function checkHotNewsValid(hotNews: HotNewsData,modal:ModalHookAPI,t:TFunction<" // 验证热点新闻数据是否正确 if(hotNews.mode == 'manual' && hotNews.list.filter(s=>s.trim().length > 0).length < 3){ - modal.confirm({ + modal.warning({ wrapClassName: 'root-modal-confirm', icon: , title: t('modal.hot_news.empty_notice_title'), - content: t('modal.hot_news.empty_notice_message'), + content: , centered:true, onOk: () => { - resolve(true) + resolve(false) }, onCancel: () => { resolve(false) @@ -148,7 +148,7 @@ export default function ArticleEditModal(props: Props) { title, metahuman_text: groups[0][0].content, content_group: groups.slice(1), - hot_news: hotNews.list, + hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list, id: props.id && props.id > 0 ? props.id : undefined }).then(() => { props.onClose?.(true) @@ -182,7 +182,7 @@ export default function ArticleEditModal(props: Props) { title, metahuman_text: groups[0][0].content, content_group: groups.slice(1), - hot_news: hotNews.list, + hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list, id: props.id, }) push2video([props.id]).then(() => { @@ -203,10 +203,10 @@ export default function ArticleEditModal(props: Props) { article.getById(props.id).then(res => { const len = res.hot_news.length const list = len >= 3 ? res.hot_news :res.hot_news.concat(Array(3 - len).fill('')) - console.log('list,',list,res.hot_news) + const mode = res.hot_news && res.hot_news.filter(s=>s.length > 0).length == 3 ?'manual':'auto'; setHotNews({ list, - mode: res.hot_news_mode ?? 'auto' + mode }) setGroups(rebuildGroups([[{content: res.metahuman_text, type: "text"}], ...res.content_group])) setTitle(res.title) diff --git a/src/i18n/translations/en-US.json b/src/i18n/translations/en-US.json index 297cdc5..6ddfe0b 100644 --- a/src/i18n/translations/en-US.json +++ b/src/i18n/translations/en-US.json @@ -50,9 +50,9 @@ }, "modal": { "hot_news": { - "edit_auto": "Smart", - "edit_manual": "Manual", - "empty_notice_message": "\"Hot News\" has not been filled in yet. Should it be filled in automatically by the system?", + "edit_auto": "Smart Fill", + "edit_manual": "Manual Fill", + "empty_notice_message": "The manually edited \"Hot News\" have not been completed.
Please fill in all, or turn on smart fill", "empty_notice_title": "Notice", "title": "Hot news" }, @@ -64,6 +64,7 @@ "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?", "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?", + "empty_notice_title": "Notice", "error_title": "Abnormal news" }, "warning": "Warning" diff --git a/src/i18n/translations/zh-CN.json b/src/i18n/translations/zh-CN.json index 4c1f6cf..223229c 100644 --- a/src/i18n/translations/zh-CN.json +++ b/src/i18n/translations/zh-CN.json @@ -52,7 +52,7 @@ "hot_news": { "edit_auto": "智能填充", "edit_manual": "手动编辑", - "empty_notice_message": "“新闻热点”尚未填写,是否由系统自动填充?", + "empty_notice_message": "手动编辑的“新闻热点”尚未填写完毕,
请填写全部热点,或开启智能填充", "empty_notice_title": "操作提示", "title": "新闻热点" }, @@ -64,6 +64,7 @@ "content_error_single": "已选中{{count}}条新闻,{{error_count}}条新闻数字人播报字数过少,是否生成全部{{count}}条视频?", "content_normal": "已选中{{count}}条新闻,是否全部生成?", "content_normal_single": "已选中{{count}}条新闻,是否生成?", + "empty_notice_title": "操作提示", "error_title": "异常新闻" }, "warning": "操作提示" diff --git a/src/pages/news/components/button-push2video.tsx b/src/pages/news/components/button-push2video.tsx index 8d08a1d..bc81669 100644 --- a/src/pages/news/components/button-push2video.tsx +++ b/src/pages/news/components/button-push2video.tsx @@ -4,7 +4,7 @@ import {useNavigate} from "react-router-dom"; import {useTranslation} from "react-i18next"; import {useSetState} from "ahooks"; -import {showErrorToast, showToast} from "@/components/message.ts"; +import {showToast} from "@/components/message.ts"; import {push2video} from "@/service/api/article.ts"; import {IconArrowRight, IconWarningCircle} from "@/components/icons"; @@ -21,6 +21,7 @@ type PushVideoProps = { } export default function ButtonPush2Video(props: PushVideoProps) { const [loading, setLoading] = useState(false) + // const {modal} = App.useApp() const [state, setState] = useSetState<{ modalVisible?: boolean; errorTitle?: string[]; @@ -30,32 +31,66 @@ export default function ButtonPush2Video(props: PushVideoProps) { }) const {t} = useTranslation() const navigate = useNavigate() - const handlePush = (action: ProcessResult) => { - const skip = action === ProcessResult.Skip && state.errorIds.length > 0 - const ids = !skip ? props.ids : props.ids.filter(id => !state.errorIds.includes(id)); - if(skip && (state.errorIds.length == props.ids.length || ids.length == 0)){ - setState({modalVisible: false}) - return; - } - setLoading(true) - push2video(ids).then(() => { - setState({modalVisible: false}) - if (skip) { - props.onResult?.(ProcessResult.Skip, state.errorIds || []) + /** + * + * @deprecated 保存即判断,此时暂不提示了 + */ + // const checkHotNewsValid = async ()=>{ + // return new Promise((resolve)=>{ + // const manualErrorCount = props.articles?.filter(s=>{ + // return s.hot_news.replace(/,/ig,'').trim().length == 0 + // })?.length || 0 + // if(manualErrorCount == 0) { + // resolve('default') + // return; + // } + // modal.confirm({ + // wrapClassName: 'root-modal-confirm', + // icon: , + // title: t('modal.push_article.empty_notice_title'), + // content: t('modal.push_article.empty_notice_message'), + // centered:true, + // onOk: () => { + // resolve('auto') + // }, + // onCancel: () => { + // resolve('reject') + // } + // }) + // }) + // } + const handlePush = async (action: ProcessResult) => { + const skip = action === ProcessResult.Skip && state.errorIds.length > 0 + const ids = !skip ? props.ids : props.ids.filter(id => !state.errorIds.includes(id)); + if (skip && (state.errorIds.length == props.ids.length || ids.length == 0)) { + setState({modalVisible: false}) return; } - showToast(t('news.push_stream_success'), 'success') - navigate('/create?state=push-success', { - state: 'push-success' + // + // const result = await checkHotNewsValid(); + // // TODO: 有热点新闻自动? + // if(result == 'reject'){ // 有热点新闻未填写 但点击取消并终止后续操作 + // return; + // } + setLoading(true) + push2video(ids).then(() => { + setState({modalVisible: false}) + if (skip) { + props.onResult?.(ProcessResult.Skip, state.errorIds || []) + return; + } + showToast(t('news.push_stream_success'), 'success') + navigate('/create?state=push-success', { + state: 'push-success' + }) + // props.onSuccess?.() + }).catch(() => { + showToast(t('service_error'), 'error') + //showErrorToast + }).finally(() => { + setLoading(false) }) - // props.onSuccess?.() - }).catch(()=>{ - showToast(t('service_error'), 'error') - //showErrorToast - }).finally(() => { - setLoading(false) - }) - } + } // double check 25-02-15 https://pu7y37y121.feishu.cn/docx/FwRrddAFWotRZlxgbr5cP7b6nud // 1.normal 数字人播报部分有内容,不少于50字;或者数字人播报部分无内容 // 2.error 数字人播报部分有内容,但是少于50字 @@ -114,13 +149,13 @@ export default function ButtonPush2Video(props: PushVideoProps) { }}> {state.errorTitle && state.errorTitle.length > 0 && -
-
{t('modal.push_article.error_title')}:
-
- {state.errorTitle.map(s =>
{s}
)} -
-
} +
+
{t('modal.push_article.error_title')}:
+
+ {state.errorTitle.map((s, idx) =>
{s}
)} +
+
}
@@ -128,10 +163,15 @@ export default function ButtonPush2Video(props: PushVideoProps) { - {state.errorIds?.length > 0 && } - + {state.errorIds?.length > 0 && ( + + )} +
diff --git a/src/types/api.d.ts b/src/types/api.d.ts index b184103..585443b 100644 --- a/src/types/api.d.ts +++ b/src/types/api.d.ts @@ -67,6 +67,7 @@ interface BasicArticleInfo { content_word_count?: number; media_id: number; fanwen_column_id: number; + hot_news: string; } /**