加入默认的破限制提示词,修改显示,支持桌面端

This commit is contained in:
yang committed 2026-08-31 13:51:58 +08:00
1 parent d488eaa30c
commit 5d2cb636f5
13 files changed
+2064 -838

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
// Spawned by /dsh-purge/restart: wait until the old web port is free, then relaunch.
import net from "node:net";
import { spawn } from "node:child_process";
const encoded = process.env.DSH_PURGE_RESTART;
if (!encoded) process.exit(1);
let info;
try {
info = JSON.parse(encoded);
} catch {
process.exit(1);
}
const port = Number(info.port) || 3080;
const host = typeof info.host === "string" && info.host ? info.host : "127.0.0.1";
function portFree() {
return new Promise((resolve) => {
const socket = net.createConnection({ host, port }, () => {
socket.destroy();
resolve(false);
});
socket.on("error", () => resolve(true));
});
}
async function waitFree() {
for (let i = 0; i < 80; i++) {
if (await portFree()) return true;
await new Promise((r) => setTimeout(r, 120));
}
return false;
}
const ok = await waitFree();
if (!ok) process.exit(1);
const child = spawn(info.execPath, info.argv, {
detached: true,
stdio: "ignore",
cwd: info.cwd || process.cwd(),
env: process.env,
windowsHide: true,
});
child.unref();
process.exit(0);