|
@@ -176,34 +176,37 @@ export class ToolsHelper {
|
|
|
* 弹出Confirm弹窗
|
|
|
* @param options
|
|
|
*/
|
|
|
- static showConfirmDialog(options: ConfirmOptions) {
|
|
|
- try {
|
|
|
- promptAction.showDialog({
|
|
|
- alignment: 1,
|
|
|
- title: options.title,
|
|
|
- message: options.msg,
|
|
|
- buttons: [{
|
|
|
- text: options.confirm?.text ?? "确定",
|
|
|
- color: options.confirm?.color ?? "#000000",
|
|
|
- }, {
|
|
|
- text: options.cancel?.text ?? "取消",
|
|
|
- color: options.cancel?.color ?? "#666666",
|
|
|
- }]
|
|
|
- })
|
|
|
- .then((data) => {
|
|
|
- if (data.index === 0) {
|
|
|
- options.confirm?.onClick && options.confirm.onClick()
|
|
|
- } else {
|
|
|
- options.cancel?.onClick && options.cancel.onClick()
|
|
|
- }
|
|
|
+ static showConfirmDialog(options: ConfirmOptions): Promise<void> {
|
|
|
+ return new Promise((reject) => {
|
|
|
+ try {
|
|
|
+ promptAction.showDialog({
|
|
|
+ alignment: 1,
|
|
|
+ title: options.title,
|
|
|
+ message: options.msg,
|
|
|
+ buttons: [{
|
|
|
+ text: options.confirm?.text ?? "确定",
|
|
|
+ color: options.confirm?.color ?? "#000000",
|
|
|
+ }, {
|
|
|
+ text: options.cancel?.text ?? "取消",
|
|
|
+ color: options.cancel?.color ?? "#666666",
|
|
|
+ }]
|
|
|
})
|
|
|
- .catch((err: Error) => {
|
|
|
- ToolsHelper.showMessage(err.message)
|
|
|
- })
|
|
|
- } catch (error) {
|
|
|
- let message = (error as BusinessError).message
|
|
|
- ToolsHelper.showMessage(message)
|
|
|
- }
|
|
|
+ .then((data) => {
|
|
|
+ if (data.index === 0) {
|
|
|
+ options.confirm?.onClick && options.confirm.onClick()
|
|
|
+ } else {
|
|
|
+ options.cancel?.onClick && options.cancel.onClick()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err: Error) => {
|
|
|
+ ToolsHelper.showMessage(err.message)
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ reject()
|
|
|
+ let message = (error as BusinessError).message
|
|
|
+ ToolsHelper.showMessage(message)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
public static mapDialog = new HashMap<string, number>()
|
|
@@ -345,7 +348,7 @@ export class ToolsHelper {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private static getUniqueId(fun: Function): string {
|
|
|
+ static getUniqueId(fun: Function): string {
|
|
|
if (!ToolsHelper.uniqueIdMap.has(fun)) {
|
|
|
ToolsHelper.uniqueIdMap.set(fun, ToolsHelper.getUuid());
|
|
|
}
|