fixed: 编辑内容时,当内容为空时禁止新建组

This commit is contained in:
LittleBoy 2025-02-05 19:41:13 +08:00 committed by Coding
parent 9eecaa4294
commit ac7e4b1b27
5 changed files with 73 additions and 70 deletions

View File

@ -17,7 +17,7 @@ type Props = {
editable?: boolean; editable?: boolean;
onChange?: (blocks: BlockContent[]) => void; onChange?: (blocks: BlockContent[]) => void;
onRemove?: () => void; onRemove?: () => void;
onAdd?: (index?:number) => void; onAdd?: (index:number,checkIndex:number) => void;
errorMessage?: string; errorMessage?: string;
} }
@ -61,7 +61,7 @@ export default function ArticleBlock(
return <div className={`${styles.blockContainer} group`}> return <div className={`${styles.blockContainer} group`}>
{editable && index == 1 && <div className={'divider-container before'}><Divider> {editable && index == 1 && <div className={'divider-container before'}><Divider>
<span onClick={()=>onAdd?.(1)} className="article-action-add" title={t('news.edit_add_group')}><IconAdd style={{fontSize: 24}}/></span> <span onClick={()=>onAdd?.(1,1)} className="article-action-add" title={t('news.edit_add_group')}><IconAdd style={{fontSize: 24}}/></span>
</Divider></div> } </Divider></div> }
<div className={styles.blockInner}> <div className={styles.blockInner}>
<div className={clsx(className || '', styles.block, index == 0 ? styles.blockFist : '', ' hover:bg-blue-10')}> <div className={clsx(className || '', styles.block, index == 0 ? styles.blockFist : '', ' hover:bg-blue-10')}>
@ -99,7 +99,7 @@ export default function ArticleBlock(
</div> </div>
{editable && <div className={'divider-container after'}><Divider> {editable && <div className={'divider-container after'}><Divider>
<span onClick={()=>onAdd?.(index + 1)} className="article-action-add" title="新增分组"><IconAdd style={{fontSize: 24}}/></span> <span onClick={()=>onAdd?.(index + 1,index)} className="article-action-add" title="新增分组"><IconAdd style={{fontSize: 24}}/></span>
</Divider></div> } </Divider></div> }
</div> </div>
} }

View File

