雪山坚石 發表於 2025-8-28 17:50:00

【小而美】HarmonyOS官方模板优秀案例(第5期:工具行业 · 日历应用)

<p style="text-align: center">💡 鸿蒙生态为开发者提供海量的HarmonyOS模板/组件,助力开发效率原地起飞 💡</p>
<p style="text-align: center">★ 一键直达生态市场组件&amp;模板市场 , 快速应用DevEco Studio插件市场集成组件&amp;模板 ★</p>
<h3 style="text-align: center"><strong>工具行业群英荟萃,是小而美应用的主要聚集赛道</strong></h3>
<h3 style="text-align: center"><strong>本期介绍的案例是其中一类:日常刚需的日历应用</strong></h3>
<p style="text-align: center">👉 覆盖20+行业,本帖以汇总形式持续更新中,点击收藏!一键三连!常看常新!</p>
<h1 style="text-align: center"><strong>【第5期】工具行业 · 日历应用</strong></h1>
<h1><strong>一、概述</strong></h1>
<h2><strong>1. 行业洞察</strong></h2>
<h3><strong>1)行业诉求:</strong></h3>
<ul>
<li>日历类应用,未来竞争将聚焦于 AI 驱动的个性化体验、场景化生态构建及文化适配能力正从单一工具进化为连接工作、生活、社交的 “时间操作系统”。</li>
<li>商业模式是日历类应用的重要场景诉求,目前免费增值为主,差异化变现破局,如何结合小艺做个性化推荐是差异化的根本。</li>
<li>满足用户的进阶需求:社交协作,隐私保护。</li>
</ul>
<h3><strong>2)行业常用三方SDK</strong></h3>
<table>
<tbody>
<tr>
<td>
<p><strong>分类</strong></p>
</td>
<td>
<p><strong>三方库名称</strong></p>
</td>
<td>
<p><strong>功能</strong></p>
</td>
<td>
<p><strong>SDK链接</strong></p>
</td>
</tr>
<tr>
<td>
<p>登录认证</p>
</td>
<td>
<p>中国移动一键登录SDK/易盾一键登录SDK/创蓝闪验/极光安全认证/阿里云号码认证SDK/中国电信一键登录SDK</p>
</td>
<td>
<p>登录</p>
</td>
<td rowspan="8">
<p>岳鹰全景监控SDk</p>
<p>支付宝支付 SDK</p>
<p>穿山甲广告SDK</p>
<p>快手联盟广告SDK</p>
<p>友盟SDK</p>
<p>腾讯微信SDK</p>
<p>腾讯优量汇</p>
<p>极光 SDK</p>
<p>高德地图</p>
<p>百度地图</p>
<p>腾讯地图定位</p>
<p>高德地图定位</p>
</td>
</tr>
<tr>
<td>
<p>分享</p>
</td>
<td>
<p>友盟/ShareSDK/微信分享/QQ分享/新浪微博SDK/MobTech ShareSDK</p>
</td>
<td>
<p>统计/推送/分享</p>
</td>
</tr>
<tr>
<td>
<p>支付</p>
</td>
<td>
<p>支付宝支付/微信支付/银联支付</p>
</td>
<td>
<p>支付</p>
</td>
</tr>
<tr>
<td>
<p>数据分析</p>
</td>
<td>
<p>友盟移动统计SD/神策数据SDK</p>
</td>
<td>
<p>数据收集、处理、分析、运用</p>
</td>
</tr>
<tr>
<td>
<p>性能监控</p>
</td>
<td>
<p>腾讯Bugly SDK/听云SDK/岳鹰全景监控SDK</p>
</td>
<td>
<p>异常上报和运营统计</p>
</td>
</tr>
<tr>
<td>
<p>地图</p>
</td>
<td>
<p>高德地图SDK</p>
</td>
<td>
<p>地图</p>
</td>
</tr>
<tr>
<td>
<p>推送</p>
</td>
<td>
<p>个推/华为推送/极光PUSH/阿里推送SDK</p>
</td>
<td>
<p>消息推送</p>
</td>
</tr>
<tr>
<td>
<p>媒体</p>
</td>
<td>
<p>阿里云视频播放器SDK</p>
</td>
<td>
<p>音视频</p>
</td>
</tr>
</tbody>
</table>
<p><em>说明:“以上三方库及链接仅为示例,三方库由三方开发者独立提供,以其官方内容为准”</em></p>
<h2><strong>2. 案例概览(</strong><strong>下载模板</strong><strong>)</strong></h2>
<p>基于以上行业分析,本期将介绍鸿蒙生态市场生活服务类行业模板——日历应用模板,为行业提供常用功能的开发案例,模板主要分为万年历、黄历、和我的三大模块。</p>
<ul>
<li>Stage开发模型 + 声明式UI开发范式。</li>
<li>分层架构设计 + 组件化拆分,支持开发者在开发时既可以选择完整使用模板,也可以根据需求单独选用其中的业务组件。</li>
<li>本模板已集成华为账号等服务,只需做少量配置和定制即可快速实现华为账号的登录。</li>
</ul>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112426038-756733945.png"></p>
<h3><strong>本模板主要页面及核心功能如下所示:</strong></h3>
<pre class="language-armasm highlighter-hljs"><code>​日历模板
|-- 万年历
|    |-- 日历选择
|    |-- 吉日查询
|    |-- 日期计算
|    |-- 节日节气
|    └-- 宜忌展示
|-- 黄历
|    |-- 日期切换
|    |-- 宜忌展示
|    |-- 五行、冲煞
|    |-- 彭祖百忌
└-- 我的
|   |-- 个人信息
|   └-- 设置
|       └-- 主题切换
|       └-- 隐私协议
|       └-- 用户协议</code></pre>
<h1><strong>二、应用架构设计</strong></h1>
<h2><strong>1. 分层模块化设计</strong></h2>
<ul>
<li><strong>产品定制层:</strong>专注于满足不同设备或使用场景的个性化需求,作为应用的入口,是用户直接互动的界面。
<ul>
<li>本实践暂时只支持直板机,为单HAP包形式,包含路由根节点、底部导航栏等。</li>
</ul>
</li>
<li><strong>基础特性层:</strong>用于存放相对独立的功能UI和业务逻辑实现。
<ul>
<li>本实践的基础特性层将应用底部导航栏的每个选项拆分成一个独立的业务功能模块。</li>
<li>每个功能模块都具备高内聚、低耦合、可定制的特点,支持产品的灵活部署。</li>
</ul>
</li>
<li><strong>公共能力层:</strong>存放公共能力,包括公共UI组件、数据管理、外部交互和工具库等共享功能。
<ul>
<li>本实践的公共能力层分为公共基础能力和可分可合组件,均打包为HAR包被上层业务组件引用。</li>
<li>公共基础能力包含日志、文件处理等工具类,公共类型定义,网络库,以及弹窗、加载等公共组件。</li>
<li>可分可合组件将包含行业特点、可完全自闭环的能力抽出独立的组件模块,支持开发者在开发中单独集成使用,详见业务组件设计章节。</li>
</ul>
</li>
</ul>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250820110840638-564894760.png" alt="http://image.huawei.com/tiny-lts/v1/images/hi3ms/edf690f19332784457ac85f9514db6d1_1226x503.png"></p>
<h2><strong>2. 业务组件设计</strong></h2>
<p>为支持开发者单独获取特定场景的页面和功能,本模板将功能完全自闭环的部分能力抽离出独立的行业组件模块,不依赖公共基础能力包,开发者可以单独集成,开箱即用,降低使用难度。</p>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250820110840551-1500916428.png" alt="http://image.huawei.com/tiny-lts/v1/images/hi3ms/0b4b99b97dd7af53b8f480b111944486_1160x399.png"></p>
<h1><strong>三、行业场景技术方案</strong></h1>
<h2><strong>1. 个人信息</strong></h2>
<h3><strong>1)场景说明</strong></h3>
<p>支持华为账号一键登录及其他方式(账号密码登录)。</p>
<p>用户登录后展示昵称和头像,点击用户信息栏可进入用户主页,查看并编辑个人信息和历史动态。</p>
<p>支持添加重要提醒(日程、生日、纪念日、代办),更新提醒,删除提醒。</p>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112426081-204684233.png"></p>
<h3><strong>2)技术方案</strong></h3>
<ul>
<li><strong>华为账号一键登录</strong>
<ul>
<li>通过Account Kit实现华为账号一键登录,并获取用户手机号,关联应用已有用户。</li>
</ul>
</li>
<li><strong>头像修改</strong>
<ul>
<li>通过Scenario Fusion Kit提供的选择头像Button快速拉起头像选择页面,供用户完成华为账号头像或其他头像的选择与展示。</li>
</ul>
</li>
<li><strong>重要提醒</strong>
<ul>
<li>通过@kit.CalendarKit提供的提供日历与日程管理能力将应用中的工作、生活中与时间相关的日程服务与系统日历进行集成,从而实现日程管理、事件创建、查询等功能。</li>
</ul>
</li>
<li><strong>主题切换</strong>
<ul>
<li>通过全局主题对象,控制全局的主题颜色切换,并使用持久化存储当前主题选择。</li>
</ul>
</li>
</ul>
<h3><strong>3)代码参考</strong></h3>
<ul>
<li>部分核心代码参见华为账号一键登录实现章节。</li>
</ul>
<h2><strong>2. 黄历</strong></h2>
<h3><strong>1)场景说明</strong></h3>
<ul>
<li>支持根据日期查看当日黄历信息。</li>
<li>切换日期查询其他日期黄历。</li>
<li>根据选择日期查看今日宜今日忌。</li>
<li>支持根据选择的黄历查看白话文。</li>
</ul>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112425885-1066034602.png"></p>
<h3><strong>2)技术方案</strong></h3>
<p>根据万年历选择日期进行对应日期黄历的展示。</p>
<p>通过日历选择组件暴露的句柄,感知当前选择的日期,并通过句柄同步修改万年历对应的日期。</p>
<h3><strong>3)代码参考</strong></h3>
<ul>
<li>部分核心代码参见黄历实现章节。</li>
</ul>
<h2><strong>3. 万年历</strong></h2>
<h3><strong>1)场景说明</strong></h3>
<p>支持日历查看,日期切换,设置周首日。</p>
<p>支持查看今日宜,今日忌。</p>
<p>支持实用工具查询(吉日查询,日期计算,节日节气)。</p>
<p>支持查看城市限行。</p>
<p>支持查看历史上的今天。</p>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112425963-751422665.png"></p>
<h3><strong>2)技术方案</strong></h3>
<ul>
<li><strong>日历查看</strong>
<ul>
<li>通过使用Swiper组件结合计算每月的日期实现日期轮播查看。</li>
</ul>
</li>
<li><strong>头像修改</strong>
<ul>
<li>通过Scenario Fusion Kit提供的选择头像Button快速拉起头像选择页面,供用户完成华为账号头像或其他头像的选择与展示。</li>
</ul>
</li>
<li><strong>实用工具</strong>
<ul>
<li>使用工具结合DatePicker日期选择器,实现日期选择并根据条件计算。</li>
</ul>
</li>
<li><strong>城市限行</strong>
<ul>
<li>通过申请位置权限,或者当前城市的限行车牌尾号,并进行展示。</li>
</ul>
</li>
</ul>
<h3><strong>3)代码参考</strong></h3>
<ul>
<li>部分核心代码参见万年历实现章节。</li>
</ul>
<h1><strong>四、模板代码</strong></h1>
<h2><strong>1. 工程结构(</strong><strong>下载模板</strong><strong>)</strong></h2>
<p>详细代码结构如下所示:</p>
<pre class="language-armasm highlighter-hljs"><code>Application
├──├──commons
│   ├──common                              // 公共能力层
│   ├──src/main/ets                        // 基础能力
│   │└──components                     // 公共组件
│   │└──dividerTmp                     // 下划线公共组件
│   │└──https                            // 网络请求库
│   │└──models                           // 公共接口常量
│   │└──quickLogin                     // 华为账号一键登录
│   │└──style                            // 公共样式
│   │└──utils                            // 工具类
│   │└──viewmodels                     // 接口层
│   └──Index.ets                           // 对外接口类
│├──router_module                        // 全局路由组件
├──├──components                           // 公共组件
│   ├──base_apis                           // 通用组件(模态框,弹窗,选择器等)
│   ├──base_calendar                         // 日历组件
│   ├──calendar_almanac                      // 黄历组件
│   ├──calendar_events                     // 重要提醒组件
│   ├──date_calculation                      // 日期计算组件
│   ├──festival_solar                        // 节日节气组件
│   ├──login_info                            // 登录组件组件
│   ├──vip_center                            // 开通会员组件
│   ├──traffic_restriction                   // 城市限行组件
│   ├──yiji_query                            // 宜忌查询组件
├──features                                  // 基础特性层
│├──almanac/src/main/ets                   // 黄历
││├──pages                               // 首页入口
│   │├──AlmanacView                      // 黄历入口
│├──almanac/src/main/resources             // 资源文件目录
│├──almanac/Index.ets                      // 对外接口类
│├──perpetual/src/main/ets               // 万年历
││├──components                        // 万年历组件
││├──pages                              
│   │├──PerpetualCalendar                // 万年历组件入口
│├──perpetual/src/main/resources         // 资源文件目录
│├──perpetual/Index.ets                  // 对外接口类
│├──mine/src/main/ets                      // 我的(包含一键登录)
││└──pages                               // 我的入口页
│   │├──MinePage                         // 登录
││└──components                        // 我的页面入口
│└──mine/src/main/resources                // 资源文件目录
└─product/entry/src/main   
   ├─ets
   │├─widget
   ││├──pages            
   ││      ├──WidgetCard.ets       // 服务卡片   
   │├─entryability
   ││      ├──EntryAbility.ets             // 应用程序入口
   │├─page
   ││├──Index.ets                        // 入口
   ││├──PrivacyPage.ets                  // 隐私协议   
   ││├──SafePage.ets                     // 隐私协议弹窗
   ││├──SplashPage.ets                   // 闪屏页      
   ││├──TabContainer.ets               // tab页入口
   └─resources</code></pre>
