From 4b8a70ac7e1715effd8f950b05651ffa10aa14de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Fri, 18 Oct 2024 18:38:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/ets/utils/ToolsHelper.ets | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/ets/utils/ToolsHelper.ets b/src/main/ets/utils/ToolsHelper.ets index c5b10b9..94436a6 100644 --- a/src/main/ets/utils/ToolsHelper.ets +++ b/src/main/ets/utils/ToolsHelper.ets @@ -98,7 +98,7 @@ export class ToolsHelper { */ static log(...args: ESObject[]) { const k = ToolsHelper.getStackKey()?.split('/') - console.log(`========>${k?k[k.length-1].split('.')[0]:''}::`, args,'\n') + console.log(`========>${k ? k[k.length-1].split('.')[0] : ''}::`, args, '\n') } /** @@ -114,12 +114,13 @@ export class ToolsHelper { } - private static oTime: number = 0 + private static oTime: number = 0 + /** * 双击退出 * @param msg */ - static doubleAndExit(event?:()=>void) { + static doubleAndExit(event?: () => void) { const cTime = new Date().getTime() console.log('=====>', cTime) console.log('=====>', cTime - ToolsHelper.oTime) @@ -129,7 +130,7 @@ export class ToolsHelper { } else { if (event) { event() - }else{ + } else { (getContext() as common.UIAbilityContext).terminateSelf() // getContext().getApplicationContext().killAllProcesses(); } @@ -141,19 +142,22 @@ export class ToolsHelper { * 弹出Alert弹窗 * @param options */ - static showAlertDialog(options: AlertOptions) { + static showAlertDialog( + title?: string, + msg?: string, + action?: Btn) { try { promptAction.showDialog({ alignment: 1, - title: options.title, - message: options.msg, + title: title, + message: msg, buttons: [{ - text: options.action.text ?? "确定", - color: options.action.color ?? "#000000", + text: action?.text ?? "确定", + color: action?.color ?? "#000000", }] }) .then(() => { - options.action.onClick() + action?.onClick() }) .catch((err: Error) => { ToolsHelper.showMessage(err.message)