Skip to content

feat: upload上传组件单独控制是否显示删除图标,手动上传时同步更新fileList#1447

Open
jiaruiyan wants to merge 1 commit intoMoonofweisheng:masterfrom
jiaruiyan:yjr_upload_20260118
Open

feat: upload上传组件单独控制是否显示删除图标,手动上传时同步更新fileList#1447
jiaruiyan wants to merge 1 commit intoMoonofweisheng:masterfrom
jiaruiyan:yjr_upload_20260118

Conversation

@jiaruiyan
Copy link

@jiaruiyan jiaruiyan commented Jan 18, 2026

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

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

🔗 相关 Issue

#1442

💡 需求背景和解决方案

新增字段

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

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

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

Summary by CodeRabbit

  • New Features
    • 上传组件新增 hideRemoveIcon 参数,支持对单个文件隐藏删除按钮;示例页面增加带 hideRemoveIcon=true 的文件项。
  • Documentation
    • 更新上传组件文档,说明新增参数的用途、默认值及最低支持版本,并调整属性表格格式与布局。
  • Localization
    • 新增中英文文案项:是否隐藏删除按钮 / Hide the delete button。

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 18, 2026

@jiaruiyan is attempting to deploy a commit to the weisheng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@netlify
Copy link

netlify bot commented Jan 18, 2026

Deploy Preview for wot-design-uni ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 6635b1f
🔍 Latest deploy log https://app.netlify.com/projects/wot-design-uni/deploys/696cdf3c6570ed0008a9da40
😎 Deploy Preview https://deploy-preview-1447--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 project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

Walkthrough

为 wd-upload 添加文件级属性 hideRemoveIcon,更新类型定义、组件实现、示例页、文档与中/英本地化字符串;组件在渲染时会根据单个文件项的该字段隐藏删除图标,并在非自动上传初始化文件时发出更新的文件列表事件。

Changes

Cohort / File(s) 变更摘要
文档 与 本地化
docs/component/upload.md, src/locale/en-US.json, src/locale/zh-CN.json
在组件文档属性表中新增 hideRemoveIcon 说明;添加中/英本地化键 shiFouYinCangShanChuAnNiu,并调整表格/JSON 格式以兼容新增项。
类型定义
src/uni_modules/wot-design-uni/components/wd-upload/types.ts
UploadFileItem 中新增可选布尔属性 hideRemoveIcon?: boolean(文件级控制删除图标可见性)。
组件实现
src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue
将文件级 hideRemoveIcon 传递到模板并将其纳入删除按钮可见性判断;初始化单个文件在 autoUpload 为 false 时会 emit 更新后的文件列表。
示例页
src/subPages/upload/Index.vue
新增示例区块与示例数据 fileList22(包含 hideRemoveIcon: true 的文件项)用于演示该行为。

Sequence Diagram(s)

(本次变更为轻量的 UI/类型扩展,未引入需要可视化的多方顺序流程,故不生成序列图。)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • Moonofweisheng

Poem

🐰 我悄悄藏起删按钮,
文件独立有主张,
文档中英已写好,
示例页里能见到,
点点更改心欢畅 ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰地反映了本次变更的核心内容:上传组件添加了单独控制删除图标显示的功能,并修复了手动上传时fileList同步更新的问题,与所有代码变更高度对应。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

🔧 markdownlint-cli2 (0.18.1)
docs/component/upload.md

markdownlint-cli2 v0.18.1 (markdownlint v0.38.0)
Finding: docs/component/upload.md
Linting: 1 file(s)
Summary: 0 error(s)
Error: EACCES: permission denied, open '/markdownlint-cli2-results.json'
at async open (node:internal/fs/promises:640:25)
at async Object.writeFile (node:internal/fs/promises:1214:14)
at async Promise.all (index 0)
at async outputSummary (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:877:5)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:1053:25)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:12:22 {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/markdownlint-cli2-results.json'
}


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 3

🤖 Fix all issues with AI agents
In `@docs/component/upload.md`:
- Around line 618-653: The docs incorrectly list hideRemoveIcon as a component
prop; remove the hideRemoveIcon row from the component props table and add it to
the "file 数据结构" table as a per-file attribute named hideRemoveIcon (type:
boolean) with a concise description like "是否隐藏删除按钮(仅在单个文件项生效)" and default
false; update its label text from "是否隐藏参数按钮" to "删除按钮" and ensure the new entry
is placed alongside other file-item keys (e.g., next to status/key fields such
as status-key or file-list entries).

