From 41e905dcbbac6f3b23a4094663a07ba3bcdd47f2 Mon Sep 17 00:00:00 2001 From: liulong <18539103286> Date: Mon, 18 May 2026 17:31:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4lenticular-studio=E4=B8=AD?= =?UTF-8?q?=E7=8E=B0=E5=B7=B2=E4=B8=8D=E8=A2=AB=E5=BC=95=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .trae/skills/karpathy-guidelines/SKILL.md | 70 ++ .../useLenticularCraftTiltPreview.js | 2 +- .../composables/useLenticularStudioTilt.js | 4 +- frontend/pages.json | 9 - frontend/pages/castlove/craft-select.vue | 4 +- frontend/pages/castlove/lenticular-studio.vue | 596 ------------------ .../lenticular/create-laser-upload.css | 1 - frontend/utils/castloveGenerationFlow.js | 8 +- frontend/utils/castloveMintForm.js | 4 +- frontend/utils/lenticular-engine.js | 2 +- 10 files changed, 82 insertions(+), 618 deletions(-) create mode 100644 .trae/skills/karpathy-guidelines/SKILL.md delete mode 100644 frontend/pages/castlove/lenticular-studio.vue delete mode 100644 frontend/pages/castlove/lenticular/create-laser-upload.css diff --git a/.trae/skills/karpathy-guidelines/SKILL.md b/.trae/skills/karpathy-guidelines/SKILL.md new file mode 100644 index 0000000..456afa3 --- /dev/null +++ b/.trae/skills/karpathy-guidelines/SKILL.md @@ -0,0 +1,70 @@ +--- +name: "karpathy-guidelines" +description: "Karpathy 启发的编码行为指南,包含四大原则:编码前思考、简洁优先、精准修改、目标驱动执行。适用于所有编码任务,自动引导模型减少常见 LLM 编码错误。" +--- + +# Karpathy 编码行为指南 + +源自 [Andrej Karpathy 的观察](https://x.com/karpathy/status/2015883857489522876) 关于 LLM 编码陷阱的总结。 + +**权衡说明:** 这些指南倾向于谨慎而非速度。对于琐碎任务(简单拼写错误修复、显而易见的一行修改),请自行判断。 + +## 1. 编码前思考 + +**不要假设。不要隐藏困惑。呈现权衡。** + +在实现之前: +- 明确陈述你的假设。如果不确定,询问。 +- 如果存在多种解释,呈现它们 —— 不要默默选择。 +- 如果存在更简单的方法,说出来。适时提出异议。 +- 如果有不清楚的地方,停下来。指出困惑之处。询问。 + +## 2. 简洁优先 + +**用最少的代码解决问题。不要过度推测。** + +- 不添加要求之外的功能。 +- 不为一次性代码创建抽象。 +- 不添加未要求的"灵活性"或"可配置性"。 +- 不为不可能发生的场景做错误处理。 +- 如果你写了 200 行代码,而 50 行就能搞定,重写它。 + +**自问:** "资深工程师会觉得这过于复杂吗?" 如果是,简化。 + +## 3. 精准修改 + +**只碰必须碰的。只清理自己造成的混乱。** + +编辑现有代码时: +- 不要"改进"相邻的代码、注释或格式。 +- 不要重构没坏的东西。 +- 匹配现有风格,即使你更倾向于不同的写法。 +- 如果注意到无关的死代码,提一下 —— 不要删除它。 + +当你的改动产生孤儿代码时: +- 删除因你的改动而变得无用的导入/变量/函数。 +- 不要删除预先存在的死代码,除非被要求。 + +**检验标准:** 每一行修改都应该能直接追溯到用户的请求。 + +## 4. 目标驱动执行 + +**定义成功标准。循环验证直到达成。** + +将指令式任务转化为可验证的目标: +- "添加验证" → "为无效输入编写测试,然后让它们通过" +- "修复 bug" → "编写重现 bug 的测试,然后让它通过" +- "重构 X" → "确保重构前后测试都能通过" + +对于多步骤任务,说明一个简短的计划: +``` +1. [步骤] → 验证: [检查] +2. [步骤] → 验证: [检查] +3. [步骤] → 验证: [检查] +``` + +强有力的成功标准让你能够独立循环执行。弱标准("让它工作")需要不断澄清。 + +--- + +**这些指南在起作用的标志:** diff 中不必要的改动更少、因过度复杂而导致的重写更少、澄清问题在实现之前提出而不是在犯错之后。 diff --git a/frontend/composables/useLenticularCraftTiltPreview.js b/frontend/composables/useLenticularCraftTiltPreview.js index c000c1a..e10fd30 100644 --- a/frontend/composables/useLenticularCraftTiltPreview.js +++ b/frontend/composables/useLenticularCraftTiltPreview.js @@ -1,5 +1,5 @@ /** - * 铸爱流程中的光栅预览:与 lenticular-studio 一致的物理参数、离散档位与陀螺仪启动节奏 + * 铸爱光栅预览(lenticular-result / asset-detail 等):物理参数、离散档位与陀螺仪启动节奏 */ import { ref, nextTick } from 'vue' import { useLenticularPreview } from '@/composables/useLenticularPreview.js' diff --git a/frontend/composables/useLenticularStudioTilt.js b/frontend/composables/useLenticularStudioTilt.js index f69a68e..4c532cd 100644 --- a/frontend/composables/useLenticularStudioTilt.js +++ b/frontend/composables/useLenticularStudioTilt.js @@ -1,5 +1,5 @@ /** - * 光栅卡工作室倾斜驱动:App 优先 imengyu-UniAndroidGyro(DCloud 插件 id=6237),否则加速度计。 + * 光栅卡倾斜驱动(铸爱预览共用):App 优先 imengyu-UniAndroidGyro(DCloud 插件 id=6237),否则加速度计。 * * 与插件约定对齐(官方说明): * - 模块:`imengyu-UniAndroidGyro-GyroModule`,`uni.requireNativePlugin`。 @@ -171,7 +171,7 @@ function uvForPlane(nx, ny, nz, mode) { * @param {(x: number, y: number) => void} opts.simulate * @param {(tiltMagDeg: number, signedDegHint?: number) => void} [opts.simulateFromSignedDegrees] 若提供:用相对进入时基准的**倾角标量(度)**驱动预览(由页面做离散档位等);可选第二参为有符号倾角(度),加速度计路径可传以平衡两侧跟手 * @param {import('vue').Ref} opts.gyroSourceLabel - * @param {boolean} [opts.useStudioAccelDirect] 光栅工作室:加速度计用重力投影直连(免原 warmup) + * @param {boolean} [opts.useStudioAccelDirect] 铸爱光栅预览:加速度计用重力投影直连(免原 warmup) * @param {() => void} [opts.onTiltDriverFallback] 从原生陀螺失败/超时回退到加速度计时调用(用于重置离散档位等 UI 状态) */ export function useLenticularStudioTilt(opts) { diff --git a/frontend/pages.json b/frontend/pages.json index 4bd3db3..7ba0b8c 100644 --- a/frontend/pages.json +++ b/frontend/pages.json @@ -134,15 +134,6 @@ } } }, - { - "path": "pages/castlove/lenticular-studio", - "style": { - "navigationStyle": "custom", - "app-plus": { - "bounce": "none" - } - } - }, { "path": "pages/castlove/laser-card-studio", "style": { diff --git a/frontend/pages/castlove/craft-select.vue b/frontend/pages/castlove/craft-select.vue index 75012fc..aafd055 100644 --- a/frontend/pages/castlove/craft-select.vue +++ b/frontend/pages/castlove/craft-select.vue @@ -140,7 +140,7 @@ export default { // 只有中间位置的卡片点击才会进入创建页 // 其他位置点击只是切换选中(把卡片移到中间),再次点击中间卡片才进入 if (pos === 2) { - if (card.name === '光栅卡') { + if (card.name === '光栅卡' || card.name === '镭射卡') { const route = this.cardRoutes[card.name]; if (route) { uni.navigateTo({ @@ -174,7 +174,7 @@ export default { }, handleSkip() { const card = this.cardList[this.selectedIndex] - if (card.name === '光栅卡') { + if (card.name === '光栅卡' || card.name === '镭射卡') { const route = this.cardRoutes[card.name] if (route) { uni.navigateTo({ diff --git a/frontend/pages/castlove/lenticular-studio.vue b/frontend/pages/castlove/lenticular-studio.vue deleted file mode 100644 index 6821567..0000000 --- a/frontend/pages/castlove/lenticular-studio.vue +++ /dev/null @@ -1,596 +0,0 @@ - - - - - - - - - diff --git a/frontend/pages/castlove/lenticular/create-laser-upload.css b/frontend/pages/castlove/lenticular/create-laser-upload.css deleted file mode 100644 index 9d88527..0000000 --- a/frontend/pages/castlove/lenticular/create-laser-upload.css +++ /dev/null @@ -1 +0,0 @@ -/* 已移除单图上传相关样式 */ \ No newline at end of file diff --git a/frontend/utils/castloveGenerationFlow.js b/frontend/utils/castloveGenerationFlow.js index 2e0a874..0bd36d7 100644 --- a/frontend/utils/castloveGenerationFlow.js +++ b/frontend/utils/castloveGenerationFlow.js @@ -2,7 +2,7 @@ * 铸爱 — 统一「Thinking → 选择 → 详情确认 → 铸造」路由与 Storage * * 本模块管理铸爱(castlove)生成流程的页面跳转、数据持久化和状态管理。 - * 支持四种模式:API生成、预填充选择、光栅工作室、镭射工作室 + * 支持四种模式:API生成、预填充选择、光栅卡流程(lenticular/*)、镭射工作室 */ import { @@ -31,7 +31,7 @@ export const CRAFT_SELECTED_INDEX_KEY = 'craft_selected_index' export const FLOW_MODE_API = 'api' /** 模式:预填充(用户已有所需图片,直接进入选择) */ export const FLOW_MODE_PREFILLED = 'prefilled' -/** 模式:光栅工作室(工作台生成,不走AI四图) */ +/** 模式:光栅卡(lenticular-create → thinking → result,不走 AI 四图) */ export const FLOW_MODE_LENTICULAR = 'lenticular' /** 模式:镭射工作室(工作台生成,不走AI四图) */ export const FLOW_MODE_LASER = 'laser' @@ -317,7 +317,7 @@ export function startPrefilledSelectionFlow({ } /** - * 持久化光栅工作室预览元数据 + * 持久化光栅卡预览元数据(写入 LENTICULAR_STUDIO_STORAGE_KEY) * 在进入光栅结果页面前调用,保存背景图、主体图、材质等信息 * * @param {Object} formData - 包含lenticularBgImage、lenticularSubjectImage等字段 @@ -425,7 +425,7 @@ export function isDetailAfterSelect(formData) { } /** - * 判断是否为光栅工作室类型 + * 判断是否为光栅卡工作室流程(studioKind === lenticular) * @param {Object} formData - 表单数据 * @returns {boolean} */ diff --git a/frontend/utils/castloveMintForm.js b/frontend/utils/castloveMintForm.js index 94ddfcc..58dbf16 100644 --- a/frontend/utils/castloveMintForm.js +++ b/frontend/utils/castloveMintForm.js @@ -24,14 +24,14 @@ export function defaultLenticularDots() { ] } -/** 进入光栅工作室前写入的临时数据(create → lenticular-studio) */ +/** 光栅卡流程:lenticular-create / thinking 写入的 bg+subject 预览载荷(见 persistLenticularPreviewMeta) */ export const LENTICULAR_STUDIO_STORAGE_KEY = 'lenticular_studio_payload' /** 单图工艺:create → 镭射工坊(Laser-Card 页)入口载荷 */ export const CASTLOVE_LASER_ENTRY_KEY = 'castlove_laser_entry_payload' /** - * 仅背景 + 主体两图层(无高光层),与光栅卡工作室一致 + * 仅背景 + 主体两图层(无高光层),与铸爱光栅预览(result 等)一致 * @param {string} bgSrc 背景图本地路径或 URL * @param {string} subjectSrc 主体图本地路径或 URL */ diff --git a/frontend/utils/lenticular-engine.js b/frontend/utils/lenticular-engine.js index c5a6d7a..f2529c9 100644 --- a/frontend/utils/lenticular-engine.js +++ b/frontend/utils/lenticular-engine.js @@ -24,7 +24,7 @@ export const DEFAULT_PHYSICS = { sensorDeadzoneStrength: 1, /** * 以下为可选叠化微调(undefined 时用引擎内置默认)。 - * 光栅工作室离散档位预览可压低「另一张图」残影。 + * 铸爱光栅离散档位预览可压低「另一张图」残影。 */ /** 首层(常为底图)最低可见度 0~1,默认约 0.18 */ lenticularAnchorFloor: undefined,