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

View File

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