<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: 桃花镇童长老</title>
    <description>The latest articles on DEV Community by 桃花镇童长老 (@787107497).</description>
    <link>https://dev.to/787107497</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3278289%2Fa6f6ca12-1463-45c0-9d37-9c9d205f37dd.png</url>
      <title>DEV Community: 桃花镇童长老</title>
      <link>https://dev.to/787107497</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/787107497"/>
    <language>en</language>
    <item>
      <title>HarmonyOS application one click graying guide</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:57:04 +0000</pubDate>
      <link>https://dev.to/787107497/one-click-graying-is-usually-used-in-the-following-scenarios-2dk4</link>
      <guid>https://dev.to/787107497/one-click-graying-is-usually-used-in-the-following-scenarios-2dk4</guid>
      <description>&lt;h2&gt;
  
  
  One-click graying is usually used in the following scenarios
&lt;/h2&gt;

&lt;h6&gt;
  
  
  1. Major memorial activities:
&lt;/h6&gt;

&lt;p&gt;In special times such as major disasters, accidents or memorial days in the country, in order to express respect and condolences for the deceased, many APPs will put the interface in the dust. For example, after some earthquakes, air crashes and other disasters, as well as during national mourning days, a large number of APPs will respond to the call to put aside one-click dust. This is not only an emotional expression, but also a reflection of the social responsibility of enterprises and platforms.&lt;/p&gt;

&lt;h6&gt;
  
  
  2. Special anniversary or themed event:
&lt;/h6&gt;

&lt;p&gt;For certain anniversary events with special significance, the APP may choose a gray interface to create a specific atmosphere. For example, on days related to historical events such as the Victory Anniversary of the Anti-Fascist War, some historical and cultural apps or related topics may guide users to pay attention and remember these important moments by putting them in the dust.&lt;/p&gt;

&lt;h6&gt;
  
  
  3. Simulate special visual effects or user experience scenarios:
&lt;/h6&gt;

&lt;p&gt;In some specific application scenarios, in order to bring a unique visual experience to the user or simulate a specific situation, the APP will use the graying function. For example, in some movies and TV series promotional apps, in order to create a nostalgic, retro or specific plot atmosphere, the interface may be placed in one click, making the user feel like he is in a specific era background; or in some game apps, specific levels or scenes may need to be placed in gray to increase the mystery, tension or highlight specific elements of the game.&lt;/p&gt;

&lt;h6&gt;
  
  
  4. System or APP maintenance and upgrade:
&lt;/h6&gt;

&lt;p&gt;When the APP is maintained, upgraded or failed, in order to clearly prompt the user for unavailability of the APP, the interface may be grayed out and relevant maintenance prompts are displayed. This can prevent users from continuing to operate without knowing it, reduce users' confusion and dissatisfaction, and also facilitate the development team to carry out maintenance work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation plan
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Component common attribute grayscale
&lt;/h3&gt;

&lt;p&gt;grayscale(value: number) Adds a grayscale effect to the component.&lt;br&gt;
value, adds a grayscale effect to the current component. The value is defined as the ratio of grayscale conversion. If the parameter is 1.0, it will be completely converted to a grayscale image. If the parameter is 0.0, the image will not change. When the parameter is between 0.0 and 1.0, the effect will change linearly. (Percent); Default value: 0.0; Value range: [0.0, 1.0]; Description: When setting a value less than 0.0, it is processed as 0.0, and when setting a value greater than 1.0, it is processed as 1.0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nc"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$r&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app.media.image&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;width&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;90%&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;height&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;grayscale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nc"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;$r&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app.media.image&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)).&lt;/span&gt;&lt;span class="nf"&gt;width&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;90%&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;height&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;grayscale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;为组件添加灰度效果&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;fontColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xFF0000&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;grayscale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Encapsulate a common graying component, which is wrapped with all pages.
&lt;/h6&gt;

&lt;h3&gt;
  
  
  2. Window properties setWindowGrayScale
&lt;/h3&gt;

&lt;p&gt;setWindowGrayScale(grayScale: number): Promise&lt;br&gt;
Set window grayscale and use Promise asynchronous callback. This interface needs to be called after calling loadContent() or setUIContent() to make the window load the page content.&lt;br&gt;
grayScale, window grayscale. This parameter is a floating point number and takes the value range [0.0, 1.0]. 0.0 means that the window image has no change, 1.0 means that the window image is completely converted to a grayscale image, and the effect changes linearly from 0.0 to 1.0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BusinessError&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@kit.BasicServicesKit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;windowClass&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;setUIContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pages/Index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BusinessError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Failed to set the content. Cause code: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Succeeded in setting the content.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="na"&gt;grayScale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;canIUse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;SystemCapability.Window.SessionManager&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;windowClass&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;setWindowGrayScale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;grayScale&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;info&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Succeeded in setting the grayScale.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="na"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BusinessError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Failed to set the grayScale. Cause code: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, message: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exception&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Failed to set the grayScale. Cause code: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;exception&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, message: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;exception&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Use the tool library&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Call the tool class method, AppUtil.setGrayScale(1);&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;AppUtil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setGrayScale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//设置灰度0.7&lt;/span&gt;
&lt;span class="nx"&gt;AppUtil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setGrayScale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//设置全灰&lt;/span&gt;
&lt;span class="nx"&gt;AppUtil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setGrayScale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//只置灰主窗口&lt;/span&gt;

&lt;span class="nx"&gt;AppUtil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setGrayScale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//取消置灰&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>harmony</category>
      <category>arkts</category>
    </item>
    <item>
      <title>harmony-utils</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:49:59 +0000</pubDate>
      <link>https://dev.to/787107497/harmony-utils-5gpl</link>
      <guid>https://dev.to/787107497/harmony-utils-5gpl</guid>
      <description>&lt;h1&gt;
  
  
  harmony-utils(API12+)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Description
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications. Its encapsulated tools cover APP, device, screen, authorization, notification, inter-thread communication, pop-up frames, toast, biometric authentication, user preferences, taking photos, albums, scanning codes, files, logs, exception capture, characters, strings, numbers, collections, dates, random, base64, encryption, decryption, JSON and other functions, which can meet various development needs.&lt;br&gt;&lt;br&gt;
&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;picker_utils&lt;/a&gt; It is a sub-store split by harmony-utils, including PickerUtil, PhotoHelper, and ScanUtil.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;*&lt;em&gt;📚 Warm reminder: *&lt;/em&gt;&lt;br&gt;
📕 Harmony-utils is a lightweight framework that integrates more than 50 tool classes, but it is only 130KB in size. Achieve the ultimate balance between tool count and lightweight performance.&lt;br&gt;
📙 Starting from version 1.3.2, the methods in the harmony-utils tool library will no longer be directly discarded. Please feel free to use it in third-party libraries and projects.&lt;br&gt;
📒 In the update record, each version number has the corresponding minimum development tool version, such as: "DevEco Studio 5.1.0 Release".&lt;br&gt;
📗 Please read the documentation carefully and view the use case before using the framework. 🙏&lt;br&gt;
📘 See, please! Follow the official account of "Elder Tong" quickly, and you are waiting for you to unlock it.&lt;br&gt;
📔 Creation is not easy, please give Elder Tong a thumbs up 👍&lt;a href="https://github.com/787107497/harmony-utils" rel="noopener noreferrer"&gt;github❤️&lt;/a&gt; &lt;a href="https://gitee.com/tongyuyan/harmony-utils" rel="noopener noreferrer"&gt;gitee❤️&lt;/a&gt; &lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;三方库❤️&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  🌞Download, installation and use instructions 🙏
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @pura/harmony-utils&lt;/code&gt;&lt;br&gt;&lt;br&gt;
OpenHarmony ohpm environment configuration and more, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;全局初始化方法，从1.2.0版本开始，在UIAbility的onCreate方法中初始化 AppUtil.init()

  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    AppUtil.init(this.context);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📂Module Introduction
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AppUtil&lt;/td&gt;
&lt;td&gt;APP-related tool categories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DeviceUtil&lt;/td&gt;
&lt;td&gt;Device-related tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WindowUtil&lt;/td&gt;
&lt;td&gt;Window related tool classes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DisplayUtil&lt;/td&gt;
&lt;td&gt;Screen related tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PermissionUtil&lt;/td&gt;
&lt;td&gt;Application Authorization Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AuthUtil&lt;/td&gt;
&lt;td&gt;Mobile phone biometric authentication (fingerprint, face, password) tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NetworkUtil&lt;/td&gt;
&lt;td&gt;Network related tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FileUtil&lt;/td&gt;
&lt;td&gt;File operation related tool categories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ImageUtil&lt;/td&gt;
&lt;td&gt;Picture-related tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PreviewUtil&lt;/td&gt;
&lt;td&gt;File Preview Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LocationUtil&lt;/td&gt;
&lt;td&gt;Positioning Tool Class (WGS-84 Coordinate System)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LogUtil&lt;/td&gt;
&lt;td&gt;Log Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CrashUtil&lt;/td&gt;
&lt;td&gt;Global exception capture, crash log collection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EmitterUtil&lt;/td&gt;
&lt;td&gt;Emitter tool class (for inter-thread communication)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;WantUtil&lt;/td&gt;
&lt;td&gt;Want Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;KvUtil&lt;/td&gt;
&lt;td&gt;Key-value database tool class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PreferencesUtil&lt;/td&gt;
&lt;td&gt;Preferences (User Preferences) Tool Class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CacheUtil&lt;/td&gt;
&lt;td&gt;Cache Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LRUCacheUtil&lt;/td&gt;
&lt;td&gt;LRUCache Cache Tool Class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NotificationUtil&lt;/td&gt;
&lt;td&gt;Notification Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SnapshotUtil&lt;/td&gt;
&lt;td&gt;Component screenshot and window screenshot tool class.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;KeyboardUtil&lt;/td&gt;
&lt;td&gt;Keyboard Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PasteboardUtil&lt;/td&gt;
&lt;td&gt;Clipboard Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AssetUtil&lt;/td&gt;
&lt;td&gt;Key Asset Storage Service Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ResUtil&lt;/td&gt;
&lt;td&gt;Resource Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ObjectUtil&lt;/td&gt;
&lt;td&gt;Object Tool Class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSONUtil&lt;/td&gt;
&lt;td&gt;JSON Tool Class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DateUtil&lt;/td&gt;
&lt;td&gt;Date Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Base64Util&lt;/td&gt;
&lt;td&gt;Base64 Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;StrUtil&lt;/td&gt;
&lt;td&gt;String Tool Class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CharUtil&lt;/td&gt;
&lt;td&gt;Character Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NumberUtil&lt;/td&gt;
&lt;td&gt;number tool class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ArrayUtil&lt;/td&gt;
&lt;td&gt;Collection Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RandomUtil&lt;/td&gt;
&lt;td&gt;Random Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;RegexUtil&lt;/td&gt;
&lt;td&gt;Regular Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeUtil&lt;/td&gt;
&lt;td&gt;Type Checking Tool Class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FormatUtil&lt;/td&gt;
&lt;td&gt;Format Tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ClickUtil&lt;/td&gt;
&lt;td&gt;Throttle, anti-shake tool class (used to click events to prevent buttons from being clicked repeatedly)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TempUtil&lt;/td&gt;
&lt;td&gt;Temperature conversion tool category&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DialogUtil&lt;/td&gt;
&lt;td&gt;Pop-up tool class (AlertDialog)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ToastUtil&lt;/td&gt;
&lt;td&gt;Toast Tools (promptAction)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SM2, SM3, SM4, &lt;br&gt;AES, DES, RSA, &lt;br&gt;MD5, SHA, ECDSA, &lt;br&gt;CryptoUtil, &lt;br&gt;CryptoHelper&lt;/td&gt;
&lt;td&gt;Encryption and decryption algorithm tool class&lt;br&gt;CryptoUtil: Encryption and decryption utility class, used with each encryption module. &lt;br&gt;CryptoHelper: Encrypt and decrypt data type conversion.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PickerUtil&lt;/td&gt;
&lt;td&gt;Selection and saving of photos, files (files, pictures, videos, audio), tools.&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;拆分至 picker_utils&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PhotoHelper&lt;/td&gt;
&lt;td&gt;Photo Album related tool category.&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;拆分至 picker_utils&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ScanUtil&lt;/td&gt;
&lt;td&gt;Code tool category (scan code, code image generation, picture identification).&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;拆分至 picker_utils&lt;/a&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Code Example
&lt;/h2&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { font, KeyboardAvoidMode, router } from '@kit.ArkUI';
import { AppUtil, LogUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
import { DescribeBean } from '../../model/DescribeBean';
import { MockSetup } from '@ohos/hamock';
import { TitleBarView } from '../../component/TitleBarView';
import {
  AbilityLifecycleCallback,
  ApplicationStateChangeCallback,
  ConfigurationConstant,
  EnvironmentCallback
} from '@kit.AbilityKit';
import { DialogAction, DialogHelper } from '@pura/harmony-dialog';
import { JSON } from '@kit.ArkTS';
import { Utils } from '../../utils/Utils';

/**
 * APP相关工具类
 */
@Entry
@Component
struct Index {
  private scroller: Scroller = new Scroller();
  @State describe: DescribeBean = router.getParams() as DescribeBean;
  @State mode: number = KeyboardAvoidMode.OFFSET; //上抬模式
  @State bright: number = 0.0; //屏幕亮度值
  @State isKeepScreenOn: boolean = false; //屏幕是否为常亮状态
  @State privacyMode: boolean = false; //是否隐私模式
  @State statusBar: boolean = false;
  @State blGray: boolean = false; //置灰状态
  @State colorMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; //深浅色模式
  @State blZhCn: boolean = false; //默认中文

  private applicationStateChangeCallback: ApplicationStateChangeCallback = {
    onApplicationForeground() {
      LogUtil.warn('applicationStateChangeCallback onApplicationForeground');
    },
    onApplicationBackground() {
      LogUtil.warn('applicationStateChangeCallback onApplicationBackground');
    }
  };
  @State callback1: number = -1;
  private environmentCallback: EnvironmentCallback = {
    onConfigurationUpdated(config) {
      LogUtil.warn(`onConfigurationUpdated config:\n${JSON.stringify(config, null)}`);
    },
    onMemoryLevel(level) {
      LogUtil.warn(`onMemoryLevel level: ${level}`);
    }
  };
  @State callback2: number = -1;
  private abilityLifecycleCallback: AbilityLifecycleCallback = {
    onAbilityCreate(ability) {
      LogUtil.info(`AbilityLifecycleCallback onAbilityCreate ability: ${ability}`);
    },
    onWindowStageCreate(ability, windowStage) {
      LogUtil.info(`AbilityLifecycleCallback onWindowStageCreate ability: ${ability}`);
      LogUtil.info(`AbilityLifecycleCallback onWindowStageCreate windowStage: ${windowStage}`);
    },
    onWindowStageActive(ability, windowStage) {
      LogUtil.info(`AbilityLifecycleCallback onWindowStageActive ability: ${ability}`);
      LogUtil.info(`AbilityLifecycleCallback onWindowStageActive windowStage: ${windowStage}`);
    },
    onWindowStageInactive(ability, windowStage) {
      LogUtil.info(`AbilityLifecycleCallback onWindowStageInactive ability: ${ability}`);
      LogUtil.info(`AbilityLifecycleCallback onWindowStageInactive windowStage: ${windowStage}`);
    },
    onWindowStageDestroy(ability, windowStage) {
      LogUtil.info(`AbilityLifecycleCallback onWindowStageDestroy ability: ${ability}`);
      LogUtil.info(`AbilityLifecycleCallback onWindowStageDestroy windowStage: ${windowStage}`);
    },
    onAbilityDestroy(ability) {
      LogUtil.info(`AbilityLifecycleCallback onAbilityDestroy ability: ${ability}`);
    },
    onAbilityForeground(ability) {
      LogUtil.info(`AbilityLifecycleCallback onAbilityForeground ability: ${ability}`);
    },
    onAbilityBackground(ability) {
      LogUtil.info(`AbilityLifecycleCallback onAbilityBackground ability: ${ability}`);
    },
    onAbilityContinue(ability) {
      LogUtil.info(`AbilityLifecycleCallback onAbilityContinue ability: ${ability}`);
    }
  };


  @MockSetup
  mock() {
    this.describe = new DescribeBean("AppUtil", "APP相关工具类");
  }

  build() {
    Column() {
      TitleBarView({ describe: this.describe })
      Divider()
      Scroll(this.scroller) {
        Column({ space: 5 }) {
          Button("isApiSupported()")
            .btnStyle()
            .onClick(async () =&amp;gt; {
              let api12 = AppUtil.isApiSupported(12);
              let api15 = AppUtil.isApiSupported(15);
              let api17 = AppUtil.isApiSupported(17);
              let api20 = AppUtil.isApiSupported(20);
              let api22 = AppUtil.isApiSupported(22);
              let api31 = AppUtil.isApiSupported(31);
              let infoStr = `API12: ${api12}\nAPI15: ${api15}\nAPI17: ${api17}\nAPI20: ${api20}\nAPI22: ${api22}\nAPI31: ${api31}`;
              Utils.showSheetText(infoStr);
            })
          Button("getApplicationContext()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let applicationContext = AppUtil.getApplicationContext();
              ToastUtil.showToast("成功获取applicationContext");
            })
          Button("getContext()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let context = AppUtil.getContext();
              ToastUtil.showToast("成功获取上下文");
            })
          Button("getUIContext()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let uiContext = AppUtil.getUIContext();
              ToastUtil.showToast("成功获取UIContext");
            })
          Button("getWindowStage()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let windowStage = AppUtil.getWindowStage();
              LogUtil.error(JSON.stringify(windowStage, null, 2));
              ToastUtil.showToast("成功获取WindowStage");
            })
          Button("getMainWindow()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let mainWindow = AppUtil.getMainWindow();
              LogUtil.error(JSON.stringify(mainWindow, null, 2));
              ToastUtil.showToast("成功获取主窗口");
            })
          Button("getConfiguration()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let config = AppUtil.getConfiguration();
              Utils.showSheetText(JSON.stringify(config, null, 2));
            })
          Button("setGrayScale()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              if (!this.blGray) {
                this.blGray = true;
                AppUtil.setGrayScale(1);
                ToastUtil.showToast("一键置灰成功");
              } else {
                this.blGray = false;
                AppUtil.setGrayScale(0);
                ToastUtil.showToast("取消置灰成功");
              }
            })
          Button("setColorMode()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              if (this.colorMode !== ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT) {
                this.colorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
                AppUtil.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT);
              } else {
                this.colorMode = ConfigurationConstant.ColorMode.COLOR_MODE_DARK;
                AppUtil.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_DARK);
              }
            })
          Button("getColorMode()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let colorMode = AppUtil.getColorMode();
              ToastUtil.showToast(`应用的颜色模式:${colorMode}`);
            })
          Button("setFont()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              font.registerFont({ familyName: 'WCSF', familySrc: $rawfile('wcsf.ttf') });
              AppUtil.setFont('WCSF');
            })
          Button("setFontSizeScale()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              AppUtil.setFontSizeScale(2);
            })
          Button("getFontSizeScale()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let fontSizeScale = AppUtil.getFontSizeScale();
              ToastUtil.showToast(`应用字体大小缩放比例:${fontSizeScale}`);
            })
          Button("setLanguage()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              if (this.blZhCn) {
                this.blZhCn = false;
                AppUtil.setLanguage('en-us');
              } else {
                this.blZhCn = true;
                AppUtil.setLanguage('zh-cn');
              }
              ToastUtil.showToast("设置成功！");
            })
          Button("getLanguage()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let language = AppUtil.getLanguage();
              ToastUtil.showToast(`应用的语言:${language}`);
            })
          Button("setSupportedProcessCache()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              AppUtil.setSupportedProcessCache(true);
              ToastUtil.showToast("设置成功！");
            })
          Button("clearUpApplicationData()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              DialogHelper.showAlertDialog({
                content: '是否清理应用本身的数据？',
                primaryButton:'取消',
                secondaryButton:'清理',
                onAction: (action) =&amp;gt; {
                  if (action === DialogAction.SURE) {
                    AppUtil.clearUpApplicationData();
                  }
                }
              });
            })
          Button("killAllProcesses()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              DialogHelper.showAlertDialog({
                content: '是否终止应用的所有进程？',
                primaryButton:'取消',
                secondaryButton:'终止',
                onAction: (action) =&amp;gt; {
                  if (action === DialogAction.SURE) {
                    AppUtil.killAllProcesses();
                  }
                }
              });
            })
          Button("restartApp()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              DialogHelper.showAlertDialog({
                autoCancel: false,
                backCancel: false,
                content: '是否重启应用？',
                primaryButton:'取消',
                secondaryButton:'重启',
                onAction: (action) =&amp;gt; {
                  if (action === DialogAction.SURE) {
                    AppUtil.restartApp();
                  }
                }
              });
            })
          Button("exit()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              DialogHelper.showAlertDialog({
                content: '是否重退出应用？',
                primaryButton:'取消',
                secondaryButton:'退出',
                onAction: (action) =&amp;gt; {
                  if (action === DialogAction.SURE) {
                    AppUtil.exit();
                  }
                }
              });
            })
          Button("getRunningProcessInformation()")
            .btnStyle()
            .onClick(async () =&amp;gt; {
              let processInformation = await AppUtil.getRunningProcessInformation();
              let jsonStr = JSON.stringify(processInformation, null, 2);
              Utils.showSheetText(jsonStr);
            })
          Button("onApplicationStateChange()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              AppUtil.onApplicationStateChange(this.applicationStateChangeCallback);
              DialogHelper.showToast('添加“applicationStateChange”监听成功！');
            })
          Button("offApplicationStateChange()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              AppUtil.offApplicationStateChange(this.applicationStateChangeCallback);
              DialogHelper.showToast('移除“applicationStateChange”监听成功！');
            })
          Button("onEnvironment()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              this.callback1 = AppUtil.onEnvironment(this.environmentCallback);
              DialogHelper.showToast('添加“environment”监听成功！');
            })
          Button("offEnvironment()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              if (this.callback1 !== -1) {
                AppUtil.offEnvironment(this.callback1);
                DialogHelper.showToast('移除“environment”监听成功！');
              }
            })
          Button("onAbilityLifecycle()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              this.callback2 = AppUtil.onAbilityLifecycle(this.abilityLifecycleCallback);
              DialogHelper.showToast('添加“abilityLifecycle”监听成功！');
            })
          Button("offAbilityLifecycle()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              if (this.callback2 !== -1) {
                AppUtil.offAbilityLifecycle(this.callback2);
                DialogHelper.showToast('移除“abilityLifecycle”监听成功！');
              }
            })
          Button("getKeyboardAvoidMode()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              this.mode = AppUtil.getKeyboardAvoidMode();
              ToastUtil.showToast(`当前模式为: ${StrUtil.equal(this.mode, KeyboardAvoidMode.OFFSET) ? "上抬模式" : "压缩模式"}`)
            })
          Button("setKeyboardAvoidMode()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              AppUtil.setKeyboardAvoidMode(StrUtil.equal(this.mode, KeyboardAvoidMode.OFFSET) ?
              KeyboardAvoidMode.RESIZE : KeyboardAvoidMode.OFFSET);
              this.mode = AppUtil.getKeyboardAvoidMode();
              ToastUtil.showToast(`设置模式为: ${StrUtil.equal(this.mode, KeyboardAvoidMode.OFFSET) ? "上抬模式" :
                "压缩模式"}`)
            })
          TextInput({ placeholder: '设置模式后点击输入框查看效果' })
            .width("95%")
            .margin({ bottom: 10 })

          Button("isPortrait()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let isPortrait = AppUtil.isPortrait();
              ToastUtil.showToast(`当前是否竖屏: ${isPortrait}`);
            })
          Button("isLandscape()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let isLandscape = AppUtil.isLandscape();
              ToastUtil.showToast(`当前是否横屏: ${isLandscape}`);
            })
          Button("getStatusBarHeight()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let statusBarHeight = AppUtil.getStatusBarHeight();
              ToastUtil.showToast(`状态栏的高度为：${statusBarHeight}px`)
            })
          Button("getNavigationIndicatorHeight()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let indicatorHeight = AppUtil.getNavigationIndicatorHeight();
              ToastUtil.showToast(`底部导航条的高度为：${indicatorHeight}px`)
            })
          Button("setStatusBar()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              this.statusBar = this.statusBar ? false : true;
              if (this.statusBar) {
                AppUtil.setStatusBar();
              } else {
                AppUtil.setStatusBar(false, true);
              }
            })
          Button("getBundleInfo()")
            .btnStyle()
            .onClick(async () =&amp;gt; {
              let bundleInfo = await AppUtil.getBundleInfo();
              let infoStr = JSON.stringify(bundleInfo, null, 2);
              Utils.showSheetText(infoStr);
            })
          Button("getAppInfoSync()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let appInfo = AppUtil.getAppInfoSync();
              let infoStr = JSON.stringify(appInfo, null, 2);
              Utils.showSheetText(infoStr);
            })
          Button("getSignatureInfo()")
            .btnStyle()
            .onClick(async () =&amp;gt; {
              let signatureInfo = await AppUtil.getSignatureInfo();
              let infoStr = JSON.stringify(signatureInfo, null, 2);
              Utils.showSheetText(infoStr);
            })
          Button("getBundleName()\ngetVersionCode()\ngetVersionName()\ngetTargetVersion()\ngetInstallTime()\ngetUpdateTime()\ngetAppProvisionType()\ndebug()")
            .labelStyle({ maxLines: 10 })
            .type(ButtonType.Normal)
            .borderRadius(10)
            .padding({ top: 10, bottom: 10 })
            .btnStyle()
            .onClick(() =&amp;gt; {
              let bundleName = AppUtil.getBundleName();
              let versionCode = AppUtil.getVersionCode();
              let versionName = AppUtil.getVersionName();
              let targetVersion = AppUtil.getTargetVersion();
              let infoStr = `bundleName: ${bundleName}\nversionCode: ${versionCode}\nversionName: ${versionName}\ntargetVersion: ${targetVersion}`;
              let installTime = AppUtil.getInstallTime();
              let updateTime = AppUtil.getUpdateTime();
              infoStr = infoStr + `\ninstallTime: ${installTime}\nupdateTime: ${updateTime}`;
              let appProvisionType = AppUtil.getAppProvisionType();
              let debug = AppUtil.debug();
              infoStr = infoStr + `\nappProvisionType: ${appProvisionType}\ndebug: ${debug}`;
              Utils.showSheetText(infoStr);
            })
        }
        .margin({ top: 5, bottom: 5 })
      }
      .layoutWeight(1)
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Start)
    .backgroundColor($r('app.color.main_background'))
  }
}


