fix(image-annotate): 1.2.3 橡皮修复(漏 import getActiveLayer + 锁定层兜底)/钢笔描边实心切换/侧栏笔刷粗细移除/顶栏输出组右置

This commit is contained in:
qiqi committed 2026-11-04 20:44:52 +08:00
1 parent f50b734fd7
commit b83b8f3755
8 files changed
+190 -242

No files matched your search

+67 -9
View File
@@ -96,7 +96,7 @@ const boot = await page.evaluate((png) => {
window.__commands['annotate-selected'].run().catch(() => {})
return { version: window.__manifest.version, settingsSchema: Object.keys(window.__manifest.settings || {}) }
}, PNG)
check('产物可执行(循环打包未炸)', boot.version === '1.2.2', 'version=' + boot.version)
check('产物可执行(循环打包未炸)', boot.version === '1.2.3', 'version=' + boot.version)
check('manifest 声明输出预设设置项', boot.settingsSchema.includes('exportPreset') && boot.settingsSchema.includes('panelsCollapsed'), boot.settingsSchema.join(','))
await page.locator('#iwb-editor-overlay').waitFor({ state: 'visible', timeout: 15000 })
@@ -136,13 +136,12 @@ check('打开编辑器默认只有「原图」1 层,且状态栏不再写「
!(await page.locator('.iwb-editor-status-layer').textContent()).includes('画笔标注'),
JSON.stringify((await dbg()).layers.map(l => l.name)))
check('侧栏保留调色板 + 笔刷大小(滑杆/数字/快捷点),硬度/透明滑杆已移除(只在选项栏)',
check('侧栏只剩调色板 + 缩放:笔刷大小/快捷点已移除(都收进工具选项栏,2026-11-04 用户裁定)',
await page.evaluate(() => {
const q = (s) => Boolean(document.querySelector(s))
return q('.iwb-editor-color-panel') && q('.iwb-color-sv') &&
q('.iwb-editor-brush-size') && q('.iwb-editor-brush-num') &&
document.querySelectorAll('.iwb-editor-brush-preset').length >= 6 &&
!q('.iwb-editor-brush-hardness') && !q('.iwb-editor-brush-opacity')
return q('.iwb-editor-color-panel') && q('.iwb-color-sv') && q('.iwb-editor-zoom') &&
!q('.iwb-editor-brush-size') && !q('.iwb-editor-brush-num') &&
document.querySelectorAll('.iwb-editor-brush-preset').length === 0
}))
const drag = async (x1, y1, x2, y2) => {
@@ -543,9 +542,12 @@ await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
check('画笔选项栏有 7 个大小快捷点',
(await page.locator('.iwb-editor-optionbar-body [data-opt-preset="brushSize"]').count()) === 7)
await page.locator('.iwb-editor-optionbar-body [data-opt-preset="brushSize"][data-value="12"]').click()
check('点快捷点 12:笔刷大小即时生效且侧栏滑杆同步',
check('点快捷点 12:笔刷大小即时生效且选项栏数字框同步',
(await dbg()).toolOptions.brushSize === 12 &&
await page.evaluate(() => Number(document.querySelector('.iwb-editor-brush-size').value) === 12))
await page.evaluate(() => {
const n = document.querySelector('.iwb-editor-optionbar-body input[type="number"][data-opt="brushSize"]')
return n && Number(n.value) === 12
}))
// 快捷点:矢量描边
await page.locator('.iwb-editor-tool[data-tool="arrow"]').click()
@@ -598,7 +600,63 @@ check('Enter 确认裁剪(画布尺寸变小、与按钮确认等效)',
JSON.stringify(docBeforeEnter) + ' → ' + JSON.stringify(docAfterEnter))
await page.keyboard.press('Control+z')
// ---- Fix4:点「退出」必须结算宿主 Promise(glue.openEditor → onClose) ----
// ---- v1.2.3:橡皮修复 / 钢笔描边实心 / 顶栏输出组右置 ----
// 顶栏输出组(输出+下载+新建+覆盖+退出)贴最右(header 右内边距 12px)
check('顶栏输出/导出按钮组贴最右侧(用户裁定 2026-11-04)', await page.evaluate(() => {
const hdr = document.querySelector('.iwb-editor-header')
const ex = document.querySelector('.iwb-editor-header > .iwb-editor-export-actions')
const hist = document.querySelector('.iwb-editor-header > .iwb-editor-history')
if (!hdr || !ex || !hist) return false
const h = hdr.getBoundingClientRect(), e = ex.getBoundingClientRect()
return h.right - e.right <= 14 && e.left > hist.getBoundingClientRect().right
}))
// 橡皮:1.2.2 回归 —— events.js 少 import getActiveLayer,一按下就 ReferenceError,表现为「橡皮不能擦」
// 注意 pixel() 探针要的是图片坐标,不是屏幕坐标:liveBox 上的比例 = 图片上的比例
const IMG = { x: Math.round((await dbg()).doc.w * 0.42), y: Math.round((await dbg()).doc.h * 0.5) }
const probe = (id) => page.evaluate(({ id, x, y }) => window.__iwbEditor.__debug().pixel(id, x, y), { id, x: IMG.x, y: IMG.y })
await page.locator('.iwb-editor-tool[data-tool="brush"]').click()
await drag2(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.5,
liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.5)
const stampLayerId = (await dbg()).activeLayerId
const stampPx = await probe(stampLayerId)
const stampBasePx = await probe('base')
check('画笔落笔自动落「标注」层且该点有像素', stampPx && stampPx[3] > 0,
'layer=' + stampLayerId + ' px=' + JSON.stringify(stampPx))
await page.locator('.iwb-editor-tool[data-tool="eraser"]').click()
await drag2(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.5,
liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.5)
const erasedPx = await probe(stampLayerId)
const basePxAfterErase = await probe('base')
check('橡皮沿同一笔迹擦除(不抛错、目标层挖空、base 原样)',
erasedPx && erasedPx[3] === 0 && JSON.stringify(basePxAfterErase) === JSON.stringify(stampBasePx),
'erased=' + JSON.stringify(erasedPx))
await page.keyboard.press('Control+z')
// 钢笔描边/实心切换(penFill 默认实心,只对闭合路径生效)
await page.locator('.iwb-editor-tool[data-tool="pen"]').click()
check('钢笔选项栏有 描边/实心 切换',
(await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="pen"]').count()) === 2)
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="pen"]').click()
const penFillOff = (await dbg()).toolOptions.penFill === false
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="pen"]').click()
check('钢笔样式切换写回 penFill(默认实心 → 描边 → 实心)',
penFillOff && (await dbg()).toolOptions.penFill === true)
// 橡皮兜底:只剩锁定的原图时用橡皮 → 明确提示而不是无声失败
await page.locator('[data-action="reset"]').click()
const layersAfterReset = (await dbg()).layers.length
await page.locator('.iwb-editor-tool[data-tool="eraser"]').click()
await drag2(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.5,
liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.5)
const toastText = await page.locator('.iwb-editor-toast').textContent()
check('原图锁定且无标注层时用橡皮:提示「先画再擦」且不建层',
layersAfterReset === 1 && (await dbg()).layers.length === 1 && toastText.indexOf('可擦') >= 0,
'layers=' + layersAfterReset + ' toast=' + toastText)
await page.keyboard.press('Control+z') // 撤销还原,恢复图层结构
await page.locator('[data-action="cancel"]').click()
const openState = await poll(async () => page.evaluate(() => window.__openState))
check('点「退出」:宿主 Promise 结算为 cancel 且编辑器关闭',