feat: 文件浏览器支持图片预览并更新发布包

This commit is contained in:
shiyue
2026-10-06 12:01:44 +08:00
parent 75989cb4de
commit caf8947cd9
16 changed files with 558 additions and 17 deletions

View File

@@ -0,0 +1,3 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
{"file": ".trellis/spec/frontend/quality-guidelines.md", "reason": "前端质量检查"}
{"file": ".trellis/spec/backend/quality-guidelines.md", "reason": "服务端质量检查"}

View File

@@ -0,0 +1,3 @@
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
{"file": ".trellis/spec/frontend/quality-guidelines.md", "reason": "前端质量与资源生命周期约束"}
{"file": ".trellis/spec/backend/quality-guidelines.md", "reason": "服务端边界校验与错误处理约束"}

View File

@@ -0,0 +1,20 @@
# 文件浏览器支持图片预览
## 目标
在 cc-web 文件浏览器中点击常见图片文件时,在现有预览面板内显示图片;文本文件预览保持不变。
## 范围
- 支持 PNG、JPEG/JPG、GIF、WebP、BMP、SVG、AVIF 图片。
- 图片读取必须沿用 Bearer 登录态、会话工作目录根约束和现有路径穿越防护。
- 图片响应设置正确 MIME 类型,并限制最大预览大小为 20 MiB;超出时返回明确错误。
- 前端复用现有文件选择流程,通过带鉴权的请求取得图片。栅格图片使用临时对象 URL 展示,并在切换文件、关闭浏览器和请求过期时释放;SVG 使用隔离来源的 data URL 展示。
- 文本预览、二进制文件拒绝和现有移动端切换行为保持不变。
## 验收
- 点击上述格式的有效图片显示在预览面板,并显示文件名、大小、格式等元信息。
- 图片加载失败显示中文错误状态,旧图片不会残留。
- 越界路径、未登录请求、目录路径和超大图片不能绕过现有安全限制。
- 回归测试覆盖图片响应、MIME、大小限制、路径边界和前端关键契约。

View File

@@ -0,0 +1,26 @@
{
"id": "file-browser-image-preview",
"name": "file-browser-image-preview",
"title": "文件浏览器支持图片预览",
"description": "文件浏览器预览常见图片格式,沿用会话授权与工作目录边界。",
"status": "in_progress",
"dev_type": null,
"scope": null,
"package": null,
"priority": "P2",
"creator": "shiyue",
"assignee": "shiyue",
"createdAt": "2026-10-05",
"completedAt": null,
"branch": null,
"base_branch": "main",
"worktree_path": null,
"commit": null,
"pr_url": null,
"subtasks": [],
"children": [],
"parent": null,
"relatedFiles": [],
"notes": "",
"meta": {}
}