@Styles
function btnStyle() {
  .width('90%')
  .margin({ top: 10, bottom: 5 })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Contribution code and technology communication
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitee.com/tongyuyan/harmony-utils" rel="noopener noreferrer"&gt;https://gitee.com/tongyuyan/harmony-utils&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/787107497" rel="noopener noreferrer"&gt;https://github.com/787107497&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>harmonyos</category>
      <category>arkts</category>
    </item>
    <item>
      <title>harmony-web</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:41:28 +0000</pubDate>
      <link>https://dev.to/787107497/harmony-web-1ia0</link>
      <guid>https://dev.to/787107497/harmony-web-1ia0</guid>
      <description>&lt;h1&gt;
  
  
  harmony-web (API12)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-web" rel="noopener noreferrer"&gt;harmony-web&lt;/a&gt; It is a WebView based on Hongmeng The powerful and extremely easy-to-use library is not only lightweight, flexible and flexible, but also provides a series of problem solutions for Hongmeng WebView, helping developers to easily deal with various development challenges.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt; An extremely simple and easy-to-use zero-invasion pop-up window, which can be easily implemented with just one line of code, and can be easily popped up no matter where you are.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌞Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @pura/harmony-web&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 &lt;strong&gt;&lt;em&gt;ArkWeb&lt;/em&gt;&lt;/strong&gt; Component, Parameter Description
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Required&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;controller&lt;/td&gt;
&lt;td&gt;webview.WebviewController&lt;/td&gt;
&lt;td&gt;Controller&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;src&lt;/td&gt;
&lt;td&gt;ResourceStr&lt;/td&gt;
&lt;td&gt;Web Resource Address&lt;/td&gt;
&lt;td&gt;Y&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;options&lt;/td&gt;
&lt;td&gt;ArkWebOptions&lt;/td&gt;
&lt;td&gt;ArkWeb property parameters&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;webClient&lt;/td&gt;
&lt;td&gt;ArkWebClient&lt;/td&gt;
&lt;td&gt;ArkWeb Lifecycle Events&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;arkJsObject&lt;/td&gt;
&lt;td&gt;ArkJsObject or ArkJsObject[]&lt;/td&gt;
&lt;td&gt;Interface object that needs to be registered&lt;/td&gt;
&lt;td&gt;N&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  📚 ArkWebHelper, method description
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method name&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;init&lt;/td&gt;
&lt;td&gt;Initialization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;prepareForPageLoad&lt;/td&gt;
&lt;td&gt;Pre-connect url, call this API before loading the url&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  📚Sample code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Entry
@ComponentV2
struct Index {
  private controller: webview.WebviewController = new webview.WebviewController();
  @Local webUrl: string = "";
  @Local options: ArkWebOptions = new ArkWebOptions();
  @Local webClient: MyWebClient = new MyWebClient();
  @Local jsObject: MyJsObject = new MyJsObject();

  onBackPress(): boolean {
    if (this.controller?.accessBackward()) {
      this.controller?.backward();
      return true;
    }
    return false;
  }

  aboutToAppear(): void {
    let params: Params = router.getParams() as Params;
    this.webUrl = params.webUrl;
  }

  build() {
    Column() {
      ArkWeb({
        controller: this.controller,
        src: this.webUrl,
        options: this.options,
        webClient: this.webClient,
        arkJsObject: this.jsObject
      })
    }
    .height('100%')
    .width('100%')
  }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitee.com/tongyuyan/harmony-utils" rel="noopener noreferrer"&gt;https://gitee.com/tongyuyan/harmony-utils&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/787107497" rel="noopener noreferrer"&gt;https://github.com/787107497&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>arkts</category>
    </item>
    <item>
      <title>picker_utils</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:36:48 +0000</pubDate>
      <link>https://dev.to/787107497/pickerutils-3eg5</link>
      <guid>https://dev.to/787107497/pickerutils-3eg5</guid>
      <description>&lt;h1&gt;
  
  
  picker_utils (API12+)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;picker_utils&lt;/a&gt; yes &lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A split sub-store includes PickerUtil, PhotoHelper, and ScanUtil.&lt;br&gt;
Main solution: When using the harmony-utils three-party library and without using picker capabilities, there is no need to declare camera permissions and storage permissions in the privacy policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌞Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @pura/picker_utils&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚API detailed explanation&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/plug/MimeTypesPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  📂Module Introduction
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PickerUtil&lt;/td&gt;
&lt;td&gt;Photos, files (files, pictures, videos) selection and saving, tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PhotoHelper&lt;/td&gt;
&lt;td&gt;Album related tools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ScanUtil&lt;/td&gt;
&lt;td&gt;Code tool category (scan code, code image generation, picture identification)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  PickerUtil (photographing, file selection and saving, tool class)&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PickerUtilPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Methods&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;camera&lt;br&gt;cameraEasy&lt;/td&gt;
&lt;td&gt;Call the system camera, take photos, record videos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;selectPhoto&lt;/td&gt;
&lt;td&gt;Pull up the photoPicker interface by selecting mode, users can select one or more pictures/videos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;savePhoto&lt;/td&gt;
&lt;td&gt;Pull up photoPicker in the save mode to save the file name of the picture or video resource. If there are no parameters, the user needs to enter it by default&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;selectDocument&lt;/td&gt;
&lt;td&gt;Pull up the documentPicker interface by selecting mode, users can select one or more files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;saveDocument&lt;br&gt;saveDocumentEasy&lt;/td&gt;
&lt;td&gt;Pull up the documentPicker interface through the save mode, and the user can save one or more files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;selectAudio&lt;/td&gt;
&lt;td&gt;Pull up the audioPicker interface by selecting mode, users can select one or more audio files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;saveAudio&lt;/td&gt;
&lt;td&gt;Pull up the audioPicker interface through save mode, and users can save one or more audio files&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  PhotoHelper (album related, tool category)&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/PhotoHelperPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Methods&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;select&lt;br&gt;selectEasy&lt;/td&gt;
&lt;td&gt;Pull up the photoPicker interface by selecting mode, users can select one or more pictures/videos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;save&lt;/td&gt;
&lt;td&gt;Apply for permission to save pictures or videos to the album.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showAssetsCreationDialog&lt;/td&gt;
&lt;td&gt;Pop-up window authorization save, call the interface to pull up the save confirmation pop-up window.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showAssetsCreationDialogEasy&lt;/td&gt;
&lt;td&gt;Pop-up window authorization save, call the interface to pull up the save confirmation pop-up window, and save.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;applyChanges&lt;/td&gt;
&lt;td&gt;Save security controls, submit media change requests, insert pictures/videos.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getPhotoAsset&lt;/td&gt;
&lt;td&gt;Get the PhotoAsset object of the corresponding uri, used to read file information&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  ScanUtil (code tool class (scan code, code image generation, picture identification))&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/utils/ScanUtilPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Methods&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;startScanForResult&lt;/td&gt;
&lt;td&gt;Call the default interface to scan the code and use the Promise method to asynchronously return the decoding result&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;generateBarcode&lt;/td&gt;
&lt;td&gt;Code diagram generation, use Promise to return the generated code diagram asynchronously&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;decode&lt;/td&gt;
&lt;td&gt;Call picture identification and use Promise to return the identification result asynchronously&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;decodeImage&lt;/td&gt;
&lt;td&gt;Call image data identification capability, use Promise asynchronous callback to return code identification results&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;onPickerScanForResult&lt;/td&gt;
&lt;td&gt;Pull up the gallery through picker and select the picture, and call the picture identification code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;canIUseScan&lt;/td&gt;
&lt;td&gt;Determine whether the current device supports code capabilities&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Code Example
&lt;/h2&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { router } from '@kit.ArkUI';
import { DateUtil, FileUtil, ImageUtil, LogUtil, PreferencesUtil, StrUtil, ToastUtil } from '@pura/harmony-utils';
import { DescribeBean } from '../../model/DescribeBean';
import { BusinessError } from '@kit.BasicServicesKit';
import { image } from '@kit.ImageKit';
import { MockSetup } from '@ohos/hamock';
import { TitleBarView } from '../../component/TitleBarView';
import { camera, cameraPicker } from '@kit.CameraKit';
import { picker } from '@kit.CoreFileKit';
import { CameraOptions, PickerUtil } from '@pura/picker_utils';


/**
 * 拍照、文件(文件、图片、视频、音频)选择和保存,工具类
 */
@Entry
@Component
struct Index {
  private scroller: Scroller = new Scroller();
  @State describe: DescribeBean = router.getParams() as DescribeBean;
  @State uriStr: string = ''
  @State filePath: string = ''; //本地图片path
  @State cacheUri: string = ''; //缓存本地Uri，上次保存的Uri。


  @MockSetup
  mock() {
    this.describe = new DescribeBean("PickerUtil", "拍照、文件(文件、图片、视频、音频)选择和保存,工具类");
  }


  async aboutToAppear(): Promise&amp;lt;void&amp;gt; {
    this.cacheUri = PreferencesUtil.getStringSync("picker_cache_uri");
    let pixelMap = await ImageUtil.getPixelMapFromMedia($r("app.media.test_as4"))
    this.filePath = await ImageUtil.savePixelMap(pixelMap, FileUtil.getFilesDirPath(""), "漂亮小姐姐.png")
    LogUtil.error("filePath: " + this.filePath);
  }

  build() {
    Column() {
      TitleBarView({ describe: this.describe })
      Divider()
      Scroll(this.scroller) {
        Column() {
          Button("cameraEasy()")
            .btnStyle()
            .onClick(async () =&amp;gt; {
              PickerUtil.cameraEasy().then((uri) =&amp;gt; {
                this.uriStr = `调用相机，返回uri：\n${uri}`;
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用相机，异常：\n${JSON.stringify(err)}`;
              });
            })
          Button("camera()")
            .btnStyle()
            .onClick(async () =&amp;gt; {
              let options: CameraOptions = {
                mediaTypes: [cameraPicker.PickerMediaType.PHOTO],
                cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK
              }
              PickerUtil.camera(options).then((result) =&amp;gt; {
                this.uriStr = `调用相机，返回uri：\n${result.resultUri}`;
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用相机，异常：\n${JSON.stringify(err)}`;
              });
            })
          Button("selectPhoto()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              PickerUtil.selectPhoto().then((uris) =&amp;gt; {
                this.uriStr = `调用相册，返回uris：\n${uris.join('\n')}`;
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用相册，异常：\n${JSON.stringify(err)}`;
              });
            })
          Button("savePhoto()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let imgName = `大漂亮_${DateUtil.getTodayTime()}.png`;
              let imgName1 = `小漂亮_${DateUtil.getTodayTime()}.png`;
              PickerUtil.savePhoto([imgName, imgName1]).then(async (uris) =&amp;gt; {
                let uri = uris[0];
                this.uriStr = `调用保存图片，返回uris：\n${uri}`
                let file = FileUtil.openSync(uri);
                FileUtil.copyFile(this.filePath, file.fd).then(() =&amp;gt; {
                  this.uriStr = `保存图片，返回uris：\n${uri}`
                  ToastUtil.showToast("图片1保存成功");
                })

                let file1 = FileUtil.openSync(uris[1]);
                let pixelMap1 = await ImageUtil.getPixelMapFromMedia($r("app.media.test_as3"))
                let packOpts: image.PackingOption = { format: 'image/png', quality: 100 }
                ImageUtil.packToFileFromPixelMap(pixelMap1, file1.fd, packOpts).then(() =&amp;gt; {
                  this.uriStr = `保存图片，返回uris：\n${uris[1]}`
                  ToastUtil.showToast("图片2保存成功");
                })
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用保存图片，异常：\n${JSON.stringify(err)}`
              })
            })
          Button("selectDocument()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let options: picker.DocumentSelectOptions = {
                maxSelectNumber: 9, //选择媒体文件数量的最大值,默认9。
                selectMode: picker.DocumentSelectMode.FILE, //支持选择的资源类型,默认文件
                // fileSuffixFilters: ['图片(.png, .jpg)|.png,.jpg', '文档|.txt', '视频|.mp4', '.pdf'], //选择文件的后缀类型['后缀类型描述|后缀类型']（可选） 若选择项存在多个后缀名，则每一个后缀名之间用英文逗号进行分隔（可选），后缀类型名不能超过100,选择所有文件：'所有文件(*.*)|.*';
                // defaultFilePathUri: "file://docs/storage/Users/currentUser/Download/com.harmony.utils", //指定选择的文件或者目录路径（可选）
                // authMode: true //选择是否对指定文件或目录授权，true为授权，当为true时，defaultFilePathUri为必选参数。
              }
              PickerUtil.selectDocument(options).then((uris) =&amp;gt; {
                this.uriStr = `调用文件管理，返回uris：\n${uris.join('\n')}`
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用文件管理，异常：\n${JSON.stringify(err)}`
              });
            })
          Button("saveDocumentEasy()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let fileName = `test_easy_${DateUtil.getTodayTime()}.txt`;
              PickerUtil.saveDocumentEasy([fileName]).then((paths) =&amp;gt; {
                let path = paths[0];
                this.cacheUri = FileUtil.getUriFromPath(path);
                PreferencesUtil.put("picker_cache_uri", this.cacheUri);
                let txtStr = `“harmony-utils 一款高效的OpenHarmony/HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。\n\n`;
                FileUtil.writeEasy(path, txtStr).then(() =&amp;gt; {
                  this.uriStr = `文件保存成功，返回uris：\n${path}`;
                  ToastUtil.showToast("文件保存成功！");
                }).catch((err: BusinessError) =&amp;gt; {
                  this.uriStr = `文件保存，异常：\n${JSON.stringify(err)}`;
                })
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用保存文件，异常：\n${JSON.stringify(err)}`;
              })
            })
          Button("saveDocument()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let fileName = `test_${DateUtil.getTodayTime()}.txt`;
              PickerUtil.saveDocument({newFileNames:[fileName]}).then((uris) =&amp;gt; {
                let uri = uris[0];
                this.cacheUri = uri
                PreferencesUtil.put("picker_cache_uri", this.cacheUri);
                let txtStr = `“harmony-utils 一款高效的OpenHarmony/HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。\n\n`;
                FileUtil.writeEasy(uri, txtStr).then(() =&amp;gt; {
                  this.uriStr = `文件保存成功，返回uris：\n${uri}`;
                  ToastUtil.showToast("文件保存成功！");
                }).catch((err: BusinessError) =&amp;gt; {
                  this.uriStr = `文件保存，异常：\n${JSON.stringify(err)}`;
                })
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用保存文件，异常：\n${JSON.stringify(err)}`;
              })
            })
          Button("selectAudio()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              PickerUtil.selectAudio().then((uris) =&amp;gt; {
                this.uriStr = `调用文件管理，返回uris：\n${uris.join('\n')}`;
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用文件管理，异常：\n${JSON.stringify(err)}`;
              });
            })
          Button("saveAudio()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let fileName = `AudioViewPicker001.mp3`;
              PickerUtil.saveAudio([fileName]).then((uris) =&amp;gt; {
                let uri = uris[0];
                this.uriStr = `音频文件，返回uris：\n${uri}`;
              }).catch((err: BusinessError) =&amp;gt; {
                this.uriStr = `调用保存文件，异常：\n${JSON.stringify(err)}`;
              })
            })

          Text(this.uriStr)
            .visibility(StrUtil.isNotEmpty(this.uriStr) ? Visibility.Visible : Visibility.None)
            .textStyle()
            .margin(12)

          Blank().layoutWeight(1)
        }
        .margin({ top: 5, bottom: 5 })
      }
      .layoutWeight(1)
    }
    .width('100%')
    .height('100%')
    .justifyContent(FlexAlign.Start)
    .backgroundColor($r('app.color.main_background'))
  }
}


