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(imagepreview): use nutui image #2793

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

xiaoyatong
Copy link
Collaborator

@xiaoyatong xiaoyatong commented Nov 22, 2024

Summary by CodeRabbit

  • 新功能

    • 更新了图像预览组件的样式,以改进图像和视频元素的布局,确保内容在水平和垂直方向上居中。
    • 增加了对 SwiperSwiperItem 组件的支持,增强了可用的 UI 组件。
  • 改进

    • 简化了图像预览组件的 JSX 结构,提升了代码可读性。
    • 更新了控制台日志,以反映新的组件导入。

Copy link

coderabbitai bot commented Nov 22, 2024

Walkthrough

此次更改主要涉及 imagepreview.scssimagepreview.taro.tsx 文件。imagepreview.scss 文件中新增了 .nut-image.nut-video 类的样式,以实现内容的水平和垂直居中。imagepreview.taro.tsx 文件则更新了 Image 组件的导入路径,并简化了 JSX 结构,未对组件的核心功能和事件处理逻辑进行更改。

Changes

文件路径 更改摘要
src/packages/imagepreview/imagepreview.scss 新增 .nut-image.nut-video 类的样式,以实现内容的水平和垂直居中。
src/packages/imagepreview/imagepreview.taro.tsx 更新 Image 组件的导入路径,简化 JSX 结构,未更改核心功能或事件处理逻辑。
packages/nutui-taro-demo/src/pages/index/index.tsx 更新导入语句,添加 SwiperSwiperItem 组件,更新控制台日志,未更改功能逻辑。

Possibly related PRs

Suggested labels

size/L

Suggested reviewers

  • xiaoyatong

🐇 在图像预览中,
新样式让内容更美妙,
居中展示如梦幻,
组件更新更简单,
兔子欢跳庆变化,
让我们一起享受吧! 🌟

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/nutui-taro-demo/src/pages/index/index.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "taro/react" to extend from. Please check that the name of the config is correct.

The config "taro/react" was referenced from the config file in "/packages/nutui-taro-demo/.eslintrc".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


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?

❤️ Share
🪧 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 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 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.

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (9332996) to head (51c02b7).
Report is 7 commits behind head on feat_v3.x.

Additional details and impacted files
@@              Coverage Diff              @@
##           feat_v3.x    #2793      +/-   ##
=============================================
- Coverage      83.99%   83.98%   -0.01%     
=============================================
  Files            220      220              
  Lines          17885    17882       -3     
  Branches        2679     2676       -3     
=============================================
- Hits           15023    15019       -4     
- Misses          2857     2858       +1     
  Partials           5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

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

🧹 Outside diff range and nitpick comments (1)
src/packages/imagepreview/imagepreview.scss (1)

80-86: 样式实现合理,建议添加注释说明

新增的样式使用 flex 布局来实现内容居中,实现方式符合最佳实践。建议添加注释说明样式的用途,以提高代码可维护性。

建议添加如下注释:

      .nut-image,
      .nut-video {
+       // 使用 flex 布局实现内容水平垂直居中
        display: flex;
        justify-content: center;
        align-items: center;
      }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c77e619 and eff25f7.

📒 Files selected for processing (2)
  • src/packages/imagepreview/imagepreview.scss (1 hunks)
  • src/packages/imagepreview/imagepreview.taro.tsx (1 hunks)
🔇 Additional comments (3)
src/packages/imagepreview/imagepreview.taro.tsx (3)

Line range hint 91-157: 建议全面测试图片缩放功能

由于更换了底层 Image 组件的实现,请重点测试以下场景:

  1. 双指缩放手势的响应性
  2. 双击放大/缩小功能
  3. 缩放过程中的性能表现
  4. 边界条件下的行为(最大/最小缩放比例)

Line range hint 313-328: 图片预览实现符合预期

代码实现合理:

  1. 正确处理了平台特定属性(showMenuByLongpress)
  2. 保持了与原有功能的一致性
  3. 图片样式设置适当

10-10: 请验证 NutUI Image 组件 API 兼容性

从 @tarojs/components 切换到 NutUI 的 Image 组件是一个重要改动。建议:

  1. 确认新的 Image 组件支持所有必需的属性(mode、showMenuByLongpress 等)
  2. 验证在各类设备和场景下的兼容性

Also applies to: 14-14

✅ Verification successful

NutUI Image 组件 API 兼容性已确认

经过验证,NutUI Image 组件完全支持当前场景所需的功能:

  • 在 imagepreview.taro.tsx 中,Image 组件仅使用了 srcmode 和基础样式属性
  • NutUI Image 组件(image.taro.tsx)继承了 Taro Image 的所有属性(通过 Omit<TImageProps, 'style'>
  • 组件使用方式符合预期,不会影响现有功能
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 检查 NutUI Image 组件的 API 定义
ast-grep --pattern 'interface $ImageProps {
  $$$
}'

Length of output: 54


Script:

#!/bin/bash
# 搜索 Image 组件的属性定义和使用方式
rg -A 10 "type ImageProps" src/packages/image/
rg -A 10 "interface ImageProps" src/packages/image/

# 检查 ImagePreview 中 Image 组件的使用
rg -A 5 "Image" src/packages/imagepreview/imagepreview.taro.tsx

# 检查原始 Taro Image 组件的使用方式
rg -A 5 "Image.*from.*@tarojs/components" 

Length of output: 11454

@xiaoyatong xiaoyatong requested a review from irisSong November 25, 2024 02:35
@irisSong
Copy link
Collaborator

irisSong commented Nov 25, 2024

1、关闭按钮icon svg 色值不对 2、设置初始页码打开滑动在关闭,展示图片不对

@github-actions github-actions bot added the 3.x label Nov 26, 2024
Copy link

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

🧹 Outside diff range and nitpick comments (1)
packages/nutui-taro-demo/src/pages/index/index.tsx (1)

13-13: 移除调试代码

建议移除这行调试用的 console.log 语句,因为它不应该出现在生产代码中。

-console.log(Button, Input, Video,Image, Swiper, SwiperItem,  )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between eff25f7 and 51c02b7.

📒 Files selected for processing (1)
  • packages/nutui-taro-demo/src/pages/index/index.tsx (2 hunks)

@@ -1,5 +1,5 @@
import Taro from '@tarojs/taro'
import { View, Image, Text, ScrollView, Button, Input, Video } from '@tarojs/components'
import { View, Image, Swiper, SwiperItem, Text, ScrollView, Button, Input, Video } from '@tarojs/components'
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

导入了未使用的组件

SwiperSwiperItem 组件虽然在导入语句中声明,但在代码实现中并未找到实际使用。建议移除这些未使用的导入以保持代码整洁。

🔗 Analysis chain

检查未使用的导入

SwiperSwiperItem 组件已导入但在代码中未被使用。如果这些组件是为了图片预览功能准备的,建议添加相关实现;如果不需要,建议移除这些未使用的导入。


Let me gather more information to verify if these components are actually used in the implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:验证Swiper和SwiperItem组件的使用情况

# 在当前文件中搜索Swiper和SwiperItem的使用
rg -l "Swiper|SwiperItem" packages/nutui-taro-demo/src/pages/index/index.tsx

Length of output: 129


Script:

#!/bin/bash
# Search for actual usage of Swiper and SwiperItem components in the file content
rg -U "(?s)<Swiper.*?>.*?</Swiper>|<SwiperItem.*?>.*?</SwiperItem>" packages/nutui-taro-demo/src/pages/index/index.tsx

# Also check for self-closing tag usage
rg "<Swiper[^>]*/?>|<SwiperItem[^>]*/?>" packages/nutui-taro-demo/src/pages/index/index.tsx

Length of output: 214

@oasis-cloud oasis-cloud merged commit 17adc55 into jdf2e:feat_v3.x Dec 2, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants