fix: v2.16 样板库画布每块可编辑+模型框污染根治

- 预览对话框打开即编辑态, 报价/下单入口保留
- 格尺寸贴外框方向联动等比缩放整窗, 任意格任意方向均可编辑
- 根因修复: computeModelBox 误含扇 bd 退化点致 W/H 与梃位/缩放参考边全错
- 悬停格淡高亮 + pointer 光标; HUD 标签改格宽/格高
- 验证: 格尺寸/梃位/贴边缩放/组合写回四项截图全过, ui-shots 6 页无报错
This commit is contained in:
HHY
2026-09-23 10:39:28 -07:00
parent 6a5a3d1ed3
commit 21760d1887
13 changed files with 108 additions and 41 deletions
+25 -13
View File
@@ -13,7 +13,7 @@ const page = await browser.newPage()
page.on('pageerror', e => console.log(`[JS异常] ${String(e).slice(0, 200)}`))
const shots = 'D:/Code/huamenchuang/shots'
// 在画布内依次尝试点击候选点, 直到 HUD 出现"格W"(选中玻璃格)
// 在画布内依次尝试点击候选点, 直到 HUD 出现"格宽"(选中玻璃格)
async function clickUntilRegion(canvasBox) {
const candidates = [[0.35, 0.30], [0.30, 0.25], [0.40, 0.35], [0.32, 0.22]]
for (const [fx, fy] of candidates) {
@@ -21,7 +21,7 @@ async function clickUntilRegion(canvasBox) {
await sleep(350)
const ok = await page.evaluate(() => {
const inputs = [...document.querySelectorAll('.hud .dim-input')]
return inputs.some(d => d.textContent.includes('格W'))
return inputs.some(d => d.textContent.includes('格宽'))
})
if (ok) return true
}
@@ -51,25 +51,21 @@ await page.goto(`http://localhost:8000/templates?token=${encodeURIComponent(toke
await sleep(1500)
await page.click('.sample-card .cap, .card .cap, .cap')
await sleep(1200)
await page.evaluate(() => {
const btn = [...document.querySelectorAll('.el-dialog button')].find(b => b.textContent.includes('编辑分格'))
btn?.click()
})
await sleep(900)
// 打开即编辑态(无需再点编辑按钮)
let cv = await (await page.$('.el-dialog .canvas-box canvas')).boundingBox()
await page.screenshot({ path: `${shots}/detail-1-editor.png`, clip: cv })
if (!(await clickUntilRegion(cv))) { console.error('✗ 未能选中玻璃格'); process.exit(1) }
await page.screenshot({ path: `${shots}/detail-2-region-selected.png`, clip: cv })
const beforeW = await page.evaluate(() => {
const wrap = [...document.querySelectorAll('.hud .dim-input')].find(d => d.textContent.includes('格W'))
const wrap = [...document.querySelectorAll('.hud .dim-input')].find(d => d.textContent.includes('格宽'))
return Number(wrap.querySelector('input').value)
})
await setDim('格H', 800) // 亮子高度调到 800 → 横梃下移
await setDim('格高', 800) // 亮子高度调到 800 → 横梃下移
await page.screenshot({ path: `${shots}/detail-3-region-resized.png`, clip: cv })
// 梃位编辑: 点击中央竖梃(画布中线附近)
await page.mouse.click(cv.x + cv.width * 0.50, cv.y + cv.height * 0.55)
await page.mouse.click(cv.x + cv.width * 0.433, cv.y + cv.height * 0.55)
await sleep(350)
if (await hasDim('梃位')) {
await setDim('梃位', 900)
@@ -78,7 +74,23 @@ if (await hasDim('梃位')) {
} else {
console.log('△ 未命中中梃(点击位置在格上), 跳过梃位编辑截图')
}
console.log(`✓ 格尺寸编辑完成 (格W ${beforeW} → 调格H=800)`)
// 贴边格等比缩放: 选中右侧整列格(高贴外框) → 改格高 → 整窗等比缩放
await page.mouse.click(cv.x + cv.width * 0.684, cv.y + cv.height * 0.5)
await sleep(350)
if (await hasDim('格宽')) {
await setDim('格高', 1200)
const wh = await page.evaluate(() => {
const wraps = [...document.querySelectorAll('.hud .dim-input')]
const w = wraps.find(d => d.textContent.trim().startsWith('W'))
const h = wraps.find(d => d.textContent.trim().startsWith('H'))
return { w: w?.querySelector('input')?.value, h: h?.querySelector('input')?.value }
})
await page.screenshot({ path: `${shots}/detail-4b-edge-scale.png`, clip: cv })
console.log(`✓ 贴边格等比缩放: 整窗 ${wh.w} × ${wh.h} (期望 1800 × 1200)`)
} else {
console.log('△ 未选中贴边格, 跳过等比缩放验证')
}
console.log(`✓ 格尺寸编辑完成 (格W ${beforeW} → 调格高=800)`)
await page.close()
// ============ ② 组合页: 细节编辑对话框 + 保存写回 ============
@@ -107,7 +119,7 @@ if (!(await (async () => {
await sleep(350)
const ok = await page2.evaluate(() => {
const inputs = [...document.querySelectorAll('.hud .dim-input')]
return inputs.some(d => d.textContent.includes('格W'))
return inputs.some(d => d.textContent.includes('格宽'))
})
if (ok) return true
}
@@ -115,7 +127,7 @@ if (!(await (async () => {
})())) { console.error('✗ 组合细节编辑未能选中玻璃格'); process.exit(1) }
await page2.screenshot({ path: `${shots}/detail-5-combine-dialog.png` })
await page2.evaluate(() => {
const wrap = [...document.querySelectorAll('.hud .dim-input')].find(d => d.textContent.includes('格H'))
const wrap = [...document.querySelectorAll('.hud .dim-input')].find(d => d.textContent.includes('格高'))
const input = wrap.querySelector('input')
input.value = '900'
input.dispatchEvent(new Event('input', { bubbles: true }))