From ecf7bf72381a675bd7f39428f909872c6a50647d Mon Sep 17 00:00:00 2001 From: Hacker_DL Date: Thu, 17 Jul 2025 04:46:52 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E3=80=81=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hacker_DL --- .../main/ets/view/CustomDialogComponent.ets | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/entry/src/main/ets/view/CustomDialogComponent.ets b/entry/src/main/ets/view/CustomDialogComponent.ets index ed13227..38150c1 100644 --- a/entry/src/main/ets/view/CustomDialogComponent.ets +++ b/entry/src/main/ets/view/CustomDialogComponent.ets @@ -19,16 +19,25 @@ import CommonConstants from '../common/constants/CommonConstants'; import { GlobalContext } from '../common/utils/GlobalContext'; /** + * 自定义弹窗 * Custom pop-up window. */ +// 启动页的隐私协议内容,需要用到自定义弹窗展示。 +// The privacy policy content on the LauncherPage needs to be presented using a custom popup. @CustomDialog export default struct CustomDialogComponent { - controller: CustomDialogController = new CustomDialogController({'builder': ''}); - cancel: Function = () => {}; - confirm: Function = () => {}; + controller: CustomDialogController = new CustomDialogController({ 'builder': '' }); + // 点击不同意按钮的事件回调 + cancel: Function = () => { + }; + // 点击同意按钮的事件回调 + confirm: Function = () => { + }; build() { Column() { + // 自定义弹窗标题 + // Title of CustomDialog Text($r('app.string.dialog_text_title')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_color')) @@ -39,9 +48,13 @@ export default struct CustomDialogComponent { top: $r('app.float.dialog_text_privacy_top'), bottom: $r('app.float.dialog_text_privacy_bottom') }) + // 自定义弹窗内容 + // Content of CustomDialog Text($r('app.string.dialog_text_privacy_content')) .fontSize($r('app.float.dialog_common_text_size')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) + // 协议链接 + // Link of Agreement Text($r('app.string.dialog_text_privacy_statement')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_statement_color')) @@ -56,6 +69,7 @@ export default struct CustomDialogComponent { Logger.error(CommonConstants.CUSTOM_DIALOG_TAG, 'CustomDialog pushUrl error ' + JSON.stringify(error)); }); }) + // 隐私协议声明 Text($r('app.string.dialog_text_declaration_prompt')) .width(CommonConstants.DIALOG_COMPONENT_WIDTH_PERCENT) .fontColor($r('app.color.dialog_text_color')) @@ -63,6 +77,7 @@ export default struct CustomDialogComponent { .opacity($r('app.float.dialog_text_opacity')) .margin({ bottom: $r('app.float.dialog_text_declaration_bottom') }) Row() { + // 取消按钮 Text($r('app.string.dialog_button_disagree')) .fancy() .onClick(() => { @@ -73,6 +88,7 @@ export default struct CustomDialogComponent { .backgroundColor($r('app.color.dialog_blank_background_color')) .width($r('app.float.dialog_blank_width')) .height($r('app.float.dialog_blank_height')) + // 同意按钮 Text($r('app.string.dialog_button_agree')) .fancy() .onClick(() => { @@ -88,8 +104,10 @@ export default struct CustomDialogComponent { } } +// 按钮公共样式抽取 // Common text styles. -@Extend(Text) function fancy () { +@Extend(Text) +function fancy() { .fontColor($r("app.color.dialog_fancy_text_color")) .fontSize($r("app.float.dialog_fancy_text_size")) .textAlign(TextAlign.Center) -- Gitee