From 6c75950b6aca5808e0b1a092bee5d67cfa154694 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 25 Apr 2021 11:54:23 +0800 Subject: [PATCH] feat: jump to page after successful form submission --- .../app/src/components/pages/Page/index.tsx | 71 +++++++++++-------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/packages/app/src/components/pages/Page/index.tsx b/packages/app/src/components/pages/Page/index.tsx index 5d7378ed9..aae9e5d74 100644 --- a/packages/app/src/components/pages/Page/index.tsx +++ b/packages/app/src/components/pages/Page/index.tsx @@ -76,41 +76,50 @@ export function Page(props: any) { message.success('草稿保存成功'); return; } - if ( - view.draft.returnType === 'message' && - view.draft.message - ) { - Modal.success({ - title: '草稿保存成功', - content: ( -
- ), - }); - } else if (view.draft.returnType === 'redirect') { - const path = get(view, 'draft.redirect.name'); - path && history.push(`${path}`); + if (!view.draft.message) { + return; } + Modal.success({ + title: '草稿保存成功', + content: ( +
+ ), + onCancel: () => { + const path = get(view, 'redirect.name'); + path && history.push(`${path}`); + }, + onOk: () => { + const path = get(view, 'redirect.name'); + path && history.push(`${path}`); + }, + }); }} onFinish={() => { - if (view.returnType === 'message' && view.message) { - Modal.success({ - title: '提交成功', - content: ( -
- ), - }); - } else if (view.returnType === 'redirect') { - const path = get(view, 'redirect.name'); - path && history.push(`${path}`); + if (!view.message) { + return; } + Modal.success({ + title: '提交成功', + content: ( +
+ ), + onOk: () => { + const path = get(view, 'redirect.name'); + path && history.push(`${path}`); + }, + onCancel: () => { + const path = get(view, 'redirect.name'); + path && history.push(`${path}`); + }, + }); }} viewName={viewName} />