修复: 生成质量机制根治——max_tokens截断检测+自动重试/icon白名单机械归一/空image剔除/金句引号伪元素治理/文本溢出扩高+重叠校正/图表y轴自适应防窄幅失真/stat缩字兜底/饼图图例流式排布/卡片icon字体锁定

This commit is contained in:
lxy
2026-08-30 17:27:58 +08:00
parent f7d994842a
commit 4e68773642
11 changed files with 1204 additions and 102 deletions
+6 -6
View File
@@ -21,7 +21,7 @@ function norm(elements: SlideElement[]): SlideElement[] {
describe('sanitizeShapes 等比化', () => {
it('star 非正方形框 → 取小者,中心不变', () => {
const els = norm([shape('a', { style: { shapeType: 'star' }, x: 40, y: 20, w: 20, h: 8 })])
const els = norm([shape('a', { style: { shapeType: 'star', fill: 'accent' }, x: 40, y: 20, w: 20, h: 8 })])
expect(els[0].w).toBe(8)
expect(els[0].h).toBe(8)
expect(els[0].x).toBe(46) // 40 + (20-8)/2
@@ -29,7 +29,7 @@ describe('sanitizeShapes 等比化', () => {
})
it('circle 扁宽框 → 正方形', () => {
const els = norm([shape('a', { style: { shapeType: 'circle' }, x: 10, y: 30, w: 30, h: 10 })])
const els = norm([shape('a', { style: { shapeType: 'circle', fill: 'accent' }, x: 10, y: 30, w: 30, h: 10 })])
expect(els[0].w).toBe(10)
expect(els[0].h).toBe(10)
expect(els[0].x).toBe(20) // 10 + 10
@@ -37,7 +37,7 @@ describe('sanitizeShapes 等比化', () => {
})
it('arrow 天然扁宽 → 不等比', () => {
const els = norm([shape('a', { style: { shapeType: 'arrow' }, x: 10, y: 30, w: 30, h: 10 })])
const els = norm([shape('a', { style: { shapeType: 'arrow', fill: 'accent' }, x: 10, y: 30, w: 30, h: 10 })])
expect(els[0].w).toBe(30)
expect(els[0].h).toBe(10)
})
@@ -102,9 +102,9 @@ describe('sanitizeShapes 怪异装饰兜底', () => {
it('多形状叠放拼图案(三角+矩形+圆拼「房子」)→ 只保留先出现的', () => {
// 三角在上方,矩形/圆与其叠放 → 后两者丢弃
const els = norm([
shape('roof', { style: { shapeType: 'triangle' }, x: 40, y: 10, w: 20, h: 12 }),
shape('body', { x: 42, y: 20, w: 16, h: 15 }),
shape('dot', { style: { shapeType: 'circle' }, x: 48, y: 24, w: 5, h: 5 })
shape('roof', { style: { shapeType: 'triangle', fill: 'accent' }, x: 40, y: 10, w: 20, h: 12 }),
shape('body', { style: { fill: 'accent' }, x: 42, y: 20, w: 16, h: 15 }),
shape('dot', { style: { shapeType: 'circle', fill: 'accent' }, x: 48, y: 24, w: 5, h: 5 })
])
expect(els.find(e => e.id === 'roof')).toBeDefined()
expect(els.find(e => e.id === 'body')).toBeUndefined()