|
@@ -7,7 +7,7 @@ import { md5_hex } from '../util/md5';
|
|
import { GlobalContext, LogHelper } from '../../../../Index';
|
|
import { GlobalContext, LogHelper } from '../../../../Index';
|
|
import { ComponentContent } from '@kit.ArkUI';
|
|
import { ComponentContent } from '@kit.ArkUI';
|
|
|
|
|
|
-class AlertBean {
|
|
|
|
|
|
+export class AlertBean {
|
|
options: ConfirmOptions
|
|
options: ConfirmOptions
|
|
dialogTag: string
|
|
dialogTag: string
|
|
|
|
|
|
@@ -35,6 +35,7 @@ export interface ConfirmOptions {
|
|
msg?: string
|
|
msg?: string
|
|
confirm?: Btn
|
|
confirm?: Btn
|
|
cancel?: Btn
|
|
cancel?: Btn
|
|
|
|
+ autoCancel?: boolean
|
|
}
|
|
}
|
|
|
|
|
|
export interface ListOptions<T> {
|
|
export interface ListOptions<T> {
|
|
@@ -304,13 +305,18 @@ export class ToolsHelper {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 弹出Alert弹窗
|
|
* 弹出Alert弹窗
|
|
|
|
+ * 第二个参数可以自定义布局,自定义布局接收的参数为AlertBean
|
|
|
|
+ * @Builder
|
|
|
|
+ * function alertDialogBuilder(options: AlertBean) {}
|
|
|
|
+ *
|
|
* @param options
|
|
* @param options
|
|
|
|
+ * @param builder wrapBuilder(alertDialogBuilder)
|
|
*/
|
|
*/
|
|
- static showAlertDialog(options: AlertOptions) {
|
|
|
|
|
|
+ static showAlertDialog(options: AlertOptions, builder?: WrappedBuilder<[Object]>) {
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const ui = GlobalContext.getUiContext()
|
|
const ui = GlobalContext.getUiContext()
|
|
if (ui) {
|
|
if (ui) {
|
|
- const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
|
|
|
|
|
+ const c = new ComponentContent(ui, builder ?? wrapBuilder(alertDialogBuilder),
|
|
new AlertBean({ title: options.title, msg: options.msg, confirm: options.action }, dialogTag))
|
|
new AlertBean({ title: options.title, msg: options.msg, confirm: options.action }, dialogTag))
|
|
ui.getPromptAction().openCustomDialog(c, {
|
|
ui.getPromptAction().openCustomDialog(c, {
|
|
autoCancel: false
|
|
autoCancel: false
|
|
@@ -352,14 +358,19 @@ export class ToolsHelper {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 弹出Confirm弹窗
|
|
* 弹出Confirm弹窗
|
|
|
|
+ * 第二个参数可以自定义布局,自定义布局接收的参数为AlertBean
|
|
|
|
+ * @Builder
|
|
|
|
+ * function alertDialogBuilder(options: AlertBean) {}
|
|
|
|
+ *
|
|
* @param options
|
|
* @param options
|
|
|
|
+ * @param builder wrapBuilder(alertDialogBuilder)
|
|
*/
|
|
*/
|
|
- static showConfirmDialog(options: ConfirmOptions) {
|
|
|
|
|
|
+ static showConfirmDialog(options: ConfirmOptions, builder?: WrappedBuilder<[Object]>) {
|
|
|
|
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const ui = GlobalContext.getUiContext()
|
|
const ui = GlobalContext.getUiContext()
|
|
if (ui) {
|
|
if (ui) {
|
|
- const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
|
|
|
|
|
+ const c = new ComponentContent(ui, builder ?? wrapBuilder(alertDialogBuilder),
|
|
new AlertBean({
|
|
new AlertBean({
|
|
title: options.title,
|
|
title: options.title,
|
|
msg: options.msg,
|
|
msg: options.msg,
|
|
@@ -367,7 +378,7 @@ export class ToolsHelper {
|
|
confirm: options.confirm
|
|
confirm: options.confirm
|
|
}, dialogTag))
|
|
}, dialogTag))
|
|
ui.getPromptAction().openCustomDialog(c, {
|
|
ui.getPromptAction().openCustomDialog(c, {
|
|
- autoCancel: false
|
|
|
|
|
|
+ autoCancel: options.autoCancel
|
|
}).then(() => {
|
|
}).then(() => {
|
|
ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
|
ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
|
}).catch(() => {
|
|
}).catch(() => {
|