Skip to content

fix: 🐛 修复 Upload 开启 multiple 后只能成功上传最后一个文件的问题 - #1044

Merged
Moonofweisheng merged 1 commit into
masterfrom
fix/upload-multiple-error
May 8, 2025
Merged

fix: 🐛 修复 Upload 开启 multiple 后只能成功上传最后一个文件的问题#1044
Moonofweisheng merged 1 commit into
masterfrom
fix/upload-multiple-error

Conversation

@Moonofweisheng

@Moonofweisheng Moonofweisheng commented May 8, 2025

Copy link
Copy Markdown
Owner

Closes: #1043

🤔 这个 PR 的性质是?(至少选择一个)

  • 日常 bug 修复
  • 新特性提交
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • CI/CD 改进
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 代码重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

#1043

💡 需求背景和解决方案

修复 Upload 开启 multiple 后只能成功上传最后一个文件的问题,useUpload提供的上传方法,提供了取消上次上传请求的参数,而Upload默认开启了此选项,导致产生此问题。

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充

Summary by CodeRabbit

  • 新功能

    • 新增“多选”演示块,支持多文件上传示例。
  • 修复

    • 移除了上传组件中自动中止前一次上传的功能,提升多文件上传体验。
  • 优化

    • 清理了未使用的事件处理函数,使代码更简洁。

@vercel

vercel Bot commented May 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wot-design-uni ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 8, 2025 7:04am

@coderabbitai

coderabbitai Bot commented May 8, 2025

Copy link
Copy Markdown

Walkthrough

本次变更在上传页面新增了多文件上传的演示示例,并在上传组件中移除了abortPrevious: true选项,使得多文件上传时不会中断前一个文件的上传。还清理了部分未使用的处理函数。

Changes

文件/文件组 变更摘要
src/subPages/upload/Index.vue 新增“多选”上传演示,绑定fileList2并启用multiple属性,移除未用的处理函数。
src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue 移除了上传配置中的abortPrevious: true,允许多文件同时上传。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant IndexVue
    participant WdUpload

    User->>IndexVue: 选择多个文件
    IndexVue->>WdUpload: 传递fileList2和multiple
    loop 对每个文件
        WdUpload->>WdUpload: startUploadFiles(不再中断前一个上传)
        WdUpload->>IndexVue: onChange/handleChange2
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
支持多文件上传功能修复(#1043
文件后缀名过滤功能(#1043 本次变更未涉及extension过滤相关逻辑。

Possibly related PRs

Poem

🐇
多选上传新登场,
文件齐飞不慌张。
旧参数悄然隐身去,
新体验跃然上。
兔子拍拍爪,
上传路上不再慌!

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eea9bf7 and 2c4f141.

📒 Files selected for processing (2)
  • src/subPages/upload/Index.vue (1 hunks)
  • src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Test Components (wd-upload)
  • GitHub Check: Redirect rules - wot-design-uni
  • GitHub Check: Header rules - wot-design-uni
  • GitHub Check: Pages changed - wot-design-uni
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue (2)

291-292: 修复了 multiple 上传中断问题

在调用 startUpload 时移除了 abortPrevious: true 选项,这样在同时上传多个文件时不会中断之前的上传请求,从而确保所有选择的文件都能成功上传。


307-308: 确保与上面的修改保持一致

这里同样移除了 abortPrevious: true 选项,与前面的修改保持一致,确保无论是使用 buildFormData 与否,都不会中断之前的上传请求。

src/subPages/upload/Index.vue (2)

46-48: 新增多选上传演示

添加了多选上传的演示示例,使用 multiple 属性启用多文件选择功能,这有助于验证之前修复的上传中断问题。


272-274: 多选上传变更处理函数实现

handleChange2 函数用于处理多选上传的文件列表变更,实现逻辑与其他变更处理函数一致,符合组件API使用规范。


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.

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

Support

Need 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)

  • @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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@petercat-assistant

Copy link
Copy Markdown

概要

修复了在 Upload 组件中启用 multiple 属性后,只能成功上传最后一个文件的问题。此问题是由于默认启用了取消上次上传请求的参数导致的。通过移除 abortPrevious 参数,解决了此问题。

变更

文件 概要
src/subPages/upload/Index.vue 添加了一个新的 demo-block 用于展示 multiple 属性的使用,并移除了未使用的处理函数。
src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue 移除了 abortPrevious 参数以修复多文件上传问题。

Comment thread src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue
@netlify

netlify Bot commented May 8, 2025

Copy link
Copy Markdown

Deploy Preview for wot-design-uni ready!

Name Link
🔨 Latest commit 2c4f141
🔍 Latest deploy log https://app.netlify.com/sites/wot-design-uni/deploys/681c579462496d00086567c6
😎 Deploy Preview https://deploy-preview-1044--wot-design-uni.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying wot-design-uni with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c4f141
Status: ✅  Deploy successful!
Preview URL: https://2eccf18b.wot-design-uni.pages.dev
Branch Preview URL: https://fix-upload-multiple-error.wot-design-uni.pages.dev

View logs

@codecov-commenter

codecov-commenter commented May 8, 2025

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 52.18%. Comparing base (0fd5053) to head (2c4f141).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
.../wot-design-uni/components/wd-upload/wd-upload.vue 0.00% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

❗ There is a different number of reports uploaded between BASE (0fd5053) and HEAD (2c4f141). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (0fd5053) HEAD (2c4f141)
wd-config-provider 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1044       +/-   ##
===========================================
- Coverage   70.31%   52.18%   -18.13%     
===========================================
  Files           2       11        +9     
  Lines          64      962      +898     
  Branches        9       94       +85     
===========================================
+ Hits           45      502      +457     
- Misses         19      460      +441     
Flag Coverage Δ
h5 52.18% <0.00%> (-18.13%) ⬇️
wd-config-provider ?
wd-upload 52.18% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented May 8, 2025

Copy link
Copy Markdown

组件测试摘要 (H5 平台)

测试时间: Thu May 8 07:06:42 UTC 2025

测试结果

组件 状态 覆盖率
wd-upload ✅ 通过 52.18%

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.

升级1.9.0版本后不支持多文件上传,只能上传成功最后一个选中的文件

2 participants