-
Notifications
You must be signed in to change notification settings - Fork 0
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(menu): support query in active excludes #1455
Conversation
概述演练此次更改主要涉及 变更
详细信息主要变更点
注意事项
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
shared/general/src/menu.ts:177
- Ensure that the behavior of 'getMatchOfSearch' is covered by tests, especially with the new changes involving query parameters.
getMatchOfSearch(search, parsedPathWithSearch.search)
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
🧹 Nitpick comments (1)
shared/general/src/menu.ts (1)
166-178
: 优化代码可读性并避免逻辑混淆当前在这里使用了“取反逻辑”来判断是否匹配 Exclude 条目,可能会给后续维护带来一些理解难度。可以考虑将此段逻辑拆分为更为直接的变量赋值,提升可读性。例如:
- 先判断此路径是否与 Exclude 条目匹配(含查询参数),并用一个中间变量存储结果。
- 根据匹配结果决定是否终止循环或更新主逻辑的 match 变量。
示例更改如下(仅供参考):
- match = !( - matchPath(pathname, { - path: parsedPathWithSearch ? parsedPathWithSearch.pathname : path, - exact, - }) && - (!parsedPathWithSearch || - getMatchOfSearch(search, parsedPathWithSearch.search)) - ); + const isExcluded = matchPath(pathname, { + path: parsedPathWithSearch ? parsedPathWithSearch.pathname : path, + exact, + }) && (!parsedPathWithSearch || getMatchOfSearch(search, parsedPathWithSearch.search)); + match = !isExcluded;这样能使后续阅读和调试逻辑更直接,减少误解的可能性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
shared/general/src/menu.spec.ts
(2 hunks)shared/general/src/menu.ts
(1 hunks)
🔇 Additional comments (1)
shared/general/src/menu.spec.ts (1)
169-185
: 测试用例覆盖到查询参数场景,验证完善
新增的测试用例 matchMenuItem with activeExcludes with query
涵盖了多种查询参数组合,能够清晰验证 activeExcludes
对含有查询参数的场景是否正确生效。这不仅提高了代码的测试覆盖率,也有助于防止后续在查询参数处理逻辑上出现回归问题。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1455 +/- ##
=======================================
Coverage 85.37% 85.37%
=======================================
Files 522 522
Lines 15586 15588 +2
Branches 2334 2335 +1
=======================================
+ Hits 13307 13309 +2
Misses 1829 1829
Partials 450 450
|
🚀 Deployed on https://docs-preview-1455--next-bricks.netlify.app |
📐🤏 Size check result (b7f182c...50af4b7): Load all bricks together
Critical changes: None. See full changes
Load bricks by each packageCritical changes: None. See full changes
Load by each brickCritical changes: None. See full changes
|
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat
作为提交类型。BREAKING CHANGE: 你的变更说明
。新特性:
feat
作为提交类型。问题修复:
fix
作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore
,docs
,test
等作为提交类型。Summary by CodeRabbit
matchMenuItem
函数在处理查询参数时的行为。