feat(button): add support for liveActivity open-type#49
feat(button): add support for liveActivity open-type#49FliPPeDround merged 2 commits intouni-helper:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds LiveActivity support to button type definitions: introduces a new open-type Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
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. Comment |
❌ Deploy Preview for uni-typed failed. Why did it fail? →
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/uni-app-types/src/form-components/button.tspackages/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
activityTypeproperty 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.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/uni-app-types/src/form-components/button.ts (1)
240-245: Previous feedback addressed; consider addingerrnofor full parity.The interface now correctly includes optional
errMsgandcodefields, addressing the earlier review feedback. For full consistency with_ButtonOnGetrealtimephonenumberDetail(which includeserrno?: number), consider adding an optionalerrnofield 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
📒 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
liveActivityopen-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
activityTypeprop andonCreateliveactivityhandler are correctly added toButtonPropswith appropriate documentation indicating their dependency onopen-type="liveActivity".Also applies to: 610-615
666-666: LGTM!All new types are correctly exported and the
UniHelpernamespace 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.
📝 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 使用示例
📚 References 相关文档
✅ Checklist 检查清单
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.