openyida 2026.7.18 → 2026.7.21

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.
Files changed (200) hide show
  1. package/README.md +37 -2
  2. package/bin/yida.js +113 -18
  3. package/docs/capabilities.md +202 -0
  4. package/lib/agent-center/agent-center.js +2 -3
  5. package/lib/app/app-list.js +3 -4
  6. package/lib/app/build-page.js +13 -6
  7. package/lib/app/check-page.js +16 -6
  8. package/lib/app/compile.js +17 -7
  9. package/lib/app/create-app.js +14 -2
  10. package/lib/app/create-form/api-path.js +25 -0
  11. package/lib/app/create-form/args.js +13 -0
  12. package/lib/app/create-form/commands.js +4 -0
  13. package/lib/app/create-form/definition-reader.js +23 -23
  14. package/lib/app/create-form/field-normalizers.js +26 -7
  15. package/lib/app/create-form/schema-patch.js +4 -1
  16. package/lib/app/create-form.js +155 -68
  17. package/lib/app/create-page.js +47 -10
  18. package/lib/app/generate-page.js +20 -1
  19. package/lib/app/get-form-config.js +2 -1
  20. package/lib/app/get-schema.js +67 -15
  21. package/lib/app/import-app.js +94 -42
  22. package/lib/app/list-forms.js +4 -8
  23. package/lib/app/page-ir.js +140 -0
  24. package/lib/app/publish.js +289 -556
  25. package/lib/app/schema-field-resolution.js +370 -0
  26. package/lib/app/services/app-reader.js +85 -0
  27. package/lib/app/services/app-service.js +235 -0
  28. package/lib/app/services/canvas-page-compiler.js +91 -0
  29. package/lib/app/services/canvas-page-schema-builder.js +149 -0
  30. package/lib/app/services/field-bindings.js +68 -0
  31. package/lib/app/services/form-compiler.js +1922 -0
  32. package/lib/app/services/form-mode-service.js +182 -0
  33. package/lib/app/services/form-schema-patcher.js +333 -0
  34. package/lib/app/services/form-schema-reader.js +59 -0
  35. package/lib/app/services/form-service.js +379 -0
  36. package/lib/app/services/form-validation.js +562 -0
  37. package/lib/app/services/native-page-compiler.js +92 -0
  38. package/lib/app/services/native-page-schema-builder.js +428 -0
  39. package/lib/app/services/page-resource-service.js +185 -0
  40. package/lib/app/update-app.js +22 -9
  41. package/lib/app/update-form-config.js +4 -2
  42. package/lib/asset/asset-cmd.js +19 -6
  43. package/lib/auth/oauth-loopback.js +376 -15
  44. package/lib/auth/token-auth.js +34 -3
  45. package/lib/auth/token-store.js +22 -4
  46. package/lib/basic-info/basic-info.js +2 -1
  47. package/lib/bridge/bridge.js +43 -18
  48. package/lib/core/agent-capabilities.js +5 -3
  49. package/lib/core/command-errors.js +38 -0
  50. package/lib/core/command-manifest.js +59 -1
  51. package/lib/core/copy.js +12 -0
  52. package/lib/core/doctor.js +15 -4
  53. package/lib/core/env-cmd.js +1 -1
  54. package/lib/core/env.js +7 -6
  55. package/lib/core/i18n.js +66 -8
  56. package/lib/core/legacy-schema-guard.js +408 -0
  57. package/lib/core/locales/en.js +38 -46
  58. package/lib/core/locales/zh.js +30 -46
  59. package/lib/core/sample.js +12 -2
  60. package/lib/core/utils.js +334 -66
  61. package/lib/core/yida-client.js +108 -5
  62. package/lib/corp-efficiency/corp-efficiency.js +2 -2
  63. package/lib/corp-manager/corp-manager.js +3 -3
  64. package/lib/formula/evaluate.js +11 -68
  65. package/lib/formula/field-refs.js +83 -0
  66. package/lib/i18n-management/i18n-management.js +2 -3
  67. package/lib/process/configure-process.js +44 -1992
  68. package/lib/process/create-process.js +54 -87
  69. package/lib/process/preview-process.js +20 -8
  70. package/lib/process/services/process-compiler.js +2056 -0
  71. package/lib/process/services/process-reader.js +232 -0
  72. package/lib/process/services/process-resource-service.js +571 -0
  73. package/lib/process/services/process-service.js +122 -0
  74. package/lib/process/services/process-stage-checkpoint.js +246 -0
  75. package/lib/report/append.js +7 -26
  76. package/lib/report/http.js +31 -5
  77. package/lib/report/index.js +10 -2
  78. package/lib/samples/yida-canvas-custom-page/business-list.canvas.jsx +63 -14
  79. package/lib/samples/yida-canvas-custom-page/dashboard-overview.canvas.jsx +176 -32
  80. package/lib/samples/yida-canvas-custom-page/dashboard-starter.canvas.jsx +5 -2
  81. package/lib/samples/yida-canvas-custom-page/data-management.canvas.jsx +228 -14
  82. package/lib/samples/yida-canvas-custom-page/portal-shell-home.canvas.jsx +2 -2
  83. package/lib/samples/yida-canvas-custom-page/split-pane-detail.canvas.jsx +206 -10
  84. package/lib/samples/yida-custom-page/data-management.oyd.jsx +14 -3
  85. package/lib/samples/yida-custom-page/design-tokens.js +2 -2
  86. package/lib/samples/yida-custom-page/detail-profile.oyd.jsx +1 -1
  87. package/lib/samples/yida-custom-page/portal-shell-home.oyd.jsx +7 -2
  88. package/lib/samples/yida-custom-page/split-pane-detail.oyd.jsx +2 -1
  89. package/lib/schema/adapters/app-adapter.js +210 -0
  90. package/lib/schema/adapters/form-adapter.js +1362 -0
  91. package/lib/schema/adapters/keys.js +19 -0
  92. package/lib/schema/adapters/page-adapter.js +566 -0
  93. package/lib/schema/adapters/process-adapter.js +519 -0
  94. package/lib/schema/applier.js +1878 -0
  95. package/lib/schema/apply-store.js +1083 -0
  96. package/lib/schema/command.js +645 -0
  97. package/lib/schema/dependency-graph.js +83 -0
  98. package/lib/schema/errors.js +481 -0
  99. package/lib/schema/hash.js +9 -0
  100. package/lib/schema/manifest-limits.js +177 -0
  101. package/lib/schema/manifest-loader.js +309 -0
  102. package/lib/schema/manifest-schema-v1.json +193 -0
  103. package/lib/schema/normalize-manifest.js +281 -0
  104. package/lib/schema/page-canvas-foundation.js +447 -0
  105. package/lib/schema/page-data-source-builder.js +561 -0
  106. package/lib/schema/page-foundation.js +556 -0
  107. package/lib/schema/page-source-loader.js +314 -0
  108. package/lib/schema/planner.js +691 -0
  109. package/lib/schema/remote-dispatch-boundary.js +39 -0
  110. package/lib/schema/remote-missing.js +21 -0
  111. package/lib/schema/remote-reader.js +189 -0
  112. package/lib/schema/resource-registry.js +157 -0
  113. package/lib/schema/server-revision.js +71 -0
  114. package/lib/schema/sort.js +28 -0
  115. package/lib/schema/state-store.js +589 -0
  116. package/package.json +10 -8
  117. package/scripts/check-release-risks.js +254 -0
  118. package/scripts/generate-command-docs.js +6 -1
  119. package/scripts/i18n-baseline.json +11 -11
  120. package/scripts/postinstall.js +8 -12
  121. package/scripts/validate-ci.sh +15 -11
  122. package/scripts/validate-i18n.js +30 -9
  123. package/scripts/validate-package-size.js +5 -2
  124. package/scripts/validate-skills.js +4 -0
  125. package/scripts/validate-structure.js +15 -0
  126. package/yida-skills/SKILL.md +117 -30
  127. package/yida-skills/references/schema-as-code-phase1.md +99 -0
  128. package/yida-skills/references/setup-and-env.md +59 -59
  129. package/yida-skills/references/task-retrospective.md +6 -6
  130. package/yida-skills/skills/yida-app/SKILL.md +78 -17
  131. package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +18 -7
  132. package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +3 -3
  133. package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +15 -0
  134. package/yida-skills/skills/yida-create-app/SKILL.md +21 -3
  135. package/yida-skills/skills/yida-create-form-page/SKILL.md +19 -1
  136. package/yida-skills/skills/yida-create-page/SKILL.md +16 -3
  137. package/yida-skills/skills/yida-create-process/SKILL.md +100 -4
  138. package/yida-skills/skills/yida-custom-page/SKILL.md +19 -4
  139. package/yida-skills/skills/yida-dashboard/SKILL.md +1 -1
  140. package/yida-skills/skills/yida-dashboard/references/pitfalls.md +1 -1
  141. package/yida-skills/skills/yida-get-schema/SKILL.md +49 -5
  142. package/yida-skills/skills/yida-i18n/SKILL.md +1 -1
  143. package/yida-skills/skills/yida-integration/SKILL.md +7 -1
  144. package/yida-skills/skills/yida-login/SKILL.md +50 -99
  145. package/yida-skills/skills/yida-page-config/SKILL.md +7 -1
  146. package/yida-skills/skills/yida-page-uiux/references/app/blueprint.md +0 -1
  147. package/yida-skills/skills/yida-page-uiux/references/app/navigation-patterns.md +0 -1
  148. package/yida-skills/skills/yida-page-uiux/references/app/role-journey.md +0 -1
  149. package/yida-skills/skills/yida-page-uiux/references/dashboard/app-blueprint.md +0 -1
  150. package/yida-skills/skills/yida-page-uiux/references/dashboard/chart-contracts.md +0 -1
  151. package/yida-skills/skills/yida-page-uiux/references/dashboard/component-contracts.md +0 -1
  152. package/yida-skills/skills/yida-page-uiux/references/dashboard/layout-patterns.md +0 -1
  153. package/yida-skills/skills/yida-page-uiux/references/dashboard/theme-recipes.md +0 -1
  154. package/yida-skills/skills/yida-page-uiux/references/detail/object-narrative.md +0 -1
  155. package/yida-skills/skills/yida-page-uiux/references/detail/section-patterns.md +0 -1
  156. package/yida-skills/skills/yida-page-uiux/references/detail/timeline-and-related.md +0 -1
  157. package/yida-skills/skills/yida-page-uiux/references/landing/assets-workflow.md +0 -1
  158. package/yida-skills/skills/yida-page-uiux/references/landing/industry-playbooks.md +0 -1
  159. package/yida-skills/skills/yida-page-uiux/references/landing/research-levels.md +0 -1
  160. package/yida-skills/skills/yida-page-uiux/references/landing/section-patterns.md +0 -1
  161. package/yida-skills/skills/yida-page-uiux/references/list/drawer-detail.md +0 -1
  162. package/yida-skills/skills/yida-page-uiux/references/list/empty-loading-error.md +0 -1
  163. package/yida-skills/skills/yida-page-uiux/references/list/filter-patterns.md +0 -1
  164. package/yida-skills/skills/yida-page-uiux/references/list/table-patterns.md +0 -1
  165. package/yida-skills/skills/yida-page-uiux/references/scenes/screen.md +0 -1
  166. package/yida-skills/skills/yida-page-uiux/references/workbench/entry-patterns.md +0 -1
  167. package/yida-skills/skills/yida-page-uiux/references/workbench/portal-layouts.md +0 -1
  168. package/yida-skills/skills/yida-page-uiux/references/workbench/task-feed.md +0 -1
  169. package/yida-skills/skills/yida-page-uiux/workflow/output-decision-block.md +1 -1
  170. package/yida-skills/skills/yida-process-rule/SKILL.md +35 -1
  171. package/yida-skills/skills/yida-publish-page/SKILL.md +46 -4
  172. package/yida-skills/skills/yida-report/SKILL.md +9 -235
  173. package/yida-skills/skills/yida-report/references/schema-builder-details.md +239 -0
  174. package/yida-skills/skills/yida-skill-evaluator/SKILL.md +170 -0
  175. package/yida-skills/skills-index.json +238 -54
  176. package/lib/core/locales/ar.js +0 -834
  177. package/lib/core/locales/de.js +0 -834
  178. package/lib/core/locales/es.js +0 -834
  179. package/lib/core/locales/fr.js +0 -834
  180. package/lib/core/locales/hi.js +0 -834
  181. package/lib/core/locales/ja.js +0 -1227
  182. package/lib/core/locales/ko.js +0 -836
  183. package/lib/core/locales/pt.js +0 -834
  184. package/lib/core/locales/vi.js +0 -834
  185. package/lib/core/locales/zh-HK.js +0 -1263
  186. package/project/pages/src/demo-birthday-game.oyd.jsx +0 -832
  187. package/project/pages/src/demo-chip-insight.oyd.jsx +0 -983
  188. package/project/pages/src/demo-compat-smoke.oyd.jsx +0 -58
  189. package/project/pages/src/demo-crm-batch-entry.oyd.jsx +0 -805
  190. package/project/pages/src/demo-crm-dashboard.oyd.jsx +0 -677
  191. package/project/pages/src/demo-future-vision-2026.oyd.jsx +0 -1102
  192. package/project/pages/src/demo-ppt.oyd.jsx +0 -1192
  193. package/project/pages/src/demo-salary-calculator.oyd.jsx +0 -904
  194. package/project/pages/src/openyida-knowledge-doc.oyd.jsx +0 -1714
  195. package/yida-skills/skills/large-file-write/SKILL.md +0 -93
  196. package/yida-skills/skills/large-file-write/references/write-patterns.md +0 -147
  197. package/yida-skills/skills/large-file-write/scripts/write.js +0 -157
  198. package/yida-skills/skills/sls-log-workbench/SKILL.md +0 -134
  199. package/yida-skills/skills/sls-log-workbench/references/workbench-reference.md +0 -130
  200. package/yida-skills/skills/sls-log-workbench/sls-query.js +0 -295
