// 拖拽移动模式端到端验证: node scripts/verify-move.mjs import puppeteer from 'puppeteer-core' const EDGE = 'C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe' const token = process.argv[2] const browser = await puppeteer.launch({ executablePath: EDGE, headless: 'new', args: ['--window-size=1440,900', '--enable-unsafe-swiftshader', '--use-gl=angle', '--use-angle=swiftshader'], defaultViewport: { width: 1440, height: 900 }, }) const page = await browser.newPage() await page.goto(`http://localhost:8000/combine?token=${encodeURIComponent(token)}`, { waitUntil: 'networkidle2' }) await page.waitForSelector('.lib-item') await page.click('.lib-item') await new Promise(r => setTimeout(r, 600)) const box = await (await page.$('.canvas-box')).boundingBox() const cx = box.x + box.width / 2, cy = box.y + box.height / 2 const bboxOf = () => page.evaluate(() => window.__ccDebug.units ? 'units()' : '') // ① 真实左键拖拽单元(应移动) const before = await page.evaluate(() => { const cv = document.querySelector('.canvas-box canvas') return cv.getBoundingClientRect().x }) await page.mouse.move(cx, cy) await page.mouse.down() for (let i = 1; i <= 8; i++) { await page.mouse.move(cx + i * 12, cy - i * 6) await new Promise(r => setTimeout(r, 25)) } await page.mouse.up() await new Promise(r => setTimeout(r, 300)) console.log('① 左键拖拽单元: 完成(位置见截图)') // ② 右键 → 菜单 → 拖拽移动此单元 → 移动 → 点击落下 await page.mouse.click(cx + 120, cy) await new Promise(r => setTimeout(r, 300)) await page.mouse.click(cx + 120, cy, { button: 'right' }) await new Promise(r => setTimeout(r, 300)) const menuItems = await page.$$('.ctx-item') let dragMoveItem = null for (const it of menuItems) { const t = await it.evaluate(el => el.dataset.action) if (t === 'drag-move') { dragMoveItem = it; break } } if (dragMoveItem) { await dragMoveItem.click() // 进入拖拽移动模式 await new Promise(r => setTimeout(r, 200)) // 移动鼠标拖动单元(分步) await page.mouse.move(cx + 200, cy - 60) for (let i = 1; i <= 6; i++) { await page.mouse.move(cx + 200 + i * 15, cy - 60 - i * 5) await new Promise(r => setTimeout(r, 40)) } await page.mouse.click(cx + 260, cy - 90) // 点击落下 await new Promise(r => setTimeout(r, 400)) console.log('② 拖拽移动+落下: 完成') } else { console.log('② 未找到拖拽移动菜单项') } await page.screenshot({ path: 'D:/Code/huamenchuang/shots/v4-drag-move.png' }) await browser.close() console.log('验证完成')