feat(task): show offline download file info - #547
Conversation
Co-authored-by: Codex <codex@openai.com>
pikachuren
left a comment
There was a problem hiding this comment.
结论:实现没问题,有两点建议讨论
在离线下载任务的展开视图中显示文件名和大小,是很实用的改进——任务名往往是一长串 URL,光看它判断不出实际下到了什么。file_name / file_size 都设为可选字段,后端未返回时不会渲染,向后兼容处理得当;fileSize() 用 props.file_size || props.total_bytes 兜底也合理,后端没给显式大小时仍能显示已知总量。
一、限定 done === "undone" 是否合适
const showFileInfo = () =>
props.type === "offline_download" && props.done === "undone"这样只有进行中的任务会显示文件信息,已完成和已失败的任务不显示。我理解意图可能是「完成后去文件列表看即可」,但从排查角度看,恰恰是已结束的任务更需要这个信息:任务失败时想知道它当时识别到的文件名和大小(比如是不是超出了预期体积),已完成时想确认下到的到底是哪个文件。这两类任务停留在列表里的时间也更长。
如果没有特别理由,建议去掉 done 的限制,只保留 props.type === "offline_download" 判断。
二、长文件名的换行处理
<GridItem color="$neutral9">{props.file_name}</GridItem>标签列加了 whiteSpace: "nowrap",但值列没有任何约束。离线下载的文件名经常很长(尤其是从 URL 或磁力链解析出来的),在窄屏或侧边栏中可能撑破网格布局。建议给值列加上 wordBreak: "break-all" 一类的处理,可以参考同文件中 url 行的现有做法保持一致。
其他已确认无误的点: getFileSize 从 ~/utils 导入正确(定义在 src/utils/str.ts);fileSize() > 0 的判断能正确过滤掉大小为 0 的情况,同时也避开了 getFileSize 对 falsy 值返回 "-" 的行为;i18n key 加在 offline_download 块内位置合适。
这两点都不是阻塞问题,第一点确认一下设计意图即可。
The file name and size are the most useful when a task has already failed or completed - failed tasks need the recognized name and size for diagnosis, and finished ones stay in the list the longest. The backend persists FileName/FileSize on DownloadTask, so the fields are still returned after the task ends. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
感谢 review,两点都确认过了。 一、去掉 没有特别理由,就是当时想窄一点。你说的场景更合理:失败的任务最需要知道它当时识别到的文件名和体积,而且这两类任务停留在列表里的时间也更长。 后端也支持这么做: 已改为只判断 type: const showFileInfo = () => props.type === "offline_download"二、长文件名换行 —— 确认已经生效,没有额外改动 这里值列其实已经有约束了:包住整个 而且你提到的「参考 url 行的现有做法」,url 行正是靠这个继承实现的 —— 如果你在某个具体宽度下实际看到过溢出,麻烦贴个截图,我再单独排查。 |
Summary / 摘要
Show file name and file size in the expanded view of running offline download tasks.
Add optional
file_nameandfile_sizefields to the frontend task response type.Add task attribute labels for the new offline download file info rows.
This PR has breaking changes.
/ 此 PR 包含破坏性变更。
This PR changes public API, config, storage format, or migration behavior.
/ 此 PR 修改了公开 API、配置、存储格式或迁移行为。
This PR requires corresponding changes in related repositories.
/ 此 PR 需要关联仓库同步修改。
Related repository PRs / 关联仓库 PR:
Testing / 测试
go test ./...pnpm exec prettier --write src/types/task.ts src/pages/manage/tasks/Task.tsx src/lang/en/tasks.jsonpnpm lint: currently blocked by existing TypeScript errors insrc/pages/home/previews/archive.tsxandsrc/pages/manage/storages/AddOrEdit.tsx.Checklist / 检查清单
/ 我已阅读 CONTRIBUTING。
/ 我确认此贡献符合仓库许可证、贡献规范和行为准则。
gofmt,go fmt, orprettierwhere applicable./ 我已按适用情况使用
gofmt、go fmt或prettier格式化变更代码。/ 我已在适用情况下请求相关维护者或代码所有者审查。
AI Disclosure / AI 使用声明
/ 此 PR 包含 AI 辅助内容。
Tools used / 使用工具:
Usage scope / 使用范围:
Code generation / 代码生成
Refactoring / 重构
Documentation / 文档
Tests / 测试
Translation / 翻译
Review assistance / 审查辅助
I have reviewed and validated all AI-assisted content included in this PR.
/ 我已审核并验证此 PR 中的所有 AI 辅助内容。
I have ensured that all AI-assisted commits include
Co-Authored-Byattribution./ 我已确保所有 AI 辅助提交都包含
Co-Authored-By归属信息。I can reproduce all AI-assisted content included in this PR without any AI tools.
/ 我可以在没有任何 AI 工具的情况下重现此 PR 中包含的所有 AI 辅助内容。