Skip to content

feat(button): add support for liveActivity open-type#49

Merged
FliPPeDround merged 2 commits intouni-helper:mainfrom
TAYUN:feat/button-liveActivity
Feb 11, 2026
Merged

feat(button): add support for liveActivity open-type#49
FliPPeDround merged 2 commits intouni-helper:mainfrom
TAYUN:feat/button-liveActivity

Conversation

@TAYUN
Copy link
Contributor

@TAYUN TAYUN commented Jan 1, 2026

📝 Description 描述

添加对微信小程序 Button 组件 open-type="liveActivity" 的类型支持,用于新版一次性订阅消息功能。

此功能从微信小程序基础库 2.26.2 版本开始支持,允许开发者通过前端获取动态令牌(code),用于后续调用服务端接口更新卡片状态。

Linked Issues 关联的 Issues

🎯 Changes 变更

新增类型定义

  • ButtonActivityType: 卡片业态类型,支持 11 种业态场景

    • 1001 - 打车服务
    • 1003 - 同城配送服务
    • 1004 - 取餐等候服务
    • 1005 - 餐厅排队服务
    • 2001 - 购物(实体物流)服务
    • 2002 - 购物(自提)服务
    • 2003 - 购物(虚拟发货)服务
    • 2004 - 快递寄送服务
    • 2005 - 保险购买服务
    • 2006 - 购物&餐饮(同城配送)服务
    • 2007 - 购物&餐饮&本地生活(等候领取)服务
    • 2008 - 酒店预订服务
    • 2009 - 机票服务
    • 2010 - 火车票、汽车票、船票服务
    • 2011 - 景区门票服务
  • ButtonOnCreateliveactivityDetail: 事件详情接口,包含 code 字段

  • ButtonOnCreateliveactivityEvent: 自定义事件类型

  • ButtonOnCreateliveactivity: 事件处理器函数类型

更新的类型

  • ButtonOpenType: 添加 "liveActivity" 选项
  • ButtonProps:
    • 新增 activityType 属性
    • 新增 onCreateliveactivity 事件处理器

💡 Usage Example 使用示例

<template>
  <button 
    open-type="liveActivity" 
    activity-type="1001" 
    @createliveactivity="handleCreateLiveActivity"
  >
    立即呼叫
  </button>
</template>

<script setup lang="ts">
import type { ButtonOnCreateliveactivityEvent } from '@uni-helper/uni-app-types'

const handleCreateLiveActivity = (event: ButtonOnCreateliveactivityEvent) => {
  const code = event.detail.code
  console.log('获取到动态令牌:', code)
  // 将 code 发送到后端,用于调用 setUserNotify 等接口
}
</script>

📚 References 相关文档

✅ Checklist 检查清单

  • 添加了新的类型定义
  • 更新了相关的类型导出
  • 完成测试并通过

Summary by CodeRabbit

  • New Features

    • Button component now supports the new "liveActivity" open-type, enabling configuration of activity codes and handling of live activity creation events through dedicated event callbacks.
  • Tests

    • Added type validation tests to verify the new LiveActivity properties, event types, and their proper integration with the component.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 1, 2026

📝 Walkthrough

Walkthrough

Adds LiveActivity support to button type definitions: introduces a new open-type "liveActivity", activity code union, event/detail interfaces, ButtonProps fields for activityType and onCreateliveactivity, and corresponding public exports and tests.

Changes

Cohort / File(s) Summary
LiveActivity Type Definitions
packages/uni-app-types/src/form-components/button.ts
Adds _ButtonActivityType union with activity codes; extends _ButtonOpenType with "liveActivity"; adds activityType and onCreateliveactivity to ButtonProps; introduces internal event/detail types; exports public aliases (ButtonActivityType, ButtonOnCreateliveactivity*); augments UniHelper namespace.
Type Definition Tests
packages/uni-app-types/test/form-components/button.test-d.ts
Imports and validates new public types: ButtonActivityType, ButtonOnCreateliveactivityDetail, ButtonOnCreateliveactivityEvent, ButtonOnCreateliveactivity; asserts mapping to UniHelper equivalents.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/M

Poem

🐰 I hopped in with a twitch of my nose,
Added live beats where the button goes,
Codes and callbacks in tidy array,
Tokens sprout wings and hop away—hooray! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding LiveActivity open-type support to the Button component TypeScript types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link

netlify bot commented Jan 1, 2026

Deploy Preview for uni-typed failed. Why did it fail? →

Name Link
🔨 Latest commit 363abb6
🔍 Latest deploy log https://app.netlify.com/projects/uni-typed/deploys/695652fd34fe1800083b0180

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3396524 and 6d509ef.

📒 Files selected for processing (2)
  • packages/uni-app-types/src/form-components/button.ts
  • packages/uni-app-types/test/form-components/button.test-d.ts
