-
Notifications
You must be signed in to change notification settings - Fork 395
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: resolved the issue where headerShown: false was not working after the interface rendering & added the AnchorSizableText component & fixed the issue of the Loading indicator showing twice on the market detail page. (OK-32345) #6395
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
概述代码变更综述这次代码变更涉及多个组件和路由配置,主要包括以下几个关键方面:
变更详情文件变更
主要变更点
技术亮点
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 🪧 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 (
|
...props | ||
}: IAnchorSizableTextProps) { | ||
const line = children as string; | ||
const isAnchor = anchorRegExp.test(line); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
This
regular expression
library input
const line = children as string; | ||
const isAnchor = anchorRegExp.test(line); | ||
if (isAnchor) { | ||
const parts = line.split(anchorRegExp); |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High
regular expression
library input
This
regular expression
library input
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: 8
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (14)
packages/components/src/actions/Toast/index.tsx
(2 hunks)packages/components/src/content/AnchorSizableText/index.tsx
(1 hunks)packages/components/src/content/index.ts
(1 hunks)packages/components/src/layouts/Navigation/Navigator/TabStackNavigator.tsx
(1 hunks)packages/kit/src/components/TradingView/index.tsx
(1 hunks)packages/kit/src/routes/Tab/Discovery/router.ts
(1 hunks)packages/kit/src/routes/Tab/Earn/router.ts
(2 hunks)packages/kit/src/routes/Tab/Marktet/router.ts
(2 hunks)packages/kit/src/routes/Tab/Swap/router.ts
(2 hunks)packages/kit/src/routes/Tab/router.ts
(0 hunks)packages/kit/src/views/Developer/pages/Gallery/Components/stories/Toast.tsx
(1 hunks)packages/kit/src/views/Developer/pages/Gallery/Components/stories/TradingView.tsx
(1 hunks)packages/kit/src/views/Home/router/index.ts
(2 hunks)packages/kit/src/views/Market/components/TokenPriceChart.tsx
(7 hunks)
💤 Files with no reviewable changes (1)
- packages/kit/src/routes/Tab/router.ts
🧰 Additional context used
🪛 eslint
packages/kit/src/views/Developer/pages/Gallery/Components/stories/Toast.tsx
[error] 44-44: Insert ⏎···················
(prettier/prettier)
🪛 GitHub Check: CodeQL
packages/components/src/content/AnchorSizableText/index.tsx
[failure] 19-19: Polynomial regular expression used on uncontrolled data
This regular expression that depends on library input may run slow on strings starting with '<url ' and with many repetitions of ' '.
This regular expression that depends on library input may run slow on strings starting with '' and with many repetitions of 'a'.
[failure] 21-21: Polynomial regular expression used on uncontrolled data
This regular expression that depends on library input may run slow on strings starting with '<url ' and with many repetitions of ' '.
This regular expression that depends on library input may run slow on strings starting with '' and with many repetitions of 'a'.
🔇 Additional comments (11)
packages/kit/src/views/Developer/pages/Gallery/Components/stories/TradingView.tsx (1)
30-30
: 代码实现正确!
在示例组件中添加 onLoadEnd
回调函数的实现简单明了,符合演示目的。
packages/kit/src/views/Market/components/TokenPriceChart.tsx (2)
52-57
: 实现正确且时机恰当!
onLoadEnd
回调函数的调用时机正确,在数据加载完成后执行。
Also applies to: 103-103
178-181
: 代码结构清晰!
正确地将 onLoadEnd
属性传递给底层 TradingView 组件。
Also applies to: 196-196
packages/kit/src/routes/Tab/Earn/router.ts (1)
2-2
: 代码实现正确,建议验证其他路由配置
代码变更符合需求,通过 platformEnv.isNative
来控制标题栏显示是个好方案。
Also applies to: 16-16
✅ Verification successful
路由配置已统一使用 headerShown 属性
检查结果显示所有 Tab 路由和主页路由都统一使用了 headerShown: !platformEnv.isNative
配置,实现保持一致。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查其他路由文件中是否统一使用了相同的 headerShown 配置
rg "headerShown:\s*!platformEnv.isNative" --type ts
Length of output: 477
packages/kit/src/routes/Tab/Marktet/router.ts (1)
2-2
: 代码实现正确,建议验证详情页行为
主页面的 headerShown 实现与其他路由一致。建议确认 MarketDetail 路由是否也需要类似的 headerShown 控制。
Also applies to: 22-22
packages/kit/src/routes/Tab/Discovery/router.ts (1)
18-18
: 代码变更看起来不错!
根据平台环境动态控制 header 显示的实现方式简洁明了,与其他路由文件保持一致。
packages/kit/src/views/Home/router/index.ts (1)
2-2
: 实现方式正确且统一!
新增的 platformEnv 导入以及基于平台环境的 headerShown 控制逻辑,与项目其他路由配置保持一致。
Also applies to: 31-31
packages/components/src/layouts/Navigation/Navigator/TabStackNavigator.tsx (1)
43-43
: 关键修复已完成,建议验证完整流程!
headerShown 属性已正确恢复到 Stack.Screen 的选项中。这个改动解决了 headerShown: false 不生效的问题。建议在不同平台环境下验证 header 的显示/隐藏状态。
✅ Verification successful
headerShown 属性配置正确,无需其他修改
代码检查显示:
- TabStackNavigator 中的 headerShown 属性配置合理,与全局配置保持一致
- GlobalScreenOptions 中的 headerShown 默认值设置完善,覆盖了各种场景
- 不同平台(iOS/Android/Browser)的 headerShown 配置已经适配
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# 检查其他路由文件中是否还有类似的 headerShown 配置需要修复
# 搜索所有包含 headerShown 的路由配置文件
rg -l "headerShown" --type ts
# 检查 Stack.Screen 组件的使用情况
ast-grep --pattern 'Stack.Screen'
Length of output: 2031
Script:
#!/bin/bash
# 检查 headerShown 的具体使用方式
rg "headerShown" -B 2 -A 2 packages/components/src/layouts/Navigation/Navigator/TabStackNavigator.tsx
# 检查其他文件中 headerShown 的使用模式
rg "headerShown" -B 2 -A 2 packages/components/src/layouts/Navigation/GlobalScreenOptions.ts packages/components/src/layouts/Navigation/GlobalScreenOptions.native.ts
# 检查 Stack.Screen 的选项配置
ast-grep --pattern 'Stack.Screen $$$options={$_}$$$'
Length of output: 8345
packages/components/src/content/index.ts (1)
1-1
: 导出声明看起来不错!
新增的 AnchorSizableText 组件导出遵循了现有的导出模式,保持了代码的一致性。
packages/components/src/content/AnchorSizableText/index.tsx (2)
5-9
: 接口定义清晰简洁
Props 接口设计合理,通过继承 ISizableTextProps 扩展了必要的属性。
12-14
:
注意:正则表达式可能存在性能风险
当前的正则表达式实现可能在处理特定输入时导致性能问题:
- 对于包含大量重复模式的文本可能会导致性能下降
- 建议添加输入长度限制以防止潜在的 DOS 攻击
建议添加以下安全措施:
export function AnchorSizableText({
anchorRegExp = /<url(?:\s+[^>]*?)?>(.*?)<\/url>/g,
hrefRegExp = /href="(.*?)"/,
children,
anchorProps,
...props
}: IAnchorSizableTextProps) {
const line = children as string;
+ if (line.length > 1000) {
+ console.warn('Text length exceeds safe limit');
+ return <SizableText {...props}>{line}</SizableText>;
+ }
Likely invalid or redundant comment.
Summary by CodeRabbit
新特性
ToastGallery
组件中添加了一个新按钮,触发包含超链接的吐司通知。TradingView
组件中添加了onLoadEnd
属性,用于加载完成后的回调。headerShown
属性,根据平台环境动态控制头部显示。修复
TabStackNavigator
组件中的headerShown
属性,确保其一致性。文档
TokenPriceChart
组件以增强加载状态管理。重构
Toast
组件的渲染逻辑,移除了 URL 处理的正则表达式。