@ -119,6 +119,7 @@ export default function ArticleEditModal(props: Props) {
useEffect(() => { useEffect(() => {
setState({...DEFAULT_STATE}) setState({...DEFAULT_STATE})
if (typeof (props.id) != 'undefined') { if (typeof (props.id) != 'undefined') {
// 如果传入了id则获取数据
if (props.id > 0) { if (props.id > 0) {
article.getById(props.id).then(res => { article.getById(props.id).then(res => {
setGroups(rebuildGroups([[{content: res.metahuman_text, type: "text"}], ...res.content_group])) setGroups(rebuildGroups([[{content: res.metahuman_text, type: "text"}], ...res.content_group]))

View File

@ -21,11 +21,13 @@ export default function ArticleGroup({groups, editable, onChange, errorMessage}:
* *
* @param insertIndex -1 * @param insertIndex -1
*/ */
const handleAddGroup = (insertIndex: number = -1) => { const handleAddGroup = (insertIndex: number,checkId:number) => {
if (insertIndex !== -1 && insertIndex !== 1) { // && insertIndex !== 1
const triggerGroup = insertIndex == -1 || insertIndex >= groups.length ? groups[groups.length - 1] : groups[insertIndex - 1]; if (checkId > 0 && checkId < groups.length) {
//const index = insertIndex == -1 || insertIndex >= groups.length ? groups.length - 1 : insertIndex - 1
const triggerGroup = groups[checkId];
// 判断 // 判断
if (triggerGroup.length == 0 || triggerGroup.some(s => !s.content)) { if (!triggerGroup || triggerGroup.length == 0 || triggerGroup.some(s => !s.content)) {
showToast(t('news.edit_notice_enter_text')) showToast(t('news.edit_notice_enter_text'))
return; return;
} }
@ -88,8 +90,8 @@ export default function ArticleGroup({groups, editable, onChange, errorMessage}:
}} }}
errorMessage={errorMessage} errorMessage={errorMessage}
index={index} index={index}
onAdd={(_index) => { onAdd={(_index,checkIndex) => {
handleAddGroup?.(_index ? _index :index + 1) handleAddGroup?.(_index ? _index :index + 1,checkIndex)
}} }}
onRemove={async () => { onRemove={async () => {
if (groups.length == 1) { if (groups.length == 1) {

View File

@ -1,12 +1,15 @@
{ {
"AppTitle": "AI Livesteam", "AppTitle": "AI Livesteam",
"Hello": "Hello", "Hello": "Hello",
"cancel": "Cancel",
"close": "Close", "close": "Close",
"confirm": { "confirm": {
"push_title": "Push Notice", "push_title": "Push Notice",
"push_video": "Are you sure editing selected news?", "push_video": "Are you sure editing selected news?",
"title": "Notice" "title": "Notice"
}, },
"confirm_text": "Confirm",
"delete": "Delete",
"delete_batch": "Delete Select", "delete_batch": "Delete Select",
"delete_failed": "Delete failed", "delete_failed": "Delete failed",
"delete_success": "Delete success", "delete_success": "Delete success",
@ -20,6 +23,7 @@
"search_key": "Please enter title keywords", "search_key": "Please enter title keywords",
"text": "Video history" "text": "Video history"
}, },
"history.pushed": "Streaming: {{count}}",
"live": { "live": {
"duration": "Duration", "duration": "Duration",
"edit_locked": "Locked", "edit_locked": "Locked",
@ -51,9 +55,24 @@
"delete_description": "This item will be deleted.<br/>It can be recovered from the \"News\" page. ", "delete_description": "This item will be deleted.<br/>It can be recovered from the \"News\" page. ",
"delete_description_count": "These item will be deleted.<br/>It can be recovered from the \"News\" page. ", "delete_description_count": "These item will be deleted.<br/>It can be recovered from the \"News\" page. ",
"delete_empty": "Please select the items to delete", "delete_empty": "Please select the items to delete",
"delete_the_picture": "Are you sure delete the picture?",
"download_empty": "Please select the news to download", "download_empty": "Please select the news to download",
"download_failed": "Download failed!", "download_failed": "Download failed!",
"edit_add_group": "Add Group",
"edit_delete_group": "Delete Group",
"edit_delete_group_confirm": "Are you sure you want to delete the group?",
"edit_digital_text": "MetaHuman Material",
"edit_form_search": "Please enter title keywords", "edit_form_search": "Please enter title keywords",
"edit_generate_again": "Regenerate",
"edit_generate_video": "Generating",
"edit_generate_video_again": "Regenerate",
"edit_notice_enter_article_content": "Please enter content",
"edit_notice_enter_article_title": "Please enter title",
"edit_notice_enter_article_title1": "Please enter news title",
"edit_notice_enter_text": "Please enter content",
"edit_notice_keep_1": "Keep at least one content block",
"edit_other_text": "Other media Material",
"edit_save_failed": "Save failed!",
"editing": "Editing", "editing": "Editing",
"filter_all": "All", "filter_all": "All",
"filter_source": "News source", "filter_source": "News source",
@ -61,7 +80,6 @@
"get_detail": "Get news details", "get_detail": "Get news details",
"get_detail_error": "Get new details failed", "get_detail_error": "Get new details failed",
"image_count": "Images", "image_count": "Images",
"word_count": "Words",
"materials": { "materials": {
"title": "News Materials" "title": "News Materials"
}, },
@ -81,30 +99,8 @@
"title_operate": "", "title_operate": "",
"title_time": "Time stamp", "title_time": "Time stamp",
"title_word_count": "Word count", "title_word_count": "Word count",
"edit_digital_text": "MetaHuman Material", "word_count": "Words"
"edit_other_text": "Other media Material",
"edit_generate_video_again": "Regenerate",
"edit_generate_again": "Regenerate",
"edit_generate_video": "Generating",
"edit_save_failed": "Save failed!",
"edit_notice_keep_1": "Keep at least one content block",
"edit_notice_enter_text": "Please enter content",
"edit_notice_enter_article_title": "Please enter title",
"edit_notice_enter_article_title1": "Please enter news title",
"edit_notice_enter_article_content": "Please enter content",
"edit_add_group": "Add Group",
"edit_delete_group": "Delete Group",
"edit_delete_group_confirm": "Are you sure you want to delete the group?",
"delete_the_picture": "Are you sure delete the picture?"
}, },
"upload": {
"upload_failed": "Upload failed",
"delete_confirm": "Are you sure delete the picture?",
"upload_image": "Upload Image"
},
"delete": "Delete",
"cancel": "Cancel",
"confirm_text": "Confirm",
"select": { "select": {
"pushed": "Pushed: {{count}}", "pushed": "Pushed: {{count}}",
"select_all": "Select all", "select_all": "Select all",
@ -121,17 +117,24 @@
"past_4_hour": "Past 4 hour", "past_4_hour": "Past 4 hour",
"past_hour": "Past 1 hour" "past_hour": "Past 1 hour"
}, },
"upload": {
"delete_confirm": "Are you sure delete the picture?",
"upload_failed": "Upload failed",
"upload_image": "Upload Image"
},
"user": { "user": {
"logout": "Logout" "logout": "Logout"
}, },
"video": { "video": {
"delete_confirm_title": "Are you sure you want to delete this video?",
"delete_confirm": "The video will be deleted.<br/> It can be recovered from the \"News\" page. ", "delete_confirm": "The video will be deleted.<br/> It can be recovered from the \"News\" page. ",
"delete_confirm_count": "These videos will be deleted.<br/> They can be recovered from the \"News\" page. ", "delete_confirm_count": "These videos will be deleted.<br/> They can be recovered from the \"News\" page. ",
"delete_confirm_title": "Are you sure you want to delete this video?",
"delete_description": "Are you sure you want to delete the video?", "delete_description": "Are you sure you want to delete the video?",
"delete_description_count": "Are you sure you want to delete these {{count}} videos?", "delete_description_count": "Are you sure you want to delete these {{count}} videos?",
"delete_empty": "Select the video you want to delete", "delete_empty": "Select the video you want to delete",
"download": "Download", "download": "Download",
"generating": "Generating",
"playing": "Playing",
"push_confirm": "Are you sure you want to streaming these video?", "push_confirm": "Are you sure you want to streaming these video?",
"push_empty": "Select the video you want to streaming", "push_empty": "Select the video you want to streaming",
"push_failed": "some video streaming failed!", "push_failed": "some video streaming failed!",
@ -145,9 +148,6 @@
"title": "Title", "title": "Title",
"title_generated_time": "Time stamp", "title_generated_time": "Time stamp",
"title_operation": "", "title_operation": "",
"title_thumb": "Cover", "title_thumb": "Cover"
"playing": "Playing", }
"generating": "Generating"
},
"history.pushed": "Streaming: {{count}}"
} }

View File

@ -1,12 +1,15 @@
{ {
"AppTitle": "数字人直播", "AppTitle": "数字人直播",
"Hello": "你好", "Hello": "你好",
"cancel": "取消",
"close": "关闭", "close": "关闭",
"confirm": { "confirm": {
"push_title": "推流提示", "push_title": "推流提示",
"push_video": "是否确定一键推流选中新闻视频?", "push_video": "是否确定一键推流选中新闻视频?",
"title": "提示" "title": "提示"
}, },
"confirm_text": "确定",
"delete": "删除",
"delete_batch": "批量删除", "delete_batch": "批量删除",
"delete_failed": "删除失败", "delete_failed": "删除失败",
"delete_success": "删除成功", "delete_success": "删除成功",
@ -20,6 +23,7 @@
"search_key": "请输入视频标题关键字进行信息", "search_key": "请输入视频标题关键字进行信息",
"text": "历史视频" "text": "历史视频"
}, },
"history.pushed": "已推送 {{count}} 条",
"live": { "live": {
"duration": "时长", "duration": "时长",
"edit_locked": "锁定状态不可排序", "edit_locked": "锁定状态不可排序",
@ -51,9 +55,24 @@
"delete_description": "删除后需从新闻素材中重新选择", "delete_description": "删除后需从新闻素材中重新选择",
"delete_description_count": "删除后需从新闻素材中重新选择", "delete_description_count": "删除后需从新闻素材中重新选择",
"delete_empty": "请选择要删除的新闻", "delete_empty": "请选择要删除的新闻",
"delete_the_picture": "请确认删除此图片",
"download_empty": "请选择要下载的新闻", "download_empty": "请选择要下载的新闻",
"download_failed": "下载新闻失败,请重试!", "download_failed": "下载新闻失败,请重试!",
"edit_add_group": "新增分组",
"edit_delete_group": "删除此分组",
"edit_delete_group_confirm": "请确认删除此分组?",
"edit_digital_text": "数字人主播台编辑区",
"edit_form_search": "请输入新闻标题关键词进行搜索", "edit_form_search": "请输入新闻标题关键词进行搜索",
"edit_generate_again": "重新生成",
"edit_generate_video": "生成视频",
"edit_generate_video_again": "重新生成",
"edit_notice_enter_article_content": "请输入正文文本内容",
"edit_notice_enter_article_title": "请输入文章标题",
"edit_notice_enter_article_title1": "请输入标题内容",
"edit_notice_enter_text": "请先填写当前组的内容",
"edit_notice_keep_1": "至少保留一个内容块",
"edit_other_text": "素材融合呈现编辑区",
"edit_save_failed": "保存失败,请重试!",
"editing": "新闻编辑", "editing": "新闻编辑",
"filter_all": "全部", "filter_all": "全部",
"filter_source": "新闻来源", "filter_source": "新闻来源",
@ -80,31 +99,8 @@
"title_operate": "操作", "title_operate": "操作",
"title_time": "时间", "title_time": "时间",
"title_word_count": "字数", "title_word_count": "字数",
"word_count": "字数", "word_count": "字数"
"edit_digital_text": "数字人主播台编辑区",
"edit_other_text": "素材融合呈现编辑区",
"edit_generate_video_again": "重新生成",
"edit_generate_again": "重新生成",
"edit_generate_video": "生成视频",
"edit_save_failed": "保存失败,请重试!",
"edit_notice_keep_1": "至少保留一个内容块",
"edit_notice_enter_text": "请先添加内容",
"edit_notice_enter_article_title": "请输入文章标题",
"edit_notice_enter_article_title1": "请输入标题内容",
"edit_notice_enter_article_content": "请输入正文文本内容",
"edit_add_group": "新增分组",
"edit_delete_group": "删除此分组",
"edit_delete_group_confirm": "请确认删除此分组?",
"delete_the_picture": "请确认删除此图片"
}, },
"upload": {
"upload_failed": "上传图片失败,请重试",
"delete_confirm": "请确认删除此图片?",
"upload_image": "上传图片"
},
"delete": "删除",
"cancel": "取消",
"confirm_text": "确定",
"select": { "select": {
"pushed": "已推送: {{count}} 条", "pushed": "已推送: {{count}} 条",
"select_all": "全选", "select_all": "全选",
@ -121,17 +117,23 @@
"past_4_hour": "四小时内", "past_4_hour": "四小时内",
"past_hour": "一小时内" "past_hour": "一小时内"
}, },
"upload": {
"delete_confirm": "请确认删除此图片?",
"upload_failed": "上传图片失败,请重试",
"upload_image": "上传图片"
},
"user": { "user": {
"logout": "退出登录" "logout": "退出登录"
}, },
"video": { "video": {
"delete_confirm_title": "你确定要删除此视频吗 ",
"delete_confirm": "删除后需重新生成视频", "delete_confirm": "删除后需重新生成视频",
"delete_confirm_count": "删除后需重新生成视频", "delete_confirm_count": "删除后需重新生成视频",
"delete_confirm_title": "你确定要删除此视频吗 ",
"delete_description": "已选择{{count}}条,确定要全部删除吗?", "delete_description": "已选择{{count}}条,确定要全部删除吗?",
"delete_description_count": "已选择{{count}}条,确定要全部删除吗?", "delete_description_count": "已选择{{count}}条,确定要全部删除吗?",
"delete_empty": "请选择要删除的视频", "delete_empty": "请选择要删除的视频",
"download": "下载视频", "download": "下载视频",
"playing": "播放中",
"push_confirm": "是否确定一键推流选中新闻视频?", "push_confirm": "是否确定一键推流选中新闻视频?",
"push_empty": "请选择要推流的新闻视频", "push_empty": "请选择要推流的新闻视频",
"push_failed": "选择视频中有部分视频还在生成中无法推送,推流成功视频前往数字人直播间页面查看!", "push_failed": "选择视频中有部分视频还在生成中无法推送,推流成功视频前往数字人直播间页面查看!",
@ -145,8 +147,6 @@
"title": "标题", "title": "标题",
"title_generated_time": "生成时间", "title_generated_time": "生成时间",
"title_operation": "操作", "title_operation": "操作",
"title_thumb": "缩略图", "title_thumb": "缩略图"
"playing": "播放中" }
},
"history.pushed": "已推送 {{count}} 条"
} }