dsh-ppt 0.26.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.en.md +5 -4
- package/README.md +5 -4
- package/docs/USAGE.en.md +1 -0
- package/docs/USAGE.md +1 -0
- package/docs/VALIDATION.md +4 -0
- package/docs/assets/intro/workflow-en-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-light.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
- package/lib/client.js +96 -12
- package/lib/execution.js +8 -4
- package/lib/tools.js +56 -1
- package/lib/types.d.ts +64 -0
- package/lib/workbench.js +67 -3
- package/package.json +1 -1
- package/skills/dsh-ppt/SKILL.md +3 -3
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/scripts/build-deck.mjs +15 -3
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +114 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +106 -15
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +114 -6
- package/skills/dsh-ppt/scripts/deck-core.mjs +6 -0
- package/skills/dsh-ppt/scripts/deck-covers.mjs +804 -0
- package/skills/dsh-ppt/scripts/deck-director.mjs +118 -1
- package/skills/dsh-ppt/scripts/deck-icons.mjs +469 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +519 -92
- package/skills/dsh-ppt/scripts/deck-media.mjs +159 -15
- package/skills/dsh-ppt/scripts/deck-taste.mjs +347 -0
|
@@ -1938,8 +1938,76 @@ export function promoteMarkdownSlides(slides, options = {}) {
|
|
|
1938
1938
|
return result
|
|
1939
1939
|
}
|
|
1940
1940
|
|
|
1941
|
+
/**
|
|
1942
|
+
* 视觉节奏编排器(Visual Rhythm Engine):
|
|
1943
|
+
* 按 Taste Recipe 规则打破连续等宽方框卡片的视觉疲劳,自动交替无框/聚光灯/Bento-Hero 并激活多章节实时议程页。
|
|
1944
|
+
*/
|
|
1945
|
+
export function optimizeVisualRhythm(slides, tasteRecipe = null) {
|
|
1946
|
+
if (!Array.isArray(slides) || slides.length === 0) return slides
|
|
1947
|
+
const sectionCount = slides.filter((s) => s?.layout === 'section').length
|
|
1948
|
+
let boxedStreak = 0
|
|
1949
|
+
return slides.map((slide, idx) => {
|
|
1950
|
+
if (!slide || typeof slide !== 'object') return slide
|
|
1951
|
+
const layout = slide.layout || 'bullets'
|
|
1952
|
+
const hasExplicitVariant = typeof slide.variant === 'string' && slide.variant.trim() !== ''
|
|
1953
|
+
let next = slide
|
|
1954
|
+
|
|
1955
|
+
if (layout === 'cover' && !hasExplicitVariant && tasteRecipe?.coverVariant && tasteRecipe.coverVariant !== 'default') {
|
|
1956
|
+
next = { ...next, variant: tasteRecipe.coverVariant }
|
|
1957
|
+
} else if (layout === 'section' && !hasExplicitVariant && sectionCount >= 2 && tasteRecipe?.sectionVariant === 'agenda') {
|
|
1958
|
+
next = { ...next, variant: 'agenda' }
|
|
1959
|
+
} else if (layout === 'kpi' && !hasExplicitVariant) {
|
|
1960
|
+
const itemCount = Array.isArray(slide.items) ? slide.items.length : (Array.isArray(slide.bullets) ? slide.bullets.length : 0)
|
|
1961
|
+
if (tasteRecipe?.kpiVariant === 'spotlight' && itemCount >= 2) {
|
|
1962
|
+
next = { ...next, variant: 'spotlight' }
|
|
1963
|
+
} else if (tasteRecipe?.kpiVariant === 'frameless') {
|
|
1964
|
+
next = { ...next, variant: 'frameless' }
|
|
1965
|
+
}
|
|
1966
|
+
boxedStreak = 0
|
|
1967
|
+
} else if (layout === 'cards') {
|
|
1968
|
+
const itemCount = Array.isArray(slide.items) ? slide.items.length : (Array.isArray(slide.bullets) ? slide.bullets.length : 0)
|
|
1969
|
+
if (!hasExplicitVariant) {
|
|
1970
|
+
if (boxedStreak >= 2) {
|
|
1971
|
+
next = { ...next, variant: itemCount >= 2 && itemCount <= 4 ? 'bento-hero' : 'frameless' }
|
|
1972
|
+
boxedStreak = 0
|
|
1973
|
+
} else if (tasteRecipe?.cardsVariant && tasteRecipe.cardsVariant !== 'pillars') {
|
|
1974
|
+
if (tasteRecipe.cardsVariant === 'bento-hero' && (itemCount < 2 || itemCount > 4)) {
|
|
1975
|
+
next = { ...next, variant: 'frameless' }
|
|
1976
|
+
} else {
|
|
1977
|
+
next = { ...next, variant: tasteRecipe.cardsVariant }
|
|
1978
|
+
}
|
|
1979
|
+
boxedStreak = 0
|
|
1980
|
+
} else {
|
|
1981
|
+
boxedStreak += 1
|
|
1982
|
+
}
|
|
1983
|
+
} else {
|
|
1984
|
+
boxedStreak = ['frameless', 'bento-hero', 'bento'].includes(slide.variant) ? 0 : boxedStreak + 1
|
|
1985
|
+
}
|
|
1986
|
+
} else if (['bullets', 'comparison', 'matrix'].includes(layout)) {
|
|
1987
|
+
boxedStreak += 1
|
|
1988
|
+
} else {
|
|
1989
|
+
boxedStreak = 0
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
if ((layout === 'chart' || layout === 'chart-split') && next.chart && tasteRecipe) {
|
|
1993
|
+
const c = next.chart
|
|
1994
|
+
const patch = {}
|
|
1995
|
+
if (tasteRecipe.chartSpotlight && c.highlight === undefined && c.spotlight === undefined && c.series?.length === 1 && ['column', 'bar'].includes(c.kind)) {
|
|
1996
|
+
patch.spotlight = true
|
|
1997
|
+
}
|
|
1998
|
+
if (tasteRecipe.chartGrowthCallout && c.showGrowthCallout === undefined && !c.callout && c.categories?.length >= 3 && ['column', 'line', 'area'].includes(c.kind)) {
|
|
1999
|
+
patch.showGrowthCallout = true
|
|
2000
|
+
}
|
|
2001
|
+
if (Object.keys(patch).length > 0) {
|
|
2002
|
+
next = { ...next, chart: { ...c, ...patch } }
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
return next
|
|
2006
|
+
})
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1941
2009
|
// ---------------------------------------------------------------------------
|
|
1942
|
-
// SLOP-01..
|
|
2010
|
+
// SLOP-01..12 审美门禁(校准零误报边界,精准拦截平庸排版反模式)
|
|
1943
2011
|
// ---------------------------------------------------------------------------
|
|
1944
2012
|
|
|
1945
2013
|
const WEAK_TOPIC_TITLE_RE = /^(?:第?[一二三四五六七八九十\d]+[章节部分页、.\s-]*)?(?:项目背景|研究背景|背景介绍|关于我们|目录页|数据分析|图表展示|相关内容|内容介绍|情况说明|总结汇报|Overview|Introduction|Background|Data\s*Analysis|Chart|Slide\s*\d+)$/i
|
|
@@ -2127,6 +2195,55 @@ export function auditSlideAesthetics(manifest, theme, textWidthFn) {
|
|
|
2127
2195
|
'穿插使用 kpi 指标页、cards 卡片页、process 流程页、comparison 对比页或 chart-split 图文解读页打破单调',
|
|
2128
2196
|
)
|
|
2129
2197
|
}
|
|
2198
|
+
// SLOP-11: 连续等宽方框卡片视觉疲劳检查
|
|
2199
|
+
let boxedRun = 0
|
|
2200
|
+
let maxBoxedRun = 0
|
|
2201
|
+
let boxedRunSlide = 1
|
|
2202
|
+
slides.forEach((s, idx) => {
|
|
2203
|
+
const lay = s.layout || 'bullets'
|
|
2204
|
+
const v = String(s.variant || '').toLowerCase()
|
|
2205
|
+
const isPlainBoxed = (lay === 'cards' && (!v || v === 'pillars')) || (lay === 'kpi' && (!v || v === 'grid'))
|
|
2206
|
+
if (isPlainBoxed) {
|
|
2207
|
+
boxedRun += 1
|
|
2208
|
+
if (boxedRun > maxBoxedRun) { maxBoxedRun = boxedRun; boxedRunSlide = idx }
|
|
2209
|
+
} else {
|
|
2210
|
+
boxedRun = 0
|
|
2211
|
+
}
|
|
2212
|
+
})
|
|
2213
|
+
if (maxBoxedRun >= 4) {
|
|
2214
|
+
push(
|
|
2215
|
+
boxedRunSlide,
|
|
2216
|
+
'visual-card-monotony',
|
|
2217
|
+
'连续 ' + maxBoxedRun + ' 页使用等宽方框卡片,视觉节奏趋于平淡(SLOP-11)',
|
|
2218
|
+
'建议穿插使用 kpi[spotlight]、cards[frameless]、cards[bento-hero] 或配置 taste 大师审美配方建立主次留白节奏',
|
|
2219
|
+
)
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
// SLOP-12: 单系列柱状/条形图缺少聚光灯聚焦强调提示(>= 5 项且未设 highlight/spotlight/referenceLine)
|
|
2224
|
+
if (slides.length >= 5) {
|
|
2225
|
+
slides.forEach((s, idx) => {
|
|
2226
|
+
if ((s.layout === 'chart' || s.layout === 'chart-split') && s.chart) {
|
|
2227
|
+
const c = s.chart
|
|
2228
|
+
if (
|
|
2229
|
+
['column', 'bar'].includes(c.kind) &&
|
|
2230
|
+
(c.series?.length ?? 0) === 1 &&
|
|
2231
|
+
(c.categories?.length ?? 0) >= 5 &&
|
|
2232
|
+
c.highlight === undefined &&
|
|
2233
|
+
c.spotlight !== true &&
|
|
2234
|
+
!c.referenceLine &&
|
|
2235
|
+
!c.callout &&
|
|
2236
|
+
c.showGrowthCallout !== true
|
|
2237
|
+
) {
|
|
2238
|
+
push(
|
|
2239
|
+
idx,
|
|
2240
|
+
'chart-emphasis-missing',
|
|
2241
|
+
'单系列柱状/条形图包含 ' + c.categories.length + ' 项但缺少焦点聚光灯或基准参考线(SLOP-12)',
|
|
2242
|
+
'可添加 highlight: "max" / spotlight: true、referenceLine 基准线或 showGrowthCallout: true 突出主角数据',
|
|
2243
|
+
)
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
})
|
|
2130
2247
|
}
|
|
2131
2248
|
|
|
2132
2249
|
return issues
|
|
@@ -0,0 +1,469 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deck-icons.mjs —— dsh-ppt 内置 56 枚极简几何线性矢量图标引擎(零外部依赖)。
|
|
3
|
+
*
|
|
4
|
+
* 双端 100% 原生矢量同构输出:
|
|
5
|
+
* - HTML 端:语义化 <svg class="deck-icon" viewBox="0 0 24 24">(继承 currentColor,随主题自动变色)
|
|
6
|
+
* - PPTX 端:原生可编辑 DrawingML <p:sp><a:custGeom>(多路径 <a:path fill="none"> + 圆头描边,零位图、PowerPoint/WPS/LibreOffice 原生可换色缩放)
|
|
7
|
+
*
|
|
8
|
+
* 另提供中英双语智能语义匹配 resolveSemanticIcon() 与 3 种徽章容器渲染器(soft / ring / bare)。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
boxToEmu,
|
|
13
|
+
ptToEmu,
|
|
14
|
+
roundRectAdj,
|
|
15
|
+
escapeXml,
|
|
16
|
+
ooxmlSolidFill,
|
|
17
|
+
ooxmlShape,
|
|
18
|
+
} from './deck-chrome.mjs'
|
|
19
|
+
|
|
20
|
+
const SCALE = 100 // 24×24 逻辑坐标 -> 2400×2400 OOXML 整数坐标精度
|
|
21
|
+
const KAPPA = 0.5522847498
|
|
22
|
+
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// 1. 轻量 SVG Path -> OOXML <a:path> 编译器(支持 M/L/H/V/Q/C/Z 与 Circle/Rect 原语)
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
function circleSubpathSvg(cx, cy, r) {
|
|
28
|
+
const k = r * KAPPA
|
|
29
|
+
const fmt = (n) => +n.toFixed(2)
|
|
30
|
+
return (
|
|
31
|
+
`M ${fmt(cx)} ${fmt(cy - r)} ` +
|
|
32
|
+
`C ${fmt(cx + k)} ${fmt(cy - r)} ${fmt(cx + r)} ${fmt(cy - k)} ${fmt(cx + r)} ${fmt(cy)} ` +
|
|
33
|
+
`C ${fmt(cx + r)} ${fmt(cy + k)} ${fmt(cx + k)} ${fmt(cy + r)} ${fmt(cx)} ${fmt(cy + r)} ` +
|
|
34
|
+
`C ${fmt(cx - k)} ${fmt(cy + r)} ${fmt(cx - r)} ${fmt(cy + k)} ${fmt(cx - r)} ${fmt(cy)} ` +
|
|
35
|
+
`C ${fmt(cx - r)} ${fmt(cy - k)} ${fmt(cx - k)} ${fmt(cy - r)} ${fmt(cx)} ${fmt(cy - r)} Z`
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function roundRectSubpathSvg(x, y, w, h, r = 0) {
|
|
40
|
+
const rr = Math.min(r, w / 2, h / 2)
|
|
41
|
+
const fmt = (n) => +n.toFixed(2)
|
|
42
|
+
if (rr <= 0.05) {
|
|
43
|
+
return `M ${fmt(x)} ${fmt(y)} L ${fmt(x + w)} ${fmt(y)} L ${fmt(x + w)} ${fmt(y + h)} L ${fmt(x)} ${fmt(y + h)} Z`
|
|
44
|
+
}
|
|
45
|
+
const k = rr * KAPPA
|
|
46
|
+
return (
|
|
47
|
+
`M ${fmt(x + rr)} ${fmt(y)} ` +
|
|
48
|
+
`L ${fmt(x + w - rr)} ${fmt(y)} ` +
|
|
49
|
+
`C ${fmt(x + w - rr + k)} ${fmt(y)} ${fmt(x + w)} ${fmt(y + rr - k)} ${fmt(x + w)} ${fmt(y + rr)} ` +
|
|
50
|
+
`L ${fmt(x + w)} ${fmt(y + h - rr)} ` +
|
|
51
|
+
`C ${fmt(x + w)} ${fmt(y + h - rr + k)} ${fmt(x + w - rr + k)} ${fmt(y + h)} ${fmt(x + w - rr)} ${fmt(y + h)} ` +
|
|
52
|
+
`L ${fmt(x + rr)} ${fmt(y + h)} ` +
|
|
53
|
+
`C ${fmt(x + rr - k)} ${fmt(y + h)} ${fmt(x)} ${fmt(y + h - rr + k)} ${fmt(x)} ${fmt(y + h - rr)} ` +
|
|
54
|
+
`L ${fmt(x)} ${fmt(y + rr)} ` +
|
|
55
|
+
`C ${fmt(x)} ${fmt(y + rr - k)} ${fmt(x + rr - k)} ${fmt(y)} ${fmt(x + rr)} ${fmt(y)} Z`
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function ptXml(x, y) {
|
|
60
|
+
return `<a:pt x="${Math.round(x * SCALE)}" y="${Math.round(y * SCALE)}"/>`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function svgPathToOoxmlCommands(d) {
|
|
64
|
+
const tokens = String(d ?? '').match(/[MLHVQCZ]|-?(?:\d+\.?\d*|\.\d+)/gi) || []
|
|
65
|
+
let i = 0
|
|
66
|
+
let cmd = ''
|
|
67
|
+
let cx = 0
|
|
68
|
+
let cy = 0
|
|
69
|
+
let sx = 0
|
|
70
|
+
let sy = 0
|
|
71
|
+
const out = []
|
|
72
|
+
|
|
73
|
+
const readNum = () => Number(tokens[i++] ?? 0)
|
|
74
|
+
|
|
75
|
+
while (i < tokens.length) {
|
|
76
|
+
if (/^[MLHVQCZ]$/i.test(tokens[i])) {
|
|
77
|
+
cmd = tokens[i++].toUpperCase()
|
|
78
|
+
if (cmd === 'Z') {
|
|
79
|
+
out.push('<a:close/>')
|
|
80
|
+
cx = sx
|
|
81
|
+
cy = sy
|
|
82
|
+
continue
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (cmd === 'M') {
|
|
86
|
+
cx = readNum()
|
|
87
|
+
cy = readNum()
|
|
88
|
+
sx = cx
|
|
89
|
+
sy = cy
|
|
90
|
+
out.push(`<a:moveTo>${ptXml(cx, cy)}</a:moveTo>`)
|
|
91
|
+
cmd = 'L'
|
|
92
|
+
} else if (cmd === 'L') {
|
|
93
|
+
cx = readNum()
|
|
94
|
+
cy = readNum()
|
|
95
|
+
out.push(`<a:lnTo>${ptXml(cx, cy)}</a:lnTo>`)
|
|
96
|
+
} else if (cmd === 'H') {
|
|
97
|
+
cx = readNum()
|
|
98
|
+
out.push(`<a:lnTo>${ptXml(cx, cy)}</a:lnTo>`)
|
|
99
|
+
} else if (cmd === 'V') {
|
|
100
|
+
cy = readNum()
|
|
101
|
+
out.push(`<a:lnTo>${ptXml(cx, cy)}</a:lnTo>`)
|
|
102
|
+
} else if (cmd === 'Q') {
|
|
103
|
+
const qx = readNum()
|
|
104
|
+
const qy = readNum()
|
|
105
|
+
cx = readNum()
|
|
106
|
+
cy = readNum()
|
|
107
|
+
out.push(`<a:quadBezTo>${ptXml(qx, qy)}${ptXml(cx, cy)}</a:quadBezTo>`)
|
|
108
|
+
} else if (cmd === 'C') {
|
|
109
|
+
const x1 = readNum()
|
|
110
|
+
const y1 = readNum()
|
|
111
|
+
const x2 = readNum()
|
|
112
|
+
const y2 = readNum()
|
|
113
|
+
cx = readNum()
|
|
114
|
+
cy = readNum()
|
|
115
|
+
out.push(`<a:cubicBezTo>${ptXml(x1, y1)}${ptXml(x2, y2)}${ptXml(cx, cy)}</a:cubicBezTo>`)
|
|
116
|
+
} else {
|
|
117
|
+
i += 1
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return out.join('')
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ---------------------------------------------------------------------------
|
|
124
|
+
// 2. 56 枚极简几何线性图标库(24×24 画布,2px 统一光学描边权重)
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
|
|
127
|
+
const RAW_ICONS = {
|
|
128
|
+
// === 商业与战略 (Business & Strategy) ===
|
|
129
|
+
target: [circleSubpathSvg(12, 12, 9), circleSubpathSvg(12, 12, 5), circleSubpathSvg(12, 12, 1.4)],
|
|
130
|
+
compass: [circleSubpathSvg(12, 12, 9), 'M 15.8 8.2 L 13.5 13.5 L 8.2 15.8 L 10.5 10.5 Z'],
|
|
131
|
+
rocket: [
|
|
132
|
+
'M 12 3 C 16.5 4.2 19 8.5 18 14 L 14 18 C 8.5 19 4.2 16.5 3 12 C 6.5 8 8.8 5 12 3 Z',
|
|
133
|
+
'M 9 15 L 6 18 L 6 21 L 9 18',
|
|
134
|
+
circleSubpathSvg(13.5, 10.5, 1.7),
|
|
135
|
+
],
|
|
136
|
+
trophy: [
|
|
137
|
+
'M 7 4 H 17 V 10 C 17 13 14.8 15 12 15 C 9.2 15 7 13 7 10 Z',
|
|
138
|
+
'M 7 6 H 4 V 9 C 4 10.8 5.2 12 7 12',
|
|
139
|
+
'M 17 6 H 20 V 9 C 20 10.8 18.8 12 17 12',
|
|
140
|
+
'M 12 15 V 20',
|
|
141
|
+
'M 8 20 H 16',
|
|
142
|
+
],
|
|
143
|
+
crown: ['M 3 17 L 5 7 L 9.5 11.5 L 12 6 L 14.5 11.5 L 19 7 L 21 17 Z', 'M 4 20 H 20'],
|
|
144
|
+
flag: ['M 5 21 V 4', 'M 5 4 H 18 L 15.5 8.5 L 18 13 H 5'],
|
|
145
|
+
briefcase: [roundRectSubpathSvg(3, 7, 18, 13, 2), 'M 8 7 V 5 C 8 4 8.8 3.5 9.8 3.5 H 14.2 C 15.2 3.5 16 4 16 5 V 7', 'M 3 12 H 21'],
|
|
146
|
+
building: ['M 4 21 V 4 H 14 V 21', 'M 14 10 H 20 V 21', 'M 2 21 H 22', 'M 8 8 H 10', 'M 8 12 H 10', 'M 8 16 H 10'],
|
|
147
|
+
globe: [circleSubpathSvg(12, 12, 9), 'M 3 12 H 21', 'M 12 3 C 15 6 15 18 12 21 C 9 18 9 6 12 3'],
|
|
148
|
+
award: [circleSubpathSvg(12, 9, 5.5), 'M 9 14 L 7.5 21 L 12 18.5 L 16.5 21 L 15 14'],
|
|
149
|
+
scale: ['M 12 3 V 20', 'M 7 20 H 17', 'M 4 7 H 20', 'M 6 7 L 3.5 13 H 8.5 Z', 'M 18 7 L 15.5 13 H 20.5 Z'],
|
|
150
|
+
diamond: ['M 6 4 H 18 L 21 9 L 12 20 L 3 9 Z', 'M 3 9 H 21', 'M 9 4 L 12 20 L 15 4'],
|
|
151
|
+
star: ['M 12 3 L 14.8 8.6 L 21 9.5 L 16.5 13.8 L 17.6 20 L 12 17 L 6.4 20 L 7.5 13.8 L 3 9.5 L 9.2 8.6 Z'],
|
|
152
|
+
|
|
153
|
+
// === 数据与财务 (Data & Finance) ===
|
|
154
|
+
'trending-up': ['M 3 17 L 9 11 L 13 15 L 21 7', 'M 15 7 H 21 V 13'],
|
|
155
|
+
'trending-down': ['M 3 7 L 9 13 L 13 9 L 21 17', 'M 15 17 H 21 V 11'],
|
|
156
|
+
'chart-bar': ['M 3 20 H 21', 'M 6 20 V 13 H 9 V 20', 'M 11 20 V 8 H 14 V 20', 'M 16 20 V 4 H 19 V 20'],
|
|
157
|
+
'chart-pie': ['M 12 3 A 9 9 0 1 0 21 12'.replace(/A.*/, 'C 7 3 3 7 3 12 C 3 17 7 21 12 21 C 17 21 21 17 21 12 H 12 Z'), 'M 14.5 3.5 C 17.8 4.4 19.6 6.2 20.5 9.5 H 14.5 Z'],
|
|
158
|
+
coins: [
|
|
159
|
+
'M 4 7 C 4 5.3 7.1 4 11 4 C 14.9 4 18 5.3 18 7 C 18 8.7 14.9 10 11 10 C 7.1 10 4 8.7 4 7 Z',
|
|
160
|
+
'M 4 7 V 12 C 4 13.7 7.1 15 11 15 C 14.9 15 18 13.7 18 12 V 7',
|
|
161
|
+
'M 4 12 V 17 C 4 18.7 7.1 20 11 20 C 14.9 20 18 18.7 18 17 V 12',
|
|
162
|
+
],
|
|
163
|
+
wallet: [roundRectSubpathSvg(3, 6, 18, 13, 2), 'M 15 11 H 21 V 15 H 15 Z', 'M 5 6 L 16 3.5 V 6'],
|
|
164
|
+
bank: ['M 3 9 L 12 3 L 21 9 Z', 'M 5 9 V 18', 'M 10 9 V 18', 'M 14 9 V 18', 'M 19 9 V 18', 'M 3 18 H 21', 'M 2 21 H 22'],
|
|
165
|
+
percent: ['M 19 5 L 5 19', circleSubpathSvg(7, 7, 2.2), circleSubpathSvg(17, 17, 2.2)],
|
|
166
|
+
layers: ['M 12 3 L 21 8 L 12 13 L 3 8 Z', 'M 3 12.5 L 12 17.5 L 21 12.5', 'M 3 16.5 L 12 21.5 L 21 16.5'],
|
|
167
|
+
funnel: ['M 3 4 H 21 L 14.5 12.5 V 19 L 9.5 21 V 12.5 Z'],
|
|
168
|
+
|
|
169
|
+
// === 科技与架构 (Tech & Architecture) ===
|
|
170
|
+
cpu: [
|
|
171
|
+
roundRectSubpathSvg(6, 6, 12, 12, 2),
|
|
172
|
+
roundRectSubpathSvg(9.5, 9.5, 5, 5, 0.8),
|
|
173
|
+
'M 9 3 V 6', 'M 15 3 V 6', 'M 9 18 V 21', 'M 15 18 V 21',
|
|
174
|
+
'M 3 9 H 6', 'M 3 15 H 6', 'M 18 9 H 21', 'M 18 15 H 21',
|
|
175
|
+
],
|
|
176
|
+
server: [
|
|
177
|
+
roundRectSubpathSvg(3, 4, 18, 6.5, 1.5),
|
|
178
|
+
roundRectSubpathSvg(3, 13.5, 18, 6.5, 1.5),
|
|
179
|
+
'M 7 7.2 H 7.5', 'M 7 16.8 H 7.5', 'M 12 7.2 H 17', 'M 12 16.8 H 17',
|
|
180
|
+
],
|
|
181
|
+
cloud: ['M 7 18 H 17.5 C 19.7 18 21 16.5 21 14.5 C 21 12.6 19.6 11.2 17.7 11 C 17.2 7.6 14.4 5 11 5 C 7.5 5 4.8 7.5 4.5 10.8 C 3.2 11.4 2.5 12.7 2.5 14.2 C 2.5 16.4 4.3 18 7 18 Z'],
|
|
182
|
+
database: [
|
|
183
|
+
'M 4 6.5 C 4 4.8 7.6 3.5 12 3.5 C 16.4 3.5 20 4.8 20 6.5 C 20 8.2 16.4 9.5 12 9.5 C 7.6 9.5 4 8.2 4 6.5 Z',
|
|
184
|
+
'M 4 6.5 V 17.5 C 4 19.2 7.6 20.5 12 20.5 C 16.4 20.5 20 19.2 20 17.5 V 6.5',
|
|
185
|
+
'M 4 12 C 4 13.7 7.6 15 12 15 C 16.4 15 20 13.7 20 12',
|
|
186
|
+
],
|
|
187
|
+
code: ['M 8 7 L 3 12 L 8 17', 'M 16 7 L 21 12 L 16 17', 'M 14 5 L 10 19'],
|
|
188
|
+
terminal: [roundRectSubpathSvg(3, 4, 18, 16, 2), 'M 7 10 L 10.5 12.5 L 7 15', 'M 12.5 15 H 17'],
|
|
189
|
+
'git-branch': [circleSubpathSvg(6.5, 6, 2.2), circleSubpathSvg(6.5, 18, 2.2), circleSubpathSvg(17.5, 8, 2.2), 'M 6.5 8.2 V 15.8', 'M 17.5 10.2 C 17.5 14.2 13 15 8.7 15'],
|
|
190
|
+
workflow: [roundRectSubpathSvg(3, 4, 6.5, 6, 1.2), roundRectSubpathSvg(14.5, 14, 6.5, 6, 1.2), 'M 9.5 7 H 14.5 C 16.2 7 17.5 8.2 17.5 10 V 14'],
|
|
191
|
+
spark: ['M 12 2.5 L 14.2 9.8 L 21.5 12 L 14.2 14.2 L 12 21.5 L 9.8 14.2 L 2.5 12 L 9.8 9.8 Z'],
|
|
192
|
+
bot: [
|
|
193
|
+
roundRectSubpathSvg(4, 7, 16, 12, 2.5),
|
|
194
|
+
'M 12 3 V 7', 'M 9 12.5 H 9.6', 'M 14.4 12.5 H 15', 'M 9 16 H 15',
|
|
195
|
+
'M 2 12 V 14', 'M 22 12 V 14',
|
|
196
|
+
],
|
|
197
|
+
zap: ['M 13 2.5 L 4.5 13.5 H 11.5 L 10.5 21.5 L 19.5 10.5 H 12.5 Z'],
|
|
198
|
+
shield: ['M 12 3 L 19.5 6 V 11.5 C 19.5 16.2 16.3 19.6 12 21 C 7.7 19.6 4.5 16.2 4.5 11.5 V 6 Z', 'M 9 12 L 11 14 L 15.5 9.5'],
|
|
199
|
+
lock: [roundRectSubpathSvg(5, 10.5, 14, 10, 2), 'M 8 10.5 V 7.5 C 8 5.2 9.8 3.5 12 3.5 C 14.2 3.5 16 5.2 16 7.5 V 10.5'],
|
|
200
|
+
key: [circleSubpathSvg(8, 12, 4), 'M 12 12 H 21', 'M 17.5 12 V 15.5', 'M 20.5 12 V 14.5'],
|
|
201
|
+
network: [circleSubpathSvg(12, 5, 2.2), circleSubpathSvg(5.5, 17.5, 2.2), circleSubpathSvg(18.5, 17.5, 2.2), 'M 10.8 7 L 6.7 15.5', 'M 13.2 7 L 17.3 15.5', 'M 7.7 17.5 H 16.3'],
|
|
202
|
+
|
|
203
|
+
// === 运营与交付 (Ops & Delivery) ===
|
|
204
|
+
clock: [circleSubpathSvg(12, 12, 9), 'M 12 7 V 12 L 15.5 14'],
|
|
205
|
+
calendar: [roundRectSubpathSvg(3.5, 5, 17, 15.5, 2), 'M 3.5 10 H 20.5', 'M 8 3 V 6.5', 'M 16 3 V 6.5'],
|
|
206
|
+
'check-circle': [circleSubpathSvg(12, 12, 9), 'M 8 12.2 L 10.8 15 L 16.2 9.2'],
|
|
207
|
+
alert: ['M 12 3.5 L 21 19.5 H 3 Z', 'M 12 9.5 V 14', 'M 12 16.8 V 17.2'],
|
|
208
|
+
flame: ['M 12 3 C 15.5 6.8 18.5 9.8 18.5 14 C 18.5 17.8 15.6 20.8 12 20.8 C 8.4 20.8 5.5 17.8 5.5 14 C 5.5 11.2 7.2 8.8 9 7.2 C 9.2 9.2 10.3 10.4 11.4 10.5 C 10.6 8 11 5.2 12 3 Z'],
|
|
209
|
+
gauge: ['M 4 17.5 C 3.3 16 3 14.3 3 12.5 C 3 7.5 7 3.5 12 3.5 C 17 3.5 21 7.5 21 12.5 C 21 14.3 20.7 16 20 17.5', 'M 12 13 L 16.2 8.8', circleSubpathSvg(12, 13.5, 1.4)],
|
|
210
|
+
wrench: ['M 14.8 4.2 C 12.2 4.6 10.4 7.1 11 9.8 L 4.5 16.3 C 3.7 17.1 3.7 18.4 4.5 19.2 C 5.3 20 6.6 20 7.4 19.2 L 13.9 12.7 C 16.6 13.3 19.1 11.5 19.5 8.9 L 16.5 10.2 L 14.2 7.9 Z'],
|
|
211
|
+
package: ['M 12 3 L 20 7.5 V 16.5 L 12 21 L 4 16.5 V 7.5 Z', 'M 4 7.5 L 12 12 L 20 7.5', 'M 12 12 V 21'],
|
|
212
|
+
truck: ['M 2.5 6 H 14.5 V 16 H 2.5 Z', 'M 14.5 9.5 H 18.5 L 21.5 12.5 V 16 H 14.5', circleSubpathSvg(6.5, 17.5, 2), circleSubpathSvg(17.5, 17.5, 2)],
|
|
213
|
+
refresh: ['M 20 11 C 19.5 6.8 16 3.8 11.8 4 C 8.4 4.2 5.6 6.4 4.5 9.5', 'M 4 5 V 9.5 H 8.5', 'M 4 13 C 4.5 17.2 8 20.2 12.2 20 C 15.6 19.8 18.4 17.6 19.5 14.5', 'M 20 19 V 14.5 H 15.5'],
|
|
214
|
+
sliders: ['M 4 7 H 20', 'M 4 12 H 20', 'M 4 17 H 20', circleSubpathSvg(9, 7, 1.8), circleSubpathSvg(15, 12, 1.8), circleSubpathSvg(10.5, 17, 1.8)],
|
|
215
|
+
|
|
216
|
+
// === 组织、学术与行业 (People, Academic & Verticals) ===
|
|
217
|
+
users: [
|
|
218
|
+
circleSubpathSvg(9, 8.5, 3),
|
|
219
|
+
'M 3.5 19.5 C 3.5 16.2 6 14 9 14 C 12 14 14.5 16.2 14.5 19.5',
|
|
220
|
+
circleSubpathSvg(16.2, 9.2, 2.4),
|
|
221
|
+
'M 15.5 14.2 C 18.2 14.6 20.5 16.6 20.5 19.5',
|
|
222
|
+
],
|
|
223
|
+
user: [circleSubpathSvg(12, 8, 3.6), 'M 5 20 C 5 16.2 8.1 13.8 12 13.8 C 15.9 13.8 19 16.2 19 20'],
|
|
224
|
+
book: ['M 3.5 5.5 C 6.2 4.5 9.5 4.8 12 6.5 C 14.5 4.8 17.8 4.5 20.5 5.5 V 18.5 C 17.8 17.5 14.5 17.8 12 19.5 C 9.5 17.8 6.2 17.5 3.5 18.5 Z', 'M 12 6.5 V 19.5'],
|
|
225
|
+
graduation: ['M 2.5 9.5 L 12 5 L 21.5 9.5 L 12 14 Z', 'M 6.5 11.5 V 16.2 C 6.5 17.8 9 19 12 19 C 15 19 17.5 17.8 17.5 16.2 V 11.5', 'M 21 10 V 15.5'],
|
|
226
|
+
microscope: ['M 10 4 H 13.5 V 12 H 10 Z', 'M 8 12 H 15.5', 'M 13.5 8.5 C 17 9 19 11.8 19 15 C 19 18.2 16.2 20.5 12 20.5 H 5', 'M 6 16.5 H 13'],
|
|
227
|
+
atom: [
|
|
228
|
+
circleSubpathSvg(12, 12, 1.5),
|
|
229
|
+
'M 4 12 C 4 8.8 7.6 6.2 12 6.2 C 16.4 6.2 20 8.8 20 12 C 20 15.2 16.4 17.8 12 17.8 C 7.6 17.8 4 15.2 4 12 Z',
|
|
230
|
+
'M 12 4 C 15.2 4 17.8 7.6 17.8 12 C 17.8 16.4 15.2 20 12 20 C 8.8 20 6.2 16.4 6.2 12 C 6.2 7.6 8.8 4 12 4 Z',
|
|
231
|
+
],
|
|
232
|
+
lightbulb: [
|
|
233
|
+
'M 9 17.5 H 15', 'M 9.8 20.5 H 14.2',
|
|
234
|
+
'M 8.5 14.5 C 7 13.2 6 11.4 6 9.4 C 6 6.1 8.7 3.5 12 3.5 C 15.3 3.5 18 6.1 18 9.4 C 18 11.4 17 13.2 15.5 14.5 L 14.8 17.5 H 9.2 Z',
|
|
235
|
+
],
|
|
236
|
+
heart: ['M 12 20 C 12 20 4 14.8 4 9.2 C 4 6.4 6.2 4.5 8.6 4.5 C 10.2 4.5 11.4 5.4 12 6.6 C 12.6 5.4 13.8 4.5 15.4 4.5 C 17.8 4.5 20 6.4 20 9.2 C 20 14.8 12 20 12 20 Z'],
|
|
237
|
+
leaf: ['M 5 19 C 5 11 10 5 20 4 C 19 14 14 19 5 19 Z', 'M 5 19 L 13 11'],
|
|
238
|
+
stethoscope: ['M 6 4 V 10 C 6 13.3 8.7 16 12 16 C 15.3 16 18 13.3 18 10 V 4', 'M 12 16 V 18.5 C 12 20 13.4 21 15 21 C 16.6 21 18 20 18 18.5 V 15', circleSubpathSvg(18, 13.5, 1.5)],
|
|
239
|
+
megaphone: ['M 4 11 V 14 H 7.5 L 18 18.5 V 6.5 L 7.5 11 Z', 'M 7.5 14 L 9 19.5 H 11.5 L 10 14'],
|
|
240
|
+
message: ['M 4 5.5 H 20 V 16 H 9.5 L 5 19.5 V 16 H 4 Z', 'M 8 9.5 H 16', 'M 8 12.5 H 13'],
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export const ICON_NAMES = Object.freeze(Object.keys(RAW_ICONS))
|
|
244
|
+
const ICON_SET = new Set(ICON_NAMES)
|
|
245
|
+
|
|
246
|
+
const SEMANTIC_ICON_RULES = [
|
|
247
|
+
[/增长|营收|收入|增速|收益|提升|爆发|growth|revenue|arr|gmv|upside|cagr|roi/i, 'trending-up'],
|
|
248
|
+
[/下降|亏损|压缩|降本|削减|成本下降|decline|drop|churn|cost cut/i, 'trending-down'],
|
|
249
|
+
[/盈利|利润|资金|现金|融资|预算|定价|估值|财务|profit|ebit|margin|cash|fund|budget|cost|price|finance/i, 'coins'],
|
|
250
|
+
[/银行|宏观|政策|监管|财政|合规审计|bank|macro|policy|fed|fiscal/i, 'bank'],
|
|
251
|
+
[/目标|战略|愿景|北极星|焦点|定位|target|strategy|goal|okr|focus|mission/i, 'target'],
|
|
252
|
+
[/方向|路线|导航|蓝图|规划|compass|roadmap|direction|blueprint/i, 'compass'],
|
|
253
|
+
[/发布|上线|增长引擎|加速|启动|突破|launch|rocket|accelerate|scale|go-live/i, 'rocket'],
|
|
254
|
+
[/领先|第一|冠|标杆|荣誉|壁垒|leader|win|award|champion|top/i, 'trophy'],
|
|
255
|
+
[/安全|风控|防御|防护|合规|隐私|零信任|security|risk|compliance|shield|guard|privacy|audit/i, 'shield'],
|
|
256
|
+
[/加密|权限|鉴权|认证|密钥|auth|lock|encrypt|sso|rbac/i, 'lock'],
|
|
257
|
+
[/智能体|大模型|模型|算法|AI|LLM|agent|bot|copilot|gpt|neural/i, 'bot'],
|
|
258
|
+
[/算力|芯片|推理|引擎|内核|硬件|gpu|cpu|compute|inference|engine|chip|kernel/i, 'cpu'],
|
|
259
|
+
[/云|多云|云原生|弹性|cloud|saas|k8s|serverless/i, 'cloud'],
|
|
260
|
+
[/数据|缓存|库|仓|知识库|检索|kv|sql|database|data|lake|rag|cache|storage/i, 'database'],
|
|
261
|
+
[/架构|分层|底座|平台|生态|模块|layer|architecture|platform|stack|ecosystem/i, 'layers'],
|
|
262
|
+
[/代码|研发|工程|开发|SDK|API|code|dev|sdk|api|engineer/i, 'code'],
|
|
263
|
+
[/编排|流程|工作流|自动化|链路|管道|workflow|pipeline|orchestrat|flow|process/i, 'workflow'],
|
|
264
|
+
[/性能|速度|延迟|毫秒|吞吐|实时|闪电|fast|latency|speed|realtime|zap|turbo|throughput/i, 'zap'],
|
|
265
|
+
[/体验|创新|亮点|灵感|创意|洞察|insight|idea|spark|magic|innovat|ai/i, 'spark'],
|
|
266
|
+
[/网络|互联|全球|出海|节点|生态网|network|global|world|intl|connect|mesh/i, 'globe'],
|
|
267
|
+
[/组织|团队|客户|用户|人才|协同|合作|team|user|customer|org|people|talent|partner/i, 'users'],
|
|
268
|
+
[/时间|周期|排期|节奏|效率|时长|clock|time|pace|schedule|sla/i, 'clock'],
|
|
269
|
+
[/里程碑|节点|日期|季度|年度|calendar|milestone|quarter|timeline/i, 'calendar'],
|
|
270
|
+
[/交付|验证|验收|通过|质量|门禁|check|verify|quality|pass|done|deliver/i, 'check-circle'],
|
|
271
|
+
[/告警|痛点|瓶颈|阻塞|挑战|风险点|warning|alert|pain|blocker|bottleneck|challenge/i, 'alert'],
|
|
272
|
+
[/图表|指标|统计|量化|看板|chart|metric|kpi|analytics|dashboard/i, 'chart-bar'],
|
|
273
|
+
[/份额|占比|结构|分布|share|ratio|percent|mix|segment/i, 'chart-pie'],
|
|
274
|
+
[/转化|漏斗|获客|留存|funnel|conversion|retention|acquisition/i, 'funnel'],
|
|
275
|
+
[/学术|论文|文献|出版|研报|书籍|paper|citation|book|journal|report|study/i, 'book'],
|
|
276
|
+
[/教育|培训|高校|答辩|课程|edu|campus|defense|thesis|course|train/i, 'graduation'],
|
|
277
|
+
[/实验|科研|生物|化学|实验室|lab|research|experiment|bio|clinical|science/i, 'microscope'],
|
|
278
|
+
[/医疗|健康|临床|医药|medical|health|clinic|care|pharma/i, 'stethoscope'],
|
|
279
|
+
[/绿色|碳中和|能源|环保|ESG|可持续|green|esg|carbon|sustain|clean|solar/i, 'leaf'],
|
|
280
|
+
[/品牌|营销|传播|声量|市场|marketing|brand|campaign|gtm|voice/i, 'megaphone'],
|
|
281
|
+
[/供应|物流|交付链|产品|打包|package|supply|product|bundle|ship/i, 'package'],
|
|
282
|
+
[/运维|迭代|闭环|循环|优化|refresh|loop|cycle|ops|iterat/i, 'refresh'],
|
|
283
|
+
[/工具|治理|配置|调优|sliders|config|tune|control|governance/i, 'sliders'],
|
|
284
|
+
[/价值|高端|旗舰|核心|奢华|diamond|value|premium|core|flagship/i, 'diamond'],
|
|
285
|
+
[/旗帜|目标|里程|flag|goal|victory/i, 'flag'],
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
const FALLBACK_CYCLE = ['spark', 'layers', 'target', 'zap', 'compass', 'shield', 'trending-up', 'cpu']
|
|
289
|
+
|
|
290
|
+
export function normalizeIconName(name) {
|
|
291
|
+
const raw = String(name ?? '').trim().toLowerCase().replace(/[_\s]+/g, '-')
|
|
292
|
+
if (!raw || raw === 'none' || raw === 'false') return ''
|
|
293
|
+
if (ICON_SET.has(raw)) return raw
|
|
294
|
+
const aliases = {
|
|
295
|
+
chart: 'chart-bar',
|
|
296
|
+
bar: 'chart-bar',
|
|
297
|
+
pie: 'chart-pie',
|
|
298
|
+
up: 'trending-up',
|
|
299
|
+
'chart-up': 'trending-up',
|
|
300
|
+
growth: 'trending-up',
|
|
301
|
+
down: 'trending-down',
|
|
302
|
+
'chart-down': 'trending-down',
|
|
303
|
+
money: 'coins',
|
|
304
|
+
dollar: 'coins',
|
|
305
|
+
revenue: 'coins',
|
|
306
|
+
finance: 'coins',
|
|
307
|
+
profit: 'coins',
|
|
308
|
+
cash: 'coins',
|
|
309
|
+
cost: 'coins',
|
|
310
|
+
ai: 'bot',
|
|
311
|
+
llm: 'bot',
|
|
312
|
+
security: 'shield',
|
|
313
|
+
safety: 'shield',
|
|
314
|
+
compliance: 'shield',
|
|
315
|
+
speed: 'zap',
|
|
316
|
+
bolt: 'zap',
|
|
317
|
+
battery: 'zap',
|
|
318
|
+
energy: 'zap',
|
|
319
|
+
power: 'zap',
|
|
320
|
+
performance: 'zap',
|
|
321
|
+
team: 'users',
|
|
322
|
+
people: 'users',
|
|
323
|
+
check: 'check-circle',
|
|
324
|
+
done: 'check-circle',
|
|
325
|
+
warning: 'alert',
|
|
326
|
+
idea: 'lightbulb',
|
|
327
|
+
bulb: 'lightbulb',
|
|
328
|
+
world: 'globe',
|
|
329
|
+
earth: 'globe',
|
|
330
|
+
network: 'globe',
|
|
331
|
+
db: 'database',
|
|
332
|
+
flow: 'workflow',
|
|
333
|
+
pipeline: 'workflow',
|
|
334
|
+
process: 'workflow',
|
|
335
|
+
chip: 'cpu',
|
|
336
|
+
compute: 'cpu',
|
|
337
|
+
gpu: 'cpu',
|
|
338
|
+
launch: 'rocket',
|
|
339
|
+
deploy: 'rocket',
|
|
340
|
+
magic: 'spark',
|
|
341
|
+
sparkles: 'spark',
|
|
342
|
+
med: 'stethoscope',
|
|
343
|
+
health: 'stethoscope',
|
|
344
|
+
eco: 'leaf',
|
|
345
|
+
esg: 'leaf',
|
|
346
|
+
science: 'microscope',
|
|
347
|
+
edu: 'graduation',
|
|
348
|
+
}
|
|
349
|
+
return aliases[raw] || ''
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function resolveSemanticIcon(itemOrText, fallbackIndex = 0) {
|
|
353
|
+
if (itemOrText && typeof itemOrText === 'object') {
|
|
354
|
+
const explicit = String(itemOrText.icon ?? '').trim()
|
|
355
|
+
if (explicit && explicit !== 'auto') {
|
|
356
|
+
const norm = normalizeIconName(explicit)
|
|
357
|
+
if (norm) return norm
|
|
358
|
+
}
|
|
359
|
+
const text = [itemOrText.tag, itemOrText.title, itemOrText.text].filter(Boolean).join(' ')
|
|
360
|
+
for (const [re, iconName] of SEMANTIC_ICON_RULES) {
|
|
361
|
+
if (re.test(text)) return iconName
|
|
362
|
+
}
|
|
363
|
+
return FALLBACK_CYCLE[Math.abs(fallbackIndex) % FALLBACK_CYCLE.length]
|
|
364
|
+
}
|
|
365
|
+
const str = String(itemOrText ?? '')
|
|
366
|
+
const direct = normalizeIconName(str)
|
|
367
|
+
if (direct) return direct
|
|
368
|
+
for (const [re, iconName] of SEMANTIC_ICON_RULES) {
|
|
369
|
+
if (re.test(str)) return iconName
|
|
370
|
+
}
|
|
371
|
+
return FALLBACK_CYCLE[Math.abs(fallbackIndex) % FALLBACK_CYCLE.length]
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// ---------------------------------------------------------------------------
|
|
375
|
+
// 3. HTML SVG 与 PPTX 原生 <a:custGeom> 同构渲染器
|
|
376
|
+
// ---------------------------------------------------------------------------
|
|
377
|
+
|
|
378
|
+
export function renderIconSvg(iconName, options = {}) {
|
|
379
|
+
const key = normalizeIconName(iconName) || 'spark'
|
|
380
|
+
const paths = RAW_ICONS[key] || RAW_ICONS.spark
|
|
381
|
+
const size = options.size ?? 20
|
|
382
|
+
const strokeWidth = options.strokeWidth ?? 1.9
|
|
383
|
+
const cls = options.className ? ` ${options.className}` : ''
|
|
384
|
+
const pathEls = paths
|
|
385
|
+
.map((d) => `<path d="${d}" fill="none" stroke="currentColor" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round"/>`)
|
|
386
|
+
.join('')
|
|
387
|
+
return `<svg class="deck-icon${cls}" width="${size}" height="${size}" viewBox="0 0 24 24" aria-hidden="true" focusable="false">${pathEls}</svg>`
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export function renderIconBadgeHtml(iconName, options = {}) {
|
|
391
|
+
const style = options.style || 'soft' // 'soft' | 'ring' | 'bare' | 'solid'
|
|
392
|
+
const size = options.size ?? 18
|
|
393
|
+
return `<span class="deck-icon-badge deck-icon-badge--${style}" aria-hidden="true">${renderIconSvg(iconName, { size })}</span>`
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* 输出 100% 原生可编辑 PowerPoint DrawingML <p:sp><a:custGeom> 线性矢量图标。
|
|
398
|
+
*/
|
|
399
|
+
export function ooxmlVectorIcon(id, name, boxIn, iconName, options = {}) {
|
|
400
|
+
const key = normalizeIconName(iconName) || 'spark'
|
|
401
|
+
const paths = RAW_ICONS[key] || RAW_ICONS.spark
|
|
402
|
+
const stroke = options.color || '#0057B8'
|
|
403
|
+
const strokePt = options.strokePt ?? 1.55
|
|
404
|
+
const b = boxToEmu(boxIn)
|
|
405
|
+
const pathsXml = paths
|
|
406
|
+
.map((d) => `<a:path w="${24 * SCALE}" h="${24 * SCALE}" fill="none">${svgPathToOoxmlCommands(d)}</a:path>`)
|
|
407
|
+
.join('')
|
|
408
|
+
|
|
409
|
+
return (
|
|
410
|
+
'<p:sp>' +
|
|
411
|
+
'<p:nvSpPr><p:cNvPr id="' + id + '" name="' + escapeXml(name) + '"/><p:cNvSpPr/><p:nvPr/></p:nvSpPr>' +
|
|
412
|
+
'<p:spPr>' +
|
|
413
|
+
'<a:xfrm><a:off x="' + b.x + '" y="' + b.y + '"/><a:ext cx="' + Math.max(12700, b.w) + '" cy="' + Math.max(12700, b.h) + '"/></a:xfrm>' +
|
|
414
|
+
'<a:custGeom><a:avLst/><a:gdLst/><a:ahLst/><a:cxnLst/><a:rect l="l" t="t" r="r" b="b"/>' +
|
|
415
|
+
'<a:pathLst>' + pathsXml + '</a:pathLst></a:custGeom>' +
|
|
416
|
+
'<a:noFill/>' +
|
|
417
|
+
'<a:ln w="' + ptToEmu(strokePt) + '" cap="rnd">' + ooxmlSolidFill(stroke) + '<a:round/></a:ln>' +
|
|
418
|
+
'</p:spPr>' +
|
|
419
|
+
'<p:txBody><a:bodyPr/><a:lstStyle/><a:p/></p:txBody>' +
|
|
420
|
+
'</p:sp>'
|
|
421
|
+
)
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* 渲染带可选精致底托(soft / ring / bare / solid)的矢量图标徽章(PPTX 原生形状组合)。
|
|
426
|
+
*/
|
|
427
|
+
export function renderIconBadgePptx(namePrefix, boxIn, iconName, nextIdFn, theme, options = {}) {
|
|
428
|
+
const tk = theme.tokens
|
|
429
|
+
const style = options.style || 'soft'
|
|
430
|
+
const color = options.color || (style === 'solid' ? tk.inkOnAccent : tk.accentPrimary)
|
|
431
|
+
const shapes = []
|
|
432
|
+
|
|
433
|
+
if (style === 'soft') {
|
|
434
|
+
shapes.push(ooxmlShape(nextIdFn(), namePrefix + ' Plate', boxIn, {
|
|
435
|
+
preset: 'roundRect',
|
|
436
|
+
adj: roundRectAdj(boxIn.w, boxIn.h, options.radiusPx ?? 10),
|
|
437
|
+
fill: options.bg || tk.accentSoft,
|
|
438
|
+
stroke: theme.dark ? tk.accentPrimary : '',
|
|
439
|
+
strokePt: theme.dark ? 0.5 : 0,
|
|
440
|
+
}))
|
|
441
|
+
} else if (style === 'ring') {
|
|
442
|
+
shapes.push(ooxmlShape(nextIdFn(), namePrefix + ' Ring', boxIn, {
|
|
443
|
+
preset: 'roundRect',
|
|
444
|
+
adj: roundRectAdj(boxIn.w, boxIn.h, options.radiusPx ?? 10),
|
|
445
|
+
fill: '',
|
|
446
|
+
stroke: options.stroke || tk.accentPrimary,
|
|
447
|
+
strokePt: 0.9,
|
|
448
|
+
}))
|
|
449
|
+
} else if (style === 'solid') {
|
|
450
|
+
shapes.push(ooxmlShape(nextIdFn(), namePrefix + ' Solid Plate', boxIn, {
|
|
451
|
+
preset: 'roundRect',
|
|
452
|
+
adj: roundRectAdj(boxIn.w, boxIn.h, options.radiusPx ?? 10),
|
|
453
|
+
fill: options.bg || tk.accentPrimary,
|
|
454
|
+
}))
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const inset = style === 'bare' ? 0.02 : Math.min(boxIn.w, boxIn.h) * 0.22
|
|
458
|
+
const iconBox = {
|
|
459
|
+
x: boxIn.x + inset,
|
|
460
|
+
y: boxIn.y + inset,
|
|
461
|
+
w: Math.max(0.14, boxIn.w - inset * 2),
|
|
462
|
+
h: Math.max(0.14, boxIn.h - inset * 2),
|
|
463
|
+
}
|
|
464
|
+
shapes.push(ooxmlVectorIcon(nextIdFn(), namePrefix + ' Icon ' + iconName, iconBox, iconName, {
|
|
465
|
+
color,
|
|
466
|
+
strokePt: options.strokePt ?? (style === 'bare' ? 1.7 : 1.45),
|
|
467
|
+
}))
|
|
468
|
+
return shapes.join('')
|
|
469
|
+
}
|