fix(diy): 贴纸编辑页滑块组件化 + CSS filter 预览 + edits 参数化保存

修正工作流批次③(问题5):
- 三个滑块统一改用 TouchSlider 组件(id 选择器定位 + touchstart 缓存
  rect),删除原 .in(e.currentTarget) 坏实现与死代码
- 预览弃用 Canvas ctx.filter(开发者工具不支持),改 Image + CSS filter
  所见即所得;Canvas 导出链路整体移除
- 保存改为 edits 参数化持久化(src 不变;裁剪/线稿的 src 替换经
  pendingSrc 一并落库),不再依赖 canvasToTempFilePath
- DIY 工作台画布与预览弹层渲染端消费 edits(同一 CSS filter 逻辑),
  checkout 预览消费 edits 记入 R3 待办(routes/R2/README.md #6)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-09-12 19:29:03 +08:00
co-authored by Claude
parent 98da907df8
commit 2e3676a470
8 changed files with 143 additions and 267 deletions
+14
View File
@@ -325,6 +325,18 @@ export default function DIYPage() {
setStickers(checked)
}
// 问题5 修正:渲染端消费贴纸 edits(亮度/色相/对比度 → CSS filter),
// 与贴纸编辑页同一呈现逻辑;checkout 预览消费 edits 记入 R3 待办
const stickerFilter = (s: StickerItem) => {
const ed = s.edits
if (!ed) return undefined
const b = ed.brightness || 0
const h = ed.hue || 0
const c = ed.contrast || 0
if (b === 0 && h === 0 && c === 0) return undefined
return `brightness(${100 + b}%) hue-rotate(${h}deg) contrast(${100 + c}%)`
}
const goBack = () => {
Taro.navigateBack()
}
@@ -425,6 +437,7 @@ export default function DIYPage() {
transform: `translate(${s.x}px, ${s.y}px) scale(${s.scale})`,
opacity: isDragging && activeStickerId === s.id ? 0.8 : 1,
zIndex: activeStickerId === s.id ? 10 : 5,
filter: stickerFilter(s),
width: s.width || 200,
height: s.height || 200
}}
@@ -510,6 +523,7 @@ export default function DIYPage() {
src={s.src}
style={{
transform: `translate(${s.x}px, ${s.y}px) scale(${s.scale})`,
filter: stickerFilter(s),
width: s.width || 200,
height: s.height || 200
}}