feat: P0-7 玻璃装饰格条设计器(8风格/2D+3D渲染/算料计价)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
// 格条设计器端到端验证: 订单详情 → 编辑 → 点选玻璃格 → 格条对话框 → 预设应用 → 截图
|
||||
// 用法: node verify-decbar.mjs <token>
|
||||
import puppeteer from 'puppeteer-core'
|
||||
const browser = await puppeteer.launch({
|
||||
executablePath: 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',
|
||||
headless: 'new',
|
||||
args: ['--window-size=1440,900', '--enable-unsafe-swiftshader'],
|
||||
defaultViewport: { width: 1440, height: 900 },
|
||||
})
|
||||
const page = await browser.newPage()
|
||||
page.on('pageerror', e => console.log(`[JS异常] ${String(e).slice(0, 200)}`))
|
||||
const token = process.argv[2]
|
||||
await page.goto(`http://localhost:8000/orders?token=${encodeURIComponent(token)}`, { waitUntil: 'networkidle2' })
|
||||
await new Promise(r => setTimeout(r, 1500))
|
||||
|
||||
// 打开第一行订单图纸
|
||||
const rows = await page.$$('.el-table__body-wrapper .el-table__row')
|
||||
if (!rows.length) { console.log('✗ 无订单行'); process.exit(1) }
|
||||
const btns = await rows[0].$$('button')
|
||||
for (const b of btns) {
|
||||
const t = await b.evaluate(el => el.textContent.trim())
|
||||
if (t === '图纸') { await b.click(); break }
|
||||
}
|
||||
await new Promise(r => setTimeout(r, 1800))
|
||||
|
||||
// 进入编辑模式
|
||||
const editBtn = await page.evaluateHandle(() => [...document.querySelectorAll('button')].find(b => b.textContent.includes('编辑分格')))
|
||||
await editBtn.asElement()?.click()
|
||||
await new Promise(r => setTimeout(r, 800))
|
||||
|
||||
// 点击画布若干位置直到选中玻璃格(格条按钮出现)
|
||||
const box = await (await page.$('.canvas-box')).boundingBox()
|
||||
const cx = box.x + box.width / 2, cy = box.y + box.height / 2
|
||||
const offsets = [[-0.18, -0.15], [0.18, -0.15], [-0.18, 0.15], [0.18, 0.15], [0, 0.2], [0, -0.2], [-0.25, 0], [0.25, 0]]
|
||||
let decBtn = null
|
||||
for (const [dx, dy] of offsets) {
|
||||
await page.mouse.click(cx + box.width * dx, cy + box.height * dy)
|
||||
await new Promise(r => setTimeout(r, 500))
|
||||
decBtn = await page.evaluateHandle(() => [...document.querySelectorAll('button')].find(b => b.textContent.trim() === '格条'))
|
||||
if (await decBtn.asElement()) break
|
||||
// 换位置前先取消当前选中(点 HUD 外空白不行, 直接再点别处即可)
|
||||
}
|
||||
if (!(await decBtn.asElement())) { console.log('✗ 格条按钮未出现(未选中玻璃格)'); await browser.close(); process.exit(1) }
|
||||
await decBtn.asElement().click()
|
||||
await new Promise(r => setTimeout(r, 800))
|
||||
|
||||
// 选第 5 个预设(欧式古典 3x3) + 应用
|
||||
const presets = await page.$$('.dec-preset')
|
||||
if (presets.length < 8) { console.log(`✗ 预设数量异常: ${presets.length}`); process.exit(1) }
|
||||
await presets[4].click()
|
||||
await new Promise(r => setTimeout(r, 300))
|
||||
await page.evaluateHandle(() => [...document.querySelectorAll('.el-dialog button')].find(b => b.textContent.includes('应用'))).then(h => h.asElement()?.click())
|
||||
await new Promise(r => setTimeout(r, 800))
|
||||
|
||||
await page.screenshot({ path: 'D:/Code/huamenchuang/shots/verify-decbar-2d.png', clip: box })
|
||||
console.log('✓ 2D 格条渲染截图完成')
|
||||
|
||||
// 3D 同窗型验证: 打开渲染/3D 页选同样板? 直接验证 2D 即可, 3D 走 validate3d
|
||||
await browser.close()
|
||||
Reference in New Issue
Block a user