feat: ✨️ 完成接口联调;去除生成视频判断
This commit is contained in:
parent
e61bfcc26c
commit
64ee960846
@ -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: <span className="anticon anticon-exclamation-circle"><IconWarningCircle/></span>,
|
||||
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,
|
||||
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)
|
||||
|
@ -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.<br/>Please fill in all, or turn on smart fill",
|
||||
"empty_notice_title": "Notice",
|
||||
"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_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?",
|
||||
"empty_notice_title": "Notice",
|
||||
"error_title": "Abnormal news"
|
||||
},
|
||||
"warning": "Warning"
|
||||
|
@ -52,7 +52,7 @@
|
||||
"hot_news": {
|
||||
"edit_auto": "智能填充",
|
||||
"edit_manual": "手动编辑",
|
||||
"empty_notice_message": "“新闻热点”尚未填写,是否由系统自动填充?",
|
||||
"empty_notice_message": "手动编辑的“新闻热点”尚未填写完毕,<br/>请填写全部热点,或开启智能填充",
|
||||
"empty_notice_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_normal": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,是否全部生成?",
|
||||
"content_normal_single": "已选中<span class=\"modal-count-normal\">{{count}}</span>条新闻,是否生成?",
|
||||
"empty_notice_title": "操作提示",
|
||||
"error_title": "异常新闻"
|
||||
},
|
||||
"warning": "操作提示"
|
||||
|
@ -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<string>((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: <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;
|
||||
}
|
||||
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) {
|
||||
}}>
|
||||
</div>
|
||||
{state.errorTitle && state.errorTitle.length > 0 &&
|
||||
<div className="error-list text-red-400 mt-6 w-[350px]">
|
||||
<div className="title">{t('modal.push_article.error_title')}:</div>
|
||||
<div className="max-h-[100px] overflow-auto" style={{lineHeight: '20px'}}>
|
||||
{state.errorTitle.map(s => <div
|
||||
className="error-item overflow-hidden pr-1 text-nowrap overflow-ellipsis">{s}</div>)}
|
||||
</div>
|
||||
</div>}
|
||||
<div className="error-list text-red-400 mt-6 w-[350px]">
|
||||
<div className="title">{t('modal.push_article.error_title')}:</div>
|
||||
<div className="max-h-[100px] overflow-auto" style={{lineHeight: '20px'}}>
|
||||
{state.errorTitle.map((s, idx) => <div key={idx}
|
||||
className="error-item overflow-hidden pr-1 text-nowrap overflow-ellipsis">{s}</div>)}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end mt-6">
|
||||
@ -128,10 +163,15 @@ export default function ButtonPush2Video(props: PushVideoProps) {
|
||||
<Button disabled={loading} onClick={() => {
|
||||
setState({modalVisible: false})
|
||||
}}>{t('modal.push_article.action_cancel')}</Button>
|
||||
{state.errorIds?.length > 0 && <Button disabled={loading} type="primary"
|
||||
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>
|
||||
{state.errorIds?.length > 0 && (
|
||||
<Button
|
||||
disabled={loading} type="primary"
|
||||
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>
|
||||
</div>
|
||||
</Modal>
|
||||
|
1
src/types/api.d.ts
vendored
1
src/types/api.d.ts
vendored
@ -67,6 +67,7 @@ interface BasicArticleInfo {
|
||||
content_word_count?: number;
|
||||
media_id: number;
|
||||
fanwen_column_id: number;
|
||||
hot_news: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user