fix: 修复弹窗修改可能的报错 (#9801)

This commit is contained in:
liaoxuezhi 2024-03-14 16:02:32 +08:00 committed by GitHub
parent e4230031ee
commit 9f027928f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 33 additions and 4 deletions

View File

@ -40,16 +40,17 @@ export default observer(function DialogList({
const handleEditDialog = React.useCallback((event: React.UIEvent<any>) => {
const index = parseInt(event.currentTarget.getAttribute('data-index')!, 10);
const dialog = store.modals[index];
const modal = store.modals[index];
const modalId = modal.$$id!;
store.openSubEditor({
title: '编辑弹窗',
value: {
type: 'dialog',
...(dialog as any),
...(modal as any),
definitions: modalsToDefinitions(store.modals)
},
onChange: ({definitions, ...modal}: any, diff: any) => {
store.updateModal(dialog.$$id!, modal, definitions);
store.updateModal(modalId, modal, definitions);
}
});
}, []);

View File

@ -609,6 +609,18 @@ function DialogActionPanel({
renderMenu={renderMenu}
/>
{currentModal &&
modals.some(
modal =>
modal.isCurrentActionModal &&
!modal.isNew &&
currentModal !== modal
) ? (
<div className={cx('Alert Alert--warning mt-3')}>
</div>
) : null}
{currentModal ? (
<div className="m-t-sm">
<Button size="sm" level="enhance" onClick={handleDialogEdit}>

View File

@ -320,6 +320,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
e.preventDefault();
e.stopPropagation();
const modalId = modal.$$id;
store.openSubEditor({
title: '编辑弹窗',
value: {
@ -328,7 +329,7 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
definitions: modalsToDefinitions(store.modals)
},
onChange: ({definitions, ...modal}: any, diff: any) => {
store.updateModal(modal.$$id!, modal, definitions);
store.updateModal(modalId, modal, definitions);
}
});
}}
@ -344,6 +345,21 @@ export const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
</div>
</>
);
} else if (Array.isArray(info.__actionModals)) {
const modal = info.__actionModals.find((item: any) => item.isActive);
if (modal) {
// 这个时候还不能打开弹窗schema 还没插入进去不知道 $$id无法定位
return (
<>
<div>
<span className="variable-left">{modal.label}</span>
&nbsp;
{modal.tip}
</div>
</>
);
}
}
return null;