@Styles
function btnStyle() {
  .width('90%')
  .margin({ top: 10, bottom: 5 })
}

@Styles
function textStyle() {
  .width('95%')
  .padding(10)
  .shadow(ShadowStyle.OUTER_DEFAULT_XS)
  .margin({ top: 5, bottom: 10 })
  .border({ width: 1, color: Color.Grey, radius: 10, style: BorderStyle.Dashed })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>arkts</category>
      <category>harmonyos</category>
    </item>
    <item>
      <title>SpinKit</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:32:12 +0000</pubDate>
      <link>https://dev.to/787107497/spinkit-1411</link>
      <guid>https://dev.to/787107497/spinkit-1411</guid>
      <description>&lt;h1&gt;
  
  
  SpinKit(API12)
&lt;/h1&gt;




&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fspinkit" rel="noopener noreferrer"&gt;SpinKit&lt;/a&gt; is a loading animation library for OpenHarmony/HarmonyOS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt; An extremely simple and easy-to-use zero-invasion pop-up window, which can be easily implemented with just one line of code, and can be easily popped up no matter where you are.&lt;/p&gt;

&lt;h2&gt;
  
  
  📚Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @pura/spinkit&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚Result Picture
&lt;/h2&gt;

&lt;p&gt;The renderings are slightly stumbled, please run the source code or add dependencies to view the effect.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fimg_convert%2F9dbf847c21a14f327652c75a3a3ea3f4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fimg_convert%2F9dbf847c21a14f327652c75a3a3ea3f4.png" alt="SpinKit" width="426" height="851"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚SpinKit Component
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Properties&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;spinType&lt;/td&gt;
&lt;td&gt;Animation type&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;spinSize&lt;/td&gt;
&lt;td&gt;Animation size, default 60&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;spinColor&lt;/td&gt;
&lt;td&gt;Animation color, default white&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  SpinKit()

  SpinKit({ spinType: SpinType.spinA })

  SpinKit({ spinType: SpinType.spinH })

  SpinKit({
     spinType: SpinType.spinA,
     spinColor: Color.Pink,
     spinSize: 70
  })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Please move the loading box&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Full Code Example
&lt;/h2&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { SpinKit, SpinType } from '@pura/spinkit';
import { ComposeTitleBar } from '@kit.ArkUI';
import { ClickUtil, ToastUtil } from '@pura/harmony-utils';
import { DialogHelper } from '@pura/harmony-dialog';

@Entry
@Component
struct Index {
  private scroller: Scroller = new Scroller();

  aboutToAppear(): void {

  }

  build() {
    Column() {
      ComposeTitleBar({
        title: $r('app.string.spin_kit'),
        subtitle: $r('app.string.spinKit_desc'),
      })
      Divider()
      Scroll(this.scroller) {
        Column({ space: 15 }) {
          Button('加载框样式配置1')
            .fontFamily('MyFont')
            .width('100%')
            .backgroundColor(Color.Grey)
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              DialogHelper.setDefaultConfig((config) =&amp;gt; {
                config.loading_loadType = SpinType.spinZ; //动画类型
                config.loading_loadSize = 60; //加载动画或进度条的大小
                config.loading_loadColor = "#0A51E0"; //加载动画或进度条的颜色
                config.loading_content = ''; //加载动画的提示文字
                config.loading_fontSize = 16; //文字大小
                config.loading_fontColor = Color.White; //文字颜色
                config.loading_backgroundColor = '#CC000000'; //背景颜色，八位色值前两位为透明度
                config.loading_borderRadius = 10; //背景圆角
                config.loading_marginTop = 20; //文字与动画的间距
                config.loading_padding = 30; //padding
              })
              ToastUtil.showToast("样式配置成功！");
            })
          Button('加载框样式配置2')
            .fontFamily('MyFont')
            .width('100%')
            .backgroundColor(Color.Grey)
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              DialogHelper.setDefaultConfig((config) =&amp;gt; {
                config.loading_loadType = SpinType.spinH; //动画类型
                config.loading_loadSize = 70; //加载动画或进度条的大小
                config.loading_loadColor = Color.Brown; //加载动画或进度条的颜色
                config.loading_content = '努力加载中'; //加载动画的提示文字
                config.loading_fontSize = 16; //文字大小
                config.loading_fontColor = Color.White; //文字颜色
                config.loading_backgroundColor = '#EE000000'; //背景颜色，八位色值前两位为透明度
                config.loading_borderRadius = 12; //背景圆角
                config.loading_marginTop = 20; //文字与动画的间距
                config.loading_padding = { top: 35, right: 45, bottom: 30, left: 45 }; //padding
              })
              ToastUtil.showToast("样式配置成功！");
            })
          Button('加载框，样式一')
            .fontFamily('MyFont')
            .width('100%')
            .fontColor($r('app.color.color_main'))
            .backgroundColor($r('app.color.card_background'))
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              ClickUtil.throttle(() =&amp;gt; {
                let dialogId = DialogHelper.showLoadingDialog({ autoCancel: false })
                let timeoutID = setTimeout(() =&amp;gt; {
                  DialogHelper.closeDialog(dialogId);
                  clearTimeout(timeoutID);
                }, 15000)
              })
            })
          Button('加载框，样式二')
            .fontFamily('MyFont')
            .width('100%')
            .fontColor($r('app.color.color_main'))
            .backgroundColor($r('app.color.card_background'))
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              ClickUtil.throttle(() =&amp;gt; {
                let dialogId = DialogHelper.showLoadingDialog({
                  loadType: SpinType.spinH,
                  autoCancel: false,
                  onDidDisappear: () =&amp;gt; {
                    ToastUtil.showToast("加载框关闭了")
                  }
                })
                let timeoutID = setTimeout(() =&amp;gt; {
                  DialogHelper.closeDialog(dialogId);
                  clearTimeout(timeoutID);
                }, 15000)
              })
            })
          Button('加载框，样式三')
            .fontFamily('MyFont')
            .width('100%')
            .fontColor($r('app.color.color_main'))
            .backgroundColor($r('app.color.card_background'))
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              ClickUtil.throttle(() =&amp;gt; {
                DialogHelper.showLoadingDialog({
                  loadType: SpinType.spinK,
                  loadColor: '#0A66F9',
                  backgroundColor: '#CC000000',
                  maskColor: '#10000000'
                })
              })
            })
          Button('加载框，样式四')
            .fontFamily('MyFont')
            .width('100%')
            .fontColor($r('app.color.color_main'))
            .backgroundColor($r('app.color.card_background'))
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              ClickUtil.throttle(() =&amp;gt; {
                DialogHelper.showLoadingDialog({
                  loadType: SpinType.spinB,
                  loadColor: Color.White,
                  autoCancel: true
                })
              })
            })
          Button('加载框，样式五')
            .fontFamily('MyFont')
            .width('100%')
            .fontColor($r('app.color.color_main'))
            .backgroundColor($r('app.color.card_background'))
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              ClickUtil.throttle(() =&amp;gt; {
                DialogHelper.showLoadingDialog({
                  loadType: SpinType.spinP,
                  loadColor: Color.White,
                  loadSize: 70,
                  content: '加载中...',
                  fontSize: 18,
                  fontColor: Color.White,
                  backgroundColor: '#BB000000',
                  maskColor: '#33000000',
                  padding: { top: 30, right: 50, bottom: 30, left: 50 },
                  marginTop: 20,
                  autoCancel: true
                })
              })
            })
          Button('加载框，样式六')
            .fontFamily('MyFont')
            .width('100%')
            .fontColor($r('app.color.color_main'))
            .backgroundColor($r('app.color.card_background'))
            .shadow(ShadowStyle.OUTER_DEFAULT_MD)
            .onClick(() =&amp;gt; {
              ClickUtil.throttle(() =&amp;gt; {
                //自定义文字和加载动画的颜色
                DialogHelper.showLoadingDialog({
                  loadType: SpinType.spinD,
                  content: "努力加载中",
                  loadColor: Color.Red,
                  backgroundColor: '#990000FF',
                  fontColor: Color.Red,
                  fontSize: 18,
                  padding: 30,
                  borderRadius: 10
                })
              })
            })
          Blank().layoutWeight(1)
        }
        .padding({ left: 15, right: 15 })
        Divider()
        Grid() {
          GridItem() {
            SpinKit({ spinType: SpinType.spinA })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color1'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinB })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color2'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinC })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color3'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinD })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color4'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinE })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color5'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinF })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color6'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinG })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color7'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinH })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color8'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinI })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color9'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinJ })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color10'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinK })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color11'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinL })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color12'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinM })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color13'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinN })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color14'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinO })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color15'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinP })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color14'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinQ })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color13'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinR })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color12'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinS })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color11'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinT })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color10'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinU })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color9'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinV })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color8'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinW })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color7'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinX })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color6'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinY })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color5'))

          GridItem() {
            SpinKit({ spinType: SpinType.spinZ })
          }.aspectRatio(1)
          .backgroundColor($r('app.color.color4'))
        }
        .rowsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr')
        .columnsTemplate('1fr 1fr 1fr')
        .columnsGap(0)
        .rowsGap(0)
        .width('100%')
        .aspectRatio(3 / 9)
      }
      .layoutWeight(1)
    }
    .width('100%')
    .height('100%')
    .backgroundColor(Color.White)
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  💖 Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitee.com/tongyuyan/harmony-utils" rel="noopener noreferrer"&gt;https://gitee.com/tongyuyan/harmony-utils&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/787107497" rel="noopener noreferrer"&gt;https://github.com/787107497&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>arkts</category>
      <category>harmony</category>
      <category>harmonyos</category>
    </item>
    <item>
      <title>mime-types</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:26:34 +0000</pubDate>
      <link>https://dev.to/787107497/mime-types-2gnb</link>
      <guid>https://dev.to/787107497/mime-types-2gnb</guid>
      <description>&lt;h1&gt;
  
  
  mime-types (API12+)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@nutpi%2Fmime-types" rel="noopener noreferrer"&gt;mime-types&lt;/a&gt; Mainly used to process and determine the MIME type of files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt; An extremely simple and easy-to-use zero-invasion pop-up window, which can be easily implemented with just one line of code, and can be easily popped up no matter where you are.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌞Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @nutpi/mime-types&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚API detailed explanation&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/plug/MimeTypesPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mime method name&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;lookup&lt;/td&gt;
&lt;td&gt;Get MIME type by file name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;contentType&lt;/td&gt;
&lt;td&gt;Get MIME type based on the suffix name of the file name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;extension&lt;/td&gt;
&lt;td&gt;Get file extension based on MIME type&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getFileExtention&lt;/td&gt;
&lt;td&gt;Get file suffix name based on file name/file path/file uri/file url&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getIconFileByFileExtension&lt;/td&gt;
&lt;td&gt;Get the icon of the corresponding file type based on the file suffix name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getIconFileByMIMEType&lt;/td&gt;
&lt;td&gt;Get the icon of the corresponding file type according to the MIME type&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getTypeDescriptorByFileExtension&lt;/td&gt;
&lt;td&gt;Get TypeDescriptor (a description class for standardized data type) based on file suffix name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getTypeDescriptorByMIMEType&lt;/td&gt;
&lt;td&gt;Get TypeDescriptor (a description class for standardized data type) according to file MIME type&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  📚Sample code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//根据文件名获取MIME类型
let mimeType1 = Mime.lookup("test.txt");
let mimeType2 = Mime.lookup("测试文档.doc");
let mimeType3 = Mime.lookup("应用.apk");
let mimeType4 = Mime.lookup("一路向西.mp4");
let mimeType5 = Mime.lookup("嗨歌.mp3");


//根据文件名的后缀名获取MIME类型
let mimeType1 = Mime.contentType("html");
let mimeType2 = Mime.contentType("jpeg");
let mimeType3 = Mime.contentType(".ofd");
let mimeType4 = Mime.contentType(".PDF");
let mimeType5 = Mime.contentType(".png");


//根据MIME类型获取文件扩展名
let mimeType1 = Mime.extension("image/jpeg");
let mimeType2 = Mime.extension("image/gif");
let mimeType3 = Mime.extension("audio/mp3");


//根据 文件名/文件path/文件uri/文件url，获取文件后缀名
let mimeType1 = Mime.getFileExtention("test.txt");
let mimeType2 = Mime.getFileExtention("/downnload/wps/测试文档.doc");
let mimeType3 = Mime.getFileExtention("https://developer.demo/files/开发说明.PDF");


//根据文件后缀名获取对应文件类型的图标
let iconFile1 = Mime.getIconFileByFileExtension(".txt");
let iconFile2 = Mime.getIconFileByFileExtension("doc");


//根据MIME类型获取对应文件类型的图标
let iconFile1 = Mime.getIconFileByMIMEType("application/pdf");
let iconFile2 = Mime.getIconFileByMIMEType("image/gif");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>arkts</category>
      <category>harmonyos</category>
    </item>
    <item>
      <title>harmony-dialog Effect Preview</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:15:40 +0000</pubDate>
      <link>https://dev.to/787107497/harmony-dialog-xiao-guo-yu-lan-2lpo</link>
      <guid>https://dev.to/787107497/harmony-dialog-xiao-guo-yu-lan-2lpo</guid>
      <description>&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt; An extremely simple and easy-to-use zero-invasion pop-up window, which can be easily implemented with just one line of code, and can be easily popped up no matter where you are. It covers&lt;br&gt;
