From 3b87dce4fa64c1e4069f724bd0fc55fa1c0bd4e9 Mon Sep 17 00:00:00 2001 From: fofolee Date: Sat, 2 Apr 2022 01:06:47 +0800 Subject: [PATCH] quickcommand.showConfirmBox --- src/js/quickcommand.js | 23 +++++++++++++++---- .../monaco/types/quickcommand.api.d.ts | 3 ++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/js/quickcommand.js b/src/js/quickcommand.js index 6685c51..8c65c1b 100644 --- a/src/js/quickcommand.js +++ b/src/js/quickcommand.js @@ -9,7 +9,6 @@ import { } from 'quasar' import inputBox from "../components/InputBox" -console.log(Notify); let showInputBox = (options = [], title = "") => { return new Promise((reslove, reject) => { @@ -28,12 +27,25 @@ let showInputBox = (options = [], title = "") => { reslove(Array.from(results)) }).onCancel(() => { console.log('取消') - }).onDismiss(() => { - console.log('对话框被关闭') }) }) }; +let showConfirmBox = (message = "", title = "提示") => { + return new Promise((reslove, reject) => { + Dialog.create({ + title: title, + message: message, + cancel: true, + persistent: true + }).onOk(() => { + reslove(true) + }).onCancel(() => { + reslove(false) + }) + }) +} + let showMessageBox = (message, icon = 'success', time = 3000) => { if (icon === 'success') icon = 'positive' if (icon === 'error') icon = 'negative' @@ -44,7 +56,10 @@ let showMessageBox = (message, icon = 'success', time = 3000) => { position: 'top', }) } + + export default { showInputBox, - showMessageBox + showMessageBox, + showConfirmBox }; diff --git a/src/plugins/monaco/types/quickcommand.api.d.ts b/src/plugins/monaco/types/quickcommand.api.d.ts index fe0b2f1..a8d87c4 100644 --- a/src/plugins/monaco/types/quickcommand.api.d.ts +++ b/src/plugins/monaco/types/quickcommand.api.d.ts @@ -133,9 +133,10 @@ interface quickcommandApi { * confirmed && console.log('点击了确定') * }) * ``` + * @param message 提示的内容 * @param title 提示的标题 */ - showConfirmBox(title?: string): Promise; + showConfirmBox(message?: string, title?: string): Promise; /** * 同步等待,会阻塞进程