feat(mirror): 探针自动加载并转储(/probe_railgun.js 路由 + 加载器引入)
- tools/serve.js: 新增 /probe_railgun.js 路由,读 sockets/probe_railgun.js - main.9f4e7a89.js: 等 __gameMode__ 就绪后自动 fetch+eval 探针(localStorage.hornetProbe='0' 可关闭),数据走 POST /__probe__ 落盘 3DTank/names/probe_railgun.log,省去每次手粘控制台
This commit is contained in:
1 parent
09f8769585
commit
dfdd69b375
2 files changed
+39
No files matched your search
@@ -232,6 +232,23 @@ const Server = http.createServer((Req, Res) => {
|
|||||||
}).end(Hook);
|
}).end(Hook);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// /probe_railgun.js:武器链路现场探针(只读采样 + WS 上行记录,数据 POST /__probe__ 落盘)
|
||||||
|
// 由加载器自动引入(localStorage.hornetProbe='0' 可关闭),省去每次手粘控制台。
|
||||||
|
if (UrlPath.split('?')[0] === '/probe_railgun.js') {
|
||||||
|
const ProbeFile = path.join(ROOT, 'sockets', 'probe_railgun.js');
|
||||||
|
if (!fs.existsSync(ProbeFile)) {
|
||||||
|
Res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' }).end('probe_railgun.js not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const Probe = fs.readFileSync(ProbeFile);
|
||||||
|
Res.writeHead(200, {
|
||||||
|
'Content-Type': 'application/javascript; charset=utf-8',
|
||||||
|
'Content-Length': Probe.length,
|
||||||
|
'Cache-Control': 'no-cache',
|
||||||
|
'X-Hornet-Probe': 'local',
|
||||||
|
}).end(Probe);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// /__probe__:页面内探针的**网络转储**入口(控制台刷屏太扰,改为 POST 落盘)
|
// /__probe__:页面内探针的**网络转储**入口(控制台刷屏太扰,改为 POST 落盘)
|
||||||
// 探针(sockets/probe_railgun.js)把组件清单与采样分批 POST 到这里,
|
// 探针(sockets/probe_railgun.js)把组件清单与采样分批 POST 到这里,
|
||||||
// 这里追加写入 3DTank/names/probe_railgun.log,供离线分析。
|
// 这里追加写入 3DTank/names/probe_railgun.log,供离线分析。
|
||||||
|
|||||||
@@ -152,6 +152,28 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===== 自动加载武器链路探针(默认开;localStorage.hornetProbe='0' 关闭)=====
|
||||||
|
// 开关只能用 localStorage:hash 会被游戏当路由(进不去战场),查询串会被当 config 参数(握手 1005)。
|
||||||
|
// 探针数据走 POST /__probe__ 落盘到 3DTank/names/probe_railgun.log,不刷控制台。
|
||||||
|
if (localStorage.getItem('hornetProbe') !== '0') {
|
||||||
|
(async () => {
|
||||||
|
for (let i = 0; i < 900; i++) { // 等进战场(最多 15 分钟)
|
||||||
|
if (window.__gameMode__) break;
|
||||||
|
await new Promise((R) => setTimeout(R, 1000));
|
||||||
|
}
|
||||||
|
if (!window.__gameMode__) { console.warn('[Hornet] 探针跳过:等不到 __gameMode__'); return; }
|
||||||
|
try {
|
||||||
|
const __probe_resp__ = await fetch('/probe_railgun.js', { cache: 'no-cache' });
|
||||||
|
if (__probe_resp__.ok) {
|
||||||
|
(0, eval)(await __probe_resp__.text());
|
||||||
|
console.log('[Hornet] 探针已自动加载并开始转储(localStorage.hornetProbe="0" 可关闭)');
|
||||||
|
} else {
|
||||||
|
console.warn('[Hornet] 探针加载失败: HTTP ' + __probe_resp__.status);
|
||||||
|
}
|
||||||
|
} catch (__probe_err__) { console.warn('[Hornet] 探针加载异常:', __probe_err__); }
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
// ===== Service Worker:已从模板移除(排查断联用,避免单包缓存接管干扰)=====
|
// ===== Service Worker:已从模板移除(排查断联用,避免单包缓存接管干扰)=====
|
||||||
// 需要恢复时见 git 历史(tools/split.js 模板);hornet_sw.js 本体与 serve.js 的 /hornet_sw.js 路由保留未删。
|
// 需要恢复时见 git 历史(tools/split.js 模板);hornet_sw.js 本体与 serve.js 的 /hornet_sw.js 路由保留未删。
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user