🧰 Additional context used
🧬 Code graph analysis (2)
packages/uni-app-types/src/form-components/button.ts (1)
packages/uni-app-types/src/events/index.ts (1)
  • CustomEvent (135-135)
packages/uni-app-types/test/form-components/button.test-d.ts (1)
packages/uni-app-types/src/form-components/button.ts (4)
  • ButtonActivityType (835-835)
  • ButtonOnCreateliveactivityDetail (859-860)
  • ButtonOnCreateliveactivityEvent (861-862)
  • ButtonOnCreateliveactivity (868-869)
🔇 Additional comments (11)
packages/uni-app-types/src/form-components/button.ts (8)

56-57: LGTM!

The documentation clearly describes the LiveActivity open-type feature and follows the existing comment style.


110-110: LGTM!

The new "liveActivity" open-type value is correctly added to the union type.


140-188: LGTM!

The activity type enumeration is well-documented with clear descriptions for each service code. The type definition follows TypeScript best practices for string literal unions.


570-575: LGTM!

The activityType property is correctly typed and documented. It follows the existing pattern for open-type-specific properties in the ButtonProps interface.


608-613: LGTM!

The event handler property is correctly added and follows the established pattern for open-type event handlers in the ButtonProps interface.


664-664: LGTM!

All new types are correctly exported following the established naming convention of removing the underscore prefix from internal types.

Also applies to: 673-675


802-835: LGTM!

The ButtonActivityType is correctly exposed in the UniHelper namespace with comprehensive documentation matching the internal type definition.


859-869: LGTM!

The event-related types are correctly exposed in the UniHelper namespace following the established pattern of extending internal types.

packages/uni-app-types/test/form-components/button.test-d.ts (3)

3-3: LGTM!

All new types are correctly imported and maintain the alphabetical ordering of the import statement.

Also applies to: 17-19


61-62: LGTM!

The type tests for ButtonActivityType are comprehensive and follow the established testing pattern.


88-95: LGTM!

The test coverage for the liveActivity event types is comprehensive and follows the established pattern for testing event detail interfaces, event types, and handler functions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/uni-app-types/src/form-components/button.ts (1)

240-245: Previous feedback addressed; consider adding errno for full parity.

The interface now correctly includes optional errMsg and code fields, addressing the earlier review feedback. For full consistency with _ButtonOnGetrealtimephonenumberDetail (which includes errno?: number), consider adding an optional errno field if the liveActivity callback can return error codes. Based on learnings, WeChat callbacks often return errno, errMsg, and code fields.

Optional: Add errno for full parity with other callback details
 interface _ButtonOnCreateliveactivityDetail {
   /** 错误信息 */
   errMsg?: string;
+  /** 错误码(失败时返回) */
+  errno?: number;
   /** 动态更新令牌,用于后续调用服务端接口更新卡片状态 */
   code?: string;
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d509ef and 363abb6.

📒 Files selected for processing (1)
  • packages/uni-app-types/src/form-components/button.ts
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-29T04:02:45.091Z
Learnt from: wtto00
Repo: uni-helper/uni-typed PR: 43
File: packages/uni-app-types/src/form-components/button.ts:159-168
Timestamp: 2025-09-29T04:02:45.091Z
Learning: The WeChat Mini Program getRealtimePhoneNumber callback (bindgetrealtimephonenumber event) returns detail object with errMsg, errno, and code fields according to official WeChat documentation at https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getRealtimePhoneNumber.html, not just the code field as some third-party sources suggest.

Applied to files:

  • packages/uni-app-types/src/form-components/button.ts
🧬 Code graph analysis (1)
packages/uni-app-types/src/form-components/button.ts (1)
packages/uni-app-types/src/events/index.ts (1)
  • CustomEvent (135-135)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules - uni-typed
  • GitHub Check: Header rules - uni-typed
  • GitHub Check: Pages changed - uni-typed
🔇 Additional comments (5)
packages/uni-app-types/src/form-components/button.ts (5)

56-57: LGTM!

The liveActivity open-type documentation and union member addition follow the existing patterns and are correctly integrated.

Also applies to: 110-110


247-257: LGTM!

The event type and handler follow the established patterns used by other button callback types in this file.


572-577: LGTM!

The activityType prop and onCreateliveactivity handler are correctly added to ButtonProps with appropriate documentation indicating their dependency on open-type="liveActivity".

Also applies to: 610-615


666-666: LGTM!

All new types are correctly exported and the UniHelper namespace augmentations follow the established patterns with appropriate documentation.

Also applies to: 675-677, 804-837, 861-871


173-188: The activity type codes are well-documented but cannot be verified against official WeChat sources.

The codes are properly documented with Chinese descriptions for each activity type. Note that "1002" is absent from the 1000-series (codes 1001, 1003, 1004, 1005)—this appears intentional based on the sequence pattern, though it cannot be confirmed against official WeChat Mini Program documentation without direct access to the official specification.

@FliPPeDround FliPPeDround merged commit 4c77e65 into uni-helper:main Feb 11, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants