From 9ab9e1973c79defa0fe7e1386af98e02fe748f74 Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Wed, 27 Mar 2019 16:38:15 +0800 Subject: [PATCH] Finished: guiApi.showMessageBox --- src/main/utils/guiApi.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/utils/guiApi.js b/src/main/utils/guiApi.js index cc0066b..d280ae2 100644 --- a/src/main/utils/guiApi.js +++ b/src/main/utils/guiApi.js @@ -87,19 +87,39 @@ class GuiApi { * For notification * @param {Object} options */ - showNotification (options) { - if (options === undefined) { - options = { - title: '', - body: '' - } - } + showNotification (options = { + title: '', + body: '' + }) { const notification = new Notification({ title: options.title, body: options.body }) notification.show() } + + /** + * + * @param {Object} options + */ + showMessageBox (options = { + title: '', + message: '', + type: 'info', + buttons: ['Yes', 'No'] + }) { + return new Promise((resolve, reject) => { + dialog.showMessageBox( + BrowserWindow.fromWebContents(this[WEBCONTENTS]), + options, + (result, checkboxChecked) => { + resolve({ + result, + checkboxChecked + }) + }) + }) + } } export default GuiApi