<h2><strong>2. 关键代码解读</strong></h2>
<p>本篇代码非应用的全量代码,只包括应用的部分能力的关键代码。</p>
<p>若需获取全量代码,请查看模板集成章节。</p>
<h3><strong>1)个人信息</strong></h3>
<ul>
<li>华为账号一键登录</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
    getQuickLoginAnonymousPhone() {
    // 创建授权请求,并设置参数
    const authRequest = new authentication.HuaweiIDProvider().createAuthorizationWithHuaweiIDRequest();
    // 获取手机号需要传如下scope,传参数之前需要先申请对应scope权限,才能返回对应数据
    authRequest.scopes = ['quickLoginAnonymousPhone'];
    authRequest.permissions = ['serviceauthcode'];
    // 用户是否需要登录授权,该值为true且用户未登录或未授权时,会拉起用户登录或授权页面
    authRequest.forceAuthorization = false;
    // 用于防跨站点请求伪造
    authRequest.state = util.generateRandomUUID();
    try {
      const controller = new authentication.AuthenticationController(getContext(this));
      controller.executeRequest(authRequest).then((response) =&gt; {
      const authorizationWithHuaweiIDResponse = response as authentication.AuthorizationWithHuaweiIDResponse;
      const state = authorizationWithHuaweiIDResponse.state;
      if (state !== undefined &amp;&amp; authRequest.state !== state) {
          hilog.error(0x0000, 'testTag', `Failed to authorize. The state is different, response state: ${state}`);
          return;
      }
      hilog.info(0x0000, 'testTag', 'Succeeded in authentication.');
      const authorizationWithHuaweiIDCredential = authorizationWithHuaweiIDResponse.data!;
      const code = authorizationWithHuaweiIDCredential.authorizationCode;
      const unionID = authorizationWithHuaweiIDCredential.unionID;
      const openID = authorizationWithHuaweiIDCredential.openID;
      const anonymousPhone = authorizationWithHuaweiIDCredential?.extraInfo?.quickLoginAnonymousPhone as string;
      if (anonymousPhone) {
          hilog.info(0x0000, 'testTag', 'Succeeded in authentication.');
          this.quickLoginAnonymousPhone = anonymousPhone;
          return;
      } else {
          this.quickLoginAnonymousPhone = '123xxxxxx456'
      }
      // 开发者处理code、unionID、openID
      this.authorizationCode = code
      }).catch((err: BusinessError) =&gt; {
      this.dealAllPhoneError(err);
      });
    } catch (error) {
      this.dealAllPhoneError(error);
    }
}</code></pre>
<p>&nbsp;</p>
<ul>
<li>重要提醒</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
class CalendarManage {
context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
private static _instance: CalendarManage

static get instance() {
    if (!CalendarManage._instance) {
      CalendarManage._instance = new CalendarManage()
    }
    return CalendarManage._instance
}

public getCalendarPermission(): Promise&lt;string&gt; {
    const permissions: Permissions[] = ['ohos.permission.READ_CALENDAR', 'ohos.permission.WRITE_CALENDAR'];
    let atManager = abilityAccessCtrl.createAtManager();
    return new Promise((resolve, reject) =&gt; {
      atManager.requestPermissionsFromUser(this.context, permissions).then((result: PermissionRequestResult) =&gt; {
      resolve('success')
      }).catch((error: BusinessError) =&gt; {
      reject('failed')
      console.error(`get Permission error, error. Code: ${error.code}, message: ${error.message}`);
      })
    })
}

/*
    * 添加提醒到日历
    * */
private async calendarEvent(calendar: calendarManager.Calendar,
    calendarInfo: UserEventItem): Promise&lt;CalendarInfo&gt; {
    const event: calendarManager.Event = {
      title: calendarInfo.content,
      type: calendarManager.EventType.NORMAL,
      id: calendarInfo.eventId,
      isLunar:calendarInfo.date.isLunar,
      startTime: new Date(dayjs(calendarInfo.date.date).format('YYYY-MM-DD') + ' ' +
      calendarInfo.date.time).getTime(),
      endTime: new Date(dayjs(calendarInfo.date.date).format('YYYY-MM-DD') + ' ' +
      calendarInfo.date.time).getTime(),
      reminderTime: CalendarManage.getReminderTime(calendarInfo.remindList),
      recurrenceRule: {
      recurrenceFrequency: repeatMap,
      },
    };
    return new Promise(async (resolve, reject) =&gt; {
      if (calendarInfo.eventId) {
      calendar.updateEvent(event).then(() =&gt; {
          resolve({
            status: 'success',
          })
      }).catch((err: BusinessError) =&gt; {
          console.error(`Failed to update event. Code: ${err.code}, message: ${err.message}`);
      });
      } else {
      calendar.addEvent(event).then((data: number) =&gt; {
          console.info(`Succeeded in adding event, id -&gt; ${data}`);
          resolve({
            status: 'success',
            data: data,
          })
      }).catch((err: BusinessError) =&gt; {
          resolve({
            status: 'failed',
          })
      });
      }
    })
}
/*
    * 根据提醒参数创建日历参数
    * */
public async calendarEventCreate(calendarInfo: UserEventItem, operationType?: string): Promise&lt;CalendarInfo&gt; {
    if (calendarInfo.remindList === '不提醒') {
      return {
      status: 'not need calendar',
      }
    }
    let permission = await this.getCalendarPermission()
    if (permission !== 'success') {
      return {
      status: 'permission failed',
      }
    }
    let calendar: calendarManager.Calendar | undefined = undefined;
    // 指定日历账户信息
    const calendarAccount: calendarManager.CalendarAccount = {
      name: '日历模板',
      type: calendarManager.CalendarType.LOCAL,
      // 日历账户显示名称,该字段如果不填,创建的日历账户在界面显示为空字符串。
      displayName: '日历模板',
    };
    let calendarMgr: calendarManager.CalendarManager | null = calendarManager.getCalendarManager(this.context);
    // 创建日历账户
    try {
      calendar = await calendarMgr?.createCalendar(calendarAccount)
      let res: CalendarInfo
      if (operationType === 'delete') {
      res = await this.calendarEventDelete(calendar, calendarInfo)
      } else {
      res = await this.calendarEvent(calendar, calendarInfo)
      }
      return res
    } catch (e) {
      return {
      status: 'calendar operation failed',
      }
    }
}
/*
    * 删除已经添加到日历的提醒
    * */
private async calendarEventDelete(calendar: calendarManager.Calendar,
    calendarInfo: UserEventItem): Promise&lt;CalendarInfo&gt; {
    try {
      await calendar.deleteEvent(calendarInfo.eventId)
      return {
      status: 'success',
      }
    } catch (e) {
      return {
      status: 'failed',
      }
    }
}
}</code></pre>
<h3><strong>2)黄历</strong></h3>
<ul>
<li>重要提醒</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
/**
* 抛出句柄
*/
export class CalendarController {
   public static vm: CalendarVM = CalendarVM.instance;
   
