Skip to content
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

fix: 优化路由接口以及修复onResize回调参数缺失的字段 #14967

Merged
merged 2 commits into from
Feb 2, 2024

Conversation

guoenxuan
Copy link
Contributor

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

  • 路由接口增加url是否是有效页面的url判断
  • page.onResize增加deviceOrientation、size.screenWidth/screenHeight字段信息

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

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

这个 PR 涉及以下平台:

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

@ZakaryCode ZakaryCode added the T-h5 Target - 编译到 H5 label Dec 12, 2023
@ZakaryCode ZakaryCode added A-router Area - H5 路由相关 A-api Area - H5 API 相关 labels Dec 13, 2023
@guoenxuan guoenxuan force-pushed the mpharmony-gex-route branch 2 times, most recently from 3371bdb to 37e9ab8 Compare December 13, 2023 09:56
const originPath = routesAlias.getOrigin(pathPieces.pathname)
const pagePath = originPath.startsWith('/') ? originPath.substring(1) : originPath
if (!RouterConfig.pages.includes(pagePath)) {
const res = { errMsg: `${method}:fail page ${pagePath} is not found` }
Copy link
Contributor

Choose a reason for hiding this comment

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

需要触发 onPageNotFound 事件

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里参考了微信小程序的行为。微信小程序在用路由函数跳转到不存在的页面时,并不会触发onPageNotFound 事件,而是返回了错误信息。

fail?.(res)
complete?.(res)
reject(res)
return
Copy link
Contributor

Choose a reason for hiding this comment

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

如果 fail 或 compete 是 function,这里应该 return resolve(res),反之则为 return reject(res),下面的 catch 中也存在类似问题

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@guoenxuan guoenxuan force-pushed the mpharmony-gex-route branch 2 times, most recently from 84c6ba8 to 084694f Compare December 29, 2023 01:56
Copy link

codecov bot commented Dec 29, 2023

Codecov Report

Attention: 18 lines in your changes are missing coverage. Please review.

Comparison is base (cd993e8) 58.94% compared to head (037da46) 58.89%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #14967      +/-   ##
==========================================
- Coverage   58.94%   58.89%   -0.05%     
==========================================
  Files         489      489              
  Lines       21681    21698      +17     
  Branches     5556     5566      +10     
==========================================
  Hits        12780    12780              
- Misses       7724     7741      +17     
  Partials     1177     1177              
Flag Coverage Δ
taro-cli 63.29% <ø> (ø)
taro-runner 46.21% <ø> (ø)
taro-runtime 65.51% <ø> (ø)
taro-web 40.96% <0.00%> (-0.10%) ⬇️

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

Files Coverage Δ
packages/taro-router/src/events/resize.ts 27.27% <0.00%> (-10.23%) ⬇️
packages/taro-router/src/api.ts 16.83% <0.00%> (-2.71%) ⬇️

Copy link
Contributor

@ZakaryCode ZakaryCode left a comment

Choose a reason for hiding this comment

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

感谢贡献~

@ZakaryCode ZakaryCode added this to the 3.6.24 milestone Feb 2, 2024
@ZakaryCode ZakaryCode merged commit 7245127 into NervJS:main Feb 2, 2024
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-api Area - H5 API 相关 A-router Area - H5 路由相关 T-h5 Target - 编译到 H5
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants