Skip to content

Conversation

wtto00
Copy link
Contributor

@wtto00 wtto00 commented Sep 29, 2025

Description 描述

添加微信小程序 button 按钮组件相关

  • open-type 添加 getRealtimePhoneNumber 类型
  • 添加手机号相关属性 phone-number-no-quota-toast
  • 添加事件 onGetrealtimephonenumber

不太清楚 onGetrealtimephonenumber 回调参数类型,这里复用的 onGetphonenumber 事件的回调参数类型

Linked Issues 关联的 Issues

Moonofweisheng/wot-design-uni#1327

Additional context 额外上下文

微信button文档

getRealtimePhoneNumber文档

Summary by CodeRabbit

  • New Features

    • Button supports realtime phone number retrieval via a new open type and callback for immediate mobile-number access when authorized.
    • Added an option to suppress the quota-exhausted toast for phone-number requests (defaults to showing the toast).
  • Tests

    • Added type tests to validate the new realtime phone-number callback and related public typings.

Copy link

netlify bot commented Sep 29, 2025

Deploy Preview for uni-typed ready!

Name Link
🔨 Latest commit 7b7ca0f
🔍 Latest deploy log https://app.netlify.com/projects/uni-typed/deploys/68da0113f3432500088946f0
😎 Deploy Preview https://deploy-preview-43--uni-typed.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

coderabbitai bot commented Sep 29, 2025

Walkthrough

Added a new Button open-type "getRealtimePhoneNumber" with its event/detail/callback types, exported public types and UniHelper mappings, added ButtonProps.onGetrealtimephonenumber and phoneNumberNoQuotaToast?, and added corresponding type tests.

Changes

Cohort / File(s) Summary
Button typings update
packages/uni-app-types/src/form-components/button.ts
Added open-type "getRealtimePhoneNumber"; added _ButtonOnGetrealtimephonenumberDetail, _ButtonOnGetrealtimephonenumberEvent, _ButtonOnGetrealtimephonenumber; exported public types ButtonOnGetrealtimephonenumberDetail, ButtonOnGetrealtimephonenumberEvent, ButtonOnGetrealtimephonenumber; added onGetrealtimephonenumber and phoneNumberNoQuotaToast? to ButtonProps; updated UniHelper/global interfaces.
Type tests for new callback
packages/uni-app-types/test/form-components/button.test-d.ts
Imported and asserted new public types ButtonOnGetrealtimephonenumber, ButtonOnGetrealtimephonenumberDetail, ButtonOnGetrealtimephonenumberEvent; tests mirror existing getphonenumber patterns.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant UI as Button (openType="getRealtimePhoneNumber")
    participant Platform as PlatformAPI
    participant App as AppCallback

    User->>UI: Tap button
    UI->>Platform: Request realtime phone number
    alt success
        Platform-->>UI: { errMsg, errno, code, cloudID }
        UI->>App: onGetrealtimephonenumber(event)
    else error
        Platform-->>UI: { errMsg, errno }
        UI->>App: onGetrealtimephonenumber(errorEvent)
    end
    note right of UI: phoneNumberNoQuotaToast? controls quota toast display
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A twitch of whiskers, keys alight,
Realtime numbers hop into sight.
Callbacks ready, types held tight,
Quota whispers—toast or quiet night,
I nibble code and bound with delight. 🐇📲

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “feat(button): add getRealtimePhoneNumber” directly and succinctly describes the primary change—the addition of the getRealtimePhoneNumber capability to the button component—using a clear conventional commit style that will be immediately understandable to team members.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

pkg-pr-new bot commented Sep 29, 2025

Open in StackBlitz

@uni-helper/uni-app-components

npm i https://pkg.pr.new/@uni-helper/uni-app-components@43

@uni-helper/uni-app-types

npm i https://pkg.pr.new/@uni-helper/uni-app-types@43

@uni-helper/uni-cloud-types

npm i https://pkg.pr.new/@uni-helper/uni-cloud-types@43

@uni-helper/uni-types

npm i https://pkg.pr.new/@uni-helper/uni-types@43

@uni-helper/uni-ui-types

npm i https://pkg.pr.new/@uni-helper/uni-ui-types@43

commit: 7b7ca0f

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/uni-app-types/test/form-components/button.test-d.ts (1)

159-166: Different callback parameters - consider creating separate event type.

According to WeChat documentation, bindgetrealtimephonenumber "returns only the Code, will not return encryptedData and iv" unlike getPhoneNumber. The current implementation reuses _ButtonOnGetphonenumberEvent which includes encryptedData, iv, and cloudID properties that won't be present in the realtime verification callback.

Consider creating a dedicated event type:

+interface _ButtonOnGetrealtimephonenumberDetail {
+  /** 错误信息 */
+  errMsg?: string;
+  /** 动态令牌 */
+  code?: string;
+  /** 错误码 (失败时返回) */
+  errno?: number;
+}
+
+type _ButtonOnGetrealtimephonenumberEvent = CustomEvent<_ButtonOnGetrealtimephonenumberDetail>;

 /**
  * 手机号实时验证回调
  *
  * Open-type="getRealtimePhoneNumber" 时有效
  */
 type _ButtonOnGetrealtimephonenumber = (
-  event: _ButtonOnGetphonenumberEvent,
+  event: _ButtonOnGetrealtimephonenumberEvent,
 ) => void;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74d3d7a and 9310576.

📒 Files selected for processing (2)
  • packages/uni-app-types/src/form-components/button.ts (9 hunks)
  • packages/uni-app-types/test/form-components/button.test-d.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/uni-app-types/test/form-components/button.test-d.ts (1)
packages/uni-app-types/src/form-components/button.ts (1)
  • ButtonOnGetrealtimephonenumber (714-715)
⏰ 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: test (windows-latest, 20)
  • GitHub Check: test (windows-latest, 18)
  • GitHub Check: test (windows-latest, 22)
🔇 Additional comments (10)
packages/uni-app-types/src/form-components/button.ts (8)

48-49: LGTM! Documentation follows existing patterns.

The JSDoc documentation for the new GetRealtimePhoneNumber open type is clear and follows the established pattern of other open types.


102-102: LGTM! Open type value added correctly.

The "getRealtimePhoneNumber" value is properly added to the _ButtonOpenType union type, maintaining alphabetical ordering within the list.


325-326: LGTM! JSDoc documentation is consistent.

The documentation in the _ButtonProps interface properly describes the new open type and maintains consistency with the existing pattern.


372-379: LGTM! New prop is well-documented.

The phoneNumberNoQuotaToast prop is properly typed as optional boolean with a clear description and default value documentation. The JSDoc follows the established pattern.


492-497: LGTM! Callback prop follows established pattern.

The onGetrealtimephonenumber prop is properly typed and documented, following the same pattern as onGetphonenumber.


571-571: LGTM! Export follows naming convention.

The export of _ButtonOnGetrealtimephonenumber as ButtonOnGetrealtimephonenumber follows the established pattern for making internal types available publicly.


641-642: LGTM! UniHelper namespace documentation is consistent.

The JSDoc documentation in the global UniHelper namespace properly describes the new open type and maintains consistency.


709-715: LGTM! Global interface declaration follows pattern.

The global interface declaration for ButtonOnGetrealtimephonenumber correctly extends the internal type, following the established pattern used by other callback interfaces.

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

21-21: LGTM! Import follows alphabetical ordering.

The ButtonOnGetrealtimephonenumber import is correctly placed in alphabetical order within the import statement.


64-65: LGTM! Type tests follow established pattern.

The type tests for ButtonOnGetrealtimephonenumber properly verify:

  1. The type is a function (toBeFunction())
  2. It matches the corresponding UniHelper namespace type (toEqualTypeOf<UniHelper.ButtonOnGetrealtimephonenumber>())

This mirrors the existing pattern used for ButtonOnGetphonenumber.

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: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9310576 and 7b7ca0f.

📒 Files selected for processing (2)
  • packages/uni-app-types/src/form-components/button.ts (9 hunks)
  • packages/uni-app-types/test/form-components/button.test-d.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/uni-app-types/test/form-components/button.test-d.ts
🧰 Additional context used
🧬 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: test (windows-latest, 22)
  • GitHub Check: test (windows-latest, 20)
  • GitHub Check: test (windows-latest, 18)

@ModyQyW ModyQyW changed the title feat(button): add getRealtimePhoneNumber feat(uat): add getRealtimePhoneNumber for Button Oct 15, 2025
@ModyQyW
Copy link
Member

ModyQyW commented Oct 15, 2025

Thank you!

@ModyQyW ModyQyW merged commit ae34a4d into uni-helper:main Oct 15, 2025
17 checks passed
@wtto00 wtto00 deleted the button-getRealtimePhoneNumber branch October 15, 2025 23:04
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