feat: ️ 完成接口联调;去除生成视频判断

This commit is contained in:
LittleBoy 2025-04-07 11:56:31 +08:00
parent e61bfcc26c
commit 64ee960846
5 changed files with 89 additions and 46 deletions

View File

@ -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){ if(hotNews.mode == 'manual' && hotNews.list.filter(s=>s.trim().length > 0).length < 3){
modal.confirm({ modal.warning({
wrapClassName: 'root-modal-confirm', wrapClassName: 'root-modal-confirm',
icon: <span className="anticon anticon-exclamation-circle"><IconWarningCircle/></span>, icon: <span className="anticon anticon-exclamation-circle"><IconWarningCircle/></span>,
title: t('modal.hot_news.empty_notice_title'), title: t('modal.hot_news.empty_notice_title'),
content: t('modal.hot_news.empty_notice_message'), content: <span dangerouslySetInnerHTML={{__html:t('modal.hot_news.empty_notice_message')}}></span>,
centered:true, centered:true,
onOk: () => { onOk: () => {
resolve(true) resolve(false)
}, },
onCancel: () => { onCancel: () => {
resolve(false) resolve(false)
@ -148,7 +148,7 @@ export default function ArticleEditModal(props: Props) {
title, title,
metahuman_text: groups[0][0].content, metahuman_text: groups[0][0].content,
content_group: groups.slice(1), 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 id: props.id && props.id > 0 ? props.id : undefined
}).then(() => { }).then(() => {
props.onClose?.(true) props.onClose?.(true)
@ -182,7 +182,7 @@ export default function ArticleEditModal(props: Props) {
title, title,
metahuman_text: groups[0][0].content, metahuman_text: groups[0][0].content,
content_group: groups.slice(1), content_group: groups.slice(1),
hot_news: hotNews.list, hot_news: hotNews.mode == 'auto' ? [''] : hotNews.list,
id: props.id, id: props.id,
}) })
push2video([props.id]).then(() => { push2video([props.id]).then(() => {
@ -203,10 +203,10 @@ export default function ArticleEditModal(props: Props) {
article.getById(props.id).then(res => { article.getById(props.id).then(res => {
const len = res.hot_news.length const len = res.hot_news.length
const list = len >= 3 ? res.hot_news :res.hot_news.concat(Array(3 - len).fill('')) 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({ setHotNews({
list, list,
mode: res.hot_news_mode ?? 'auto' mode
}) })
setGroups(rebuildGroups([[{content: res.metahuman_text, type: "text"}], ...res.content_group])) setGroups(rebuildGroups([[{content: res.metahuman_text, type: "text"}], ...res.content_group]))
setTitle(res.title) setTitle(res.title)

View File

@ -50,9 +50,9 @@
}, },
"modal": { "modal": {
"hot_news": { "hot_news": {
"edit_auto": "Smart", "edit_auto": "Smart Fill",
"edit_manual": "Manual", "edit_manual": "Manual Fill",
"empty_notice_message": "\"Hot News\" has not been filled in yet. Should it be filled in automatically by the system?", "empty_notice_message": "The manually edited \"Hot News\" have not been completed.<br/>Please fill in all, or turn on smart fill",
"empty_notice_title": "Notice", "empty_notice_title": "Notice",
"title": "Hot news" "title": "Hot news"
}, },
@ -64,6 +64,7 @@
"content_error_single": "<span class=\"modal-count-normal\">{{count}}</span> news is selected, and the metahuman content is too short in this news. Do you want to transfer it to a video?", "content_error_single": "<span class=\"modal-count-normal\">{{count}}</span> news is selected, and the metahuman content is too short in this news. Do you want to transfer it to a video?",
"content_normal": "<span class=\"modal-count-normal\">{{count}}</span> news are selected, Do you want to transfer them into videos?", "content_normal": "<span class=\"modal-count-normal\">{{count}}</span> news are selected, Do you want to transfer them into videos?",
"content_normal_single": "<span class=\"modal-count-normal\">{{count}}</span> news is selected. Do you want to transfer it to a video?", "content_normal_single": "<span class=\"modal-count-normal\">{{count}}</span> news is selected. Do you want to transfer it to a video?",
"empty_notice_title": "Notice",
"error_title": "Abnormal news" "error_title": "Abnormal news"
}, },
"warning": "Warning" "warning": "Warning"

View File

@ -52,7 +52,7 @@
"hot_news": { "hot_news": {
"edit_auto": "智能填充", "edit_auto": "智能填充",
"edit_manual": "手动编辑", "edit_manual": "手动编辑",
"empty_notice_message": "“新闻热点”尚未填写,是否由系统自动填充?", "empty_notice_message": "手动编辑的“新闻热点”尚未填写完毕,<br/>请填写全部热点,或开启智能填充",
"empty_notice_title": "操作提示", "empty_notice_title": "操作提示",
"title": "新闻热点" "title": "新闻热点"
}, },
@ -64,6 +64,7 @@
"content_error_single": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,<span class=\"modal-count-warning\">{{error_count}}</span>条新闻数字人播报字数过少,是否生成全部<span class=\"modal-count-normal\">{{count}}</span>条视频?", "content_error_single": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,<span class=\"modal-count-warning\">{{error_count}}</span>条新闻数字人播报字数过少,是否生成全部<span class=\"modal-count-normal\">{{count}}</span>条视频?",
"content_normal": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,是否全部生成?", "content_normal": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,是否全部生成?",
"content_normal_single": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,是否生成?", "content_normal_single": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,是否生成?",
"empty_notice_title": "操作提示",
"error_title": "异常新闻" "error_title": "异常新闻"
}, },
"warning": "操作提示" "warning": "操作提示"

View File

@ -4,7 +4,7 @@ import {useNavigate} from "react-router-dom";
import {useTranslation} from "react-i18next"; import {useTranslation} from "react-i18next";
import {useSetState} from "ahooks"; 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 {push2video} from "@/service/api/article.ts";
import {IconArrowRight, IconWarningCircle} from "@/components/icons"; import {IconArrowRight, IconWarningCircle} from "@/components/icons";
@ -21,6 +21,7 @@ type PushVideoProps = {
} }
export default function ButtonPush2Video(props: PushVideoProps) { export default function ButtonPush2Video(props: PushVideoProps) {
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
// const {modal} = App.useApp()
const [state, setState] = useSetState<{ const [state, setState] = useSetState<{
modalVisible?: boolean; modalVisible?: boolean;
errorTitle?: string[]; errorTitle?: string[];
@ -30,32 +31,66 @@ export default function ButtonPush2Video(props: PushVideoProps) {
}) })
const {t} = useTranslation() const {t} = useTranslation()
const navigate = useNavigate() 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)); * @deprecated
if(skip && (state.errorIds.length == props.ids.length || ids.length == 0)){ */
setState({modalVisible: false}) // const checkHotNewsValid = async ()=>{
return; // return new Promise<string>((resolve)=>{
} // const manualErrorCount = props.articles?.filter(s=>{
setLoading(true) // return s.hot_news.replace(/,/ig,'').trim().length == 0
push2video(ids).then(() => { // })?.length || 0
setState({modalVisible: false}) // if(manualErrorCount == 0) {
if (skip) { // resolve('default')
props.onResult?.(ProcessResult.Skip, state.errorIds || []) // return;
// }
// modal.confirm({
// wrapClassName: 'root-modal-confirm',
// icon: <span className="anticon anticon-exclamation-circle"><IconWarningCircle/></span>,
// 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; return;
} }
showToast(t('news.push_stream_success'), 'success') //
navigate('/create?state=push-success', { // const result = await checkHotNewsValid();
state: 'push-success' // // 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 // double check 25-02-15 https://pu7y37y121.feishu.cn/docx/FwRrddAFWotRZlxgbr5cP7b6nud
// 1.normal 数字人播报部分有内容不少于50字或者数字人播报部分无内容 // 1.normal 数字人播报部分有内容不少于50字或者数字人播报部分无内容
// 2.error 数字人播报部分有内容但是少于50字 // 2.error 数字人播报部分有内容但是少于50字
@ -114,13 +149,13 @@ export default function ButtonPush2Video(props: PushVideoProps) {
}}> }}>
</div> </div>
{state.errorTitle && state.errorTitle.length > 0 && {state.errorTitle && state.errorTitle.length > 0 &&
<div className="error-list text-red-400 mt-6 w-[350px]"> <div className="error-list text-red-400 mt-6 w-[350px]">
<div className="title">{t('modal.push_article.error_title')}:</div> <div className="title">{t('modal.push_article.error_title')}:</div>
<div className="max-h-[100px] overflow-auto" style={{lineHeight: '20px'}}> <div className="max-h-[100px] overflow-auto" style={{lineHeight: '20px'}}>
{state.errorTitle.map(s => <div {state.errorTitle.map((s, idx) => <div key={idx}
className="error-item overflow-hidden pr-1 text-nowrap overflow-ellipsis">{s}</div>)} className="error-item overflow-hidden pr-1 text-nowrap overflow-ellipsis">{s}</div>)}
</div> </div>
</div>} </div>}
</div> </div>
</div> </div>
<div className="flex justify-end mt-6"> <div className="flex justify-end mt-6">
@ -128,10 +163,15 @@ export default function ButtonPush2Video(props: PushVideoProps) {
<Button disabled={loading} onClick={() => { <Button disabled={loading} onClick={() => {
setState({modalVisible: false}) setState({modalVisible: false})
}}>{t('modal.push_article.action_cancel')}</Button> }}>{t('modal.push_article.action_cancel')}</Button>
{state.errorIds?.length > 0 && <Button disabled={loading} type="primary" {state.errorIds?.length > 0 && (
onClick={() => handlePush(ProcessResult.Skip)}>{t('modal.push_article.action_skip')}</Button>} <Button
<Button disabled={loading} type={state.errorIds.length == 0 ? 'primary' : 'default'} disabled={loading} type="primary"
onClick={() => handlePush(ProcessResult.All)} >{t('modal.push_article.action_all')}</Button> onClick={() => handlePush(ProcessResult.Skip)}
>{t('modal.push_article.action_skip')}</Button>
)}
<Button
disabled={loading} type={state.errorIds.length == 0 ? 'primary' : 'default'}
onClick={() => handlePush(ProcessResult.All)}>{t('modal.push_article.action_all')}</Button>
</Space> </Space>
</div> </div>
</Modal> </Modal>

1
src/types/api.d.ts vendored
View File

@ -67,6 +67,7 @@ interface BasicArticleInfo {
content_word_count?: number; content_word_count?: number;
media_id: number; media_id: number;
fanwen_column_id: number; fanwen_column_id: number;
hot_news: string;
} }
/** /**