feat(style-source): 变量全部平铺,去掉「展开其余 N 个变量」按钮 (1.0.4)

用户反馈:折叠按钮的「收起」状态容易让人以为变量就这几个,且要多点一次。

- 删掉 VAR_SHOW=6 的折叠逻辑与 .iwb-ss-vartoggle / .iwb-ss-varmore 相关代码样式
- 有多少占位符就平铺多少输入框,详情页本身可滚动(Vigo 那批最多 24 个也能撑住)
- harness:删「先给 6 个 / 折叠默认收起 / 点展开后出现」3 条,换成
  「8 个输入框全可见且无折叠按钮」;顺手修正 2 条随上游数据整改失效的样本断言
  (mondrian 8 个已全部有声明 → 改断言中英混写声明都能对上;
   婚礼那 3 个也不再是零声明 → 改断言标签可读)
This commit is contained in:
qiqi committed 2026-11-02 11:04:25 +08:00
1 parent 005c0307a6
commit 3f3bd5690b
4 files changed
+19 -51

No files matched your search

+12 -27
View File
@@ -133,7 +133,7 @@ async function main() {
const m = window.__manifest
return { id: m.id, name: m.name, version: m.version, apiVersion: m.apiVersion, caps: m.capabilities, hasDataUrl: Boolean(m.settings && m.settings.dataUrl) }
})
check('manifest id/version 正确', manifest.id === 'style-source' && manifest.version === '1.0.3', JSON.stringify({ id: manifest.id, version: manifest.version }))
check('manifest id/version 正确', manifest.id === 'style-source' && manifest.version === '1.0.4', JSON.stringify({ id: manifest.id, version: manifest.version }))
check('capabilities 含 panels+canvas+canvasWrite',
['panels', 'canvas', 'canvasWrite'].every((c) => manifest.caps.includes(c)), manifest.caps.join(','))
check('settings 暴露 dataUrl', manifest.hasDataUrl)
@@ -416,8 +416,6 @@ async function main() {
return page.evaluate(() => {
const box = window.__hostA.querySelector('.iwb-ss-detail')
const inputs = Array.from(box.querySelectorAll('.iwb-ss-varinput'))
const toggle = box.querySelector('.iwb-ss-vartoggle')
const more = box.querySelector('.iwb-ss-varmore')
const preview = (box.querySelector('.iwb-ss-text') || {}).textContent || ''
const names = inputs.map((i) => i.getAttribute('placeholder'))
return {
@@ -432,8 +430,7 @@ async function main() {
visible: inputs.filter((i) => i.getBoundingClientRect().height > 0).length,
dead: names.filter((n) => preview.indexOf('{' + n + '}') < 0).length,
hasVarLabel: Array.from(box.querySelectorAll('.iwb-ss-label')).some((e) => e.textContent.indexOf('变量') >= 0),
toggle: toggle ? toggle.textContent : '',
moreHidden: more ? getComputedStyle(more).display === 'none' : null,
hasToggle: Boolean(box.querySelector('.iwb-ss-vartoggle')),
}
})
}
@@ -441,6 +438,10 @@ async function main() {
const undeclared = await openBySearch('婚礼喜字影像画报')
check('提示词有占位符、数据没声明的风格也有输入框',
undeclared.names.length === 3 && undeclared.dead === 0, undeclared.name + ' → ' + undeclared.names.join(','))
check('每个输入框都有可读标签(不是空串/裸花括号)',
undeclared.pairs.length === 3 &&
undeclared.pairs.every((p) => p.label.trim().length > 0 && !/[{}]/.test(p.label)),
undeclared.pairs.map((p) => p.label + '→{' + p.name + '}').join(', '))
const vigo = await openBySearch('黄黑漫画食品小志广告风格')
const subj = vigo.pairs.find((p) => p.name === 'SUBJECT')
@@ -451,28 +452,12 @@ async function main() {
vigo.dead === 0, 'inputs=' + vigo.names.length + ' dead=' + vigo.dead)
const mondrian = await openBySearch('蒙德里安秩序风')
check('声明与提示词对不上时退回占位符名(不再静默消失)',
mondrian.names.length === 8 && mondrian.pairs.every((p) => p.implicit && p.label.indexOf('`') < 0),
check('中英文混写的 kv_var 都能对上声明(8 个全部 declared)',
mondrian.names.length === 8 && mondrian.pairs.every((p) => !p.implicit && p.label.indexOf('`') < 0),
mondrian.pairs.slice(0, 3).map((p) => p.label + '→{' + p.name + '}').join(', '))
check('变量超过 6 个时先给 6 个、其余折叠',
mondrian.visible === 6 && mondrian.names.length > 6 && /展开其余 \d+ 个变量/.test(mondrian.toggle),
'可见=' + mondrian.visible + ' 全部=' + mondrian.names.length + ' / ' + mondrian.toggle)
check('折叠区默认收起', mondrian.moreHidden === true)
const expand = await page.evaluate(() => {
const box = window.__hostA.querySelector('.iwb-ss-detail')
const btn = box.querySelector('.iwb-ss-vartoggle')
if (!btn) return null
btn.click()
const more = box.querySelector('.iwb-ss-varmore')
return {
shown: more ? getComputedStyle(more).display !== 'none' : null,
count: more ? more.querySelectorAll('.iwb-ss-varinput').length : 0,
text: btn.textContent,
}
})
check('点「展开」后其余变量出现', Boolean(expand) && expand.shown === true && expand.count > 0,
expand ? '展开 ' + expand.count + ' 个 / 按钮=' + expand.text : '')
check('变量全部平铺:8 个输入框全可见,且没有折叠按钮',
mondrian.names.length === 8 && mondrian.visible === 8 && mondrian.hasToggle === false,
'全部=' + mondrian.names.length + ' 可见=' + mondrian.visible + ' 折叠按钮=' + mondrian.hasToggle)
const noVar = await openBySearch('旷野的风')
check('提示词里没有占位符就不摆空输入框',
@@ -535,7 +520,7 @@ async function main() {
})
await page.waitForTimeout(400)
await page.locator('#hostA').screenshot({ path: shotNarrow }).catch(() => {})
// 变量区留档:8 个占位符 → 前 6 个 + 「展开其余 2 个」
// 变量区留档:8 个占位符全部平铺
await page.evaluate(() => { window.__hostA.style.width = '980px'; window.__hostA.style.height = '1180px' })
await page.waitForTimeout(260)
await page.locator('#hostA .iwb-ss-search').fill('黄黑漫画食品小志广告风格')