In `@src/subPages/upload/Index.vue`:
- Around line 116-119: The demo for the hidden-delete-button example is missing
the upload endpoint which can cause the demo to fail; update the <demo-block>
example by adding the action prop to the wd-upload component (the instance bound
to fileList22) and set it to the same upload URL used by the other examples so
wd-upload(action="...") has a valid upload endpoint for fileList22.

In `@src/uni_modules/wot-design-uni/components/wd-upload/types.ts`:
- Around line 55-56: The comment for the hideRemoveIcon property is backwards;
update the comment on the hideRemoveIcon field in types.ts (the declaration of
hideRemoveIcon?: boolean) so it correctly states that when hideRemoveIcon is
true the remove/delete icon is hidden (and false shows it). Ensure the comment
language mirrors the property name semantics (e.g., "是否隐藏删除按钮,true 时隐藏") and
keep it adjacent to the hideRemoveIcon declaration.

Comment on lines +618 to +653
| 参数 | 说明 | 类型 | 可选值 | 默认值 | 最低版本 |
|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|------------------------------------------------|----------------------------|--------|
| file-list / v-model:file-list | 上传的文件列表, 例如: [{ name: 'food.jpg', url: 'https://xxx.cdn.com/xxx.jpg' }] | array | - | [] | - |
| action | 必选参数,上传的地址 | string | - | - | - |
| header | 设置上传的请求头部 | object | - | - | - |
| multiple | 是否支持多选文件 | boolean | - | - | - |
| disabled | 是否禁用 | boolean | - | false | - |
| reupload | 是否开启覆盖上传,开启后会关闭图片预览 | boolean | - | false | 1.5.0 |
| limit | 最大允许上传个数 | number | - | - | - |
| show-limit-num | 限制上传个数的情况下,是否展示当前上传的个数 | boolean | - | false | - |
| max-size | 文件大小限制,单位为`byte` | number | - | - | - |
| source-type | 选择图片的来源,chooseImage 接口详细参数,查看[官方手册](https://uniapp.dcloud.net.cn/api/media/image.html#chooseimage) | array / string | - | ['album', 'camera'] | - |
| size-type | 所选的图片的尺寸,chooseImage 接口详细参数,查看[官方手册](https://uniapp.dcloud.net.cn/api/media/image.html#chooseimage) | array / string | - | ['original', 'compressed'] | - |
| name | 文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容,uploadFile 接口详细参数,查看[官方手册](https://uniapp.dcloud.net.cn/api/request/network-file#uploadfile) | string | - | file | - |
| formData | HTTP 请求中其他额外的 form data,uploadFile 接口详细参数,查看[官方手册](https://uniapp.dcloud.net.cn/api/request/network-file#uploadfile) | object | - | - | - |
| header | HTTP 请求 Header,Header 中不能设置 Referer,uploadFile 接口详细参数,查看[官方手册](https://uniapp.dcloud.net.cn/api/request/network-file#uploadfile) | object | - | - | - |
| on-preview-fail | 预览失败执行操作 | function({ index, imgList }) | - | - | - |
| before-upload | 上传文件之前的钩子,参数为上传的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止上传。 | function({ files, fileList, resolve }) | - | - | - |
| before-choose | 选择图片之前的钩子,参数为文件列表,若返回 false 或者返回 Promise 且被 reject,则停止上传。 | function({ fileList, resolve }) | - | - | - |
| before-remove | 删除文件之前的钩子,参数为要删除的文件和文件列表,若返回 false 或者返回 Promise 且被 reject,则停止上传。 | function({ file, fileList, resolve }) | - | - | - |
| before-preview | 图片预览前的钩子,参数为预览的图片下标和图片列表,若返回 false 或者返回 Promise 且被 reject,则停止上传。 | function({file, index, imgList, resolve }) | - | - | - |
| build-form-data | 构建上传`formData`的钩子,参数为上传的文件、待处理的`formData`,返回值为处理后的`formData`,若返回 false 或者返回 Promise 且被 reject,则停止上传。 | function({ file, formData, resolve }) | - | - | 0.1.61 |
| loading-type | [加载中图标类型](/component/loading) | string | - | circular-ring | - |
| loading-color | [加载中图标颜色](/component/loading) | string | - | #ffffff | - |
| loading-size | [加载中图标尺寸](/component/loading) | string | - | 24px | - |
| status-key | file 数据结构中,status 对应的 key | string | - | status | - |
| image-mode | 预览图片的 mode 属性 | ImageMode | - | aspectFit | - |
| accept | 接受的文件类型 | UploadFileType | **image** **video** **media** **file** **all** | **image** | 1.3.0 |
| compressed | 是否压缩视频,当 accept 为 video \| media 时生效 | boolean | - | true | 1.3.0 |
| maxDuration | 拍摄视频最长拍摄时间,当 accept 为 video \| media 时生效,单位秒 | Number | - | 60 | 1.3.0 |
| camera | 使用前置或者后置相机,当 accept 为 video \| media 时生效 | UploadCameraType | **front** | **back** | 1.3.0 |
| successStatus | 接口响应的成功状态(statusCode)值 | number | - | 200 | 1.3.4 |
| auto-upload | 是否选择文件后自动上传。为 false 时应手动调用 submit() 方法开始上传 | boolean | - | true | 1.3.8 |
| upload-method | 自定义上传方法 | UploadMethod | - | - | 1.3.8 |
| extension | 根据文件拓展名过滤(H5支持全部类型过滤,微信小程序支持all和file时过滤,其余平台不支持) | string[] | - | - | 1.9.0 |
| hideRemoveIcon | 是否隐藏参数按钮(如果组件禁用状态不生效) | boolean | - | - | $LOWEST_VERSION$ |
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

hideRemoveIcon 文档位置与描述不准确。
该字段是文件项属性而非组件 prop,且应描述为“删除按钮”。建议移到“file 数据结构”表并修正文案。

🛠️ 建议修改(移除属性表行)
-| hideRemoveIcon                     | 是否隐藏参数按钮(如果组件禁用状态不生效)                                                                                                               | boolean                                   | -                                              | -                          | $LOWEST_VERSION$ |
🛠️ 建议新增(在“file 数据结构”表中添加)
 | response | string / object | 后端返回的内容,可能是对象,也可能是字符串            | -        |
+| hideRemoveIcon | boolean | 是否隐藏删除按钮(true 隐藏)                        | $LOWEST_VERSION$ |
🤖 Prompt for AI Agents
In `@docs/component/upload.md` around lines 618 - 653, The docs incorrectly list
hideRemoveIcon as a component prop; remove the hideRemoveIcon row from the
component props table and add it to the "file 数据结构" table as a per-file
attribute named hideRemoveIcon (type: boolean) with a concise description like
"是否隐藏删除按钮(仅在单个文件项生效)" and default false; update its label text from "是否隐藏参数按钮"
to "删除按钮" and ensure the new entry is placed alongside other file-item keys
(e.g., next to status/key fields such as status-key or file-list entries).

@jiaruiyan jiaruiyan force-pushed the yjr_upload_20260118 branch from 2ef366f to 63eb12f Compare January 18, 2026 13:15
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue (1)

336-360: 重传时会重置 hideRemoveIcon,导致配置失效

currentIndex 存在时会替换旧项,但目前固定写死为 false,会把用户在 fileList 中配置的隐藏状态覆盖掉。建议保留旧值(或允许从 file 传入)。

✅ 建议修复
 function initFile(file: ChooseFile, currentIndex?: number) {
   const { statusKey } = props
+  const prev = typeof currentIndex === 'number' ? uploadFiles.value[currentIndex] : undefined
   // 状态初始化
   const initState: UploadFileItem = {
     uid: context.id++,
     // 仅h5支持 name
     name: file.name || '',
     thumb: file.thumb || '',
     [statusKey]: 'pending',
     size: file.size || 0,
     url: file.path,
     percent: 0,
     // 是否隐藏删除按钮 默认展示
-    hideRemoveIcon: false
+    hideRemoveIcon: (file as UploadFileItem).hideRemoveIcon ?? prev?.hideRemoveIcon ?? false
   }

@jiaruiyan jiaruiyan changed the title feat: 上传组件单独控制是否显示删除图标,手动上传时同步更新fileList feat: upload上传组件单独控制是否显示删除图标,手动上传时同步更新fileList Jan 18, 2026
@jiaruiyan jiaruiyan force-pushed the yjr_upload_20260118 branch from 63eb12f to 6635b1f Compare January 18, 2026 13:25
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 participant