Skip to content

fix: 修复支付宝 openLocation API 参数错误 #17547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

luckyadam
Copy link
Member

@luckyadam luckyadam commented Apr 14, 2025

这个 PR 做了什么? (简要描述所做更改)

这个 PR 是什么类型? (至少选择一个)

  • 错误修复(Bugfix) issue: fix #
  • 新功能(Feature)
  • 代码重构(Refactor)
  • TypeScript 类型定义修改(Typings)
  • 文档修改(Docs)
  • 代码风格更新(Code style update)
  • 其他,请描述(Other, please describe):

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

Summary by CodeRabbit

  • New Features

    • 新增 “openLocation” 接口,支持以异步方式调用定位服务,提供更灵活的操作体验。
  • Refactor

    • 优化了部分接口的内部结构和格式,提升了系统一致性和整体稳定性。(该改进对现有功能无影响。)

Copy link

coderabbitai bot commented Apr 14, 2025

Walkthrough

本次更新对 packages/taro-platform-alipay 模块内的两个文件进行了修改。在 apis-list.ts 文件中,扩展了返回 Promise 的 API 列表,新增了 openLocation 接口;同时保留了已有的 getConnectedBluetoothDevices。在 apis.ts 文件中,通过在对象属性、数组和函数参数列表中添加尾逗号,统一调整了代码格式,确保风格一致性,未对实际功能产生影响。

Changes

文件路径 更改说明
packages/taro-platform-alipay/.../apis-list.ts needPromiseApis 集合中新增 openLocation,保留 getConnectedBluetoothDevices
packages/taro-platform-alipay/.../apis.ts apiDiffasyncResultApiDiff 对象及函数签名中添加尾逗号,优化代码格式。

Sequence Diagram(s)

sequenceDiagram
    participant 客户端
    participant Taro平台
    客户端->>Taro平台: 调用 openLocation()
    Taro平台-->>客户端: 返回 Promise 结果
Loading

Poem

我是小兔,跳跃在代码间,
新增 openLocation,如月光般灿烂。
格式整理,逗号细腻又严谨,
每个函数跳跃着代码的韵律。
代码世界,因变更更显生机!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (2)
packages/taro-platform-alipay/src/apis.ts (2)

181-183: 优化链式调用

静态分析工具提示可以将此处代码优化为可选链式调用。

可以考虑将:

- return (options.scanType && options.scanType[0].slice(0, -4)) || 'qr'
+ return (options.scanType?.[0]?.slice(0, -4)) || 'qr'

这样可以避免潜在的空引用错误。

🧰 Tools
🪛 Biome (1.9.4)

[error] 182-182: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


367-370: 优化回调处理和避免使用 delete 操作符

静态分析工具提示可以优化回调处理,并避免使用影响性能的 delete 操作符。

可以考虑将:

- res.header = res.headers
- delete res.headers
- originSuccess && originSuccess(res)
+ res.header = res.headers
+ res.headers = undefined
+ originSuccess?.(res)

- originFail && originFail(res)
+ originFail?.(res)

- originComplete && originComplete(res)
+ originComplete?.(res)

这样可以提高代码性能和可读性。

Also applies to: 372-377

🧰 Tools
🪛 Biome (1.9.4)

[error] 367-367: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 369-369: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 500c102 and 3654431.

⛔ Files ignored due to path filters (2)
  • tests/__tests__/__snapshots__/mini-platform.spec.ts.snap is excluded by !**/*.snap
  • tests/__tests__/__snapshots__/tabbar.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (2)
  • packages/taro-platform-alipay/src/apis-list.ts (1 hunks)
  • packages/taro-platform-alipay/src/apis.ts (12 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/taro-platform-alipay/src/apis.ts

[error] 182-182: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 367-367: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 369-369: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 369-372: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


[error] 374-377: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (11)
packages/taro-platform-alipay/src/apis-list.ts (1)

44-45: 支持支付宝 openLocation API Promise 化

通过添加 'openLocation' 到 needPromiseApis 集合中,使该 API 能够返回 Promise,从而允许使用 async/await 语法或 then/catch 链式调用,提高代码可读性和可维护性。

packages/taro-platform-alipay/src/apis.ts (10)

16-19: 代码格式调整:增加尾逗号

在对象属性中添加尾逗号,提高了代码的一致性和可维护性。这种格式化调整使得未来的代码变更(增加或删除条目)在 git diff 中更加清晰。


23-29: 代码格式调整:增加尾逗号

在数组内的对象中添加尾逗号,保持了代码风格的一致性。


33-54: 代码格式调整:增加尾逗号

在嵌套的对象和数组结构中添加尾逗号,提高了代码的可读性和一致性。这种调整有助于代码的长期维护。


58-75: 代码格式调整:增加尾逗号

在选项对象中统一添加尾逗号,使得代码格式更加一致。


78-78: 简单格式调整

对 alias 属性值行末增加尾逗号,保持与其它属性格式一致。

Also applies to: 81-81


85-93: 代码格式调整:增加尾逗号

为对象和数组元素添加尾逗号,保持代码格式一致性。


97-103: 代码格式调整:统一添加尾逗号

在 apiDiff 对象的多个属性中统一添加尾逗号,提高代码一致性和可维护性。

Also applies to: 107-113, 117-123, 127-133, 137-143, 146-146, 151-157, 161-167, 172-186, 190-196, 199-199, 202-203, 205-206, 208-209


221-224: 代码格式调整:asyncResultApiDiff 对象格式统一

在 asyncResultApiDiff 对象的各个值函数和数组中添加尾逗号,保持代码格式一致性。

Also applies to: 233-236, 238-239, 246-249, 258-261, 270-273, 282-285, 291-299, 303-311, 318-321, 330-335


337-338: 完善格式:补充缺失的尾逗号

为 getBLEDeviceServices 对象添加尾逗号,使其与其他对象格式保持一致。


341-341: 函数参数和返回值格式统一

为函数定义、对象属性和函数调用等添加尾逗号,使整个代码库的格式更加统一和一致。

Also applies to: 345-346, 349-350, 364-364, 372-372, 377-377, 418-419, 432-434, 440-440, 451-451, 461-461, 466-466, 477-478, 481-482, 492-492, 519-519, 532-532, 538-538, 545-545, 552-552

Copy link

codecov bot commented Apr 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.37%. Comparing base (500c102) to head (3654431).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17547   +/-   ##
=======================================
  Coverage   58.37%   58.37%           
=======================================
  Files         469      469           
  Lines       27231    27231           
  Branches     5950     5954    +4     
=======================================
  Hits        15896    15896           
- Misses       9957     9963    +6     
+ Partials     1378     1372    -6     
Flag Coverage Δ
taro-cli 72.37% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 52.75% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Single-Dancer Single-Dancer added this to the 4.0.12 milestone Apr 15, 2025
@Single-Dancer Single-Dancer merged commit 0237608 into main Apr 15, 2025
49 of 50 checks passed
@Single-Dancer Single-Dancer deleted the fix/alipay_location branch April 15, 2025 02:01
This was referenced Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants