From 398b4d512cf98ae68133b424ca722053b05733e1 Mon Sep 17 00:00:00 2001 From: hanyuxinting Date: Fri, 28 Feb 2025 18:57:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20dialog=20=E5=9C=A8=E9=B8=BF=E8=92=99?= =?UTF-8?q?=E4=B8=8B=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/dialog/dialog.scss | 7 +- src/packages/dialog/dialog.taro.tsx | 165 +++++++++++++++++----------- src/packages/dialog/dialog.tsx | 1 + 3 files changed, 101 insertions(+), 72 deletions(-) diff --git a/src/packages/dialog/dialog.scss b/src/packages/dialog/dialog.scss index 0aed9a8a87..5dcbc5194a 100644 --- a/src/packages/dialog/dialog.scss +++ b/src/packages/dialog/dialog.scss @@ -8,7 +8,9 @@ align-items: center; width: $dialog-width; min-width: $dialog-min-width; + /* #ifndef harmony*/ max-height: 67%; + /* #endif */ min-height: $dialog-min-height; padding: $dialog-padding; box-sizing: border-box; @@ -112,15 +114,10 @@ min-width: 100%; } - .nut-dialog-footer-ok { - order: 1; - } - .nut-dialog-footer-cancel { margin: 0; color: $color-text; font-size: $font-size-base; - order: 2; display: flex; justify-content: center; margin-top: $dialog-vertical-footer-ok-margin-top; diff --git a/src/packages/dialog/dialog.taro.tsx b/src/packages/dialog/dialog.taro.tsx index 9f14971362..328399ed47 100644 --- a/src/packages/dialog/dialog.taro.tsx +++ b/src/packages/dialog/dialog.taro.tsx @@ -122,43 +122,68 @@ export const BaseDialog: FunctionComponent> & { const btnClass = hideCancelButton || hideConfirmButton ? `${classPrefix}-footer-block` : '' + const renderCancelOfVertical = () => { + return ( + !hideCancelButton && ( + handleCancel(e)} + > + {cancelText || locale.cancel} + + ) + ) + } + + const renderCancel = () => { + return ( + !hideCancelButton && ( + + ) + ) + } + + const renderConfirm = () => { + return ( + !hideConfirmButton && ( + + ) + ) + } + return ( footer || ( <> - {!hideCancelButton && - (footerDirection === 'vertical' ? ( - handleCancel(e)} - > - {cancelText || locale.cancel} - - ) : ( - - ))} - - {!hideConfirmButton && ( - + {footerDirection === 'vertical' ? ( + <> + {renderConfirm()} + {renderCancelOfVertical()} + + ) : ( + <> + {renderCancel()} + {renderConfirm()} + )} ) @@ -193,46 +218,52 @@ export const BaseDialog: FunctionComponent> & { } } + const renderContent = () => { + return ( + + + {content || children} + + + ) + } + return ( - <> - {overlay && ( - - )} - - - - {content || children} - - - + {renderContent()} + + ) : ( + renderContent() + )} ) } diff --git a/src/packages/dialog/dialog.tsx b/src/packages/dialog/dialog.tsx index c049d16c61..e1bb241f5d 100644 --- a/src/packages/dialog/dialog.tsx +++ b/src/packages/dialog/dialog.tsx @@ -93,6 +93,7 @@ const BaseDialog: ForwardRefRenderFunction< {!hideCancelButton && (footerDirection === 'vertical' ? (
handleCancel(e)} >