refactor(FormBuilder): 重命名变量以提高代码可读性

- 保持原有逻辑不变,仅优化命名规范
master
LiuJiaNan 2026-04-24 17:36:51 +08:00
parent 02f4401c5a
commit 5268ca8e10
1 changed files with 6 additions and 6 deletions

View File

@ -526,17 +526,17 @@ const FormItemsRenderer = ({
return renderFormList(params); return renderFormList(params);
// 判断一个项是否需要显示按钮(不是 onlyForLabel 且不是隐藏的) // 判断一个项是否需要显示按钮(不是 onlyForLabel 且不是隐藏的)
const isShowButton = (opt) => { const isShow = (opt) => {
return !getHidden(opt.hidden) && !opt.onlyForLabel; return !getHidden(opt.hidden) && !opt.onlyForLabel;
}; };
// 从后往前找,找到第一个需要显示按钮的项的索引 // 从后往前找,找到第一个需要显示按钮的项的索引
const findLastButtonIndex = () => { const findLastShowIndex = () => {
for (let i = listOptions.length - 1; i >= 0; i--) { for (let i = listOptions.length - 1; i >= 0; i--) {
const opt = listOptions[i]; const opt = listOptions[i];
if (opt.render === FORM_ITEM_RENDER_ENUM.FORM_LIST) if (opt.render === FORM_ITEM_RENDER_ENUM.FORM_LIST)
return i; return i;
if (isShowButton(opt)) if (isShow(opt))
return i; return i;
} }
return -1; return -1;
@ -545,11 +545,11 @@ const FormItemsRenderer = ({
// 判断下一个是否是嵌套的 FormList或者是 onlyForLabel/hidden 项 // 判断下一个是否是嵌套的 FormList或者是 onlyForLabel/hidden 项
const nextOption = listOptions[listIndex + 1]; const nextOption = listOptions[listIndex + 1];
const isNextNestedFormList = nextOption && nextOption.render === FORM_ITEM_RENDER_ENUM.FORM_LIST; const isNextNestedFormList = nextOption && nextOption.render === FORM_ITEM_RENDER_ENUM.FORM_LIST;
const isNextNoButton = nextOption && !isShowButton(nextOption); const isNextNoShow = nextOption && !isShow(nextOption);
// 如果是最后一个需要显示按钮的项,或者下一个是嵌套的 FormList或者下一个不需要按钮则在其后添加操作按钮 // 如果是最后一个需要显示按钮的项,或者下一个是嵌套的 FormList或者下一个不需要按钮则在其后添加操作按钮
const lastButtonIndex = findLastButtonIndex(); const lastShowIndex = findLastShowIndex();
if (listIndex === lastButtonIndex || isNextNestedFormList || isNextNoButton) { if (listIndex === lastShowIndex || isNextNestedFormList || isNextNoShow) {
delete formItemProps.dependencies; delete formItemProps.dependencies;
delete formItemProps.shouldUpdate; delete formItemProps.shouldUpdate;
return ( return (