@@ -1,1192 +0,0 @@
1
- // ══════════════════════════════════════════════════════════════
2
- // OpenYida PPT 演示 — 包含数字键翻页、导航隐藏、全屏、中英文切换
3
- // ══════════════════════════════════════════════════════════════
4
-
5
- // ── 国际化文案 ──────────────────────────────────────────────
6
- var I18N = {
7
- zh: {
8
- prev: '← 上一页',
9
- next: '下一页 →',
10
- pageOf: function(c, t) { return c + ' / ' + t; },
11
- fullscreen: '全屏',
12
- exitFullscreen: '退出全屏',
13
- darkMode: '深色',
14
- lightMode: '浅色',
15
- langSwitch: 'EN',
16
- },
17
- en: {
18
- prev: '← Prev',
19
- next: 'Next →',
20
- pageOf: function(c, t) { return c + ' / ' + t; },
21
- fullscreen: 'Fullscreen',
22
- exitFullscreen: 'Exit Fullscreen',
23
- darkMode: 'Dark',
24
- lightMode: 'Light',
25
- langSwitch: '中',
26
- },
27
- };
28
-
29
- // ── 幻灯片数据 ──────────────────────────────────────────────
30
- var SLIDES = [
31
- {
32
- type: 'cover',
33
- bg: '#1a1a2e', bgLight: '#ffffff',
34
- accent: '#0089ff',
35
- eyebrow: '2026 技术分享',
36
- title: 'OpenYida 2.0',
37
- subtitle: 'AI 驱动的低代码开发平台',
38
- tags: ['AI 原生', '低代码', '企业级'],
39
- },
40
- {
41
- type: 'toc',
42
- bg: '#1a1a2e', bgLight: '#ffffff',
43
- accent: '#0089ff',
44
- title: '目录 / Agenda',
45
- items: [
46
- '核心能力 Core Features',
47
- '应用场景 Use Cases',
48
- '技术架构 Architecture',
49
- '快速上手 Quick Start',
50
- ],
51
- },
52
- {
53
- type: 'chapter',
54
- bg: '#16213e', bgLight: '#f0f7ff',
55
- accent: '#0089ff',
56
- partNum: '01',
57
- title: '核心能力',
58
- subtitle: 'Core Features',
59
- desc: 'AI 对话驱动,一句话生成完整应用',
60
- },
61
- {
62
- type: 'key-points',
63
- bg: '#1a1a2e', bgLight: '#ffffff',
64
- accent: '#0089ff',
65
- chapter: '01 核心能力',
66
- title: 'AI 对话驱动开发',
67
- subtitle: '从需求到上线,最快 5 分钟',
68
- points: [
69
- { icon: '🤖', title: 'AI 表单设计', desc: '描述需求,自动生成字段结构' },
70
- { icon: '⚡', title: '秒级发布', desc: '编译 + 发布一键完成' },
71
- { icon: '🔗', title: '全流程覆盖', desc: '创建 → 配置 → 发布 → 数据管理' },
72
- { icon: '🌐', title: '多语言支持', desc: '中英日韩等 12 种语言' },
73
- ],
74
- },
75
- {
76
- type: 'chapter',
77
- bg: '#16213e', bgLight: '#f0f7ff',
78
- accent: '#0089ff',
79
- partNum: '02',
80
- title: '应用场景',
81
- subtitle: 'Use Cases',
82
- desc: '覆盖企业数字化的各类场景',
83
- },
84
- {
85
- type: 'key-points',
86
- bg: '#1a1a2e', bgLight: '#ffffff',
87
- accent: '#0089ff',
88
- chapter: '02 应用场景',
89
- title: '典型应用',
90
- subtitle: '从 CRM 到项目管理,一站式搞定',
91
- points: [
92
- { icon: '📊', title: 'CRM 客户管理', desc: '客户跟进、商机管理、数据看板' },
93
- { icon: '📋', title: '项目管理', desc: '任务分配、进度追踪、甘特图' },
94
- { icon: '💰', title: '财务报销', desc: '费用申请、审批流程、报表分析' },
95
- { icon: '🏭', title: '生产管理', desc: '工单管理、质量检测、产能分析' },
96
- ],
97
- },
98
- {
99
- type: 'chapter',
100
- bg: '#16213e', bgLight: '#f0f7ff',
101
- accent: '#0089ff',
102
- partNum: '03',
103
- title: '技术架构',
104
- subtitle: 'Architecture',
105
- desc: 'CLI + 宜搭 API + AI 的三层架构',
106
- },
107
- {
108
- type: 'key-points',
109
- bg: '#1a1a2e', bgLight: '#ffffff',
110
- accent: '#0089ff',
111
- chapter: '03 技术架构',
112
- title: '三层架构',
113
- subtitle: 'CLI → API → Platform',
114
- points: [
115
- { icon: '🖥️', title: 'CLI 层', desc: 'openyida 命令行工具,Node.js 实现' },
116
- { icon: '🔌', title: 'API 层', desc: '宜搭 OpenAPI,RESTful 接口' },
117
- { icon: '☁️', title: '平台层', desc: '宜搭低代码平台,阿里云基础设施' },
118
- ],
119
- },
120
- {
121
- type: 'chapter',
122
- bg: '#16213e', bgLight: '#f0f7ff',
123
- accent: '#0089ff',
124
- partNum: '04',
125
- title: '快速上手',
126
- subtitle: 'Quick Start',
127
- desc: '三步开始你的低代码之旅',
128
- },
129
- {
130
- type: 'key-points',
131
- bg: '#1a1a2e', bgLight: '#ffffff',
132
- accent: '#0089ff',
133
- chapter: '04 快速上手',
134
- title: '三步上手',
135
- subtitle: '安装 → 登录 → 创建',
136
- points: [
137
- { icon: '1️⃣', title: '安装', desc: 'npm install -g openyida' },
138
- { icon: '2️⃣', title: '登录', desc: 'openyida login(扫码登录)' },
139
- { icon: '3️⃣', title: '创建', desc: 'openyida create-app "我的应用"' },
140
- ],
141
- },
142
- {
143
- type: 'echarts-race',
144
- bg: '#1a1a2e', bgLight: '#ffffff',
145
- accent: '#0089ff',
146
- chapter: '附录',
147
- title: '中国历代经济全球排名',
148
- subtitle: 'GDP 占全球比重变迁(公元前 2000 年 — 2025 年)',
149
- },
150
- {
151
- type: 'ending',
152
- bg: '#0089ff', bgLight: '#0089ff',
153
- accent: '#ffffff',
154
- title: '立即体验 OpenYida',
155
- subtitle: 'npm install -g openyida',
156
- quote: '让 AI 成为你的低代码开发伙伴',
157
- },
158
- ];
159
-
160
- // ── 状态管理 ────────────────────────────────────────────────
161
- var _customState = {
162
- currentIndex: 0,
163
- navVisible: false,
164
- isFullscreen: false,
165
- darkMode: true,
166
- lang: 'zh',
167
- numBuffer: '',
168
- numTimer: null,
169
- echartsLoaded: false,
170
- echartsInstance: null,
171
- raceTimer: null,
172
- raceIndex: 0,
173
- raceFinished: false,
174
- echartsInitTimer: null,
175
- };
176
-
177
- // ── 中国历代经济全球排名数据(GDP 估算,单位:亿 1990 国际元)──
178
- // 数据来源参考:Angus Maddison 历史统计、世界银行
179
- // 统一 8 个实体:中国(朝代)、印度、欧洲、中东、美国、日本、俄国、其他
180
- // chinaLabel 字段控制中国柱子显示的朝代名
181
- var RACE_ENTITIES = ['china', 'india', 'europe', 'mideast', 'usa', 'japan', 'russia', 'other'];
182
- var RACE_LABELS = {
183
- china: '华夏', india: '印度', europe: '欧洲', mideast: '中东',
184
- usa: '美国', japan: '日本', russia: '俄国', other: '其他',
185
- };
186
- var RACE_KEYFRAMES = [
187
- { year: -2000, chinaLabel: '华夏', values: [450, 350, 100, 400, 0, 0, 0, 200] },
188
- { year: -500, chinaLabel: '春秋列国', values: [800, 600, 300, 650, 0, 0, 0, 400] },
189
- { year: -200, chinaLabel: '大秦', values: [1200, 700, 500, 400, 0, 0, 0, 600] },
190
- { year: 100, chinaLabel: '大汉', values: [1500, 800, 1100, 350, 0, 0, 0, 700] },
191
- { year: 600, chinaLabel: '大隋', values: [1600, 1100, 500, 450, 0, 50, 0, 800] },
192
- { year: 800, chinaLabel: '大唐', values: [2200, 1400, 600, 900, 0, 80, 0, 1000] },
193
- { year: 1000, chinaLabel: '北宋', values: [2650, 1600, 800, 700, 0, 120, 0, 1100] },
194
- { year: 1200, chinaLabel: '南宋', values: [2800, 1500, 1000, 600, 0, 150, 0, 1200] },
195
- { year: 1400, chinaLabel: '大明', values: [2500, 1800, 1400, 400, 0, 200, 0, 1300] },
196
- { year: 1600, chinaLabel: '大明', values: [3600, 2800, 2800, 350, 0, 350, 0, 1500] },
197
- { year: 1700, chinaLabel: '大清', values: [4100, 3600, 3500, 280, 0, 500, 0, 1600] },
198
- { year: 1820, chinaLabel: '大清', values: [5500, 2800, 3400, 250, 500, 600, 700, 1800] },
199
- { year: 1870, chinaLabel: '大清', values: [3800, 2600, 5500, 200, 3100, 700, 1400, 2200] },
200
- { year: 1913, chinaLabel: '中华民国', values: [3200, 2500, 6800, 180, 5300, 1100, 2300, 2800] },
201
- { year: 1950, chinaLabel: '新中国', values: [2400, 2200, 5800, 300, 9600, 1100, 3100, 3200] },
202
- { year: 1978, chinaLabel: '中国', values: [3500, 2800, 8200, 800, 12000, 5500, 4800, 4500] },
203
- { year: 2001, chinaLabel: '中国', values: [8200, 4200, 12000, 1500, 19000, 6800, 3200, 7000] },
204
- { year: 2010, chinaLabel: '中国', values: [14000, 6500, 14000, 2000, 21000, 5800, 4200, 9000] },
205
- { year: 2020, chinaLabel: '中国', values: [24000, 9500, 15000, 2500, 22000, 5200, 4500, 12000] },
206
- { year: 2025, chinaLabel: '中国', values: [28000, 11000, 15500, 2800, 23000, 4800, 4200, 13000] },
207
- ];
208
-
209
- // ── 幻灯片内容渲染 ──────────────────────────────────────────
210
- function renderSlideContent(slide, accent, isMobile) {
211
- var type = slide.type;
212
- var isDark = slide.bg !== '#ffffff' && slide.bg !== '#f0f7ff';
213
- var textColor = isDark ? '#ffffff' : '#1a1a2e';
214
- var subColor = isDark ? 'rgba(255,255,255,0.7)' : 'rgba(26,26,46,0.6)';
215
-
216
- if (type === 'cover') {
217
- return (
218
- <div style={{
219
- display: 'flex', flexDirection: 'column', justifyContent: 'center',
220
- alignItems: 'center', height: '100%', textAlign: 'center',
221
- padding: isMobile ? '40px 20px' : '60px 80px',
222
- }}>
223
- {slide.eyebrow && (
224
- <div style={{
225
- fontSize: isMobile ? '13px' : '15px', fontWeight: 600,
226
- color: accent, letterSpacing: '2px', textTransform: 'uppercase',
227
- marginBottom: '20px',
228
- }}>
229
- {slide.eyebrow}
230
- </div>
231
- )}
232
- <h1 style={{
233
- fontSize: isMobile ? '36px' : '64px', fontWeight: 900,
234
- color: textColor, lineHeight: 1.1, margin: '0 0 16px 0',
235
- }}>
236
- {slide.title}
237
- </h1>
238
- {slide.subtitle && (
239
- <p style={{
240
- fontSize: isMobile ? '18px' : '28px', color: subColor,
241
- margin: '0 0 32px 0', fontWeight: 300,
242
- }}>
243
- {slide.subtitle}
244
- </p>
245
- )}
246
- {slide.tags && (
247
- <div style={{ display: 'flex', gap: '10px', flexWrap: 'wrap', justifyContent: 'center' }}>
248
- {slide.tags.map(function(tag, idx) {
249
- return (
250
- <span key={idx} style={{
251
- padding: '6px 16px', borderRadius: '20px', fontSize: '13px',
252
- fontWeight: 600, background: accent + '15', color: accent,
253
- }}>
254
- {tag}
255
- </span>
256
- );
257
- })}
258
- </div>
259
- )}
260
- </div>
261
- );
262
- }
263
-
264
- if (type === 'toc') {
265
- return (
266
- <div style={{
267
- display: 'flex', flexDirection: 'column', justifyContent: 'center',
268
- height: '100%', padding: isMobile ? '40px 24px' : '60px 120px',
269
- }}>
270
- <h2 style={{
271
- fontSize: isMobile ? '28px' : '42px', fontWeight: 800,
272
- color: textColor, marginBottom: '40px',
273
- }}>
274
- {slide.title}
275
- </h2>
276
- {slide.items && slide.items.map(function(item, idx) {
277
- return (
278
- <div key={idx} style={{
279
- display: 'flex', alignItems: 'center', gap: '16px',
280
- padding: '16px 0',
281
- borderBottom: idx < slide.items.length - 1 ? '1px solid rgba(26,26,46,0.08)' : 'none',
282
- }}>
283
- <span style={{
284
- fontSize: isMobile ? '20px' : '28px', fontWeight: 800,
285
- color: accent, minWidth: '40px',
286
- }}>
287
- {'0' + (idx + 1)}
288
- </span>
289
- <span style={{
290
- fontSize: isMobile ? '16px' : '22px', color: textColor, fontWeight: 500,
291
- }}>
292
- {item}
293
- </span>
294
- </div>
295
- );
296
- })}
297
- </div>
298
- );
299
- }
300
-
301
- if (type === 'chapter') {
302
- return (
303
- <div style={{
304
- display: 'flex', flexDirection: 'column', justifyContent: 'center',
305
- alignItems: 'center', height: '100%', textAlign: 'center',
306
- padding: isMobile ? '40px 24px' : '60px 80px',
307
- }}>
308
- <div style={{
309
- fontSize: isMobile ? '48px' : '80px', fontWeight: 900,
310
- color: accent, opacity: 0.15, marginBottom: '-20px',
311
- }}>
312
- {slide.partNum}
313
- </div>
314
- <h2 style={{
315
- fontSize: isMobile ? '32px' : '52px', fontWeight: 800,
316
- color: textColor, margin: '0 0 8px 0',
317
- }}>
318
- {slide.title}
319
- </h2>
320
- {slide.subtitle && (
321
- <p style={{
322
- fontSize: isMobile ? '16px' : '22px', color: subColor,
323
- margin: '0 0 16px 0', fontWeight: 300,
324
- }}>
325
- {slide.subtitle}
326
- </p>
327
- )}
328
- {slide.desc && (
329
- <p style={{
330
- fontSize: isMobile ? '14px' : '18px', color: subColor,
331
- margin: 0, maxWidth: '600px',
332
- }}>
333
- {slide.desc}
334
- </p>
335
- )}
336
- </div>
337
- );
338
- }
339
-
340
- if (type === 'key-points') {
341
- return (
342
- <div style={{
343
- display: 'flex', flexDirection: 'column', justifyContent: 'center',
344
- height: '100%', padding: isMobile ? '40px 20px' : '48px 80px',
345
- }}>
346
- {slide.chapter && (
347
- <div style={{
348
- fontSize: '13px', fontWeight: 600, color: accent,
349
- letterSpacing: '1px', marginBottom: '8px',
350
- }}>
351
- {slide.chapter}
352
- </div>
353
- )}
354
- <h2 style={{
355
- fontSize: isMobile ? '24px' : '38px', fontWeight: 800,
356
- color: textColor, margin: '0 0 6px 0',
357
- }}>
358
- {slide.title}
359
- </h2>
360
- {slide.subtitle && (
361
- <p style={{
362
- fontSize: isMobile ? '14px' : '18px', color: subColor,
363
- margin: '0 0 32px 0',
364
- }}>
365
- {slide.subtitle}
366
- </p>
367
- )}
368
- <div style={{
369
- display: 'grid',
370
- gridTemplateColumns: isMobile ? '1fr' : 'repeat(' + Math.min(slide.points.length, 4) + ', 1fr)',
371
- gap: isMobile ? '16px' : '24px',
372
- }}>
373
- {slide.points.map(function(point, idx) {
374
- return (
375
- <div key={idx} style={{
376
- padding: isMobile ? '16px' : '24px',
377
- borderRadius: '12px',
378
- background: isDark ? 'rgba(255,255,255,0.05)' : 'rgba(26,26,46,0.02)',
379
- border: isDark ? '1px solid rgba(255,255,255,0.1)' : '1px solid rgba(26,26,46,0.06)',
380
- }}>
381
- <div style={{ fontSize: '28px', marginBottom: '12px' }}>{point.icon}</div>
382
- <div style={{
383
- fontSize: isMobile ? '15px' : '17px', fontWeight: 700,
384
- color: textColor, marginBottom: '6px',
385
- }}>
386
- {point.title}
387
- </div>
388
- <div style={{
389
- fontSize: isMobile ? '13px' : '14px', color: subColor, lineHeight: 1.5,
390
- }}>
391
- {point.desc}
392
- </div>
393
- </div>
394
- );
395
- })}
396
- </div>
397
- </div>
398
- );
399
- }
400
-
401
- if (type === 'echarts-race') {
402
- return (
403
- <div style={{
404
- display: 'flex', flexDirection: 'column',
405
- height: '100%', padding: isMobile ? '20px 12px' : '32px 60px',
406
- }}>
407
- {slide.chapter && (
408
- <div style={{
409
- fontSize: '13px', fontWeight: 600, color: accent,
410
- letterSpacing: '1px', marginBottom: '6px',
411
- }}>
412
- {slide.chapter}
413
- </div>
414
- )}
415
- <h2 style={{
416
- fontSize: isMobile ? '20px' : '32px', fontWeight: 800,
417
- color: textColor, margin: '0 0 4px 0',
418
- }}>
419
- {slide.title}
420
- </h2>
421
- {slide.subtitle && (
422
- <p style={{
423
- fontSize: isMobile ? '13px' : '16px', color: subColor,
424
- margin: '0 0 12px 0',
425
- }}>
426
- {slide.subtitle}
427
- </p>
428
- )}
429
- <div
430
- id="ppt-echarts-race"
431
- style={{
432
- flex: 1, width: '100%', minHeight: '300px',
433
- borderRadius: '12px',
434
- background: isDark ? 'rgba(255,255,255,0.03)' : 'rgba(26,26,46,0.02)',
435
- }}
436
- />
437
- </div>
438
- );
439
- }
440
-
441
- if (type === 'ending') {
442
- return (
443
- <div style={{
444
- display: 'flex', flexDirection: 'column', justifyContent: 'center',
445
- alignItems: 'center', height: '100%', textAlign: 'center',
446
- padding: isMobile ? '40px 24px' : '60px 80px',
447
- }}>
448
- <h1 style={{
449
- fontSize: isMobile ? '32px' : '56px', fontWeight: 900,
450
- color: textColor, margin: '0 0 16px 0',
451
- }}>
452
- {slide.title}
453
- </h1>
454
- {slide.subtitle && (
455
- <div style={{
456
- fontSize: isMobile ? '16px' : '22px', color: subColor,
457
- margin: '0 0 32px 0', fontFamily: 'monospace',
458
- padding: '12px 24px', borderRadius: '8px',
459
- background: 'rgba(255,255,255,0.15)',
460
- }}>
461
- {slide.subtitle}
462
- </div>
463
- )}
464
- {slide.quote && (
465
- <p style={{
466
- fontSize: isMobile ? '14px' : '18px', color: subColor,
467
- fontStyle: 'italic', margin: 0,
468
- }}>
469
- "{slide.quote}"
470
- </p>
471
- )}
472
- </div>
473
- );
474
- }
475
-
476
- // 默认:简单标题 + 副标题
477
- return (
478
- <div style={{
479
- display: 'flex', flexDirection: 'column', justifyContent: 'center',
480
- height: '100%', padding: isMobile ? '40px 20px' : '48px 80px',
481
- }}>
482
- <h2 style={{ fontSize: isMobile ? '24px' : '38px', fontWeight: 800, color: textColor }}>
483
- {slide.title}
484
- </h2>
485
- {slide.subtitle && (
486
- <p style={{ fontSize: isMobile ? '16px' : '22px', color: subColor }}>
487
- {slide.subtitle}
488
- </p>
489
- )}
490
- </div>
491
- );
492
- }
493
-
494
- // ── 生命周期 ────────────────────────────────────────────────
495
- export function didMount() {
496
- var self = this;
497
- _customState.total = SLIDES.length;
498
-
499
- // ── 从 URL hash 读取初始页码(如 #3 跳到第 3 页)──
500
- var hash = window.location.hash;
501
- if (hash) {
502
- var pageNum = parseInt(hash.replace('#', ''), 10);
503
- if (pageNum >= 1 && pageNum <= SLIDES.length) {
504
- _customState.currentIndex = pageNum - 1;
505
- }
506
- }
507
-
508
- // ── 监听 hash 变化(浏览器前进/后退)──
509
- this._handleHashChange = function() {
510
- var h = window.location.hash;
511
- if (h) {
512
- var p = parseInt(h.replace('#', ''), 10);
513
- if (p >= 1 && p <= SLIDES.length && p - 1 !== _customState.currentIndex) {
514
- _customState.currentIndex = p - 1;
515
- self.forceUpdate();
516
- }
517
- }
518
- };
519
- window.addEventListener('hashchange', this._handleHashChange);
520
-
521
- // 键盘翻页(方向键 + 演讲笔 + 数字键快速跳页)
522
- this._handleKeyDown = function(e) {
523
- // ── 数字键快速跳页(300ms 延迟缓冲,支持双位数)──
524
- var digit = null;
525
- if (e.key >= '0' && e.key <= '9') {
526
- digit = e.key;
527
- }
528
- if (digit !== null) {
529
- if (_customState.numTimer) {
530
- clearTimeout(_customState.numTimer);
531
- }
532
- _customState.numBuffer += digit;
533
- _customState.numTimer = setTimeout(function() {
534
- var targetIndex = parseInt(_customState.numBuffer, 10) - 1;
535
- if (targetIndex >= 0 && targetIndex < SLIDES.length) {
536
- _customState.currentIndex = targetIndex;
537
- self.forceUpdate();
538
- }
539
- _customState.numBuffer = '';
540
- _customState.numTimer = null;
541
- }, 300);
542
- return;
543
- }
544
-
545
- // ── 方向键 / 演讲笔翻页 ──
546
- if (e.key === 'ArrowRight' || e.key === 'ArrowDown' || e.key === 'PageDown') {
547
- if (_customState.currentIndex < SLIDES.length - 1) {
548
- _customState.currentIndex++;
549
- self.forceUpdate();
550
- }
551
- } else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp' || e.key === 'PageUp') {
552
- if (_customState.currentIndex > 0) {
553
- _customState.currentIndex--;
554
- self.forceUpdate();
555
- }
556
- }
557
- };
558
- document.addEventListener('keydown', this._handleKeyDown);
559
-
560
- // 触摸滑动(移动端)
561
- this._touchStartX = 0;
562
- this._handleTouchStart = function(e) {
563
- this._touchStartX = e.changedTouches[0].screenX;
564
- }.bind(this);
565
- this._handleTouchEnd = function(e) {
566
- var touchEndX = e.changedTouches[0].screenX;
567
- if (this._touchStartX - touchEndX > 50) {
568
- if (_customState.currentIndex < SLIDES.length - 1) {
569
- _customState.currentIndex++;
570
- self.forceUpdate();
571
- }
572
- }
573
- if (touchEndX - this._touchStartX > 50) {
574
- if (_customState.currentIndex > 0) {
575
- _customState.currentIndex--;
576
- self.forceUpdate();
577
- }
578
- }
579
- }.bind(this);
580
- document.addEventListener('touchstart', this._handleTouchStart);
581
- document.addEventListener('touchend', this._handleTouchEnd);
582
-
583
- // 鼠标移到底部显示导航栏
584
- this._handleMouseMove = function(e) {
585
- var isNearBottom = e.clientY > window.innerHeight - 80;
586
- if (isNearBottom !== _customState.navVisible) {
587
- _customState.navVisible = isNearBottom;
588
- self.forceUpdate();
589
- }
590
- };
591
- document.addEventListener('mousemove', this._handleMouseMove);
592
-
593
- // 全屏状态变化监听
594
- this._handleFullscreenChange = function() {
595
- _customState.isFullscreen = !!document.fullscreenElement;
596
- self.forceUpdate();
597
- };
598
- document.addEventListener('fullscreenchange', this._handleFullscreenChange);
599
-
600
- // ── 加载 ECharts CDN ──
601
- if (!window.echarts) {
602
- var script = document.createElement('script');
603
- script.src = 'https://g.alicdn.com/code/lib/echarts/5.6.0/echarts.min.js';
604
- script.onload = function() {
605
- _customState.echartsLoaded = true;
606
- _tryInitEchartsRace();
607
- };
608
- document.head.appendChild(script);
609
- } else {
610
- _customState.echartsLoaded = true;
611
- }
612
- }
613
-
614
- // ── ECharts 动态柱状图初始化 ────────────────────────────────
615
- var _entityColors = {
616
- china: '#ff4444',
617
- india: '#4d96ff',
618
- europe: '#9b59b6',
619
- mideast: '#6bcb77',
620
- usa: '#4d96ff',
621
- japan: '#ffd93d',
622
- russia: '#6bcb77',
623
- other: '#95a5a6',
624
- };
625
-
626
- function _tryInitEchartsRace() {
627
- if (!_customState.echartsLoaded || !window.echarts) return;
628
- var currentSlide = SLIDES[_customState.currentIndex];
629
- if (!currentSlide || currentSlide.type !== 'echarts-race') {
630
- _destroyEchartsRace();
631
- return;
632
- }
633
- var dom = document.getElementById('ppt-echarts-race');
634
- if (!dom) return;
635
- if (_customState.echartsInstance) return;
636
-
637
- var isDark = _customState.darkMode;
638
- var chart = window.echarts.init(dom, isDark ? 'dark' : null);
639
- _customState.echartsInstance = chart;
640
- _customState.raceIndex = 0;
641
- _customState.raceYearTimer = null;
642
-
643
- // 渲染首帧并立即开始动画
644
- _renderRaceFrame(chart, 0, RACE_KEYFRAMES[0].values, RACE_KEYFRAMES[0].chinaLabel, RACE_KEYFRAMES[0].year, isDark);
645
- _advanceRaceSegment(chart);
646
- }
647
-
648
- // 推进到下一段(两个关键帧之间逐帧插值)
649
- function _advanceRaceSegment(chart) {
650
- var fromIdx = _customState.raceIndex;
651
- var toIdx = fromIdx + 1;
652
- if (toIdx >= RACE_KEYFRAMES.length) {
653
- // 播放完毕,在图表中央显示重播按钮
654
- _customState.raceFinished = true;
655
- _showReplayButton(chart);
656
- return;
657
- }
658
-
659
- var fromKf = RACE_KEYFRAMES[fromIdx];
660
- var toKf = RACE_KEYFRAMES[toIdx];
661
- var fromYear = fromKf.year;
662
- var toYear = toKf.year;
663
- var totalFrames = 30;
664
- var frame = 0;
665
-
666
- _customState.raceYearTimer = setInterval(function() {
667
- // 防御:chart 已被销毁时立即停止
668
- if (!_customState.echartsInstance || _customState.echartsInstance !== chart) {
669
- clearInterval(_customState.raceYearTimer);
670
- _customState.raceYearTimer = null;
671
- return;
672
- }
673
- frame++;
674
- var progress = frame / totalFrames;
675
- // 线性插值每个实体的数值
676
- var interpolated = [];
677
- for (var i = 0; i < RACE_ENTITIES.length; i++) {
678
- interpolated.push(Math.round(fromKf.values[i] + (toKf.values[i] - fromKf.values[i]) * progress));
679
- }
680
- // 插值年份
681
- var currentYear = Math.round(fromYear + (toYear - fromYear) * progress);
682
- // 朝代名:后半段切换到目标朝代
683
- var chinaLabel = progress < 0.5 ? fromKf.chinaLabel : toKf.chinaLabel;
684
-
685
- _renderRaceFrame(chart, toIdx, interpolated, chinaLabel, currentYear, _customState.darkMode);
686
-
687
- if (frame >= totalFrames) {
688
- clearInterval(_customState.raceYearTimer);
689
- _customState.raceYearTimer = null;
690
- _customState.raceIndex = toIdx;
691
- // 立即开始下一段,无停顿
692
- _advanceRaceSegment(chart);
693
- }
694
- }, 80);
695
- }
696
-
697
- // 格式化数值显示(如 28000 → 2.8万)
698
- function _formatGdpValue(value) {
699
- if (value >= 10000) return (value / 10000).toFixed(1) + '万';
700
- if (value >= 1000) return (value / 1000).toFixed(1) + '千';
701
- return '' + value;
702
- }
703
-
704
- // 渲染一帧
705
- function _renderRaceFrame(chart, keyframeIdx, values, chinaLabel, displayYear, isDark) {
706
- // 构建 {name, value, color, entity} 数组
707
- var pairs = [];
708
- for (var i = 0; i < RACE_ENTITIES.length; i++) {
709
- var entity = RACE_ENTITIES[i];
710
- var label = entity === 'china' ? chinaLabel : RACE_LABELS[entity];
711
- pairs.push({
712
- name: label,
713
- value: values[i],
714
- color: _entityColors[entity],
715
- entity: entity,
716
- });
717
- }
718
- // 按值排序(小的在下,大的在上)
719
- pairs = _.sortBy(pairs, 'value');
720
-
721
- var categories = [];
722
- var barData = [];
723
- for (var j = 0; j < pairs.length; j++) {
724
- categories.push(pairs[j].name);
725
- barData.push({
726
- value: pairs[j].value,
727
- itemStyle: { color: pairs[j].color, borderRadius: [0, 6, 6, 0] },
728
- });
729
- }
730
-
731
- // 年份显示
732
- var yearText = displayYear < 0 ? ('BC ' + Math.abs(displayYear)) : ('' + displayYear);
733
- var titleText = displayYear < 0
734
- ? ('公元前 ' + Math.abs(displayYear) + ' 年 · ' + chinaLabel)
735
- : ('公元 ' + displayYear + ' 年 · ' + chinaLabel);
736
-
737
- // 底部时间轴
738
- var timelineElements = _buildTimelineGraphic(chart, keyframeIdx, isDark);
739
-
740
- // 动态计算 xAxis max(取当前最大值的 1.3 倍,至少 500)
741
- var maxVal = 500;
742
- for (var m = 0; m < values.length; m++) {
743
- if (values[m] > maxVal) maxVal = values[m];
744
- }
745
- maxVal = Math.ceil(maxVal * 1.3 / 1000) * 1000;
746
-
747
- var option = {
748
- backgroundColor: 'transparent',
749
- title: {
750
- text: titleText,
751
- left: 'center',
752
- top: 6,
753
- textStyle: { fontSize: 18, fontWeight: 800, color: isDark ? '#ffffff' : '#1a1a2e' },
754
- },
755
- graphic: {
756
- elements: [{
757
- type: 'text',
758
- right: 30,
759
- bottom: 55,
760
- style: {
761
- text: yearText,
762
- fontSize: 90,
763
- fontWeight: 900,
764
- fill: isDark ? 'rgba(255,255,255,0.06)' : 'rgba(26,26,46,0.04)',
765
- textAlign: 'right',
766
- },
767
- z: 1,
768
- }].concat(timelineElements),
769
- },
770
- grid: { left: '12%', right: '15%', top: 45, bottom: '16%' },
771
- xAxis: {
772
- type: 'value',
773
- max: maxVal,
774
- axisLabel: {
775
- formatter: function(v) { return _formatGdpValue(v); },
776
- color: isDark ? 'rgba(255,255,255,0.5)' : 'rgba(26,26,46,0.5)',
777
- fontSize: 11,
778
- },
779
- splitLine: {
780
- lineStyle: { color: isDark ? 'rgba(255,255,255,0.06)' : 'rgba(26,26,46,0.06)' },
781
- },
782
- axisLine: { show: false },
783
- axisTick: { show: false },
784
- },
785
- yAxis: {
786
- type: 'category',
787
- data: categories,
788
- inverse: false,
789
- axisLabel: { fontSize: 13, fontWeight: 600, color: isDark ? '#ffffff' : '#1a1a2e' },
790
- axisTick: { show: false },
791
- axisLine: { show: false },
792
- },
793
- series: [{
794
- type: 'bar',
795
- data: barData,
796
- barWidth: '55%',
797
- label: {
798
- show: true,
799
- position: 'right',
800
- formatter: function(params) { return _formatGdpValue(params.value); },
801
- fontSize: 12,
802
- fontWeight: 700,
803
- color: isDark ? '#ffffff' : '#1a1a2e',
804
- },
805
- }],
806
- animationDuration: 0,
807
- animationDurationUpdate: 80,
808
- animationEasing: 'linear',
809
- animationEasingUpdate: 'linear',
810
- };
811
-
812
- chart.setOption(option, true);
813
- }
814
-
815
- // 构建底部时间轴 graphic 元素
816
- function _buildTimelineGraphic(chart, activeIdx, isDark) {
817
- var nodes = [];
818
- var totalNodes = RACE_KEYFRAMES.length;
819
- var chartWidth = chart.getWidth() || 800;
820
-
821
- // 底线
822
- nodes.push({
823
- type: 'line',
824
- position: ['10%', '93%'],
825
- shape: { x1: 0, y1: 0, x2: chartWidth * 0.8, y2: 0 },
826
- style: { stroke: isDark ? 'rgba(255,255,255,0.1)' : 'rgba(26,26,46,0.08)', lineWidth: 2 },
827
- z: 5,
828
- });
829
- // 进度线
830
- var progressX = totalNodes > 1 ? (activeIdx / (totalNodes - 1)) * chartWidth * 0.8 : 0;
831
- nodes.push({
832
- type: 'line',
833
- position: ['10%', '93%'],
834
- shape: { x1: 0, y1: 0, x2: progressX, y2: 0 },
835
- style: { stroke: '#0089ff', lineWidth: 2 },
836
- z: 6,
837
- });
838
-
839
- for (var t = 0; t < totalNodes; t++) {
840
- var isActive = t === activeIdx;
841
- var isPast = t < activeIdx;
842
- var nodeX = (t / (totalNodes - 1)) * 80 + 10;
843
- var yr = RACE_KEYFRAMES[t].year;
844
- var yrLabel = yr < 0 ? ('BC' + Math.abs(yr)) : ('' + yr);
845
-
846
- nodes.push({
847
- type: 'circle',
848
- shape: { cx: 0, cy: 0, r: isActive ? 5 : 2.5 },
849
- position: [nodeX + '%', '93%'],
850
- style: {
851
- fill: isActive ? '#0089ff' : (isPast ? (isDark ? 'rgba(255,255,255,0.5)' : 'rgba(26,26,46,0.4)') : (isDark ? 'rgba(255,255,255,0.15)' : 'rgba(26,26,46,0.12)')),
852
- },
853
- z: 10,
854
- });
855
-
856
- if (isActive || t === 0 || t === totalNodes - 1 || t % 5 === 0) {
857
- nodes.push({
858
- type: 'text',
859
- position: [nodeX + '%', '97%'],
860
- style: {
861
- text: yrLabel,
862
- fontSize: isActive ? 10 : 8,
863
- fontWeight: isActive ? 700 : 400,
864
- fill: isActive ? '#0089ff' : (isDark ? 'rgba(255,255,255,0.35)' : 'rgba(26,26,46,0.3)'),
865
- textAlign: 'center',
866
- },
867
- z: 10,
868
- });
869
- }
870
- }
871
- return nodes;
872
- }
873
-
874
- // 播放完毕后在图表中央显示重播按钮
875
- function _showReplayButton(chart) {
876
- var isDark = _customState.darkMode;
877
- chart.setOption({
878
- graphic: {
879
- elements: [
880
- {
881
- type: 'circle',
882
- shape: { cx: 0, cy: 0, r: 36 },
883
- left: 'center',
884
- top: 'middle',
885
- style: {
886
- fill: isDark ? 'rgba(0,137,255,0.9)' : 'rgba(0,137,255,0.85)',
887
- shadowBlur: 20,
888
- shadowColor: 'rgba(0,137,255,0.3)',
889
- },
890
- cursor: 'pointer',
891
- onclick: function() { _replayRace(chart); },
892
- z: 100,
893
- },
894
- {
895
- type: 'text',
896
- left: 'center',
897
- top: 'middle',
898
- style: {
899
- text: '▶',
900
- fontSize: 28,
901
- fill: '#ffffff',
902
- textAlign: 'center',
903
- textVerticalAlign: 'middle',
904
- },
905
- cursor: 'pointer',
906
- onclick: function() { _replayRace(chart); },
907
- z: 101,
908
- },
909
- ],
910
- },
911
- });
912
- }
913
-
914
- // 重新播放
915
- function _replayRace(chart) {
916
- // 先清理旧的播放定时器,防止多个 interval 并行
917
- if (_customState.raceYearTimer) {
918
- clearInterval(_customState.raceYearTimer);
919
- _customState.raceYearTimer = null;
920
- }
921
- _customState.raceIndex = 0;
922
- _customState.raceFinished = false;
923
- var isDark = _customState.darkMode;
924
- _renderRaceFrame(chart, 0, RACE_KEYFRAMES[0].values, RACE_KEYFRAMES[0].chinaLabel, RACE_KEYFRAMES[0].year, isDark);
925
- _advanceRaceSegment(chart);
926
- }
927
-
928
- function _destroyEchartsRace() {
929
- if (_customState.echartsInitTimer) {
930
- clearTimeout(_customState.echartsInitTimer);
931
- _customState.echartsInitTimer = null;
932
- }
933
- if (_customState.raceYearTimer) {
934
- clearInterval(_customState.raceYearTimer);
935
- _customState.raceYearTimer = null;
936
- }
937
- if (_customState.raceTimer) {
938
- clearTimeout(_customState.raceTimer);
939
- _customState.raceTimer = null;
940
- }
941
- if (_customState.echartsInstance) {
942
- _customState.echartsInstance.dispose();
943
- _customState.echartsInstance = null;
944
- }
945
- _customState.raceIndex = 0;
946
- _customState.raceFinished = false;
947
- }
948
-
949
- export function didUnmount() {
950
- window.removeEventListener('hashchange', this._handleHashChange);
951
- document.removeEventListener('keydown', this._handleKeyDown);
952
- document.removeEventListener('touchstart', this._handleTouchStart);
953
- document.removeEventListener('touchend', this._handleTouchEnd);
954
- document.removeEventListener('mousemove', this._handleMouseMove);
955
- document.removeEventListener('fullscreenchange', this._handleFullscreenChange);
956
- if (_customState.numTimer) {
957
- clearTimeout(_customState.numTimer);
958
- }
959
- _destroyEchartsRace();
960
- }
961
-
962
- export function getCustomState(key) {
963
- if (key) return _customState[key];
964
- return _.clone(_customState);
965
- }
966
-
967
- export function setCustomState(newState) {
968
- _.assign(_customState, newState);
969
- this.forceUpdate();
970
- }
971
-
972
- export function forceUpdate() {
973
- this.setState({ timestamp: new Date().getTime() });
974
- }
975
-
976
- // ── 主渲染函数 ──────────────────────────────────────────────
977
- export function renderJsx() {
978
- var state = _customState;
979
- var slideData = SLIDES[state.currentIndex];
980
- var slideBg = state.darkMode ? slideData.bg : (slideData.bgLight || slideData.bg);
981
- var accent = slideData.accent || '#0089ff';
982
- var isMobile = this.utils.isMobile();
983
- var total = SLIDES.length;
984
- var self = this;
985
- var lang = I18N[state.lang] || I18N.zh;
986
-
987
- // 构造当前 slide 对象(用动态 bg 替换原始 bg)
988
- var slide = {};
989
- for (var k in slideData) { slide[k] = slideData[k]; }
990
- slide.bg = slideBg;
991
-
992
- var isDarkSlide = slideBg !== '#ffffff' && slideBg !== '#f0f7ff';
993
-
994
- // ── 事件处理函数(顶部定义,避免内联创建)──
995
- var handlePrev = function() {
996
- if (state.currentIndex > 0) {
997
- state.currentIndex--;
998
- self.forceUpdate();
999
- }
1000
- };
1001
- var handleNext = function() {
1002
- if (state.currentIndex < total - 1) {
1003
- state.currentIndex++;
1004
- self.forceUpdate();
1005
- }
1006
- };
1007
- var handleToggleFullscreen = function() {
1008
- if (!document.fullscreenElement) {
1009
- document.documentElement.requestFullscreen().catch(function() {});
1010
- } else {
1011
- document.exitFullscreen().catch(function() {});
1012
- }
1013
- };
1014
- var handleLangSwitch = function() {
1015
- state.lang = state.lang === 'zh' ? 'en' : 'zh';
1016
- self.forceUpdate();
1017
- };
1018
- var handleToggleDarkMode = function() {
1019
- state.darkMode = !state.darkMode;
1020
- _destroyEchartsRace();
1021
- self.forceUpdate();
1022
- };
1023
-
1024
- // ── 同步 URL hash(翻页时更新,方便分享定位)──
1025
- var expectedHash = '#' + (state.currentIndex + 1);
1026
- if (window.location.hash !== expectedHash) {
1027
- history.replaceState(null, '', expectedHash);
1028
- }
1029
-
1030
- // ── 每次渲染后检测是否需要初始化/销毁 ECharts ──
1031
- if (_customState.echartsInitTimer) {
1032
- clearTimeout(_customState.echartsInitTimer);
1033
- }
1034
- _customState.echartsInitTimer = setTimeout(function() {
1035
- _customState.echartsInitTimer = null;
1036
- _tryInitEchartsRace();
1037
- }, 100);
1038
-
1039
- // ── 导航栏样式(默认隐藏,鼠标移到底部显示)──
1040
- var navStyle = {
1041
- position: 'absolute',
1042
- bottom: 0,
1043
- left: 0,
1044
- right: 0,
1045
- padding: '16px 0',
1046
- display: 'flex',
1047
- justifyContent: 'center',
1048
- alignItems: 'center',
1049
- gap: '16px',
1050
- background: isDarkSlide ? 'linear-gradient(transparent, rgba(0,0,0,0.3))' : 'linear-gradient(transparent, rgba(0,0,0,0.05))',
1051
- opacity: state.navVisible ? 1 : 0,
1052
- transform: state.navVisible ? 'translateY(0)' : 'translateY(10px)',
1053
- transition: 'opacity 0.3s ease, transform 0.3s ease',
1054
- pointerEvents: state.navVisible ? 'auto' : 'none',
1055
- };
1056
-
1057
- // ── 分页点 ──
1058
- var handleDotClick = function(idx) {
1059
- return function() {
1060
- state.currentIndex = idx;
1061
- self.forceUpdate();
1062
- };
1063
- };
1064
- var dots = [];
1065
- var maxVisible = 7;
1066
- var dotStart = Math.max(0, Math.min(state.currentIndex - Math.floor(maxVisible / 2), total - maxVisible));
1067
- var dotEnd = Math.min(total, dotStart + maxVisible);
1068
- for (var i = dotStart; i < dotEnd; i++) {
1069
- var isActive = i === state.currentIndex;
1070
- dots.push(
1071
- <div
1072
- key={i}
1073
- style={{
1074
- width: isActive ? '24px' : '7px',
1075
- height: '7px',
1076
- borderRadius: '4px',
1077
- background: isActive ? accent : (isDarkSlide ? 'rgba(255,255,255,0.25)' : 'rgba(26,26,46,0.2)'),
1078
- transition: 'all 0.3s ease',
1079
- cursor: 'pointer',
1080
- }}
1081
- onClick={handleDotClick(i)}
1082
- />
1083
- );
1084
- }
1085
-
1086
- return (
1087
- <div style={{
1088
- position: 'fixed', top: 0, left: 0, right: 0, bottom: 0,
1089
- background: slide.bg, overflow: 'hidden',
1090
- padding: '0 !important', borderRadius: '0 !important', margin: '0 !important',
1091
- }}>
1092
- {/* 隐藏时间戳(触发重渲染)*/}
1093
- <div style={{ display: 'none' }}>{this.state.timestamp}</div>
1094
-
1095
- {/* 隐藏宜搭低代码开发工具开关 */}
1096
- <style>{'\
1097
- #__lowcode_devtool_switch__,\
1098
- [id="__lowcode_devtool_switch__"] {\
1099
- display: none !important;\
1100
- visibility: hidden !important;\
1101
- opacity: 0 !important;\
1102
- pointer-events: none !important;\
1103
- }\
1104
- '}</style>
1105
-
1106
- {/* ── 右上角工具栏:深浅切换 + 语言切换 + 全屏按钮 ── */}
1107
- <div style={{
1108
- position: 'absolute', top: '16px', right: '16px',
1109
- display: 'flex', gap: '8px', zIndex: 100,
1110
- }}>
1111
- <div
1112
- onClick={(e) => { handleToggleDarkMode(); }}
1113
- style={{
1114
- width: '36px', height: '36px', borderRadius: '8px',
1115
- background: isDarkSlide ? 'rgba(255,255,255,0.1)' : 'rgba(26,26,46,0.06)',
1116
- display: 'flex', alignItems: 'center', justifyContent: 'center',
1117
- cursor: 'pointer', fontSize: '16px',
1118
- color: isDarkSlide ? '#ffffff' : '#1a1a2e',
1119
- }}
1120
- title={state.darkMode ? lang.lightMode : lang.darkMode}
1121
- >
1122
- {state.darkMode ? '☀️' : '🌙'}
1123
- </div>
1124
- <div
1125
- onClick={(e) => { handleLangSwitch(); }}
1126
- style={{
1127
- height: '36px', padding: '0 12px', borderRadius: '8px',
1128
- background: isDarkSlide ? 'rgba(255,255,255,0.1)' : 'rgba(26,26,46,0.06)',
1129
- display: 'flex', alignItems: 'center', justifyContent: 'center',
1130
- cursor: 'pointer', fontSize: '13px', fontWeight: 600,
1131
- color: isDarkSlide ? '#ffffff' : '#1a1a2e',
1132
- }}
1133
- >
1134
- {lang.langSwitch}
1135
- </div>
1136
- <div
1137
- onClick={(e) => { handleToggleFullscreen(); }}
1138
- style={{
1139
- width: '36px', height: '36px', borderRadius: '8px',
1140
- background: isDarkSlide ? 'rgba(255,255,255,0.1)' : 'rgba(26,26,46,0.06)',
1141
- display: 'flex', alignItems: 'center', justifyContent: 'center',
1142
- cursor: 'pointer', fontSize: '16px',
1143
- color: isDarkSlide ? '#ffffff' : '#1a1a2e',
1144
- }}
1145
- title={state.isFullscreen ? lang.exitFullscreen : lang.fullscreen}
1146
- >
1147
- {state.isFullscreen ? '⊡' : '⛶'}
1148
- </div>
1149
- </div>
1150
-
1151
- {/* ── 幻灯片内容区 ── */}
1152
- {renderSlideContent(slide, accent, isMobile)}
1153
-
1154
- {/* ── 导航栏(默认隐藏,鼠标移到底部显示)── */}
1155
- <div style={navStyle}>
1156
- <button
1157
- onClick={(e) => { handlePrev(); }}
1158
- style={{
1159
- padding: '8px 20px', borderRadius: '20px',
1160
- border: isDarkSlide ? '1px solid rgba(255,255,255,0.2)' : '1px solid #d9d9d9',
1161
- cursor: 'pointer',
1162
- background: isDarkSlide ? 'rgba(255,255,255,0.1)' : '#fff',
1163
- color: isDarkSlide ? '#fff' : '#333',
1164
- fontSize: '14px',
1165
- }}
1166
- >
1167
- {lang.prev}
1168
- </button>
1169
-
1170
- {/* 分页点 */}
1171
- <div style={{ display: 'flex', gap: '6px', alignItems: 'center' }}>
1172
- {dots}
1173
- </div>
1174
-
1175
- <span style={{ lineHeight: '36px', color: isDarkSlide ? 'rgba(255,255,255,0.6)' : '#666', fontSize: '14px', minWidth: '60px', textAlign: 'center' }}>
1176
- {lang.pageOf(state.currentIndex + 1, total)}
1177
- </span>
1178
-
1179
- <button
1180
- onClick={(e) => { handleNext(); }}
1181
- style={{
1182
- padding: '8px 20px', borderRadius: '20px',
1183
- border: 'none', cursor: 'pointer',
1184
- background: accent, color: '#fff', fontSize: '14px',
1185
- }}
1186
- >
1187
- {lang.next}
1188
- </button>
1189
- </div>
1190
- </div>
1191
- );
1192
- }