AlertDialog, TipsDialog, ConfirmDialog, SelectDialog, CustomContentDialog, TextInputDialog, TextAreaDialog, BottomSheetDialog, ActionSheetDialog, TextPickerDialog, DatePickerDialog, CustomDialog, LoadingDialog, LoadingProgress, Toast, ToastTip&lt;br&gt;
Various types can meet various pop-up development needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. AlertDialog operation confirmation class pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F91ec51562b5346ecac718110a4dcba34.png%23pic_center" alt="AlertDialog" width="476" height="442"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fa5f1563c9773478390030fca87f6fe62.png%23pic_center" alt="AlertDialog" width="484" height="500"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F7bbc94395d6d40ce9aaf602827c48b3e.png%23pic_center" alt="AlertDialog" width="486" height="482"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F705fbe8925d543fba08bce0983458e0a.png%23pic_center" alt="AlertDialog" width="467" height="411"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;2. ConfirmDialog information confirmation class pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F803d396003244fb1973a789700c3bcb5.png%23pic_center" alt="ConfirmDialog" width="478" height="473"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F7a12a1a1d1d04924b87740a72013f015.png%23pic_center" alt="ConfirmDialog" width="479" height="455"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F82e3adf267124946b0fe8cbe94a1245b.png%23pic_center" alt="ConfirmDialog" width="477" height="439"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;3. TipsDialog prompt pop-up box, which is a graphic confirmation box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F0821939d2b3c4b5b96677287c5dbdd54.png%23pic_center" alt="TipsDialog" width="481" height="446"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fba23010e91a54c189eb2d8bb7cb784cd.png%23pic_center" alt="TipsDialog" width="481" height="444"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F41506cc90fbb4143b551e315319dc22a.png%23pic_center" alt="TipsDialog" width="478" height="449"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;4. SelectDialog Select class pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fd2bbc80238af44e096c3f59344823227.png%23pic_center" alt="SelectDialog" width="477" height="609"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F7cb629479d0d4ab48fdf1ae3115a727d.png%23pic_center" alt="SelectDialog" width="482" height="616"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F92725f132768493cbbeda144319b1231.png%23pic_center" alt="SelectDialog" width="481" height="647"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;5. TextInputDialog Single-line text input pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fac8cff18bcd04aeb84a9c1a4bdfebbb3.png%23pic_center" alt="TextInputDialog" width="473" height="1006"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fc0f7f25bdee741a880e6860130a1d5cc.png%23pic_center" alt="TextInputDialog" width="468" height="1000"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fc622169a26e04e0a9d0610a8c1019b7d.png%23pic_center" alt="TextInputDialog" width="470" height="1013"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;6. TextAreaDialog Multi-line text input box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fd39b74e0d55444f5a902ea38b0802c2d.png%23pic_center" alt="TextAreaDialog" width="466" height="1004"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F3c91613b1ac54e4497f21aaf3a7c8eee.png%23pic_center" alt="TextAreaDialog" width="458" height="1004"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F87f9aee66fbe44248b2f17119b80f9ec.png%23pic_center" alt="TextAreaDialog" width="474" height="1001"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;7. BottomSheetDialog Action Panel&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F4157640e74fc437f908e3a1d5d15843b.png%23pic_center" alt="BottomSheetDialog" width="481" height="562"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F7daf01d4ca1344d095f7802aa2d783b1.png%23pic_center" alt="BottomSheetDialog" width="480" height="553"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F743a3effe8304cc79736499d04376b4a.png%23pic_center" alt="BottomSheetDialog" width="480" height="551"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;8. ActionSheetDialog Action Panel (IOS Style)&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fa7341cf47e894035acfd10b53bd17d1c.png%23pic_center" alt="ActionSheetDialog" width="479" height="566"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fae59eb8ba4a44f9c92067b2d04033c94.png%23pic_center" alt="ActionSheetDialog" width="479" height="557"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F11ec15e0f55a4c75b255e7b6550c3d9e.png%23pic_center" alt="ActionSheetDialog" width="484" height="556"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;9. TextPickerDialog selector pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fef133dbcf35b49cb98c97fbf7898d21e.png%23pic_center" alt="TextPickerDialog" width="482" height="507"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F0d2b964d6a21490589ed8edc8aca6c59.png%23pic_center" alt="TextPickerDialog" width="485" height="506"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F02dd0756a9674919bd86b783c4d994c0.png%23pic_center" alt="TextPickerDialog" width="485" height="500"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;10. DatePickerDialog date selector pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fc61c02f151cf444e9361b26f62a5aa1d.png%23pic_center" alt="DatePickerDialog" width="485" height="496"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F9d6d0f3dbd42419d8d9c9bcc36b85fd9.png%23pic_center" alt="DatePickerDialog" width="485" height="490"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fa183779413134f9f8fb980d83d34ec38.png%23pic_center" alt="DatePickerDialog" width="484" height="484"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;11. LoadingDialog load class pop-up box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F4c545c5043634c9fb53d05b2668c3985.gif%23pic_center" alt="LoadingDialog" width="484" height="467"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F7c5d374f3615489ca064b6728c5a3735.gif%23pic_center" alt="LoadingDialog" width="481" height="464"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F974d1c46b0674b0c8c60dc89a1b8bf07.gif%23pic_center" alt="LoadingDialog" width="481" height="464"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fd48d049dda1d47829edeb6091d1564af.gif%23pic_center" alt="LoadingDialog" width="481" height="464"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;12. LoadingProgress Progress Progress Box&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fb98c65cf26c9435da0968e3284066b8f.gif%23pic_center" alt="LoadingProgress" width="483" height="464"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F6c1a4ae2bd1e42948d10f4e4a1eaccec.gif%23pic_center" alt="LoadingProgress" width="483" height="464"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Ffc1f45f579b7479ba8082e2df5d9abd1.gif%23pic_center" alt="LoadingProgress" width="483" height="464"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;13. Toast Toast&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F6144b91f21f14134a1684205c06d7f79.png%23pic_center" alt="Toast" width="466" height="372"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F3004dc8b229f43ceafbb1c6de20f9fe7.png%23pic_center" alt="Toast" width="465" height="369"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F34e6119f44e94862abe121ad50dbfb24.png%23pic_center" alt="Toast" width="459" height="372"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F0dafa03ba50e459391cfe96497c32f56.png%23pic_center" alt="Toast" width="465" height="370"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;13. ToastTip Toast with Graphics&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fa36e5f9798214be4984a4184da483eac.png%23pic_center" alt="ToastTip" width="466" height="377"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2Fad97fb764d33488d831cd2a0f3bd6002.png%23pic_center" alt="ToastTip" width="478" height="369"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F6c56f720ba7f4e449f6b039c1be9b8a6.png%23pic_center" alt="ToastTip" width="463" height="369"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F3b331546f847404fa689e17e1ce9c710.png%23pic_center" alt="ToastTip" width="462" height="368"&gt;&lt;/th&gt;
&lt;th&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwsrv.nl%2F%3Furl%3Dhttps%3A%2F%2Fi-blog.csdnimg.cn%2Fdirect%2F6dd84c689eb44e9e96f57573464c557d.png%23pic_center" alt="ToastTip" width="362" height="238"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Full Code Example
&lt;/h2&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { AreaHelper } from '@nutpi/china_area';
import { AnimationHelper, DateType, DialogAction, DialogHelper, Orientation } from '@pura/harmony-dialog';
import { DateUtil, DisplayUtil, LogUtil, ToastUtil } from '@pura/harmony-utils';
import { SpinType } from '@pura/spinkit';
import { CardButton } from '../../component/CardButton';
import { CustomImageView } from '../../component/CustomImageView';
import { CustomTextViewBuilder } from '../../component/CustomTextView';
import { DrawerBuilder } from '../../component/DrawerLayout';
import { LottieBuilder } from '../../component/LottieView';
import { MenuBuilder } from '../../component/MenuLayout';
import { MenuSheetBuilder } from '../../component/MenuSheetLayout';
import { TipBuilder } from '../../component/TipLayout';
import { TitleView } from '../../component/TitleView';
import { DrawerOptions } from '../../model/DrawerOptions';
import { LoadOptions } from '../../model/LoadOptions';
import { MenuOptions } from '../../model/MenuOptions';
import { MenuSheetOptions } from '../../model/MenuSheetOptions';
import { TipOptions } from '../../model/TipOptions';
import { Utils } from '../../utils/Utils';
import { LevelMode, router } from '@kit.ArkUI';


/**
 * TODO 弹窗工具
 * author: 桃花镇童长老ᥫ᭡
 * since: 2024/08/18
 */
@Preview
@Component
export struct DialogPage {
  private scroller: Scroller = new Scroller();
  @State menuArray: Array&amp;lt;ResourceStr&amp;gt; = [$r('app.string.str_camera'), $r('app.string.str_album'), "文件管理器"];
  @State inputText: string = ""; //输入框内容
  @State progress: number = 1;
  private likes: string[] = ['乒乓球', '鸿蒙手机', 'ArkTS', 'Mate70Pro', '三折叠手机', '小米su7', '红米K80pro', '广东名菜烤乳猪'];
  private apfruits: string[] = ['apple1', 'apple2', 'apple3', 'apple4']
  private orfruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4']
  private pefruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4']
  private multis: string[][] = [this.apfruits, this.orfruits, this.pefruits]
  @BuilderParam customTextBuilderParam: (str: string | Resource) =&amp;gt; void = CustomTextViewBuilder; //自定义文本内容
  private rangeContent: TextPickerRangeContent[] = [{
    icon: $r('sys.media.ohos_ic_normal_white_grid_doc'),
    text: 'DOC'
  }, {
    icon: $r('sys.media.ohos_ic_normal_white_grid_pdf'),
    text: 'PDF'
  }, {
    icon: $r('sys.media.ohos_ic_normal_white_grid_xls'),
    text: 'XLS'
  }, {
    icon: $r('sys.media.ohos_ic_normal_white_grid_image'),
    text: 'IMAGE'
  }, {
    icon: $r('sys.media.ohos_ic_normal_white_grid_html'),
    text: 'HTML'
  }];




  /**
   * 统一配置一
   */
  customConfig1() {
    DialogHelper.setDefaultConfig((config) =&amp;gt; {
      config.autoCancel = false; //点击遮障层时，是否关闭弹窗，true表示关闭弹窗。
      config.backCancel = false; //点击返回键或手势返回时，是否关闭弹窗；实现onWillDismiss函数时，该参数不起作用。
      config.actionCancel = true; //点击操作按钮时，是否关闭弹窗。false表示不关闭弹窗。
      config.alignment = DialogAlignment.Center; //弹窗的对齐方式。
      config.offset = { dx: 0, dy: 0 }; //弹窗相对alignment所在位置的偏移量。默认值：{ dx: 0, dy: 0 }
      config.maskColor = 0x11000000; //自定义蒙层颜色。默认值 0x33000000
      config.backgroundColor = Color.White; //弹窗背板颜色。默认值：Color.White
      config.backgroundBlurStyle = BlurStyle.NONE; //弹窗背板模糊材质
      config.cornerRadius = 35; //设置背板的圆角半径。可分别设置4个圆角的半径。
      // config.maskRect={ x: 'auto', y: 'auto', width: 'auto', height: 'auto' };

      config.title = $r("app.string.dialog_tip"); //弹框标题
      config.primaryButton = $r("app.string.btn_cancel"); //弹框左侧按钮。
      config.secondaryButton = $r("app.string.btn_sure"); //弹框右侧按钮。
      config.imageRes = undefined; //TipsDialog用到，展示的图片。
      config.imageSize = { width: '64vp', height: '64vp' }; //TipsDialog用到，自定义图片尺寸。默认值：64*64vp

      config.loading_loadSize = 60; //加载动画或进度条的大小
      config.loading_loadColor = Color.White; //加载动画或进度条的颜色
      config.loading_content = ''; //加载动画的提示文字
      config.loading_fontSize = 16; //文字大小
      config.loading_fontColor = Color.White; //文字颜色
      config.loading_backgroundColor = '#CC094CD1'; //背景颜色，八位色值前两位为透明度
      config.loading_borderRadius = 10; //背景圆角

      config.toast_fontSize = 16; //文字大小
      config.toast_fontColor = Color.White; //文字颜色
      config.toast_backgroundColor = '#CC56D866'; //背景颜色，建议八位色值前两位为透明度
      config.toast_alignment = Alignment.Center; //土司居中显示
      config.toast_borderRadius = 8; //背景圆角
      config.toast_padding = { left: 16, right: 16, top: 12, bottom: 12 }; //Padding
      config.toast_imageSize = { width: 45, height: 45 }; //Tip图片尺寸。默认值：45*45vp
      config.toast_duration = 1500; //显示时长(1500ms-10000ms)
      config.toast_durationLong = 5000; //显示时长
    });
    ToastUtil.showToast("统一配置设置成功！");
  }

  /**
   * 统一配置二
   */
  customConfig2() {
    DialogHelper.setDefaultConfig((config) =&amp;gt; {
      config.autoCancel = false; //点击遮障层时，是否关闭弹窗，true表示关闭弹窗。
      config.backCancel = false; //点击返回键或手势返回时，是否关闭弹窗；实现onWillDismiss函数时，该参数不起作用。
      config.actionCancel = true; //点击操作按钮时，是否关闭弹窗。false表示不关闭弹窗。
      config.alignment = DialogAlignment.Bottom; //弹窗的对齐方式。
      config.offset = { dx: 0, dy: -35 }; //弹窗相对alignment所在位置的偏移量。
      config.maskColor = 0x11000000; //自定义蒙层颜色。默认值 0x33000000
      config.backgroundColor = Color.White; //弹窗背板颜色。默认值：Color.White
      config.backgroundBlurStyle = BlurStyle.COMPONENT_ULTRA_THICK; //弹窗背板模糊材质
      config.cornerRadius = 20; //设置背板的圆角半径。可分别设置4个圆角的半径。

      config.title = '提示'; //弹框标题
      config.primaryButton = '取消'; //弹框左侧按钮。
      config.secondaryButton = '确定'; //弹框右侧按钮。
      config.imageRes = undefined; //TipsDialog用到，展示的图片。
      config.imageSize = { width: '64vp', height: '64vp' }; //TipsDialog用到，自定义图片尺寸。

      config.loading_loadSize = 60; //加载动画或进度条的大小
      config.loading_loadColor = Color.White; //加载动画或进度条的颜色
      config.loading_content = ''; //加载动画的提示文字
      config.loading_fontSize = 16; //文字大小
      config.loading_fontColor = Color.White; //文字颜色
      config.loading_backgroundColor = '#CC56D866'; //背景颜色，八位色值前两位为透明度
      config.loading_borderRadius = 10; //背景圆角

      config.toast_fontSize = 16; //文字大小
      config.toast_fontColor = Color.Black; //文字颜色
      config.toast_backgroundColor = '#CC0FCEE3'; //背景颜色，建议八位色值前两位为透明度
      config.toast_alignment = Alignment.Top; //土司Top显示
      config.toast_borderRadius = 8; //背景圆角
      config.toast_padding = { left: 16, right: 16, top: 12, bottom: 12 }; //Padding
      config.toast_imageSize = { width: 45, height: 45 }; //Tip图片尺寸。默认值：45*45vp
      config.toast_duration = 1500; //显示时长(1500ms-10000ms)
      config.toast_durationLong = 5000; //显示时长
    });
    ToastUtil.showToast("统二配置设置成功！");
  }

  /**
   * 默认的配置
   */
  defaultConfig() {
    DialogHelper.setDefaultConfig((config) =&amp;gt; {
      config.autoCancel = true; //点击遮障层时，是否关闭弹窗，true表示关闭弹窗。false表示不关闭弹窗。默认值：true
      config.backCancel = true; //点击返回键或手势返回时，是否关闭弹窗；实现onWillDismiss函数时，该参数不起作用。true表示关闭弹窗。false表示不关闭弹窗。默认值：true。
      config.actionCancel = true; //点击操作按钮时，是否关闭弹窗。false表示不关闭弹窗。默认值：true。
      config.alignment = DialogAlignment.Default; //弹窗的对齐方式。
      config.offset = { dx: 0, dy: 0 }; //弹窗相对alignment所在位置的偏移量。默认值：{ dx: 0, dy: 0 }
      config.maskColor = 0x33000000; //自定义蒙层颜色。默认值 0x33000000
      config.backgroundColor = Color.White; //弹窗背板颜色。默认值：Color.White
      config.backgroundBlurStyle = BlurStyle.COMPONENT_ULTRA_THICK; //弹窗背板模糊材质。默认值：BlurStyle.COMPONENT_ULTRA_THICK
      config.cornerRadius = 20; //设置背板的圆角半径。可分别设置4个圆角的半径。

      config.title = '温馨提示'; //弹框标题
      config.primaryButton = '取消'; //弹框左侧按钮。
      config.secondaryButton = '确定'; //弹框右侧按钮。
      config.imageRes = undefined; //TipsDialog用到，展示的图片。
      config.imageSize = { width: '64vp', height: '64vp' }; //TipsDialog用到，自定义图片尺寸。默认值：64*64vp

      config.loading_loadSize = 60; //加载动画或进度条的大小
      config.loading_loadColor = Color.White; //加载动画或进度条的颜色
      config.loading_content = ''; //加载动画的提示文字
      config.loading_fontSize = 16; //文字大小
      config.loading_fontColor = Color.White; //文字颜色
      config.loading_backgroundColor = '#CC000000'; //背景颜色，八位色值前两位为透明度
      config.loading_borderRadius = 10; //背景圆角

      config.toast_fontSize = 16; //文字大小
      config.toast_fontColor = Color.White; //文字颜色
      config.toast_backgroundColor = '#CC000000'; //背景颜色，建议八位色值前两位为透明度
      config.toast_alignment = undefined; //土司显示位置
      config.toast_borderRadius = 8; //背景圆角
      config.toast_padding = { left: 16, right: 16, top: 12, bottom: 12 }; //Padding
      config.toast_imageSize = { width: 45, height: 45 }; //Tip图片尺寸。默认值：45*45vp
      config.toast_duration = 2000; //显示时长(1500ms-10000ms)
      config.toast_durationLong = 10000; //显示时长(10000ms)
    });
    ToastUtil.showToast("默认配置,设置成功！");
  }

