更新demo界面

This commit is contained in:
YHH
2025-09-28 21:00:28 +08:00
parent 727b1864eb
commit d48b22c656
2 changed files with 28 additions and 7 deletions

View File

@@ -139,6 +139,7 @@
<div class="control-group"> <div class="control-group">
<label>Worker 设置:</label> <label>Worker 设置:</label>
<button id="toggleWorker">禁用 Worker</button> <button id="toggleWorker">禁用 Worker</button>
<button id="toggleSAB">禁用 SharedArrayBuffer</button>
</div> </div>
<div class="control-group"> <div class="control-group">
@@ -164,6 +165,7 @@
<div class="stat-line">实体数量: <span id="entityCountStat">0</span></div> <div class="stat-line">实体数量: <span id="entityCountStat">0</span></div>
<div class="stat-line">Worker状态: <span id="workerStatus" class="worker-disabled">未启用</span></div> <div class="stat-line">Worker状态: <span id="workerStatus" class="worker-disabled">未启用</span></div>
<div class="stat-line">Worker负载: <span id="workerLoad">N/A</span></div> <div class="stat-line">Worker负载: <span id="workerLoad">N/A</span></div>
<div class="stat-line">运行模式: <span id="sabStatus" class="worker-disabled">同步模式</span></div>
<div class="stat-line">物理系统耗时: <span id="physicsTime">0</span>ms</div> <div class="stat-line">物理系统耗时: <span id="physicsTime">0</span>ms</div>
<div class="stat-line">渲染系统耗时: <span id="renderTime">0</span>ms</div> <div class="stat-line">渲染系统耗时: <span id="renderTime">0</span>ms</div>
<div class="stat-line">总帧时间: <span id="frameTime">0</span>ms</div> <div class="stat-line">总帧时间: <span id="frameTime">0</span>ms</div>

View File

@@ -47,18 +47,37 @@ function updateWorkerDemo() {
fs.copyFileSync(sourcePath, targetPath); fs.copyFileSync(sourcePath, targetPath);
console.log(`📁 复制新文件: ${newJsFile}`); console.log(`📁 复制新文件: ${newJsFile}`);
// 3. 更新 index.html 中的引用 // 3. 同步 HTML 结构更新
const indexHtmlPath = path.join(VITEPRESS_DEMO_DIR, 'index.html'); const sourceIndexPath = path.join(DEMO_DIST_DIR, 'index.html');
if (fs.existsSync(indexHtmlPath)) { const targetIndexPath = path.join(VITEPRESS_DEMO_DIR, 'index.html');
let content = fs.readFileSync(indexHtmlPath, 'utf-8');
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(/<div class="controls">([\s\S]*?)<\/div>\s*<\/div>/);
const targetControlsMatch = targetContent.match(/<div class="controls">([\s\S]*?)<\/div>\s*<\/div>/);
if (sourceControlsMatch && targetControlsMatch) {
targetContent = targetContent.replace(targetControlsMatch[0], sourceControlsMatch[0]);
}
// 提取 stats 部分
const sourceStatsMatch = sourceContent.match(/<div class="stats">([\s\S]*?)<\/div>/);
const targetStatsMatch = targetContent.match(/<div class="stats">([\s\S]*?)<\/div>/);
if (sourceStatsMatch && targetStatsMatch) {
targetContent = targetContent.replace(targetStatsMatch[0], sourceStatsMatch[0]);
}
// 更新 script 标签中的文件名 // 更新 script 标签中的文件名
const scriptRegex = /src="\/ecs-framework\/demos\/worker-system\/assets\/index-[^"]+\.js"/; const scriptRegex = /src="\/ecs-framework\/demos\/worker-system\/assets\/index-[^"]+\.js"/;
const newScriptSrc = `/ecs-framework/demos/worker-system/assets/${newJsFile}`; 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); fs.writeFileSync(targetIndexPath, targetContent);
console.log(`📝 更新 index.html 引用: ${newJsFile}`); console.log(`📝 更新 index.html 结构和引用: ${newJsFile}`);
} }
console.log('✅ Worker System Demo 资源更新完成!'); console.log('✅ Worker System Demo 资源更新完成!');