From e9d4f121ac1ef07fc14e6bd5b21ae2712c8491d9 Mon Sep 17 00:00:00 2001 From: surunzi Date: Sat, 7 Oct 2023 11:27:49 +0800 Subject: [PATCH] release(modal): v1.2.1 --- index.json | 2 +- src/modal/CHANGELOG.md | 4 ++++ src/modal/README.md | 2 +- src/modal/index.ts | 37 ++++++++++++++++++++----------------- src/modal/package.json | 2 +- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/index.json b/index.json index 071e060..5b9dcb0 100644 --- a/index.json +++ b/index.json @@ -191,7 +191,7 @@ "modal": { "react": true, "icon": true, - "version": "1.2.0", + "version": "1.2.1", "style": true, "test": true, "install": false, diff --git a/src/modal/CHANGELOG.md b/src/modal/CHANGELOG.md index 1b55cb7..707e7ea 100644 --- a/src/modal/CHANGELOG.md +++ b/src/modal/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.1 (7 Oct 2023) + +* fix: alert promise + ## 1.2.0 (25 Sep 2023) * feat: i18n diff --git a/src/modal/README.md b/src/modal/README.md index 6ced644..a072691 100644 --- a/src/modal/README.md +++ b/src/modal/README.md @@ -57,7 +57,7 @@ Hide the modal. Show the modal. -### static alert(msg: string): void +### static alert(msg: string): Promise Like `window.alert`. diff --git a/src/modal/index.ts b/src/modal/index.ts index 528c2d0..896e644 100644 --- a/src/modal/index.ts +++ b/src/modal/index.ts @@ -88,26 +88,29 @@ export default class Modal extends Component { * Like `window.alert`. * @static */ - static alert(msg: string) { - const modal = getGlobalModal() - const { c } = modal - modal.setOption({ - title: '', - content: msg, - width: getDefaultWidth(), - footer: createButtons( - { - [Modal.i18n.t('ok')]: { - type: 'primary', - onclick() { - modal.hide() + static alert(msg: string): Promise { + return new Promise((resolve) => { + const modal = getGlobalModal() + const { c } = modal + modal.setOption({ + title: '', + content: msg, + width: getDefaultWidth(), + footer: createButtons( + { + [Modal.i18n.t('ok')]: { + type: 'primary', + onclick() { + modal.hide() + resolve() + }, }, }, - }, - c - ), + c + ), + }) + modal.show() }) - modal.show() } /** * Like `window.confirm`. diff --git a/src/modal/package.json b/src/modal/package.json index 8dc7064..2c42c5e 100644 --- a/src/modal/package.json +++ b/src/modal/package.json @@ -1,6 +1,6 @@ { "name": "modal", - "version": "1.2.0", + "version": "1.2.1", "description": "Create modal dialogs", "luna": { "react": true,