   public setSelectDate(date: Date) {
       CalendarController.vm.changeDate(date)
   }
   
   public getTodayYiJi() {
       CalendarController.vm.getTodayYiJi()
   }
}</code></pre>
<ul>
<li>切换日期</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
/**
* 切换日期
*/
public changeDate(date: Date) {
    let gap = (date.getFullYear() - this.curDate.year()) * 12 + date.getMonth() - this.curDate.month()
    this.dateListSource.clearData()
    let i = -2
    while (i &lt;= 2) {
      let month = this.getDateList(i + gap)
      this.dateListSource.pushData(month)
      i++
    }
    this.curIndex = 2
    this.selectDate = dayjs(date)
}</code></pre>
<ul>
<li>获取今日宜和忌</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
/**
* 获取今日宜和忌
*/
public getTodayYiJi() {
    const todayLunar = Lunar.fromDate(new Date(this.selectDate.format('YYYY-MM-DD')));
    const yi = todayLunar.getDayYi();
    const ji = todayLunar.getDayJi();
    this.todayYiJi = {
      yi,
      ji,
    }
}</code></pre>
<h3><strong>3)万年历</strong></h3>
<ul>
<li>展示日历</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
/**
* 展示日历
*/
Swiper(this.swiperController) {
      LazyForEach(this.vm.dateListSource, (item: DateModelList) =&gt; {
          Grid() {
            ForEach(item, (item: DateModel) =&gt; {
            GridItem() {
            }
            },(item: DateModel) =&gt; JSON.stringify(item));
          }
          .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr 1fr')
          .maxCount(7)
          .columnsGap(0)
          .rowsGap(0)
          .padding({ bottom: 20 })
      },(item: DateModelList) =&gt; JSON.stringify(item));
}</code></pre>
<ul>
<li>获取位置权限</li>
</ul>
<pre class="language-armasm highlighter-hljs"><code>typescript
/**
* 获取位置权限
*/
getCurrentLocation() {
    this.permissionRequestUtils.locationPermissionRequest().then(async (res) =&gt; {
      if (res === 'success') {
      this.locationPermission = res
      this.permissionRequestUtils.getCurrentLocation().then((res: string) =&gt; {
          this.location = res
      }).catch((err:BusinessError) =&gt; {
          this.location = '北京'
      })
      } else {
      this.dealError()
      }
    }).catch(() =&gt; {
      this.dealError()
    })
}</code></pre>
<h2><strong>3. 模板集成</strong></h2>
<p>本模板提供了两种代码集成方式,供开发者自由选用。</p>
<h3><strong>1)整体集成(</strong><strong>下载模板</strong><strong>)</strong></h3>
<p>开发者可以选择直接基于模板工程开发自己的应用工程。</p>
<ul>
<li><strong>模板代码获取:</strong>
<ul>
<li>通过IDE插件创建模板工程,开发指导。</li>
<li>通过生态市场下载源码, 下载模板。</li>
<li>通过开源仓访问源码,仓库地址。</li>
</ul>
</li>
<li><strong>打开模板工程,根据README说明中的快速入门章节,将自己的应用信息配置在模板工程内,即可运行并查看模板效果。</strong></li>
</ul>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250820110840585-1795006564.png"></p>
<ul>
<li><strong>对接开发者自己的服务器接口,转换数据结构,展示真实的云侧数据。</strong></li>
</ul>
<p>将<code>commons/lib_common/src/main/ets/httprequest/HttpRequestApi.ets</code>文件中的mock接口替换为真实的服务器接口。</p>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112426040-1501083194.png"></p>
<p>在<code>commons/lib_common/src/main/ets/httprequest/HttpRequest.ets</code>文件中将云侧开发者自定义的数据结构转换为端侧数据结构。</p>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112425908-1294233644.png"></p>
<p>根据自己的业务内容修改模板,进行定制化开发。</p>
<h3><strong>2)按需集成</strong></h3>
<p>若开发者已搭建好自己的应用工程,但暂未实现其中的部分场景能力,可以选择取用其中的业务组件,集成在自己的工程中。</p>
<ul>
<li><strong>组件代码获取:</strong>
<ul>
<li>通过IDE插件下载组件源码。开发指导</li>
<li>通过生态市场下载组件源码。 下载地址</li>
</ul>
</li>
<li><strong>下载组件源码,根据README中的说明,将组件包配置在自己的工程中。</strong></li>
</ul>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250820110840567-176746592.png"></p>
<ul>
<li><strong>根据API参考和示例代码,将组件集成在自己的对应场景中。</strong></li>
</ul>
<p style="text-align: center"><strong>以上是第五期“工具行业-日历应用”行业优秀案例的内容,更多行业敬请期待~</strong></p>
<p style="text-align: center">欢迎下载使用行业模板“<strong>点击下载</strong>”,<strong>若您有体验和开发问题,或者迫不及待想了解XX行业的优秀案例,欢迎在评论区留言</strong>,小编会快马加鞭为您解答~</p>
<p style="text-align: center">同时诚邀您添加下方二维码加入“组件模板活动社群”,精彩上新&amp;活动不错过!</p>
<p><img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250828112425985-343778289.png" width="600" style="display: block; margin-left: auto; margin-right: auto"></p>
<p id="1756352622934"></p>
<p>👉 <strong>本系列持续更新,欢迎点击帖子末尾左下角</strong>“<img src="https://img2024.cnblogs.com/blog/3637060/202508/3637060-20250820110840532-1499024617.png" width="30">”<strong>收藏本帖!</strong></p>
<table style="border-collapse: collapse; width: 80%">
<tbody>
<tr>
<td style="text-align: center">
<p><strong>期数</strong></p>
</td>
<td style="text-align: center">
<p><strong>帖子</strong></p>
</td>
<td style="text-align: center">
<p><strong>链接</strong></p>
</td>
</tr>
<tr>
<td style="text-align: center">
<p>第1期</p>
</td>
<td style="text-align: center">
<p>HarmonyOS官方模板优秀案例 | 便捷生活行业 · 购物中心</p>
</td>
<td style="text-align: center">
<p>点击查看</p>
</td>
</tr>
<tr>
<td style="text-align: center">
<p>第2期</p>
</td>
<td style="text-align: center">
<p>HarmonyOS官方模板优秀案例 | 新闻行业 · 综合新闻</p>
</td>
<td style="text-align: center">
<p>点击查看</p>
</td>
</tr>
<tr>
<td style="text-align: center">
<p>第3期</p>
</td>
<td style="text-align: center">
<p>HarmonyOS官方模板优秀案例 | 教育行业 · 教育备考</p>
</td>
<td style="text-align: center">
<p>点击查看</p>
</td>
</tr>
<tr>
<td style="text-align: center">
<p>第4期</p>
</td>
<td style="text-align: center">
<p>HarmonyOS官方模板优秀案例 | 餐饮行业 · 美食菜谱</p>
</td>
<td style="text-align: center">
<p>点击查看</p>
</td>
</tr>
<tr>
<td style="text-align: center">
<p>第5期</p>
</td>
<td style="text-align: center">
<p>HarmonyOS官方模板优秀案例 | 工具行业 · 日历应用</p>
</td>
<td style="text-align: center">
<p>点击查看</p>
</td>
</tr>
<tr>
<td style="text-align: center">
<p>第6期</p>
</td>
<td style="text-align: center">
<p><span style="color: rgba(94, 94, 94, 1)">小编加急整理中,敬请期待</span></p>
</td>
<td style="text-align: center">&nbsp;</td>
</tr>
</tbody>
</table>
<h3>👉 <strong>HarmonyOS组件模板相关推荐</strong></h3>
<ul>
<li><strong>【活动ing】HarmonyOS组件/模板集成创新活动</strong>,报名时间截止2025年8月30日,<strong>点击查看</strong></li>
<li><strong>鸿蒙应用开发者激励计划2025,</strong><strong>点击查看</strong></li>
</ul><br><br>
来源:https://www.cnblogs.com/HarmonyOS5/p/19062270
頁: [1]
查看完整版本: 【小而美】HarmonyOS官方模板优秀案例(第5期:工具行业 · 日历应用)