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

feat: improve banner style in Earn module & fix webpack building on Desktop & add webviewDebuggingEnabled into Dev Settings. #6386

Merged
merged 12 commits into from
Dec 21, 2024

Conversation

huhuanming
Copy link
Contributor

@huhuanming huhuanming commented Dec 20, 2024

Summary by CodeRabbit

  • 新功能

    • 增加了应用程序窗口焦点状态的检查功能。
    • 在开发设置中新增了“webview调试”选项,允许用户启用或禁用该功能。
    • Banner组件中添加了可选的size属性,支持小型和大型显示。
  • 样式

    • 调整了EarnHome页面中组件的布局和样式,优化了视觉呈现。
  • 文档

    • 新增了日志记录功能,以跟踪浮动图标的显示状态。
  • 修复

    • 增强了错误处理机制,确保在开发设置中进行操作时的稳定性。

Copy link

codesandbox bot commented Dec 20, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

概述

浏览

此次更改涉及多个文件,主要包括桌面应用程序的焦点状态检查、WebView调试设置、开发者设置以及一些组件的样式和布局调整。新增了应用程序焦点状态的IPC处理、开发设置中的WebView调试选项,并对一些组件的渲染和交互进行了细微优化。

变更

文件路径 变更摘要
apps/desktop/src-electron/... 新增应用程序焦点状态IPC处理
development/webpack/... 调整输出文件夹逻辑,移除重复函数
packages/components/Banner/... 调整Banner组件布局和尺寸
packages/kit/WebView/... 新增WebView调试设置
packages/kit-bg/devSettings 添加WebView调试开关
packages/kit/Setting/... 新增开发者设置中的WebView调试选项

序列图

sequenceDiagram
    participant App as 应用程序
    participant IPC as IPC通道
    participant Window as 主窗口

    App->>IPC: 请求窗口焦点状态
    IPC->>Window: 检查焦点状态
    Window-->>IPC: 返回焦点状态
    IPC-->>App: 响应焦点状态
Loading

这个序列图展示了应用程序如何通过IPC通道查询主窗口的焦点状态。

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


🪧 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 or 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.

@huhuanming huhuanming changed the title style: improve banner style in Earn module style: improve banner style in Earn module & fix webpack building on Desktop & add webviewDebuggingEnabled into Dev Settings. Dec 20, 2024
@huhuanming huhuanming changed the title style: improve banner style in Earn module & fix webpack building on Desktop & add webviewDebuggingEnabled into Dev Settings. feat: improve banner style in Earn module & fix webpack building on Desktop & add webviewDebuggingEnabled into Dev Settings. Dec 20, 2024
@huhuanming huhuanming enabled auto-merge (squash) December 20, 2024 15:50
Copy link
Contributor

@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: 8

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5fb98 and 3fd5c53.

📒 Files selected for processing (18)
  • apps/desktop/src-electron/app.ts (1 hunks)
  • apps/desktop/src-electron/config.ts (1 hunks)
  • apps/desktop/src-electron/preload.ts (2 hunks)
  • development/webpack/utils.js (1 hunks)
  • development/webpack/webpack.ext.config.js (2 hunks)
  • development/webpack/webpack.prod.config.js (2 hunks)
  • packages/components/src/composite/Banner/index.tsx (2 hunks)
  • packages/components/src/hooks/useVisibilityChange.ts (2 hunks)
  • packages/kit-bg/src/states/jotai/atoms/devSettings.ts (2 hunks)
  • packages/kit/src/components/WebView/InpageProviderWebView.native.tsx (2 hunks)
  • packages/kit/src/components/WebView/NativeWebView.tsx (4 hunks)
  • packages/kit/src/components/WebView/index.tsx (3 hunks)
  • packages/kit/src/components/WebView/types.ts (1 hunks)
  • packages/kit/src/provider/Container/NetworkReachabilityTracker.tsx (1 hunks)
  • packages/kit/src/views/Earn/EarnHome.tsx (1 hunks)
  • packages/kit/src/views/Setting/pages/FloatingIcon/index.tsx (2 hunks)
  • packages/kit/src/views/Setting/pages/List/DevSettingsSection/index.tsx (1 hunks)
  • packages/shared/src/logger/scopes/discovery/scenes/dapp.ts (1 hunks)
🔇 Additional comments (13)
packages/kit/src/views/Setting/pages/FloatingIcon/index.tsx (1)

14-14: 代码变更看起来不错!

添加日志记录有助于跟踪浮动图标状态的变化,实现方式简洁明了。

Also applies to: 39-41

development/webpack/utils.js (1)

44-48: 代码实现清晰简洁!

函数实现符合以下要点:

  • 使用解构赋值获取参数
  • 使用模板字符串处理字符串拼接
  • 使用三元运算符简化条件判断
development/webpack/webpack.prod.config.js (1)

5-5: 重构改动合理!

  • 从utils模块导入函数,提高了代码的模块化
  • 正确使用了新的getOutputFolder函数生成输出路径

Also applies to: 16-16

development/webpack/webpack.ext.config.js (1)

18-18: 重构改动正确,建议验证构建配置!

代码变更:

  • 正确导入了utils模块
  • 使用新的getOutputFolder函数替换了原有实现

建议验证不同构建配置(V2/V3)下的输出路径是否正确。

Also applies to: 47-47

✅ Verification successful

构建配置变更已验证,无需担心!

getOutputFolder函数已正确实现V2/V3版本的输出路径逻辑:

  • 根据isManifestV3()自动选择正确的输出目录
  • V3版本输出到{browser}_v3目录
  • V2版本输出到{browser}目录

webpack.ext.config.js中的输出路径配置也已正确使用此函数。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 验证不同配置下的输出路径生成
# 检查构建输出目录结构
fd -t d -d 1 . build/

Length of output: 117


Script:

#!/bin/bash
# 检查utils模块中的getOutputFolder函数实现
ast-grep --pattern 'function getOutputFolder($$$) { $$$ }'

# 检查webpack配置文件中的输出路径配置
rg -A 3 'output:' development/webpack/

Length of output: 2641

packages/components/src/composite/Banner/index.tsx (1)

145-145: IconButton 定位调整需要验证

将 IconButton 从 top 调整为 bottom 定位可能会影响按钮的视觉表现。建议在不同屏幕尺寸下进行测试。

Also applies to: 166-166

✅ Verification successful

Let me analyze the positioning changes with these broader search patterns to better understand the impact.


让我们查看完整的Banner组件代码和相关样式文件,以便更好地理解这个定位变更的上下文。


IconButton 定位调整是安全的

查看完整代码后,可以确认这个定位变更是安全的:

  • IconButton 使用了 transform: translateY(-50%) 配合 bottom: 50% 实现垂直居中
  • 这种定位方式是标准的垂直居中实现方式,在各种屏幕尺寸下都能正常工作
  • 组件内部已经处理了移动端适配(通过 platformEnv.isNative 判断)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查其他使用 IconButton 的组件是否会受到影响
rg -A 2 'IconButton.*position.*top'

Length of output: 37


Script:

#!/bin/bash
# Search for IconButton positioning patterns in the Banner component
rg -A 5 'IconButton.*position' packages/components/src/composite/Banner/

# Search for any IconButton style props in the codebase
rg -A 5 'IconButton.*(?:bottom|top|position)' packages/components/

# Find all IconButton imports and usages
ast-grep --pattern 'import { IconButton }'

Length of output: 188


Script:

#!/bin/bash
# 查找Banner组件文件的内容
cat packages/components/src/composite/Banner/index.tsx

# 查找相关样式文件
fd -e css -e scss -e less Banner packages/components/src/composite/Banner/

Length of output: 6417

packages/kit/src/provider/Container/NetworkReachabilityTracker.tsx (1)

22-23: 需要注意性能影响

reachabilityShouldRun 设置为始终返回 true 可能会增加设备的电池消耗,特别是在移动设备上。建议实现 TODO 中提到的周期性检查机制,以平衡网络可达性检测和设备性能。

packages/components/src/hooks/useVisibilityChange.ts (1)

13-15: 桌面端实现逻辑清晰

为桌面端添加的可见性状态检查逻辑实现得很好,使用 globalThis.desktopApi.isFocused() 保持了代码的一致性。

apps/desktop/src-electron/config.ts (1)

59-59: IPC 消息键命名规范

新增的 APP_IS_FOCUSED 消息键遵循了现有的命名规范,并且正确地放置在了 app 相关的配置区域中。

apps/desktop/src-electron/preload.ts (2)

57-57: 接口定义清晰简洁!

isFocused 方法的类型定义符合接口设计规范。


281-281: 实现逻辑正确!

使用同步 IPC 通信获取窗口焦点状态是合适的选择,因为这是一个需要立即响应的操作。

apps/desktop/src-electron/app.ts (1)

640-644: IPC 处理程序实现安全可靠!

代码特点:

  • 使用 getSafelyBrowserWindow 确保窗口引用安全
  • 使用可选链操作符处理潜在的空值情况
  • 正确返回窗口焦点状态
packages/kit-bg/src/states/jotai/atoms/devSettings.ts (1)

24-24: 开发设置集成合理

将调试开关添加到开发设置中是个好选择,默认关闭也符合安全性要求。

Also applies to: 47-47

packages/kit/src/components/WebView/InpageProviderWebView.native.tsx (1)

36-36: 代码实现正确!

webviewDebuggingEnabled 属性的添加和传递符合 React 组件最佳实践。

Also applies to: 124-124

@originalix
Copy link
Contributor

@coderabbitai resolve

@huhuanming huhuanming merged commit a4f210d into x Dec 21, 2024
9 checks passed
Copy link
Contributor

coderabbitai bot commented Dec 21, 2024

✅ Actions performed

Comments resolved.

@huhuanming huhuanming deleted the earn-banner-style branch December 21, 2024 02:51
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.

3 participants