这个提交包含在:
徐勤民 2024-10-18 18:38:49 +08:00
父节点 bd7ec970f3
当前提交 4b8a70ac7e

查看文件

@ -98,7 +98,7 @@ export class ToolsHelper {
*/ */
static log(...args: ESObject[]) { static log(...args: ESObject[]) {
const k = ToolsHelper.getStackKey()?.split('/') 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 * @param msg
*/ */
static doubleAndExit(event?:()=>void) { static doubleAndExit(event?: () => void) {
const cTime = new Date().getTime() const cTime = new Date().getTime()
console.log('=====>', cTime) console.log('=====>', cTime)
console.log('=====>', cTime - ToolsHelper.oTime) console.log('=====>', cTime - ToolsHelper.oTime)
@ -129,7 +130,7 @@ export class ToolsHelper {
} else { } else {
if (event) { if (event) {
event() event()
}else{ } else {
(getContext() as common.UIAbilityContext).terminateSelf() (getContext() as common.UIAbilityContext).terminateSelf()
// getContext().getApplicationContext().killAllProcesses(); // getContext().getApplicationContext().killAllProcesses();
} }
@ -141,19 +142,22 @@ export class ToolsHelper {
* 弹出Alert弹窗 * 弹出Alert弹窗
* @param options * @param options
*/ */
static showAlertDialog(options: AlertOptions) { static showAlertDialog(
title?: string,
msg?: string,
action?: Btn) {
try { try {
promptAction.showDialog({ promptAction.showDialog({
alignment: 1, alignment: 1,
title: options.title, title: title,
message: options.msg, message: msg,
buttons: [{ buttons: [{
text: options.action.text ?? "确定", text: action?.text ?? "确定",
color: options.action.color ?? "#000000", color: action?.color ?? "#000000",
}] }]
}) })
.then(() => { .then(() => {
options.action.onClick() action?.onClick()
}) })
.catch((err: Error) => { .catch((err: Error) => {
ToolsHelper.showMessage(err.message) ToolsHelper.showMessage(err.message)