feat(image-annotate): 1.2.4 选择态就地改形状参数(描边/实心/线宽) + 顶栏命令带(更多菜单图标化: 新建/导入图层、置顶/上/下/置底、适应窗口、收起侧栏) + 选区命令入竖工具条

This commit is contained in:
qiqi committed 2026-11-04 21:12:36 +08:00
1 parent b83b8f3755
commit 77b4f7d5fe
8 files changed
+307 -147

No files matched your search

+89 -7
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.3', 'version=' + boot.version)
check('产物可执行(循环打包未炸)', boot.version === '1.2.4', '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 })
@@ -106,11 +106,11 @@ const pixel = (cx, cy) => page.evaluate(({ x, y }) => {
return { base: d.pixel('base', x, y), draw: d.pixel('draw', x, y), layers: d.layers.map(l => ({ id: l.id, a: d.pixel(l.id, x, y) })) }
}, { x: cx, y: cy })
check('编辑器打开 + 便利 UI 五区齐全', await page.evaluate(() => {
check('编辑器打开 + 便利 UI 五区齐全(v1.2.4 起命令带取代「更多」菜单)', await page.evaluate(() => {
const q = (s) => Boolean(document.querySelector(s))
return q('.iwb-editor-optionbar') && q('.iwb-editor-statusbar') && q('.iwb-editor-sel-bar') &&
q('.iwb-editor-toast') && q('.iwb-editor-selection-overlay') && q('.iwb-editor-cursor-overlay') &&
q('[data-action="download"]') && q('[data-action="toggleMore"]')
q('[data-action="download"]') && q('.iwb-editor-commands')
}))
check('新增选区工具按钮', (await page.locator('.iwb-editor-tool[data-tool="marquee"]').count()) === 1 &&
(await page.locator('.iwb-editor-tool[data-tool="lasso"]').count()) === 1)
@@ -430,7 +430,7 @@ check('选中形状 → Ctrl+A → Delete ⇒ 形状仍在、当前层像素被
await page.keyboard.press('Control+z')
await page.keyboard.press('Control+d')
// ---- Fix2:裁剪与选区互斥(快捷键 / 更多菜单 / 右键菜单三入口) + confirmCrop 清残留 ----
// ---- Fix2:裁剪与选区互斥(快捷键 / 顶栏全选图标 / 右键菜单三入口) + confirmCrop 清残留 ----
await page.locator('.iwb-editor-tool[data-tool="crop"]').click()
const cropStart = await dbg()
check('切到裁剪:旧选区被清、蚂蚁线停止', cropStart.selection === null && cropStart.ants === false)
@@ -439,10 +439,9 @@ const cropAfterA = await dbg()
check('裁剪中 Ctrl+A:不建选区、不启动蚂蚁线、浮动条不出现',
cropAfterA.selection === null && cropAfterA.ants === false &&
(await page.locator('.iwb-editor-sel-bar').isVisible()) === false)
await page.locator('[data-action="toggleMore"]').click()
await page.locator('[data-more="sel.all"]').click()
await page.locator('.iwb-editor-selcmd[data-more="sel.all"]').click()
const cropAfterMenu = await dbg()
check('裁剪中「更多 → 全选」同样被拦', cropAfterMenu.selection === null && cropAfterMenu.ants === false)
check('裁剪中「全选」图标同样被拦', cropAfterMenu.selection === null && cropAfterMenu.ants === false)
await page.mouse.click(box2.x + box2.width * 0.5, box2.y + box2.height * 0.5, { button: 'right' })
const menuShown = await page.locator('.iwb-editor-sel-bar.as-menu').count()
await page.locator('.iwb-editor-sel-bar button[data-sel-cmd="sel.all"]').click()
@@ -656,6 +655,89 @@ check('原图锁定且无标注层时用橡皮:提示「先画再擦」且不
'layers=' + layersAfterReset + ' toast=' + toastText)
await page.keyboard.press('Control+z') // 撤销还原,恢复图层结构
// ---- v1.2.4:顶栏命令带(「更多」图标化)/ 选择工具就地改形状参数 ----
check('「更多」菜单已移除,新建/导入/顺序/视图图标进顶栏命令带', await page.evaluate(() => {
const q = (s) => Boolean(document.querySelector(s))
const hdrCmds = document.querySelectorAll('.iwb-editor-header .iwb-editor-commands .iwb-editor-layer-btn').length
return !q('.iwb-editor-more-wrap') && !q('[data-action="toggleMore"]') && hdrCmds === 4 &&
q('.iwb-editor-header [data-action="addBitmapLayer"]') &&
q('.iwb-editor-header [data-action="addBlankLayer"]') &&
q('.iwb-editor-header [data-action="zoomFit"]') &&
q('.iwb-editor-header [data-action="togglePanels"]')
}))
check('全选/反选/取消选区三个图标紧跟「选择」工具', await page.evaluate(() => {
const tools = Array.from(document.querySelectorAll('.iwb-editor-header > .iwb-editor-tools .iwb-editor-tool'))
const idx = tools.findIndex(b => b.dataset.tool === 'select')
const cmds = tools.slice(idx + 1, idx + 4)
return idx >= 0 && cmds.length === 3 && cmds.every(b => /^sel\./.test(b.dataset.more || ''))
}))
await page.locator('.iwb-editor-selcmd[data-more="sel.all"]').click()
const selAllDbg = await dbg()
check('点「全选」图标 = Ctrl+A(选区生成)', Boolean(selAllDbg.selection && selAllDbg.selection.w === selAllDbg.doc.w),
JSON.stringify(selAllDbg.selection))
await page.locator('.iwb-editor-selcmd[data-more="sel.none"]').click()
check('点「取消选区」图标清掉选区', !(await dbg()).selection)
// 画一个矩形 → 切选择工具点中它 → 选项栏就地改 描边/实心 + 线宽
await page.locator('.iwb-editor-tool[data-tool="rect"]').click()
await drag2(liveBox.x + liveBox.width * 0.2, liveBox.y + liveBox.height * 0.2,
liveBox.x + liveBox.width * 0.45, liveBox.y + liveBox.height * 0.45)
await page.locator('.iwb-editor-tool[data-tool="select"]').click()
await page.mouse.click(liveBox.x + liveBox.width * 0.3, liveBox.y + liveBox.height * 0.3)
await page.waitForTimeout(150)
let selShapeDbg = await dbg()
check('选择工具选中矩形后选项栏出该形状的参数',
selShapeDbg.selectedShapeId &&
(await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="rect"]').count()) === 2 &&
(await page.locator('.iwb-editor-optionbar-body [data-opt="shapeLineWidth"]').count()) >= 2,
'selected=' + selShapeDbg.selectedShapeId)
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="rect"]').click()
selShapeDbg = await dbg()
check('选中矩形就地切「实心」(对象与按钮激活态一致)',
selShapeDbg.shapes[selShapeDbg.shapes.length - 1].fill === true &&
await page.evaluate(() => document.querySelector('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="rect"]').classList.contains('active')),
JSON.stringify(selShapeDbg.shapes.slice(-1)))
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="rect"]').click()
selShapeDbg = await dbg()
check('再切回「描边」(按钮激活态跟随)',
selShapeDbg.shapes[selShapeDbg.shapes.length - 1].fill === false &&
await page.evaluate(() => document.querySelector('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="rect"]').classList.contains('active')))
await page.locator('.iwb-editor-optionbar-body input[type="number"][data-opt="shapeLineWidth"]').fill('9')
await page.waitForTimeout(120)
selShapeDbg = await dbg()
check('选中矩形就地改线宽 9', selShapeDbg.shapes[selShapeDbg.shapes.length - 1].lw === 9,
JSON.stringify(selShapeDbg.shapes.slice(-1)))
// 钢笔:闭合路径选中后同样可切描边/实心
await page.locator('.iwb-editor-tool[data-tool="pen"]').click()
const pA = [liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.25]
const pB = [liveBox.x + liveBox.width * 0.75, liveBox.y + liveBox.height * 0.25]
const pC = [liveBox.x + liveBox.width * 0.75, liveBox.y + liveBox.height * 0.45]
const pD = [liveBox.x + liveBox.width * 0.55, liveBox.y + liveBox.height * 0.45]
for (const [x, y] of [pA, pB, pC, pD]) await page.mouse.click(x, y)
await page.mouse.click(pA[0], pA[1]) // 点回起点闭合
await page.waitForTimeout(120)
const penShapeDbg = await dbg()
check('钢笔闭合路径落成并自动选中', penShapeDbg.selectedShapeId &&
penShapeDbg.shapes[penShapeDbg.shapes.length - 1].type === 'pen' &&
penShapeDbg.shapes[penShapeDbg.shapes.length - 1].closed === true,
JSON.stringify(penShapeDbg.shapes.slice(-1)))
check('选中钢笔路径的选项栏有 描边/实心(pen 归属)',
(await page.locator('.iwb-editor-optionbar-body [data-opt-toggle][data-fill-owner="pen"]').count()) === 2)
await page.locator('.iwb-editor-tool[data-tool="select"]').click()
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="stroke"][data-fill-owner="pen"]').click()
let penSelDbg = await dbg()
check('选中钢笔路径就地切「描边」', penSelDbg.shapes[penSelDbg.shapes.length - 1].fill === false)
await page.locator('.iwb-editor-optionbar-body [data-opt-toggle="fill"][data-fill-owner="pen"]').click()
penSelDbg = await dbg()
check('再切回「实心」', penSelDbg.shapes[penSelDbg.shapes.length - 1].fill === true)
await page.keyboard.press('Control+z') // 撤销最后一次填充
await page.keyboard.press('Control+z') // 撤销钢笔路径
await page.keyboard.press('Control+z') // 撤销矩形线宽
await page.locator('[data-action="cancel"]').click()
const openState = await poll(async () => page.evaluate(() => window.__openState))