  /**
   * 操作确认类弹出框
   */
  alertDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showAlertDialog({
        uiContext:this.getUIContext(),
        backgroundColor: Color.Orange,
        content: "确定保存该WPS文件吗？",
        onAction: (action) =&amp;gt; {
          if (action == DialogAction.CANCEL) {
            ToastUtil.showToast(`您点击了取消按钮`);
          } else if (action == DialogAction.SURE) {
            ToastUtil.showToast(`您点击了确认按钮`);
          }
        }
      })
    } else if (index == 1) {
      //自定义按钮颜色
      DialogHelper.showAlertDialog({
        title: "提示",
        content: "确定保存该视频文件吗？",
        // primaryButton:'取消',
        secondaryButton: {
          value: "确认",
          fontColor: Color.Brown
        },
        onAction: (action) =&amp;gt; {
          if (action == DialogAction.CANCEL) {
            ToastUtil.showToast(`您取消了保存`);
          } else if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已保存`);
          }
        }
      })
    } else if (index == 2) {
      //自定义按钮和二级标题
      DialogHelper.showAlertDialog({
        primaryTitle: "提示",
        secondaryTitle: "保存前请确认文件",
        content: "确定保存该视频文件吗",
        primaryButton: "取消",
        secondaryButton: $r('app.string.btn_save'),
        onAction: (action) =&amp;gt; {
          if (action == DialogAction.CANCEL) {
            ToastUtil.showToast(`您取消了保存`);
          } else if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已保存`);
          }
        }
      })
    } else {
      //不带标题，不主动关闭弹框
      DialogHelper.showAlertDialog({
        title: "",
        content: "确定保存该视频文件吗",
        actionCancel: false, //点击操作按钮不关闭弹框
        autoCancel: false, //点击遮障层时，不关闭弹窗
        backCancel: false, //点击返回键，不关闭弹窗
        onAction: (action, dialogId) =&amp;gt; {
          DialogHelper.closeDialog(dialogId); //关闭弹框
          if (action == DialogAction.CANCEL) {
            ToastUtil.showToast(`您取消了保存`);
          } else if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已保存`);
          }
        }
      })
    }
  }

  /**
   * 信息确认类弹出框
   */
  confirmDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showConfirmDialog({
        checkTips: "是否记住密码？",
        content: "您是否退出当前应用",
        onCheckedChange: (check) =&amp;gt; {
          ToastUtil.showToast(`${check}`);
        },
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else if (index == 1) {
      //自定义按钮
      DialogHelper.showConfirmDialog({
        checkTips: "是否记住密码？",
        content: "您是否退出当前应用",
        primaryButton: { value: "取消", fontColor: Color.Red },
        secondaryButton: "退出",
        onCheckedChange: (check) =&amp;gt; {
          ToastUtil.showToast(`${check}`);
        },
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else if (index == 2) {
      //不显示标题
      DialogHelper.showConfirmDialog({
        title: "",
        checkTips: "是否记住密码？",
        content: "您是否退出当前应用",
        onCheckedChange: (check) =&amp;gt; {
          ToastUtil.showToast(`${check}`);
        },
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else {
      //底部弹出
      DialogHelper.showConfirmDialog({
        checkTips: "是否记住密码？",
        content: "您是否退出当前应用",
        alignment: DialogAlignment.Bottom, //底部弹出
        offset: { dx: 0, dy: -35 },
        autoCancel: false, //点击遮障层时，不关闭弹窗
        onCheckedChange: (check) =&amp;gt; {
          ToastUtil.showToast(`${check}`);
        },
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    }
  }

  /**
   * 提示弹出框
   */
  tipsDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showTipsDialog({
        uiContext:this.getUIContext(),
        content: '想要卸载这个APP嘛?',
        showInSubWindow:false,
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else if (index == 1) {
      //自定义图标和图标大小
      DialogHelper.showTipsDialog({
        imageRes: $r('sys.media.ohos_app_icon'),
        imageSize: { width: 50, height: 50 },
        content: '想要卸载这个APP嘛?',
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else if (index == 2) {
      //自定义图标和按钮
      DialogHelper.showTipsDialog({
        imageRes: $r('app.media.icon_tip_warn'),
        content: '想要卸载这个APP嘛?',
        primaryButton: "卸载",
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else {
      //自定义
      DialogHelper.showTipsDialog({
        imageRes: $r('sys.media.ohos_app_icon'),
        imageSize: { width: 50, height: 50 },
        content: '想要卸载这个APP嘛?',
        checkTips: "是否删除缓存文件",
        onCheckedChange: (check) =&amp;gt; {
          ToastUtil.showToast(`${check}`);
        },
        primaryButton: {
          value: "取消",
          fontColor: Color.Black
        },
        secondaryButton: {
          value: "卸载",
          fontColor: Color.Red
        },
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    }
  }

  /**
   * 选择类弹出框
   */
  selectDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showSelectDialog({
        radioContent: ["文本菜单选项一", "文本菜单选项二", "文本菜单选项三", "文本菜单选项四", "文本菜单选项五"],
        onCheckedChanged: (index) =&amp;gt; {
          ToastUtil.showToast(`${index}`);
        },
        onAction: (action, dialogId, value) =&amp;gt; {
          ToastUtil.showToast(`${action} --- ${value}`);
        }
      })
    } else if (index == 1) {
      //自定义标题，内容，底部弹出框
      let dialogID = DialogHelper.showSelectDialog({
        title: "请选择",
        content: "选择您中意的文本菜单",
        alignment: DialogAlignment.Bottom, //底部弹出
        offset: { dx: 0, dy: -35 },
        autoCancel: false, //点击遮障层时，不关闭弹窗
        radioContent: ["文本菜单选项一", "文本菜单选项二", "文本菜单选项三", "文本菜单选项四", "文本菜单选项五"],
        onCheckedChanged: (index) =&amp;gt; {
          ToastUtil.showToast(`${index}`);
          DialogHelper.closeDialog(dialogID);
        },
        onAction: (action, dialogId, value) =&amp;gt; {
          ToastUtil.showToast(`${action} --- ${value}`);
          DialogHelper.closeDialog(dialogId);
        }
      })
    } else if (index == 2) {
      //自定义标题，内容，底部弹出框
      DialogHelper.showSelectDialog({
        title: "请选择菜单",
        content: "选择您中意的文本菜单",
        selectedIndex: 3, //设置选中索引
        autoCancel: false, //点击遮障层时，不关闭弹窗
        radioContent: [{
          title: "文本菜单选项一",
          icon: $r('app.media.icon_tip_warn'),
          action: () =&amp;gt; {
          }
        },
          {
            title: "文本菜单选项二",
            icon: $r('sys.media.ohos_ic_public_voice'),
            action: () =&amp;gt; {
            }
          },
          {
            title: "文本菜单选项三",
            icon: $r('sys.media.ohos_ic_public_voice'),
            action: () =&amp;gt; {
            }
          },
          {
            title: "文本菜单选项四",
            icon: $r('sys.media.ohos_ic_public_voice'),
            action: () =&amp;gt; {
            }
          },
          {
            title: "文本菜单选项五",
            icon: $r('sys.media.ohos_ic_public_voice'),
            action: () =&amp;gt; {
            }
          }],
        onCheckedChanged: (index) =&amp;gt; {
          ToastUtil.showToast(`${index}`);
        },
        onAction: (action, dialogId, value) =&amp;gt; {
          ToastUtil.showToast(`${action} --- ${value}`);
        }
      })
    }
  }

  /**
   * 单行文本输入弹出框
   */
  textInputDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showTextInputDialog({
        autoCancel: false,
        backCancel: false,
        actionCancel: false,
        text: this.inputText,
        onAction: (action, dialogId, content) =&amp;gt; {
          if (action == DialogAction.SURE) {
            this.inputText = content;
            ToastUtil.showToast(content);
          }
          DialogHelper.closeDialog(dialogId);
        }
      })
    } else if (index == 1) {
      //自定义按钮、标题、边距等
      DialogHelper.showTextInputDialog({
        title: "支付密码",
        placeholder: "请输入密码",
        inputType: InputType.Password,
        showPassword: false,
        showPasswordIcon: true,
        passwordIcon: {
          onIconSrc: $r('sys.media.ohos_ic_public_voice'),
          offIconSrc: $r('sys.media.ohos_ic_public_voice_off')
        },
        passwordRules:"1234567",
        cancelButton: {
          style: CancelButtonStyle.INPUT
        },
        defaultFocus: true, //主动拉起键盘
        text: this.inputText,
        alignment: DialogAlignment.Bottom,
        offset: { dx: 0, dy: -35 },
        contentAreaPadding: { top: 12, bottom: 16, left: 15, right: 15 },
        buttons: [
          { value: "取消", fontColor: Color.Red },
          "确认"
        ],
        onChange: (text) =&amp;gt; {
          console.error("onChange: " + text);
        },
        onAction: (action, dialogId, content) =&amp;gt; {
          this.inputText = content;
        }
      })
    } else if (index == 2) {
      //不带标题的
      DialogHelper.showTextInputDialog({
        title: "",
        buttons: [
          '取消',
          { value: '保存', fontColor: Color.Red }
        ],
        alignment: DialogAlignment.Bottom,
        offset: { dx: 0, dy: -35 },
        contentAreaPadding: { top: 30, bottom: 10, left: 15, right: 15 },
        text: this.inputText,
        placeholder: "请输入人员年龄",
        inputType: InputType.Number,
        maxLength: 3,
        inputFilter: {
          value: "[0-9]",
          error: (value) =&amp;gt; {
            console.error("inputFilter: " + value);
          }
        },
        onChange: (text) =&amp;gt; {
          console.error("onChange: " + text);
        },
        onAction: (action, dialogId, content) =&amp;gt; {
          if (action == DialogAction.SURE) {
            this.inputText = content;
            ToastUtil.showToast(content);
          } else if (action == DialogAction.CANCEL) {

          }
        }
      })
    }
  }

  /**
   * 多行文本输入弹出框
   */
  textAreaDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showTextAreaDialog({
        text: this.inputText,
        onChange: (text) =&amp;gt; {
          console.error("onChange: " + text);
        },
        onAction: (action, dialogId, content) =&amp;gt; {
          if (action == DialogAction.SURE) {
            this.inputText = content;
            ToastUtil.showToast(content);
          }
        }
      })
    } else if (index == 1) {
      //自定义弹框高度
      DialogHelper.showTextAreaDialog({
        title: "评论内容",
        text: this.inputText,
        defaultFocus: true,
        placeholder: "请输入，[a-z,A-Z,0-9]，长度20",
        maxLength: 20,
        inputFilter: {
          value: "[0-9A-Za-z]",
          error: (value) =&amp;gt; {
            LogUtil.error("inputFilter: " + value);
          }
        },
        inputHeight: 160,
        alignment: DialogAlignment.Bottom,
        offset: { dx: 0, dy: -35 },
        buttons: [{
          value: "确认",
          fontColor: Color.Red
        }],
        autoCancel: false,
        onChange: (text) =&amp;gt; {
          console.error("onChange: " + text);
        },
        onAction: (action, dialogId, content) =&amp;gt; {
            this.inputText = content;
        }
      })
    } else if (index == 2) {
      //自定义弹框，多按钮，
      DialogHelper.showTextAreaDialog({
        primaryTitle: "批示操作弹框",
        secondaryTitle: "请填写批示意见",
        text: this.inputText,
        buttons: ["暂存", "提交"],
        autoCancel: false,
        onChange: (text) =&amp;gt; {
          console.error("onChange: " + text);
        },
        onAction: (action, dialogId, content) =&amp;gt; {
          if (action == DialogAction.SURE) {
            this.inputText = content;
            ToastUtil.showToast(content);
          }
        }
      })
    }
  }


  /**
   * 自定义内容区弹出框
   */
  customContentDialog(index: number) {
    if (index == 0) {
      //简单使用，局部 @Builder
      DialogHelper.showCustomContentDialog({
        contentBuilder: () =&amp;gt; {
          this.customTextBuilder("我是一个自定义文本内的弹框！")
        },
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else if (index == 1) {
      //自定义文本内容，使用全局 @Builder 和 自定义组件
      DialogHelper.showCustomContentDialog({
        title: "哈哈哈哈哈哈",
        contentBuilder: () =&amp;gt; {
          this.customTextBuilderParam($r('app.string.module_desc'))
        },
        buttons: [
          '取消',
          { value: '知道了', fontColor: Color.Red }
        ],
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    } else if (index == 2) {
      //自定义图文，使用局部 @Builder 和 自定义组件
      DialogHelper.showCustomContentDialog({
        primaryTitle: "爱心提示",
        secondaryTitle: "其实我是一个二级标题",
        contentBuilder: () =&amp;gt; {
          this.customTextImgBuilder("最受欢迎的三方库，@pura/harmony-utils",$r('app.media.test_as2'))
        },
        buttons: [
          { value: '取消', fontColor: Color.Black },
          { value: '知道了', fontColor: Color.Red }
        ],
        onAction: (action) =&amp;gt; {
          ToastUtil.showToast(`${action}`);
        }
      })
    }
  }

  /**
   * 动作面板
   */
  bottomSheetDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showBottomSheetDialog({
        sheets: this.menuArray,
        onAction: (index) =&amp;gt; {
          ToastUtil.showToast(`您点击了，${this.menuArray[index]}`);
        }
      })
    } else if (index == 1) {
      //带标题
      DialogHelper.showBottomSheetDialog({
        title: "请选择上传方式",
        sheets: this.menuArray,
        onAction: (index) =&amp;gt; {
          ToastUtil.showToast(`您点击了，${this.menuArray[index]}`);
        }
      })
    } else if (index == 2) {
      //自定义按钮
      DialogHelper.showBottomSheetDialog({
        title: "请选择操作方式",
        sheets: [{
          value: "文本操作选项一",
          fontColor: Color.Red,
          fontSize: 18
        }, {
          value: "文本操作选项二",
          fontColor: Color.Blue,
          fontSize: 18
        }, {
          value: "文本操作选项三",
          fontColor: Color.Brown,
          fontSize: 18
        }, {
          value: "文本操作选项四",
          fontColor: Color.Green,
          fontSize: 18
        }],
        onAction: (index) =&amp;gt; {
          ToastUtil.showToast(`您点击了第几个按钮，${index + 1}`);
        }
      })
    }
  }

  /**
   * 动作面板（IOS风格）
   */
  actionSheetDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showActionSheetDialog({
        actionCancel: false,
        sheets: this.menuArray,
        onAction: (index) =&amp;gt; {
          ToastUtil.showToast(`您点击了，${this.menuArray[index]}`);
        }
      })
    } else if (index == 1) {
      //带标题
      DialogHelper.showActionSheetDialog({
        title: "请选择上传方式",
        cancelFontColor: Color.Red,
        cancelFontWeight: FontWeight.Normal,
        sheets: this.menuArray,
        onAction: (index) =&amp;gt; {
          ToastUtil.showToast(`您点击了，${this.menuArray[index]}`);
        }
      })
    } else if (index == 2) {
      //自定义按钮
      DialogHelper.showActionSheetDialog({
        title: "请选择操作方式",
        sheets: [{
          value: "文本操作选项一",
          fontColor: Color.Red,
          fontSize: 18
        }, {
          value: "文本操作选项二",
          fontColor: Color.Blue,
          fontSize: 18
        }, {
          value: "文本操作选项三",
          fontColor: Color.Brown,
          fontSize: 18
        }, {
          value: "文本操作选项四",
          fontColor: Color.Green,
          fontSize: 18
        }],
        onAction: (index) =&amp;gt; {
          ToastUtil.showToast(`您点击了第几个按钮，${index + 1}`);
        },
        onDidDisappear: () =&amp;gt; {
          ToastUtil.showToast("ActionSheetDialog关闭了");
        }
      })
    }
  }

  /**
   * TextPickerDialog，选择器弹框
   */
  textPickerDialog(index: number) {
    if (index == 0) {
      DialogHelper.showTextPickerDialog({
        title: "请选择",
        range: this.likes,
        // range: this.rangeContent,
        onAction: (action: number, dialogId: string, value: string | string[]) =&amp;gt; {
          if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已选择：${value as string}`);
          }
        }
      })
    } else if (index == 1) {
      DialogHelper.showTextPickerDialog({
        autoCancel: false,
        title: "请选择",
        titleFontColor: Color.Pink,
        titleBackground: "#E6E6E6",
        primaryButton: "取消",
        secondaryButton: {
          value: "确定",
          fontColor: Color.Red,
        },
        range: this.multis,
        value: ["apple2", "orange3", "peach1"], //设置选中
        onAction: (action: number, dialogId: string, value: string | string[]) =&amp;gt; {
          if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已选择：${value as string}`);
          }
        },
        onChange: (value: string | string[], index: number | number[]): void =&amp;gt; {
          LogUtil.error(`value: ${value}`);
          LogUtil.error(`index: ${index}`);
        }
      })
    } else if (index == 2) {
      let aiHuiList = AreaHelper.getCityByNameSync("安徽省");
      DialogHelper.showTextPickerDialog({
        range: aiHuiList,
        onAction: (action: number, dialogId: string, value: string | string[]) =&amp;gt; {
          if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已选择：${value}`);
          }
        }
      })
    } else if (index == 3) {
      let areas = AreaHelper.getAreaSync();
      DialogHelper.showTextPickerDialog({
        title: "请选择收货地址",
        range: areas,
        onAction: (action: number, dialogId: string, value: string | string[]) =&amp;gt; {
          if (action == DialogAction.SURE) {
            ToastUtil.showToast(`已选择：${value}`);
          }
        }
      })
    }
  }


  /**
   * DatePickerDialog，日期选择器弹框
   */
  datePickerDialog(index: number) {
    if (index == 0) {
      DialogHelper.showDatePickerDialog({
        dateType: DateType.YmdHms,
        onAction: (action: number, dialogId: string, date: Date): void =&amp;gt; {
          if (action == DialogAction.SURE) {
            let dateStr = DateUtil.getFormatDateStr(date, "yyyy-MM-dd HH:mm:ss");
            ToastUtil.showToast(`选中日期：${dateStr}`);
            LogUtil.error(`选中日期：${dateStr}`);
          }
        }
      })
    } else if (index == 1) {
      DialogHelper.showDatePickerDialog({
        primaryButton: {
          value: "取消",
          fontColor: Color.Red
        },
        secondaryButton: "确认",
        title: "请选择日期",
        dateType: DateType.YmdHm,
        // selected: new Date("2999-12-16 19:20:35"),
        start:new Date("1976-01-01 00:00:00"),
        end: new Date(),
        onAction: (action: number, dialogId: string, date: Date): void =&amp;gt; {
          if (action == DialogAction.SURE) {
            let dateStr = DateUtil.getFormatDateStr(date, "yyyy-MM-dd HH:mm");
            ToastUtil.showToast(`选中日期：${dateStr}`);
            LogUtil.error(`选中日期：${dateStr}`);
          }
        }
      })
    } else if (index == 2) {
      DialogHelper.showDatePickerDialog({
        title: "请选择年月日",
        dateType: DateType.YmdH,
        canLoop: false,
        onAction: (action: number, dialogId: string, date: Date): void =&amp;gt; {
          if (action == DialogAction.SURE) {
            let dateStr = DateUtil.getFormatDateStr(date, "yyyy-MM-dd HH");
            ToastUtil.showToast(`选中日期：${dateStr}`);
            LogUtil.error(`选中日期：${dateStr}`);
          }
        }
      })
    } else if (index == 3) {
      DialogHelper.showDatePickerDialog({
        title: "请选择时分秒",
        transition: AnimationHelper.transitionInDown(300),
        dateType: DateType.Hms,
        onAction: (action: number, dialogId: string, date: Date): void =&amp;gt; {
          if (action == DialogAction.SURE) {
            let dateStr = DateUtil.getFormatDateStr(date, "HH:mm:ss");
            ToastUtil.showToast(`选中日期：${dateStr}`);
            LogUtil.error(`选中日期：${dateStr}`);
          }
        }
      })
    }
  }


  /**
   * 显示自定义弹窗
   */
  customDialog(index: number) {
    if (index == 0) {
      //自定义一个Tip弹出框
      let tipOptions: TipOptions = {
        autoCancel: true,
        backCancel: true,
        title: "提交成功",
        content: "请假单已成功提交给您的领导啦",
        levelMode:LevelMode.EMBEDDED,
        onAction: (action, dialogId) =&amp;gt; {
          router.pushUrl({ url: "pages/spinkit/SpinKit1" });
          // DialogHelper.closeDialog(dialogId);
        }
      };
      DialogHelper.showCustomDialog(wrapBuilder(TipBuilder), tipOptions);
    } else if (index == 1) {
      //自定义一个底部的MenuLayout
      let menuOptions: MenuOptions = {
        transition:AnimationHelper.transitionInDown(),
        alignment: DialogAlignment.Bottom,
        title: "分享",
        menus: Utils.getMenus(),
        onItemClick: (menu) =&amp;gt; {
          DialogHelper.showToast(menu.text);
          DialogHelper.closeDialog(menuOptions.dialogId ?? "");
        }
      };
      DialogHelper.showCustomDialog(wrapBuilder(MenuBuilder), menuOptions);
    } else if (index == 2) {
      //自定义一个左边的DrawerLayout
      let drawer: DrawerOptions = {
        width: px2vp(DisplayUtil.getWidth()) - 50, //自定义的宽度
        autoCancel: false,
        alignment: DialogAlignment.TopStart,
        keyboardAvoidMode: KeyboardAvoidMode.NONE,
        transition: AnimationHelper.transitionInLeft(250)
      };
      DialogHelper.showCustomDialog(wrapBuilder(DrawerBuilder), drawer);
    } else {
      //基于Lottie动画的自定义加载框
      let loadOptions: LoadOptions = new LoadOptions();
      loadOptions.backCancel = true;
      DialogHelper.showCustomDialog(wrapBuilder(LottieBuilder), loadOptions);
      setTimeout(() =&amp;gt; {
        DialogHelper.closeDialog(loadOptions.dialogId ?? "");
      }, 10000)
    }
  }


  /**
   * 显示自定义半模态
   */
  showBindSheet(index: number) {
    // let targetId = this.getUniqueId();
    let targetId = "10001";

    //自定义一个底部的MenuLayout
    let menuOptions: MenuSheetOptions = {
      dialogId: DialogHelper.generateId(),
      title: {
        title: "分享我的动态",
      },
      detents: [SheetSize.FIT_CONTENT, SheetSize.MEDIUM, SheetSize.FIT_CONTENT],
      borderWidth: 10,
      borderColor: Color.White,
      targetId: targetId,
      mode: SheetMode.EMBEDDED,
      preferType: SheetType.BOTTOM,
      menus: Utils.getMenus(),
      onItemClick: (menu) =&amp;gt; {
        router.pushUrl({ url: "pages/spinkit/SpinKit1" });
        DialogHelper.showToast(menu.text);
      }
    };
    DialogHelper.showBindSheet(wrapBuilder(MenuSheetBuilder), menuOptions);
  }


  /**
   * 显示进度加载类弹出框
   */
  loadingDialog(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showLoadingDialog({ autoCancel: true })
    } else if (index == 1) {
      //自定义文字内容
      DialogHelper.showLoadingDialog({
        loadColor: Color.White,
        content: "努力加载中",
        fontSize: 15,
        backgroundColor: '#ED000000',
        autoCancel: true,
      })
    } else if (index == 2) {
      //指定加载动画和加载动画的颜色
      DialogHelper.showLoadingDialog({
        loadType: SpinType.spinH,
        loadColor: $r('app.color.color_main'),
        backgroundColor: '#DD000000',
        fontColor: Color.White,
        borderRadius: 8
      })
    } else {
      //禁止点击返回关闭弹窗 和 禁止点击遮蔽层关闭弹窗
      let dialogId = DialogHelper.showLoadingDialog({
        loadType: SpinType.spinU,
        loadColor: $r('app.color.color_main'),
        marginTop: 20,
        content: "努力加载中",
        fontColor: $r('app.color.color_main'),
        autoCancel: false,
        backCancel: false
      })
      //延时关闭
      let timeoutID = setTimeout(() =&amp;gt; {
        DialogHelper.closeDialog(dialogId); //关闭加载框
        clearTimeout(timeoutID);
      }, 5000);
    }
  }

  /**
   * 进度条加载弹框
   */
  loadingProgress(index: number) {
    if (index == 0) {
      //简单使用
      this.progress = 50;
      let dialogId = DialogHelper.showLoadingProgress({
        progress: this.progress,
      });
      //模拟网络
      let intervalID = setInterval(() =&amp;gt; {
        if (this.progress &amp;lt; 100) {
          this.progress = this.progress + 1
          DialogHelper.updateLoading(dialogId, "", this.progress)
          console.log("progress: " + this.progress);
        } else {
          DialogHelper.closeDialog(dialogId); //加载成功
          ToastUtil.showToast("加载成功啦~");
          clearInterval(intervalID);
        }
      }, 100);
    } else if (index == 1) {
      //自定义加载内容和主题色
      this.progress = 10;
      let dialogId = DialogHelper.showLoadingProgress({
        progress: this.progress,
        content: "努力加载中",
        loadColor: $r('app.color.color_main'),
        fontColor: $r('app.color.color_main'),
        autoCancel: false,
        shadow: { radius: 0 }
      })
      //模拟网络
      let intervalID = setInterval(() =&amp;gt; {
        if (this.progress &amp;lt; 100) {
          this.progress = this.progress + 1
          DialogHelper.updateLoading(dialogId, undefined, this.progress)
          console.log("progress: " + this.progress);
        } else {
          DialogHelper.closeDialog(dialogId); //加载成功
          ToastUtil.showToast("加载成功啦~");
          clearInterval(intervalID);
        }
      }, 150);
    } else if (index == 2) {
      //自定义加载内容和主题色
      this.progress = 0;
      let dialogId = DialogHelper.showLoadingProgress({
        progress: this.progress,
        content: "文件下载中",
        loadColor: Color.White,
        autoCancel: false,
      })
      //模拟网络
      let intervalID = setInterval(() =&amp;gt; {
        if (this.progress &amp;lt; 100) {
          this.progress = this.progress + 1
          DialogHelper.updateLoading(dialogId, undefined, this.progress)
          console.log("progress: " + this.progress);
        } else {
          DialogHelper.closeDialog(dialogId); //加载成功
          ToastUtil.showToast("下载成功啦~");
          clearInterval(intervalID);
        }
      }, 200);
    }
  }

  /**
   * 自定义的吐司
   */
  toast(index: number) {
    if (index == 0) {
      //简单使用,长文本
      DialogHelper.showToast("女人什么年龄是最好？任何年龄都可以。因为每个年龄段都有不一样的美。看XX的穿搭你就会发现成熟女性的魅力，反而会更加的吸引人。难道这就是传说中的可爱在性感面前真的不值得一提吗？")
    } else if (index == 1) {
      //自定义的长吐司
      DialogHelper.showToastLong("这是一个自定义的长吐司呀~~~", {
        fontColor: Color.White,
        backgroundColor: "#DD0066FF",
        bottom: "120vp"
      });
    } else if (index == 2) {
      //自定义吐司
      DialogHelper.showToast("这是一个居中的自定义吐司", {
        fontColor: Color.Red,
        backgroundColor: Color.Black,
        alignment: Alignment.Center,
      });
    } else {
      //自定义吐司
      DialogHelper.showToastLong("这是一个距离顶部100vp的自定义吐司", {
        fontColor: Color.White,
        backgroundColor: "#99FF0000",
        alignment: Alignment.Top,
        offset: { dx: 0, dy: vp2px(100) }
      });
    }
  }

  /**
   * 带图标的吐司Tip
   */
  toastTip(index: number) {
    if (index == 0) {
      //简单使用
      DialogHelper.showToastTip({
        message: "操作成功",
        imageRes: $r('app.media.icon_tip_ok')
      })
    } else if (index == 1) {
      DialogHelper.showToastTip({
        message: "操作失败",
        imageRes: $r('app.media.icon_tip_warn')
      })
    } else if (index == 2) {
      //自定义背景和圆角
      DialogHelper.showToastTip({
        message: "操作成功",
        imageRes: $r('app.media.icon_tip_info'),
        backgroundColor: $r('app.color.color_main'),
        borderRadius: 6
      })
    } else {
      //自定义颜色和时长
      DialogHelper.showToastTip({
        message: "操作成功",
        imageRes: $r('app.media.icon_tip_ok'),
        // fontColor: $r('app.color.color_main'),
        alignment: DialogAlignment.Bottom,
        offset: { dy: -100, dx: 0 },
        duration: 2000,
        orientation: Orientation.HORIZONTAL,
        imageSize: { height: 24, width: 24 },
        margin: 8,
      })
    }
  }

  build() {
    Column() {
      TitleView({ title: "弹框指南" })
      Scroll(this.scroller) {
        Column() {
          CardButton({
            label: "弹框，加载框、吐司 的统一配置",
            buttons:["配置一", "配置二", "默认的配置"],
            onClickAction: (index: number): void =&amp;gt; {
              if (index === 0) {
                this.customConfig1();
              } else if (index === 1) {
                this.customConfig2();
              } else {
                this.defaultConfig();
              }
            }
          })

          CardButton({
            label: "AlertDialog",
            content: "操作确认类弹出框",
            onClickAction: (index: number): void =&amp;gt; this.alertDialog(index)
          })
          CardButton({
            label: "ConfirmDialog",
            content: "信息确认类弹出框",
            onClickAction: (index: number): void =&amp;gt; this.confirmDialog(index)
          })
          CardButton({
            label: "TipsDialog",
            content: "提示弹出框",
            onClickAction: (index: number): void =&amp;gt; this.tipsDialog(index)
          })
          CardButton({
            label: "SelectDialog",
            content: "选择类弹出框",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.selectDialog(index)
          })
          CardButton({
            label: "TextInputDialog",
            content: "单行文本输入弹出框",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.textInputDialog(index)
          })
          CardButton({
            label: "TextAreaDialog",
            content: "多行文本输入弹出框",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.textAreaDialog(index)
          })
          CardButton({
            label: "CustomContentDialog",
            content: "显示自定义内容区弹出框，同时支持定义操作区按钮样式",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.customContentDialog(index)
          })
          CardButton({
            label: "BottomSheetDialog",
            content: "显示动作面板",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.bottomSheetDialog(index)
          })
          CardButton({
            label: "ActionSheetDialog",
            content: "显示动作面板（IOS风格）",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.actionSheetDialog(index)
          })
          CardButton({
            label: "TextPickerDialog",
            content: "选择器弹框-TextPicker",
            num: 4,
            onClickAction: (index: number): void =&amp;gt; this.textPickerDialog(index)
          })
          CardButton({
            label: "DatePickerDialog",
            content: "日期选择器弹框",
            num: 4,
            onClickAction: (index: number): void =&amp;gt; this.datePickerDialog(index)
          })
          CardButton({
            label: "CustomDialog",
            content: "自定义弹窗",
            onClickAction: (index: number): void =&amp;gt; this.customDialog(index)
          })
          CardButton({
            label: "BindSheet",
            content: "自定义半模态",
            onClickAction: (index: number): void =&amp;gt; this.showBindSheet(index)
          })
            .id("10001")
          CardButton({
            label: "LoadingDialog",
            content: "进度加载类弹出框",
            onClickAction: (index: number): void =&amp;gt; this.loadingDialog(index)
          })
          CardButton({
            label: "LoadingProgress",
            content: "进度条加载弹框",
            num: 3,
            onClickAction: (index: number): void =&amp;gt; this.loadingProgress(index)
          })
          CardButton({
            label: "Toast",
            content: "自定义的吐司",
            onClickAction: (index: number): void =&amp;gt; this.toast(index)
          })
          CardButton({
            label: "ToastTip",
            content: "带图标的吐司Tip",
            onClickAction: (index: number): void =&amp;gt; this.toastTip(index)
          })
            .margin({ bottom: 15 })
        }
      }
      .layoutWeight(1)
      .width('100%')
      .backgroundColor($r('app.color.main_background'))
    }
  }


  //自定义文本
  @Builder
  customTextBuilder(content: string) {
    Text(content)
      .fontFamily('MyFont')
      .fontColor($r('app.color.font_title'))
      .fontSize(16)
      .padding(5)
      .textShadow({
        color: Color.Brown,
        type: ShadowType.COLOR,
        radius: 3,
        offsetX: 5,
        offsetY: 5,
        fill: false
      })
  }


  //自定义文本和图片
  @Builder
  customTextImgBuilder(content: ResourceStr, src: Resource) {
    CustomImageView({ content: content, src: src })
  }


}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>harmonyos</category>
      <category>harmony</category>
      <category>arkts</category>
    </item>
    <item>
      <title>harmony-dialog</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 15:09:43 +0000</pubDate>
      <link>https://dev.to/787107497/harmony-dialog-17gp</link>
      <guid>https://dev.to/787107497/harmony-dialog-17gp</guid>
      <description>&lt;h1&gt;
  
  
  harmony-dialog(API12+)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt; An extremely simple and easy-to-use zero-invasion pop-up window, which can be easily implemented with just one line of code, and can be easily popped up no matter where you are. It covers&lt;br&gt;
