🐛 feat: 新增 disableRemoveMessage 属性以控制删除提示信息

This commit is contained in:
LittleBoy 2025-03-02 12:24:50 +08:00
parent 496192061f
commit 54056aec3a
2 changed files with 6 additions and 3 deletions

View File

@ -16,6 +16,7 @@ type Props = {
blocks: BlockContent[];
editable?: boolean;
onChange?: (blocks: BlockContent[]) => void;
disableRemoveMessage?:string;
onRemove?: () => void;
onAdd?: (index:number,checkIndex:number) => void;
errorMessage?: string;
@ -46,6 +47,7 @@ export default function ArticleBlock(
blocks: defaultBlocks,
editable,
onRemove,
disableRemoveMessage,
onAdd,
onChange,
index,
@ -80,7 +82,7 @@ export default function ArticleBlock(
</div>
{editable && <div className="ml-2 flex items-center">
{
index > 0 ? <Popconfirm
disableRemoveMessage? <span></span> : <Popconfirm
rootClassName={'popconfirm-main'}
placement={'left'}
arrow={false}
@ -93,7 +95,7 @@ export default function ArticleBlock(
<span className="article-action-icon hidden group-hover:block ml-1" title={t('news.edit_delete_group')}>
<IconDelete style={{fontSize: 24}}/>
</span>
</Popconfirm> : <span></span>
</Popconfirm>
}
</div>}
</div>

View File

@ -93,8 +93,9 @@ export default function ArticleGroup({groups, editable, onChange, errorMessage}:
onAdd={(_index,checkIndex) => {
handleAddGroup?.(_index ? _index :index + 1,checkIndex)
}}
disableRemoveMessage={groups.length <= 2?t('news.edit_notice_keep_1'):''}
onRemove={async () => {
if (groups.length == 1) {
if (groups.length <= 2) {
message.warning(t('news.edit_notice_keep_1'))
return;
}