优化了布局结构并增强了自定义图片上传功能的用户体验#1
Open
Sheyiyuan wants to merge 2 commits into
Open
Conversation
优化了自定义图片时选择角色的操作逻辑与命名
There was a problem hiding this comment.
Pull request overview
该 PR 主要围绕两点改进:在桌面端将导出面板(ExportPanel)布局更紧凑地放置到画布区域下方,以及在上传自定义图片时优化角色选择与导出命名的用户体验。
Changes:
- 调整
App中的响应式布局:桌面端将 ExportPanel 移到 Canvas 区域下方,移动端保持单独一行显示 - 增强自定义图片场景:为
Picker增加disabled/tooltip入参,并在App中根据customImage禁用角色选择入口 - 更新导出文件名生成逻辑:
useExport在存在自定义图片时使用“自定义角色”作为文件名前缀
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/App.tsx | 调整 Grid/响应式展示逻辑;在自定义图片存在时禁用 Picker 并更新角色名展示;桌面端新增 Canvas 下方的 ExportPanel |
| src/components/Picker.tsx | 新增 disabled、tooltip 参数,并在禁用时阻止打开选择器 |
| src/hooks/useExport.ts | useExport 新增 customImage 参数;导出文件名在自定义图片场景下使用“自定义角色”前缀 |
| src/components/sections/ExportPanel.tsx | 调整导出按钮在 md 断点下的 Grid 宽度以适配新的布局宽度 |
| src/hooks/useCharacter.ts | 上传回调的结构/格式调整(无明显行为变更) |
Comments suppressed due to low confidence (1)
src/components/Picker.tsx:108
Picker接收了disabled,但触发器IconButton没有设置disabled/aria-disabled,目前只是通过onClick里return来阻止打开:按钮视觉与可访问性状态仍是可用的(键盘/读屏也会认为可点击)。建议把disabled={disabled}传给IconButton,并用外层<span>包裹以确保禁用时 Tooltip 仍可触发。
<IconButton
color="secondary"
onClick={handleOpen}
sx={{ color: color }}
size="small"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| return `${characterName}.${ext}` | ||
| }, | ||
| [character, text] |
There was a problem hiding this comment.
generateFileName 的回调里读取了 customImage,但依赖数组里没有包含它,导致上传/清除自定义图片后文件名可能仍使用旧的角色前缀(闭包值不更新)。请把 customImage(以及如果需要的话 typedCharacters/sanitize 的稳定引用)加入依赖,或改为基于参数/局部变量避免闭包过期。
Suggested change
| [character, text] | |
| [character, text, customImage] |
Comment on lines
+728
to
+730
| {characterHook.customImage | ||
| ? '自定义图片' | ||
| : characters[characterHook.character].name} |
There was a problem hiding this comment.
这里自定义图片时显示的是“自定义图片”,但 PR 描述与 useExport 的文件名前缀使用的是“自定义角色”。同一概念在 UI 与导出命名不一致会让用户困惑。建议统一为同一个文案(按描述应为“自定义角色”),并确保其它相关提示(Tooltip/文件名)也一致。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
本次更新优化了布局结构并增强了自定义图片上传功能的用户体验。
修改内容
1. 布局调整:ExportPanel 位置优化
问题:ExportPanel 原本独占一行,布局不够紧凑。
解决方案:
涉及文件:
src/App.tsx- 调整 Grid 布局,添加响应式显示控制原理:
display: { xs: 'none', md: 'block' }实现响应式显示2. 自定义角色功能增强
问题:上传自定义图片后,角色名称和导出文件名仍显示原角色,且可以切换角色造成混淆。
解决方案:
涉及文件:
src/components/Picker.tsx- 添加disabled、tooltip属性,支持禁用状态下的提示src/hooks/useExport.ts- 添加customImage参数,修改文件名生成逻辑src/App.tsx- 传递customImage参数,控制 Picker 禁用状态技术细节
禁用按钮显示 Tooltip:
onMouseEnter/onMouseLeave<span>包裹实现提示显示文件名生成逻辑:
测试要点