-
Notifications
You must be signed in to change notification settings - Fork 4.9k
fix(harmony): 修复 harmony_cpp 在开启 tabbar 后无法正常编译的问题 #17797
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
Conversation
""" Walkthrough本次更改在鸿蒙平台的页面生成逻辑中,针对 tabbar 页添加了分支处理。涉及页面状态、节点引用、生命周期方法等多个环节,均新增了对 tabbar 页的数组化处理和组件包裹,确保多个 tab 页能正确生成、渲染和响应事件。 Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant PageParser
participant Tabs
participant TabPage
App->>PageParser: 初始化页面
alt 非 tabbar 页
PageParser->>TabPage: 构建单一页面节点
else tabbar 页
PageParser->>Tabs: 创建 Tabs 组件
Tabs->>TabPage: ForEach 遍历 tabBarList 构建多个页面节点
end
PageParser->>TabPage: 生命周期方法(如 handlePageAppear)按索引处理
Assessment against linked issues
Suggested reviewers
Poem
✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/taro-platform-harmony-cpp/src/program/vite/page.ts
(10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
🔇 Additional comments (5)
packages/taro-platform-harmony-cpp/src/program/vite/page.ts (5)
174-184
: 正确处理了 tabbar 页面的配置索引foreach 回调的修改正确地区分了 tabbar 页面和普通页面的处理逻辑,为每个 tab 页面维护独立的导航栏隐藏状态。
355-374
: 正确实现了 tabbar 页面的索引访问页面构建代码正确地使用了数组索引来访问 tabbar 页面的各个状态,包括
isReady
、node
、nodeContent
、背景色和isHideTitleBar
。这确保了每个 tab 页面能够独立管理自己的状态。Also applies to: 395-406
413-445
: Tabs 组件实现完善新增的 Tabs 组件包装代码完整实现了 tabbar 页面的功能:
- 正确使用 ForEach 渲染各个 tab 内容
- onChange 事件恰当地处理了页面切换时的生命周期(onHide/onShow)
- 考虑了底部安全区域的适配
456-473
: handlePageAppear 正确处理了 tabbar 页面方法修改正确地为 tabbar 页面使用了数组索引来访问
nodeContent
和设置isReady
状态,确保每个 tab 页面的初始化独立进行。
504-506
: 方法正确适配了 tabbar 页面
getNavHeight
和handlePageDetach
方法都正确地使用了索引来访问 tabbar 页面的状态,确保了每个 tab 页面的独立性。Also applies to: 513-516
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #17797 +/- ##
========================================
Coverage 59.36% 59.36%
========================================
Files 387 387
Lines 23420 23420
Branches 5166 5151 -15
========================================
Hits 13904 13904
+ Misses 8149 8018 -131
- Partials 1367 1498 +131
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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
♻️ Duplicate comments (1)
packages/taro-platform-harmony-cpp/src/program/vite/page.ts (1)
150-150
: 修正 renderState 的第二个参数这几处将
this.isTabbarPage
改为false
可能是错误的。根据代码的其他部分,当页面是 tabbar 页面时,这些状态应该被渲染为数组形式。建议恢复原有逻辑:
this.renderState( { name: '__layoutSize', type: 'TaroAny', foreach: () => 'null', disabled: !this.buildConfig.isBuildNativeComp && isPure, }, - false + this.isTabbarPage ),对
areaChange
和params
的 renderState 调用也应做同样修改。Also applies to: 158-158, 177-177
🧹 Nitpick comments (6)
packages/taro-platform-harmony-cpp/src/program/vite/style.ts (1)
55-67
: 逻辑正确,但建议修复数组检查方式多页面处理逻辑实现正确,为每个页面生成独立的样式导入和注册。但应使用
Array.isArray()
替代instanceof Array
。应用此修复:
- if (page instanceof Array) { + if (Array.isArray(page)) {🧰 Tools
🪛 Biome (1.9.4)
[error] 55-55: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.(lint/suspicious/useIsArray)
packages/taro-platform-harmony-cpp/src/program/vite/page.ts (5)
42-50
: 修复数组检查方式函数逻辑正确,但应使用
Array.isArray()
替代instanceof Array
。应用此修复:
- if (page instanceof Array) return false + if (Array.isArray(page)) return false🧰 Tools
🪛 Biome (1.9.4)
[error] 43-44: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.(lint/suspicious/useIsArray)
113-138
: 多页面导入逻辑实现正确正确处理单页面和多页面场景的路由名称和入口选项设置,但需要修复数组检查方式。
应用此修复:
- if (page instanceof Array) { + if (Array.isArray(page)) {🧰 Tools
🪛 Biome (1.9.4)
[error] 125-125: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.(lint/suspicious/useIsArray)
293-299
: 多页面初始化逻辑正确,但需修复数组检查正确处理多页面的 EtsBuilder 初始化和页面名称设置,但应使用标准数组检查方法。
应用此修复:
- ...(page instanceof Array ? [ + ...(Array.isArray(page) ? [🧰 Tools
🪛 Biome (1.9.4)
[error] 294-294: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.(lint/suspicious/useIsArray)
303-307
: 样式表初始化逻辑正确,但需修复数组检查多页面样式表初始化逻辑实现正确,为每个页面使用对应的 styleJson 索引。
应用此修复:
- ...(page instanceof Array ? [ + ...(Array.isArray(page) ? [🧰 Tools
🪛 Biome (1.9.4)
[error] 304-304: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.(lint/suspicious/useIsArray)
338-350
: 避免区域变化处理逻辑正确,但需修复数组检查正确实现了 tabbar 页面的状态栏高度更新和环境规则更新逻辑。
应用此修复:
- ...(page instanceof Array + ...(Array.isArray(page)🧰 Tools
🪛 Biome (1.9.4)
[error] 340-340: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.(lint/suspicious/useIsArray)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/taro-platform-harmony-cpp/src/program/vite/page.ts
(15 hunks)packages/taro-platform-harmony-cpp/src/program/vite/render.ts
(1 hunks)packages/taro-platform-harmony-cpp/src/program/vite/style.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/taro-platform-harmony-cpp/src/program/vite/render.ts (1)
packages/taro-vite-runner/src/harmony/template/page.ts (1)
TaroHarmonyPageMeta
(24-42)
🪛 Biome (1.9.4)
packages/taro-platform-harmony-cpp/src/program/vite/style.ts
[error] 55-55: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.
(lint/suspicious/useIsArray)
packages/taro-platform-harmony-cpp/src/program/vite/page.ts
[error] 43-44: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.
(lint/suspicious/useIsArray)
[error] 125-125: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.
(lint/suspicious/useIsArray)
[error] 294-294: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.
(lint/suspicious/useIsArray)
[error] 304-304: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.
(lint/suspicious/useIsArray)
[error] 340-340: Use Array.isArray() instead of instanceof Array.
instanceof Array returns false for array-like objects and arrays from other execution contexts.
Unsafe fix: Use Array.isArray() instead.
(lint/suspicious/useIsArray)
⏰ Context from checks skipped due to timeout of 90000ms (10)
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Testing on Rust
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-musl
- GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
- GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
- GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
- GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (6)
packages/taro-platform-harmony-cpp/src/program/vite/render.ts (1)
89-89
: 类型签名更新正确将
page
参数类型更新为支持数组,与TaroHarmonyPageMeta
接口定义保持一致,为 tabbar 多页面场景提供支持。packages/taro-platform-harmony-cpp/src/program/vite/style.ts (1)
48-48
: 类型签名更新正确更新
page
参数类型以支持数组,与其他文件保持一致。packages/taro-platform-harmony-cpp/src/program/vite/page.ts (4)
12-14
: 新类型定义合理添加
TCPageMeta
类型扩展TPageMeta
并包含可选的isPure
标志,有助于区分纯组件页面。
98-99
: 类型签名更新正确更新
modifyInstantiate
以支持页面数组,逻辑中正确检查非数组情况。
193-203
: tabbar 页面状态处理逻辑正确正确实现了 tabbar 页面的导航栏样式状态处理,根据页面索引动态获取配置。
447-479
: tabbar 页面构建逻辑实现完整正确实现了 tabbar 页面的 Tabs 组件包装,包含所有必要的配置项如位置、控制器、索引等,以及页面切换的生命周期处理。
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit
新功能
修复