feat: 检索词表 + 表情技能 + 海报字重编排 三向增强

- 中文语义词表 425 → 619 条(+194),新增行业细分/商业指标/技术工程/合规风控/节日节气/生活服务等 17 组场景词;对 11.8 万图标名语料复核覆盖率 99.0%

- 表情技能 12 → 20(motion 11→13 新增循环接缝/多元素错峰;emotion 1→7 新增强度匹配/场景克制/覆盖度/可读性/调性一致/情绪跳变)

- 共享技能 54 → 55:新增头像向技能 avatar-safe-zone(圆/方裁切安全区),映射到方案评审步骤

- 海报字体层级:新增 TYPE_SCALES 四档白名单(impact/editorial/steady/quiet),AI 决策 JSON 增加 typeScaleId,渲染层按预设输出 400/700/800 与字号比;非法值回退默认

- 修复 audit-emojis.html 技能数量断言过期(12→20);emoji-smoke 62/62 通过,audit-emojis 27 通过 0 失败

- 版本联动 20261108e(cn-tags / skills core+layout / sticker skills / poster-generator+ai)
This commit is contained in:
sgp
2026-11-08 10:45:28 +08:00
parent 50d6e019ce
commit beb10e170b
16 changed files with 2020 additions and 80 deletions
+14 -5
View File
@@ -10,16 +10,20 @@ const HGB_PosterAI = (function () {
function buildPrompt(opt) {
const layoutList = HGB_PosterGenerator.LAYOUTS.map(l => `${l.id}:${l.name}`).join('\n');
const paletteList = HGB_PosterGenerator.PALETTES.map(p => `${p.id}:${p.name}(背景 ${p.bg})`).join('\n');
const sys = `你是顶级的海报设计师。请基于用户提供的主题信息,从白名单中选择版式与配色,设计多套专业海报方案。
const scaleList = HGB_PosterGenerator.TYPE_SCALES
.map(s => `${s.id}:${s.name}(标题 ${s.titleWeight} / 副标题 ${s.subWeight},标题占画布宽 ${Math.round(s.titleRatio * 1000) / 10}%)— ${s.note}`)
.join('\n');
const sys = `你是顶级的海报设计师。请基于用户提供的主题信息,从白名单中选择版式、配色与字体层级,设计多套专业海报方案。
设计原则:
1. 标题(title)精炼有力、突出主题;副标题(subtitle)补充说明(可空)。
2. 版式 layoutId 与配色 paletteId 必须从白名单中选择,不得编造。
3. 多套方案尽量使用不同的版式与配色,呈现不同设计方向。
4. 每套方案给出贴切的中文方案名(name)与设计理念(concept)。
2. 版式 layoutId、配色 paletteId、字体层级 typeScaleId 必须从白名单中选择,不得编造。
3. 字体层级按信息调性选择:促销/活动用强冲击,文化/品牌叙事用编辑感,政务/金融用稳健均衡,高端/极简用克制留白。
4. 多套方案尽量使用不同的版式、配色与字体层级,呈现不同设计方向。
5. 每套方案给出贴切的中文方案名(name)与设计理念(concept)。
只输出 JSON,不要输出任何其他文字。JSON 结构:
{ "overallConcept": "整体理念", "plans": [ { "name": "方案名", "title": "主标题", "subtitle": "副标题(可空)", "paletteId": "indigo", "layoutId": "centered", "concept": "设计理念" } ] }
{ "overallConcept": "整体理念", "plans": [ { "name": "方案名", "title": "主标题", "subtitle": "副标题(可空)", "paletteId": "indigo", "layoutId": "centered", "typeScaleId": "impact", "concept": "设计理念" } ] }
其中 plans 数组包含 ${opt.count || 5} 套方案。`;
const user = `【主题信息】
- 行业/主题:${opt.industry || '通用'}
@@ -33,6 +37,9 @@ ${layoutList}
【配色白名单】
${paletteList}
【字体层级白名单】
${scaleList}
请设计 ${opt.count || 5} 套海报方案。`;
return [
{ role: 'system', content: sys },
@@ -54,6 +61,7 @@ ${paletteList}
for (const p of data.plans) {
if (!HGB_PosterGenerator.PALETTES.some(x => x.id === p.paletteId)) p._paletteInvalid = true;
if (!HGB_PosterGenerator.LAYOUTS.some(x => x.id === p.layoutId)) p._layoutInvalid = true;
if (!HGB_PosterGenerator.TYPE_SCALES.some(x => x.id === p.typeScaleId)) p._scaleInvalid = true;
}
return data;
}
@@ -63,6 +71,7 @@ ${paletteList}
const decision = HGB_PosterGenerator.defaultDecision(p.title, p.subtitle);
if (!p._paletteInvalid) decision.paletteId = p.paletteId;
if (!p._layoutInvalid) decision.layoutId = p.layoutId;
if (!p._scaleInvalid) decision.typeScaleId = p.typeScaleId;
const elements = HGB_PosterGenerator.generate(spec, decision);
return {
id: 'poster_' + Date.now().toString(36) + idx.toString(36),
+31 -12
View File
@@ -13,6 +13,24 @@ const HGB_PosterGenerator = (function () {
{ id: 'minimal', name: '极简', bg: '#ffffff', primary: '#111827', accent: '#4f46e5' }
];
/**
* 字体层级预设(白名单):AI 只能从中选择,保证标题/副标题的字号比与字重组合可控。
* 字重限制在 400 / 700 / 800 —— 渲染器只内嵌 Noto Sans SC Regular(400) 与 Bold(700-900),
* 超出范围的权重会被浏览器合成,视觉不可控。
*/
const TYPE_SCALES = [
{ id: 'impact', name: '强冲击', titleWeight: 800, subWeight: 400, titleRatio: 0.075, subRatio: 0.38, note: '促销/活动主视觉,超大粗标题压场' },
{ id: 'editorial', name: '编辑感', titleWeight: 700, subWeight: 400, titleRatio: 0.062, subRatio: 0.44, note: '文化/品牌叙事,标题收敛、副标题更可读' },
{ id: 'steady', name: '稳健均衡', titleWeight: 700, subWeight: 700, titleRatio: 0.068, subRatio: 0.40, note: '政务/金融等信息型海报,标题副标题同粗同稳' },
{ id: 'quiet', name: '克制留白', titleWeight: 400, subWeight: 400, titleRatio: 0.052, subRatio: 0.46, note: '高端/极简,细标题+大留白,靠空间而非字重建立层级' }
];
const DEFAULT_SCALE = 'impact';
function scaleOf(id) {
return TYPE_SCALES.find(s => s.id === id) || TYPE_SCALES[0];
}
function uid(p) { return p + '_' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6); }
function rect(id, x, y, w, h, fill) { return { id, type: 'rect', x, y, w, h, fill }; }
@@ -28,9 +46,9 @@ const HGB_PosterGenerator = (function () {
const cw = spec.w, ch = spec.h, els = [];
els.push(rect(uid('bg'), 0, 0, cw, ch, o.palette.bg));
els.push(circle(uid('dot'), cw / 2, ch * 0.30, ch * 0.12, o.palette.accent));
const fs = Math.round(cw * 0.075);
els.push(text(uid('title'), o.title, cw / 2, ch * 0.50, fs, 800, o.palette.primary, 'middle'));
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.56, Math.round(fs * 0.38), 400, o.palette.primary, 'middle'));
const fs = Math.round(cw * o.scale.titleRatio);
els.push(text(uid('title'), o.title, cw / 2, ch * 0.50, fs, o.scale.titleWeight, o.palette.primary, 'middle'));
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.56, Math.round(fs * o.scale.subRatio), o.scale.subWeight, o.palette.primary, 'middle'));
els.push(rect(uid('bar'), cw / 2 - cw * 0.12, ch * 0.62, cw * 0.24, 8, o.palette.accent));
return els;
}
@@ -42,9 +60,9 @@ const HGB_PosterGenerator = (function () {
els.push(rect(uid('bg'), 0, 0, cw, ch, o.palette.bg));
els.push(rect(uid('side'), 0, 0, cw * 0.06, ch, o.palette.accent));
const mx = cw * 0.13;
const fs = Math.round(cw * 0.08);
els.push(text(uid('title'), o.title, mx, ch * 0.44, fs, 800, o.palette.primary, 'start'));
if (o.sub) els.push(text(uid('sub'), o.sub, mx, ch * 0.52, Math.round(fs * 0.36), 400, o.palette.primary, 'start'));
const fs = Math.round(cw * o.scale.titleRatio);
els.push(text(uid('title'), o.title, mx, ch * 0.44, fs, o.scale.titleWeight, o.palette.primary, 'start'));
if (o.sub) els.push(text(uid('sub'), o.sub, mx, ch * 0.52, Math.round(fs * o.scale.subRatio), o.scale.subWeight, o.palette.primary, 'start'));
els.push(rect(uid('bar'), mx, ch * 0.58, cw * 0.18, 8, o.palette.accent));
return els;
}
@@ -55,9 +73,9 @@ const HGB_PosterGenerator = (function () {
const cw = spec.w, ch = spec.h, els = [];
els.push(rect(uid('bg'), 0, 0, cw, ch, o.palette.bg));
els.push(rect(uid('band'), 0, ch * 0.18, cw, ch * 0.16, o.palette.accent));
const fs = Math.round(cw * 0.07);
els.push(text(uid('title'), o.title, cw / 2, ch * 0.26, fs, 800, o.palette.bg, 'middle'));
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.55, Math.round(fs * 0.42), 400, o.palette.primary, 'middle'));
const fs = Math.round(cw * o.scale.titleRatio);
els.push(text(uid('title'), o.title, cw / 2, ch * 0.26, fs, o.scale.titleWeight, o.palette.bg, 'middle'));
if (o.sub) els.push(text(uid('sub'), o.sub, cw / 2, ch * 0.55, Math.round(fs * o.scale.subRatio), o.scale.subWeight, o.palette.primary, 'middle'));
return els;
}
}
@@ -67,13 +85,14 @@ const HGB_PosterGenerator = (function () {
function generate(spec, decision) {
const palette = PALETTES.find(p => p.id === decision.paletteId) || PALETTES[0];
const layout = LAYOUTS.find(l => l.id === decision.layoutId) || LAYOUTS[0];
const o = { palette, title: decision.title || '海报标题', sub: decision.sub || '' };
const scale = scaleOf(decision.typeScaleId);
const o = { palette, scale, title: decision.title || '海报标题', sub: decision.sub || '' };
return layout.build(spec, o);
}
function defaultDecision(title, sub) {
return { paletteId: 'indigo', layoutId: 'centered', title: title || '海报标题', sub: sub || '' };
return { paletteId: 'indigo', layoutId: 'centered', typeScaleId: DEFAULT_SCALE, title: title || '海报标题', sub: sub || '' };
}
return { PALETTES, LAYOUTS, generate, defaultDecision };
return { PALETTES, LAYOUTS, TYPE_SCALES, scaleOf, generate, defaultDecision };
})();