From d48b22c656e7ce3dc5f4a8786ec2e0b95d920d15 Mon Sep 17 00:00:00 2001 From: YHH <359807859@qq.com> Date: Sun, 28 Sep 2025 21:00:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0demo=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/public/demos/worker-system/index.html | 2 ++ scripts/update-worker-demo.js | 33 +++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/docs/public/demos/worker-system/index.html b/docs/public/demos/worker-system/index.html index 3fe386cf..d8706b9d 100644 --- a/docs/public/demos/worker-system/index.html +++ b/docs/public/demos/worker-system/index.html @@ -139,6 +139,7 @@
+
@@ -164,6 +165,7 @@
实体数量: 0
Worker状态: 未启用
Worker负载: N/A
+
运行模式: 同步模式
物理系统耗时: 0ms
渲染系统耗时: 0ms
总帧时间: 0ms
diff --git a/scripts/update-worker-demo.js b/scripts/update-worker-demo.js index 1f2133eb..1e3fb76d 100644 --- a/scripts/update-worker-demo.js +++ b/scripts/update-worker-demo.js @@ -47,18 +47,37 @@ function updateWorkerDemo() { fs.copyFileSync(sourcePath, targetPath); console.log(`📁 复制新文件: ${newJsFile}`); - // 3. 更新 index.html 中的引用 - const indexHtmlPath = path.join(VITEPRESS_DEMO_DIR, 'index.html'); - if (fs.existsSync(indexHtmlPath)) { - let content = fs.readFileSync(indexHtmlPath, 'utf-8'); + // 3. 同步 HTML 结构更新 + const sourceIndexPath = path.join(DEMO_DIST_DIR, 'index.html'); + const targetIndexPath = path.join(VITEPRESS_DEMO_DIR, 'index.html'); + + if (fs.existsSync(sourceIndexPath) && fs.existsSync(targetIndexPath)) { + const sourceContent = fs.readFileSync(sourceIndexPath, 'utf-8'); + let targetContent = fs.readFileSync(targetIndexPath, 'utf-8'); + + // 提取 controls 部分 + const sourceControlsMatch = sourceContent.match(/
([\s\S]*?)<\/div>\s*<\/div>/); + const targetControlsMatch = targetContent.match(/
([\s\S]*?)<\/div>\s*<\/div>/); + + if (sourceControlsMatch && targetControlsMatch) { + targetContent = targetContent.replace(targetControlsMatch[0], sourceControlsMatch[0]); + } + + // 提取 stats 部分 + const sourceStatsMatch = sourceContent.match(/
([\s\S]*?)<\/div>/); + const targetStatsMatch = targetContent.match(/
([\s\S]*?)<\/div>/); + + if (sourceStatsMatch && targetStatsMatch) { + targetContent = targetContent.replace(targetStatsMatch[0], sourceStatsMatch[0]); + } // 更新 script 标签中的文件名 const scriptRegex = /src="\/ecs-framework\/demos\/worker-system\/assets\/index-[^"]+\.js"/; const newScriptSrc = `/ecs-framework/demos/worker-system/assets/${newJsFile}`; - content = content.replace(scriptRegex, `src="${newScriptSrc}"`); + targetContent = targetContent.replace(scriptRegex, `src="${newScriptSrc}"`); - fs.writeFileSync(indexHtmlPath, content); - console.log(`📝 更新 index.html 引用: ${newJsFile}`); + fs.writeFileSync(targetIndexPath, targetContent); + console.log(`📝 更新 index.html 结构和引用: ${newJsFile}`); } console.log('✅ Worker System Demo 资源更新完成!');