|
@@ -0,0 +1,28 @@
|
|
|
+const {dialog} = require('electron');
|
|
|
+const obj = {};
|
|
|
+
|
|
|
+obj.messagePromise = function(title, content, type = '', buttons = ['Ok'], defaultButton = 0, attach = true) {
|
|
|
+ const opts = {
|
|
|
+ type: type,
|
|
|
+ title: title,
|
|
|
+ message: content,
|
|
|
+ buttons: buttons,
|
|
|
+ defaultId: defaultButton
|
|
|
+ };
|
|
|
+ if (attach) {
|
|
|
+ return dialog.showMessageBox(mainWindow, opts);
|
|
|
+ } else {
|
|
|
+ return dialog.showMessageBox(opts);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+obj.message = function(title, content, type = 'info', buttons = ['Ok'], defaultButton = 0, attach = true, callback = null) {
|
|
|
+ const promise = obj.messagePromise(title, content, type, buttons, defaultButton, attach);
|
|
|
+ if (callback !== null) {
|
|
|
+ promise.then(data => {
|
|
|
+ callback(data.response, buttons[data.response]);
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+module.exports = obj;
|