AlertDialog, TipsDialog, ConfirmDialog, SelectDialog, CustomContentDialog, TextInputDialog, TextAreaDialog, BottomSheetDialog, ActionSheetDialog, TextPickerDialog, DatePickerDialog, CustomDialog, BindSheet, LoadingDialog, LoadingProgress, Toast, ToastTip&lt;br&gt;
Various types can meet various pop-up development needs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌞Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @pura/harmony-dialog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚API detailed explanation&lt;a href="https://blog.csdn.net/qq_32922545/article/details/144492075" rel="noopener noreferrer"&gt;预览效果&lt;/a&gt;🌞
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;DialogHelper Method&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;setDefaultConfig&lt;/td&gt;
&lt;td&gt;Set default uniform style&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showAlertDialog&lt;/td&gt;
&lt;td&gt;Display operation confirmation class pop-up box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showConfirmDialog&lt;/td&gt;
&lt;td&gt;Display information confirmation class pop-up box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showTipsDialog&lt;/td&gt;
&lt;td&gt;The display prompt pop-up box is a confirmation box with graphics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showSelectDialog&lt;/td&gt;
&lt;td&gt;Show Select class pop-up box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showTextInputDialog&lt;/td&gt;
&lt;td&gt;Show single line text input pop-up box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showTextAreaDialog&lt;/td&gt;
&lt;td&gt;Show multi-line text input box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showCustomContentDialog&lt;/td&gt;
&lt;td&gt;Display the pop-up box of the custom content area, and supports defining the button style of the operation area&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showBottomSheetDialog&lt;/td&gt;
&lt;td&gt;Show action panel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showActionSheetDialog&lt;/td&gt;
&lt;td&gt;Show Action Panel (IOS Style)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showTextPickerDialog&lt;/td&gt;
&lt;td&gt;Display selector pop-up box; refer to the TextPicker component; cooperate&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@nutpi%2Fchina_area" rel="noopener noreferrer"&gt;china_area&lt;/a&gt;Data selection of provinces, cities and counties in China can be made.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showDatePickerDialog&lt;/td&gt;
&lt;td&gt;Show date selector pop-up box, in conjunction&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt;The DateUtil tool class uses, formats the date.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showCustomDialog&lt;/td&gt;
&lt;td&gt;Show custom popups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;update&lt;/td&gt;
&lt;td&gt;Refresh custom pop-ups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;isShowing&lt;/td&gt;
&lt;td&gt;Is the current pop-up window displayed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;closeDialog&lt;/td&gt;
&lt;td&gt;Close pop-up box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showLoadingDialog&lt;/td&gt;
&lt;td&gt;Show loading class pop-up box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showLoadingProgress&lt;/td&gt;
&lt;td&gt;Show progress bar loading box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;updateLoading&lt;/td&gt;
&lt;td&gt;Refresh loading box&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showBindSheet&lt;/td&gt;
&lt;td&gt;Show custom semi-modal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;updateBindSheet&lt;/td&gt;
&lt;td&gt;Refresh custom semi-modal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;closeBindSheet&lt;/td&gt;
&lt;td&gt;Show toast with graphics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showToast&lt;/td&gt;
&lt;td&gt;Show Toast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showToastLong&lt;/td&gt;
&lt;td&gt;Show long toast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showToastShort&lt;/td&gt;
&lt;td&gt;Show short toast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;showToastTip&lt;/td&gt;
&lt;td&gt;Show toast with graphics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;generateId&lt;/td&gt;
&lt;td&gt;GenerateBox ID&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AnimationHelper Method&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;transitionInUp&lt;/td&gt;
&lt;td&gt;InUp animation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;transitionInDown&lt;/td&gt;
&lt;td&gt;InDown Animation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;transitionInLeft&lt;/td&gt;
&lt;td&gt;InLeft Animation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;transitionInRight&lt;/td&gt;
&lt;td&gt;InRight Animation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  📚Sample code&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/index/DialogPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //简单初始化（1.0.8版本及以后）
    //必须在UIAbility的onCreate方法里初始化context。
    DialogHelper.setDefaultConfig((config) =&amp;gt; {
      config.uiAbilityContext = this.context;
    })

    //设置默认的统一配置，在UIAbility的onCreate方法里初始化
    DialogHelper.setDefaultConfig((config) =&amp;gt; {
      config.uiAbilityContext = this.context  //必须初始化上下文
      config.autoCancel = true; //点击遮障层时，是否关闭弹窗，true表示关闭弹窗。false表示不关闭弹窗。默认值：true
      config.backCancel = true; //点击返回键或手势返回时，是否关闭弹窗；实现onWillDismiss函数时，该参数不起作用。true表示关闭弹窗。false表示不关闭弹窗。默认值：true。
      config.actionCancel = true; //点击操作按钮时，是否关闭弹窗。false表示不关闭弹窗。默认值：true。
      config.alignment = DialogAlignment.Center; //弹窗的对齐方式。
      config.offset = { dx: 0, dy: 0 }; //弹窗相对alignment所在位置的偏移量。默认值：{ dx: 0, dy: 0 }
      config.maskColor = 0x33000000; //自定义蒙层颜色。默认值 0x33000000
      config.backgroundColor = Color.White; //弹窗背板颜色。默认值：Color.White
      config.backgroundBlurStyle = BlurStyle.COMPONENT_ULTRA_THICK; //弹窗背板模糊材质。默认值：BlurStyle.COMPONENT_ULTRA_THICK
      config.cornerRadius = 20; //设置背板的圆角半径。可分别设置4个圆角的半径。

      config.title = '温馨提示'; //弹框标题
      config.primaryButton = '取消'; //弹框左侧按钮。
      config.secondaryButton = '确定'; //弹框右侧按钮。
      config.imageRes = undefined; //TipsDialog用到，展示的图片。
      config.imageSize = { width: '64vp', height: '64vp' }; //TipsDialog用到，自定义图片尺寸。默认值：64*64vp

      config.loading_loadSize = 60; //加载动画或进度条的大小
      config.loading_loadColor = Color.White; //加载动画或进度条的颜色
      config.loading_content = ''; //加载动画的提示文字
      config.loading_fontSize = 16; //文字大小
      config.loading_fontColor = Color.White; //文字颜色
      config.loading_backgroundColor = '#CC000000'; //背景颜色，八位色值前两位为透明度
      config.loading_borderRadius = 10; //背景圆角

      config.picker_textStyle = ; //设置所有选项中除了最上、最下及选中项以外的文本颜色、字号、字体粗细。
      config.picker_selectedTextStylee = ; //设置选中项的文本颜色、字号、字体粗细。
      config.picker_disappearTextStylee = ; //设置所有选项中最上和最下两个选项的文本颜色、字号、字体粗细。
      config.picker_divider: DividerOptions = { strokeWidth: '2px', startMargin: 0, endMargin: 0, color: '#33000000' }; //设置分割线样式，不设置该属性则按“默认值”展示分割线。
      config.picker_canLoop: boolean = true; //设置是否可循环滚动。
      config.picker_titleFontColor = $r("sys.color.ohos_id_picker_title_text_color"); //弹框标题的字体颜色。
      config.picker_titleBackground = "#F9F9F9"; //头部背景颜色
      config.picker_buttonFontColor = $r("sys.color.ohos_id_picker_button_text_color"); //按钮颜色

      config.toast_duration = 2000; //显示时长(1500ms-10000ms)
      config.toast_durationLong = 10000; //显示时长(10000ms)
      config.toast_fontSize = 16; //文字大小
      config.toast_fontColor = Color.White; //文字颜色
      config.toast_backgroundColor = '#CC000000'; //背景颜色，建议八位色值前两位为透明度
      config.toast_borderRadius = 8; //背景圆角
      config.toast_padding = { left: 16, right: 16, top: 12, bottom: 12 }; //Padding
      config.toast_orientation = Orientation.VERTICAL; //吐司布局方向，默认垂直。设置该值时，请重新设置imageSize和margin。
      config.toast_imageSize = { width: 45, height: 45 }; //Tip图片尺寸。垂直默认值：45*45vp，水平建议值：24*24vp。
      config.toast_margin = 10; //吐司的图片与文字间距。
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //在子窗口 使用弹框需要传入uiContext
    DialogHelper.showTipsDialog({
      uiContext:this.getUIContext(), //子窗口需要传入UIContext
      content: '想要卸载这个APP嘛?',
      onAction: (action) =&amp;gt; {
        ToastUtil.showToast(`${action}`);
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //操作确认类弹出框
    DialogHelper.showAlertDialog({
      content: "确定保存该WPS文件吗？",
      onAction: (action) =&amp;gt; {
        if (action == DialogAction.CANCEL) {
          ToastUtil.showToast(`您点击了取消按钮`);
        } else if (action == DialogAction.SURE) {
          ToastUtil.showToast(`您点击了确认按钮`);
        }
      }
    })


    //信息确认类弹出框
    DialogHelper.showConfirmDialog({
      checkTips: "是否记住密码？",
      content: "您是否退出当前应用",
      onCheckedChange: (check) =&amp;gt; {
        ToastUtil.showToast(`${check}`);
      },
      onAction: (action) =&amp;gt; {
        ToastUtil.showToast(`${action}`);
      }
    })


    //提示弹出框
    DialogHelper.showTipsDialog({
      content: '想要卸载这个APP嘛?',
      onAction: (action) =&amp;gt; {
        ToastUtil.showToast(`${action}`);
      }
    })


    //选择类弹出框
    DialogHelper.showSelectDialog({
      radioContent: ["文本菜单选项一", "文本菜单选项二", "文本菜单选项三", "文本菜单选项四", "文本菜单选项五"],
      onCheckedChanged: (index) =&amp;gt; {
        ToastUtil.showToast(`${index}`);
      },
      onAction: (action, dialogId, value) =&amp;gt; {
        ToastUtil.showToast(`${action} --- ${value}`);
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //单行文本输入弹出框
    DialogHelper.showTextInputDialog({
      text: this.inputText,
      onChange: (text) =&amp;gt; {
        console.error("onChange: " + text);
      },
      onAction: (action, dialogId, content) =&amp;gt; {
        if (action == DialogAction.SURE) {
          this.inputText = content;
        }
      }
    })


    //多行文本输入弹出框
    DialogHelper.showTextAreaDialog({
      text: this.inputText,
      onChange: (text) =&amp;gt; {
        console.error("onChange: " + text);
      },
      onAction: (action, dialogId, content) =&amp;gt; {
        if (action == DialogAction.SURE) {
          this.inputText = content;
        }
      }
    })


    //自定义内容区弹出框
    DialogHelper.showCustomContentDialog({
      contentBuilder: () =&amp;gt; {
        this.customTextBuilder("我是一个自定义弹框！")
      },
      onAction: (action) =&amp;gt; {
        ToastUtil.showToast(`${action}`);
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //动作面板
    DialogHelper.showBottomSheetDialog({
      title: "请选择上传方式",
      sheets: ["相机", "相册", "文件管理器"],
      onAction: (index) =&amp;gt; {
        ToastUtil.showToast(`您点击了，${this.menuArray[index]}`);
      }
    })


    //动作面板（IOS风格）
    DialogHelper.showActionSheetDialog({
      title: "请选择上传方式",
      sheets: ["相机", "相册", "文件管理器"],
      onAction: (index) =&amp;gt; {
        ToastUtil.showToast(`您点击了，${this.menuArray[index]}`);
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //选择器弹框（TextPickerDialog）
    let areas = AreaHelper.getAreaSync();
    DialogHelper.showTextPickerDialog({
      title: "请选择收货地址",
      range: areas,
      onAction: (action: number, dialogId: string, value: string | string[]) =&amp;gt; {
        if (action == DialogAction.SURE) {
          ToastUtil.showToast(`已选择：${value}`);
        }
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //日期选择器弹框（DatePickerDialog）
    DialogHelper.showDatePickerDialog({
      dateType: DateType.YmdHm,
      onAction: (action: number, dialogId: string, date: Date): void =&amp;gt; {
        if (action == DialogAction.SURE) {
          let dateStr = DateUtil.getFormatDateStr(date, "yyyy-MM-dd HH:mm");
          ToastUtil.showToast(`选中日期：${dateStr}`);
          LogUtil.error(`选中日期：${dateStr}`);
        }
      }
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //进度加载类弹出框
    DialogHelper.showLoadingDialog({
      loadType: SpinType.spinP,
      loadColor: Color.White,
      loadSize: 70,
      backgroundColor: '#BB000000',
      content: "加载中…",
      fontSize: 18,
      padding: { top: 30, right: 50, bottom: 30, left: 50 },
      autoCancel: true
     })


    //进度条加载弹框
    DialogHelper.showLoadingProgress({ progress: this.progress })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    //吐司
    DialogHelper.showToast("这是一个自定义吐司")
    DialogHelper.showToastLong("这是一个自定义的长吐司呀")


    //吐司Tip
    DialogHelper.showToastTip({
      message: "操作成功",
      imageRes: $r('sys.media.ohos_ic_public_ok')
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   //自定义弹窗
    let drawer: DrawerOptions = {
      width: 260,
      msg: "这是一个自定义弹框，DrawerLayout",
      alignment: DialogAlignment.CenterStart,
      offset: { dx: 0, dy: 0 },
      transition: AnimationHelper.transitionInLeft(250)
    }
    DialogHelper.showCustomDialog(wrapBuilder(DrawerBuilder), drawer)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gitee.com/tongyuyan/harmony-utils" rel="noopener noreferrer"&gt;https://gitee.com/tongyuyan/harmony-utils&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/787107497" rel="noopener noreferrer"&gt;https://github.com/787107497&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>harmonyos</category>
      <category>arkts</category>
    </item>
    <item>
      <title>EventBus</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 14:58:06 +0000</pubDate>
      <link>https://dev.to/787107497/eventbus-15e0</link>
      <guid>https://dev.to/787107497/eventbus-15e0</guid>
      <description>&lt;h1&gt;
  
  
  EventBus
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@nutpi%2Feventbus" rel="noopener noreferrer"&gt;EventBus&lt;/a&gt; Message bus, supports Sticky, supports cross-APP broadcasting.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌞Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @nutpi/eventbus&lt;/code&gt;&lt;br&gt;
OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚API detailed explanation
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;EventBus method&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;on&lt;/td&gt;
&lt;td&gt;Register Event Listening&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;once&lt;/td&gt;
&lt;td&gt;Register a single event listening&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;off&lt;/td&gt;
&lt;td&gt;Logout event listening&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;offAll&lt;/td&gt;
&lt;td&gt;Log out all event listening&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;post&lt;/td&gt;
&lt;td&gt;Post regular news&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;postSticky&lt;/td&gt;
&lt;td&gt;Post sticky news&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;postApp&lt;/td&gt;
&lt;td&gt;Publish cross-app messages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getSticky&lt;/td&gt;
&lt;td&gt;Get sticky event data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;removeSticky&lt;/td&gt;
&lt;td&gt;Remove sticky events&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  📚Sample code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//注册事件监听
EventBus.on('id', (id: string) =&amp;gt; {
  ToastUtil.showToast(`ID: ${id}`);
});

//注册单次事件监听
EventBus.once('id', (id: string) =&amp;gt; {
  ToastUtil.showToast(`单次ID: ${id}`);
});


//发布普通消息
EventBus.post('id', '100001200');

//发布粘性消息
EventBus.postSticky('id', '100001201');

//发布跨App消息
EventBus.postApp('id', '100001202');


//获取粘性事件数据
let sticky = EventBus.getSticky('id');
ToastUtil.showToast(`粘性事件数据：${sticky}`);

//移除粘性事件
EventBus.removeSticky('id');
ToastUtil.showToast(`移除粘性事件成功！`);


//注销事件监听
EventBus.off('id');

//注销所有事件监听
EventBus.offAll();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Full Code Example
&lt;/h2&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { router } from '@kit.ArkUI';
import { TitleBarView } from '../../component/TitleBarView';
import { DescribeBean } from '../../model/DescribeBean';
import { EventBus } from '@nutpi/eventbus';
import { ToastUtil } from '@pura/harmony-utils';
import { DialogHelper } from '@pura/harmony-dialog';

/**
 * @nutpi/eventbus，使用案例
 */
@Entry
@ComponentV2
export struct EventBusPage {
  private scroller: Scroller = new Scroller();
  @Local describe: DescribeBean = router.getParams() as DescribeBean;
  @Local txtStr: string = "";

  build() {
    Column() {
      TitleBarView({ describe: this.describe })
      Divider()
      Scroll(this.scroller) {
        Column({ space: 5 }) {
          Button("on()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              //注册事件监听
              EventBus.on('id', (id: string) =&amp;gt; {
                DialogHelper.showAlertDialog({
                  autoCancel: false,
                  backCancel: false,
                  content: `ID: ${id}`,
                  primaryButton: '已收到',
                  onAction: (action, id) =&amp;gt; {
                    DialogHelper.closeDialog(id);
                  }
                });
              });
              ToastUtil.showToast(`注册事件监听成功！`);
            })
          Button("once()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              //注册单次事件监听
              EventBus.once('id', (id: string) =&amp;gt; {
                DialogHelper.showAlertDialog({
                  autoCancel: false,
                  backCancel: false,
                  content: `单次ID: ${id}`,
                  primaryButton: '已收到',
                  onAction: (action, id) =&amp;gt; {
                    DialogHelper.closeDialog(id);
                  }
                });
              });
              ToastUtil.showToast(`注册单次事件监听成功！`);
            })
          Button("post()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              EventBus.post('id', '100001200');
              ToastUtil.showToast(`发布普通消息！`);
            })
          Button("postSticky()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              EventBus.postSticky('id', '100001201');
              ToastUtil.showToast(`发布粘性消息！`);
            })
          Button("getSticky()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              let sticky = EventBus.getSticky('id');
              ToastUtil.showToast(`粘性事件数据：${sticky}`);
            })
          Button("removeSticky()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              EventBus.removeSticky('id');
              ToastUtil.showToast(`移除粘性事件成功！`);
            })
          Button("postApp()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              EventBus.postApp('id', '100001202');
              ToastUtil.showToast(`发布跨App消息！`);
            })
          Button("off()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              //注销事件监听
              EventBus.off('id');
              ToastUtil.showToast(`注销事件监听！`);
            })
          Button("offAll()")
            .btnStyle()
            .onClick(() =&amp;gt; {
              //注销所有事件监听
              EventBus.offAll();
              ToastUtil.showToast(`注销所有事件监听！`);
            })

          Blank().layoutWeight(1)
        }
        .margin({ top: 5, bottom: 5 })
      }
      .layoutWeight(1)
    }
    .width('100%')
    .height('100%')
    .backgroundColor($r('app.color.main_background'))
  }
}


@Styles
function btnStyle() {
  .width('90%')
  .margin({ top: 10, bottom: 5 })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>haromonyos</category>
      <category>arkts</category>
    </item>
    <item>
      <title>china_area</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 14:51:53 +0000</pubDate>
      <link>https://dev.to/787107497/chinaarea-o9h</link>
      <guid>https://dev.to/787107497/chinaarea-o9h</guid>
      <description>&lt;h1&gt;
  
  
  china_area
&lt;/h1&gt;

&lt;h2&gt;
  
  
  🏆Introduction and Recommendations
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@nutpi%2Fchina_area" rel="noopener noreferrer"&gt;china_area&lt;/a&gt; China's regional data, provincial, municipal and county data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt; A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-dialog" rel="noopener noreferrer"&gt;harmony-dialog&lt;/a&gt; An extremely simple and easy-to-use zero-invasion pop-up window, which can be easily implemented with just one line of code, and can be easily popped up no matter where you are.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌞Download and install
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ohpm i @nutpi/china_area&lt;/code&gt;&lt;br&gt;
OpenHarmony ohpm&lt;br&gt;
For more information, please refer to&lt;a href="https://ohpm.openharmony.cn/#/cn/help/downloadandinstall" rel="noopener noreferrer"&gt;如何安装 OpenHarmony ohpm 包&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚API detailed explanation&lt;a href="https://gitee.com/tongyuyan/harmony-utils/blob/master/entry/src/main/ets/pages/plug/ChinaAreaPage.ets" rel="noopener noreferrer"&gt;使用案例&lt;/a&gt;
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AreaHelper Method&lt;/th&gt;
&lt;th&gt;Introduction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;getAreaStrSync&lt;br&gt;getAreaStr&lt;/td&gt;
&lt;td&gt;Get JSON strings for provinces, cities and counties&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getAreaSync&lt;br&gt;getArea&lt;/td&gt;
&lt;td&gt;Get data from provinces, cities and counties&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getCityByNameSync&lt;br&gt;getCityByName&lt;/td&gt;
&lt;td&gt;Get the following city according to the provincial name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;getDintrictByNameSync&lt;br&gt;getDintrictByName&lt;/td&gt;
&lt;td&gt;Get the following district and county based on the city name&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  📚Sample code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//获取省市县的JSON字符串
let txtStr = await AreaHelper.getAreaStr();
let areaList = JSONUtil.jsonToArray&amp;lt;AreaEntity&amp;gt;(txtStr);


//获取省市县的数据
let areas = AreaHelper.getAreaSync();


//根据省名获取下面的市
let citys = await AreaHelper.getCityByName("安徽省");


//根据市名获取下面的区县
let list = AreaHelper.getDistrictByNameSync("合肥市");


//配合‘@pura/harmony-dialog’的\nshowTextPickerDialog()方法使用
let data = AreaHelper.getAreaSync();
DialogHelper.showTextPickerDialog({
  title: "请选择",
  range: data,
  onChange: (value: string | string[], index: number | number[]) =&amp;gt; {
    LogUtil.error(`value: ${value} --- index: ${index}`);
  },
  onAction: (action: number, dialogId: string, value: string | string[]) =&amp;gt; {
    if (action === DialogAction.SURE) {
      DialogHelper.showToast(`已选择：${value}`);
    }
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🍎Communication and communication 🙏
&lt;/h2&gt;

&lt;p&gt;Any problems found during use can be asked&lt;a href="https://gitee.com/tongyuyan/harmony-utils/issues" rel="noopener noreferrer"&gt;Issue&lt;/a&gt;Give us;&lt;br&gt;
Of course, we also welcome you to send us a message&lt;a href="https://gitee.com/tongyuyan/harmony-utils/pulls" rel="noopener noreferrer"&gt;PR&lt;/a&gt; 。&lt;/p&gt;

&lt;h2&gt;
  
  
  🌏Open Source Protocol
&lt;/h2&gt;

&lt;p&gt;This project is based on&lt;a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;, when copying and borrowing codes, please be sure to indicate the source.&lt;/p&gt;

</description>
      <category>harmony</category>
      <category>harmonyos</category>
      <category>arkts</category>
    </item>
    <item>
      <title>SM4, SM4 encryption and decryption</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 14:45:18 +0000</pubDate>
      <link>https://dev.to/787107497/sm4-sm4-encryption-and-decryption-1km</link>
      <guid>https://dev.to/787107497/sm4-sm4-encryption-and-decryption-1km</guid>
      <description>&lt;h2&gt;
  
  
  Introduction and description of harmony-utils
&lt;/h2&gt;




&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt;  A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications. Its encapsulated tools cover APP, device, screen, authorization, notification, inter-thread communication, pop-up frames, toast, biometric authentication, user preferences, taking photos, albums, scanning codes, files, logs, exception capture, characters, strings, numbers, collections, dates, random, base64, encryption, decryption, JSON and other functions, which can meet various development needs.&lt;br&gt;&lt;br&gt;
&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;picker_utils&lt;/a&gt; It is a sub-store split by harmony-utils, including PickerUtil, PhotoHelper, and ScanUtil.&lt;/p&gt;

&lt;p&gt;Download and install&lt;br&gt;&lt;br&gt;
&lt;code&gt;ohpm i @pura/harmony-utils&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;ohpm i @pura/picker_utils&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //Global initialization method, initialized in the onCreate method of UIAbility AppUtil.init()
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    AppUtil.init(this.context);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Introduction to SM4 algorithm
&lt;/h2&gt;




&lt;p&gt;SM4 is a commercial symmetric encryption algorithm independently developed by China. It was released by the State Cryptography Administration in 2006 and became the national cryptography industry standard in 2012 (GM/T 0002-2012). This algorithm uses a 128-bit packet length and a 128-bit key length to realize data encryption through 32 rounds of nonlinear iterative structures, and the security strength is comparable to that of AES-128. Its core design includes S-box replacement, cyclic shifting and other operations, and supports standard working modes such as ECB and CBC. As the core component of China's cryptographic system (SM series), SM4 is widely used in financial payment, e-government, Internet of Things and other fields, meeting domestic cryptographic compliance requirements. The algorithm has the characteristics of efficient software and hardware implementation, and has passed the ISO/IEC international standard certification (18033-3), becoming an important basic algorithm in the field of information security in my country.&lt;/p&gt;

&lt;h2&gt;
  
  
  SM4 application scenarios
&lt;/h2&gt;




&lt;p&gt;Financial payment: Encrypt sensitive data (such as transaction amount and account information) in bank card transactions, mobile payments and online banking to ensure the security of transmission and comply with the password compliance requirements of China's financial industry;&lt;br&gt;
E-government: used for data transmission and encryption of electronic ID cards and government affairs systems, and combined with SM2 signature algorithm to achieve identity authentication and data integrity protection;&lt;br&gt;
Internet of Things Security: Encrypt communication data between smart devices to prevent data leakage in industrial-grade SSDs, smart homes and other scenarios;&lt;br&gt;
Replacement of localized innovation and innovation: replace AES algorithm in information technology application innovation projects to meet the independent and controllable needs of party and government organs and key infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  API methods and usage
&lt;/h2&gt;




&lt;h5&gt;
  
  
  generateSymKey generates symmetric key SymKey
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let symKey1 = await SM4.generateSymKey();
let symKeyStr1 = CryptoHelper.dataBlobToStr(symKey1.getEncoded(), 'hex');
LogUtil.error(`对称密钥1：${symKeyStr1}`);

let symKey2 = SM4.generateSymKeySync();
let symKeyStr2 = CryptoHelper.dataBlobToStr(symKey2.getEncoded(), 'base64');
LogUtil.error(`对称密钥2：${symKeyStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  encryptGCM encryption (GCM mode)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let gcmParams = CryptoUtil.generateGcmParamsSpec();

let str1 = "鸿蒙技术交流群：xxxxxxxxxxx";

let smyKeyHexStr = "da4eed5a22f8883e2339c0b563161c38"; //16进制字符串密钥
let symKey = await CryptoUtil.getConvertSymKey('SM4_128', smyKeyHexStr, 'hex');
let dataBlob = CryptoHelper.strToDataBlob(str1, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptGCM(dataBlob, symKey, gcmParams); //加密
let encryptStr1 = CryptoHelper.dataBlobToStr(encryptDataBlob1, 'utf-8');
LogUtil.error(`加密（GCM模式）,异步：${encryptStr1}`);

let encryptDataBlob2 = SM4.encryptGCMSync(dataBlob, symKey, gcmParams!); //加密
let encryptStr2 = CryptoHelper.dataBlobToStr(encryptDataBlob2, 'utf-8');
LogUtil.error(`加密（GCM模式）,同步：${encryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  decryptGCM decryption (GCM mode)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let gcmParams = CryptoUtil.generateGcmParamsSpec();

let str1 = "鸿蒙技术交流群：xxxxxxxxxxx";

let smyKeyHexStr = "da4eed5a22f8883e2339c0b563161c38"; //16进制字符串密钥
let symKey = await CryptoUtil.getConvertSymKey('SM4_128', smyKeyHexStr, 'hex');
let dataBlob = CryptoHelper.strToDataBlob(str1, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptGCM(dataBlob, symKey, gcmParams!); //加密
let decryptDataBlob1 = await SM4.decryptGCM(encryptDataBlob1, symKey, gcmParams!); //解密
let decryptStr1 = CryptoHelper.dataBlobToStr(decryptDataBlob1, 'utf-8');
LogUtil.error(`解密（GCM模式）,异步：${decryptStr1}`);

let encryptDataBlob2 = SM4.encryptGCMSync(dataBlob, symKey, gcmParams!); //加密
let decryptDataBlob2 = SM4.decryptGCMSync(encryptDataBlob2, symKey, gcmParams!); //解密
let decryptStr2 = CryptoHelper.dataBlobToStr(decryptDataBlob2, 'utf-8');
LogUtil.error(`解密（GCM模式）,同步：${decryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  encryptCBC encryption (CBC mode)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let ivParams = CryptoUtil.generateIvParamsSpec();

let str2 = "harmony-utils，一款高效的HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。";
let smyKeyBase64Str = "2k7tWiL4iD4jOcC1YxYcOA=="; //base64符串密钥
let symKey = CryptoUtil.getConvertSymKeySync('SM4_128', smyKeyBase64Str, 'base64');
let dataBlob = CryptoHelper.strToDataBlob(str2, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptCBC(dataBlob, symKey, ivParams); //加密
let encryptStr1 = CryptoHelper.dataBlobToStr(encryptDataBlob1, 'utf-8');
LogUtil.error(`加密（CBC模式）,异步：${encryptStr1}`);

let encryptDataBlob2 = SM4.encryptCBCSync(dataBlob, symKey, ivParams); //加密
let encryptStr2 = CryptoHelper.dataBlobToStr(encryptDataBlob2, 'utf-8');
LogUtil.error(`加密（CBC模式）,同步：${encryptStr2}`);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  decryptCBC decryption (CBC mode)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let ivParams = CryptoUtil.generateIvParamsSpec();

let str2 = "harmony-utils，一款高效的HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。";
et smyKeyBase64Str = "2k7tWiL4iD4jOcC1YxYcOA=="; //base64符串密钥
let symKey = CryptoUtil.getConvertSymKeySync('SM4_128', smyKeyBase64Str, 'base64');
let dataBlob = CryptoHelper.strToDataBlob(str2, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptCBC(dataBlob, symKey, ivParams); //加密
let decryptDataBlob1 = await SM4.decryptCBC(encryptDataBlob1, symKey, ivParams); //解密
let decryptStr1 = CryptoHelper.dataBlobToStr(decryptDataBlob1, 'utf-8');
LogUtil.error(`解密（CBC模式）,异步：${decryptStr1}`);

let encryptDataBlob2 = SM4.encryptCBCSync(dataBlob, symKey, ivParams); //加密
let decryptDataBlob2 = SM4.decryptCBCSync(encryptDataBlob2, symKey, ivParams); //解密
let decryptStr2 = CryptoHelper.dataBlobToStr(decryptDataBlob2, 'utf-8');
LogUtil.error(`解密（CBC模式）,同步：${decryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  encryptECB encryption (ECB mode)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str1 = "鸿蒙技术交流群：xxxxxxxxxxx";

let smyKeyBase64Str = "2k7tWiL4iD4jOcC1YxYcOA=="; //base64符串密钥
let symKey = CryptoUtil.getConvertSymKeySync('SM4_128', smyKeyBase64Str, 'base64');
let dataBlob = CryptoHelper.strToDataBlob(str1, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptECB(dataBlob, symKey); //加密
let encryptStr1 = CryptoHelper.dataBlobToStr(encryptDataBlob1, 'utf-8');
LogUtil.error(`加密（ECB模式）,异步：${encryptStr1}`);

let encryptDataBlob2 = SM4.encryptECBSync(dataBlob, symKey); //加密
let encryptStr2 = CryptoHelper.dataBlobToStr(encryptDataBlob2, 'utf-8');
LogUtil.error(`加密（ECB模式）,同步：${encryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  decryptECB decryption (ECB mode)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str1 = "鸿蒙技术交流群：xxxxxxxxxxx";

let smyKeyBase64Str = "2k7tWiL4iD4jOcC1YxYcOA=="; //base64符串密钥
let symKey = CryptoUtil.getConvertSymKeySync('SM4_128', smyKeyBase64Str, 'base64');
let dataBlob = CryptoHelper.strToDataBlob(str1, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptECB(dataBlob, symKey); //加密
let decryptDataBlob1 = await SM4.decryptECB(encryptDataBlob1, symKey); //解密
let decryptStr1 = CryptoHelper.dataBlobToStr(decryptDataBlob1, 'utf-8');
LogUtil.error(`解密（ECB模式）,异步：${decryptStr1}`);

let encryptDataBlob2 = SM4.encryptECBSync(dataBlob, symKey); //加密
let decryptDataBlob2 = SM4.decryptECBSync(encryptDataBlob2, symKey); //解密
let decryptStr2 = CryptoHelper.dataBlobToStr(decryptDataBlob2, 'utf-8');
LogUtil.error(`解密（ECB模式）,同步：${decryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  encryptGCMSegment encryption (GCM mode) segmentation
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let gcmParams = CryptoUtil.generateGcmParamsSpec();

let str3 = "harmony-utils，一款高效的HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。。。";

let smyKeyHexStr = "da4eed5a22f8883e2339c0b563161c38"; //16进制字符串密钥
let symKey = await CryptoUtil.getConvertSymKey('SM4_128', smyKeyHexStr, 'hex');
let dataBlob = CryptoHelper.strToDataBlob(str3, 'utf-8'); //待加密数据


let encryptDataBlob1 = await SM4.encryptGCMSegment(dataBlob, symKey, gcmParams!); //加密
let encryptStr1 = CryptoHelper.dataBlobToStr(encryptDataBlob1, 'utf-8');
LogUtil.error(`分段加密（GCM模式）,异步：${encryptStr1}`);

let encryptDataBlob2 = SM4.encryptGCMSegmentSync(dataBlob, symKey, gcmParams!); //加密
let encryptStr2 = CryptoHelper.dataBlobToStr(encryptDataBlob2, 'utf-8');
LogUtil.error(`分段加密（GCM模式）,同步：${encryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  decryptGCMSegment Decrypt (GCM mode) segmentation
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let gcmParams = CryptoUtil.generateGcmParamsSpec();

let str3 = "harmony-utils，一款高效的HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。。。";

let smyKeyHexStr = "da4eed5a22f8883e2339c0b563161c38"; //16进制字符串密钥
let symKey = await CryptoUtil.getConvertSymKey('SM4_128', smyKeyHexStr, 'hex');
let dataBlob = CryptoHelper.strToDataBlob(str3, 'utf-8'); //待加密数据

let encryptDataBlob1 = await SM4.encryptGCMSegment(dataBlob, symKey, gcmParams!); //加密);
let decryptDataBlob1 = await SM4.decryptGCMSegment(encryptDataBlob1, symKey, gcmParams!); //解密
let decryptStr1 = CryptoHelper.dataBlobToStr(decryptDataBlob1, 'utf-8');
LogUtil.error(`分段解密（GCM模式）,异步：${decryptStr1}`);

let encryptDataBlob2 = SM4.encryptGCMSegmentSync(dataBlob, symKey, gcmParams!); //加密
let decryptDataBlob2 = SM4.decryptGCMSegmentSync(encryptDataBlob2, symKey, gcmParams!); //解密
let decryptStr2 = CryptoHelper.dataBlobToStr(decryptDataBlob2, 'utf-8');
LogUtil.error(`分段解密（GCM模式）,同步：${decryptStr2}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>harmonyos</category>
      <category>harmony</category>
      <category>arkts</category>
    </item>
    <item>
      <title>SM3, SM3 tool class</title>
      <dc:creator>桃花镇童长老</dc:creator>
      <pubDate>Sun, 29 Jun 2025 14:39:59 +0000</pubDate>
      <link>https://dev.to/787107497/sm3-sm3-tool-class-2doe</link>
      <guid>https://dev.to/787107497/sm3-sm3-tool-class-2doe</guid>
      <description>&lt;h2&gt;
  
  
  Introduction and description of harmony-utils
&lt;/h2&gt;




&lt;p&gt;&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fharmony-utils" rel="noopener noreferrer"&gt;harmony-utils&lt;/a&gt;  A HarmonyOS tool library with rich features and extremely easy to use, with the help of many practical tools, is committed to helping developers quickly build Hongmeng applications. Its encapsulated tools cover APP, device, screen, authorization, notification, inter-thread communication, pop-up frames, toast, biometric authentication, user preferences, taking photos, albums, scanning codes, files, logs, exception capture, characters, strings, numbers, collections, dates, random, base64, encryption, decryption, JSON and other functions, which can meet various development needs.&lt;br&gt;&lt;br&gt;
&lt;a href="https://ohpm.openharmony.cn/#/cn/detail/@pura%2Fpicker_utils" rel="noopener noreferrer"&gt;picker_utils&lt;/a&gt; It is a sub-store split by harmony-utils, including PickerUtil, PhotoHelper, and ScanUtil.&lt;/p&gt;

&lt;p&gt;Download and install&lt;br&gt;&lt;br&gt;
&lt;code&gt;ohpm i @pura/harmony-utils&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;ohpm i @pura/picker_utils&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  //Global initialization method, initialized in the onCreate method of UIAbility AppUtil.init()
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
    AppUtil.init(this.context);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Introduction to SM3 algorithm
&lt;/h2&gt;




&lt;p&gt;SM3 is the commercial cryptographic hash algorithm standard (GM/T 0004-2012) issued by the China National Cryptography Administration in 2010. It outputs a 256-bit fixed-length hash value, and its security strength is equivalent to that of SHA-256. This algorithm adopts the Merkle-Damgard structure design, and achieves data obfuscation through message filling, grouping expansion and 32 rounds of iterative compression, and has anti-collision attack and original image attack capabilities. As the core component of the domestic cryptographic system, SM3 is widely used in digital signatures, electronic certification, financial payments, and Internet of Things security, and has been included in the ISO/IEC 10118-3 international standard. Its efficiency is adapted to ordinary computers and embedded devices, and supports the formulation of more than 30 domestic cryptographic industry standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  SM3 application scenarios
&lt;/h2&gt;




&lt;p&gt;Digital signature: Used in conjunction with SM2 asymmetric algorithm to generate hash summary and sign electronic contracts, government documents, etc. to ensure data integrity and non-repudiation;&lt;br&gt;
Financial security: used for online banking transaction verification and payment packet integrity protection. More than 80% of domestic financial institutions deploy this algorithm in key systems;&lt;br&gt;
Internet of Things Authentication: Generate message authentication code (HMAC-SM3) for smart device communication data to prevent data tampering in industrial-grade SSDs, smart grids and other scenarios;&lt;br&gt;
Crypto protocol basis: Support key derivation and verification of security protocols such as SSL/TLS, VPN, etc. to meet the needs of domestic substitution.&lt;/p&gt;

&lt;h2&gt;
  
  
  API methods and usage
&lt;/h2&gt;




&lt;h5&gt;
  
  
  digest SM3 summary
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str1 = "鸿蒙技术交流群：xxxxxxxxxxx";

let digest1 = await SM3.digest(str1);
LogUtil.error(`摘要，异步: ${digest1}`);

let digest2 = SM3.digestSync(str1,'hex');
LogUtil.error(`摘要，同步1: ${digest2}`);

let digest3 = SM3.digestSync(str1, 'base64');
LogUtil.error(`摘要，同步2:  ${digest3}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  digestSegment SM3 segment summary
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str3 = "harmony-utils，一款高效的HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。";

let digest1 = await SM3.digestSegment(str3);
LogUtil.error(`分段摘要，异步: ${digest1}`);

let digest2 = SM3.digestSegmentSync(str3);
LogUtil.error(`分段摘要，同步1: ${digest2}`);

let digest3 = SM3.digestSegmentSync(str3, 'base64', 256);
LogUtil.error(`分段摘要，同步2: ${digest3}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  hmac SM3 message authentication code calculation
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str1 = "鸿蒙技术交流群：xxxxxxxxxxx";
let symKey = CryptoUtil.generateSymKeySync("HMAC|SM3");

let digest1 = await SM3.hmac(str1, symKey);
LogUtil.error(`消息认证码计算，异步: ${digest1}`);

let digest2 = SM3.hmacSync(str1, symKey);
LogUtil.error(`消息认证码计算，同步1: ${digest2}`);

let digest3 = SM3.hmacSync(str1, symKey, 'base64');
LogUtil.error(`消息认证码计算，同步2: ${digest3}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  hmacSegment SM3 message authentication code calculation, segmented
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str2 = "harmony-utils，一款高效的HarmonyOS工具包，封装了常用工具类，提供一系列简单易用的方法。帮助开发者快速构建鸿蒙应用。";
let symKey = CryptoUtil.generateSymKeySync("HMAC|SM3");

let digest1 = await SM3.hmacSegment(str2, symKey);
LogUtil.error(`分段消息认证码计算，异步: ${digest1}`);

let digest2 = SM3.hmacSegmentSync(str2, symKey);
LogUtil.error(`分段消息认证码计算，同步1: ${digest2}`);

let digest3 = SM3.hmacSegmentSync(str2, symKey, 'hex', 256);
LogUtil.error(`分段消息认证码计算，同步2: ${digest3}`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>harmony</category>
      <category>harmonyos</category>
      <category>arkts</category>
    </item>
  </channel>
</rss>
