panrouter 1.0.1 → 1.0.2

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 (2) hide show
  1. package/cli.js +18 -14
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -109,23 +109,27 @@ function startServer() {
109
109
 
110
110
  log("..", "正在启动 Pan Router(端口 50816)...", "yellow");
111
111
 
112
- // 后台启动,不阻塞终端
113
- const child = spawn("node", [serverPath], {
114
- cwd: __dirname,
115
- stdio: "ignore",
116
- detached: true,
117
- });
118
- child.unref();
119
-
120
- // 等 2 秒确认启动
121
- setTimeout(() => {
112
+ // Windows: 用 start 命令开新窗口,不依赖 node 后台进程
113
+ if (process.platform === "win32") {
114
+ execSync(`start "Pan Router" cmd /c "node "${serverPath}" & pause"`, { stdio: "pipe" });
115
+ } else {
116
+ const child = spawn("node", [serverPath], { cwd: __dirname, stdio: "ignore", detached: true });
117
+ child.unref();
118
+ }
119
+
120
+ // 等待服务启动
121
+ for (let i = 0; i < 15; i++) {
122
122
  try {
123
- const req = http.get("http://127.0.0.1:50816/health", () => {});
123
+ const req = http.get("http://127.0.0.1:50816/health", (res) => {});
124
124
  req.on("error", () => {});
125
+ const check = await new Promise(rs => { req.on("response", () => rs(true)); req.on("error", () => rs(false)); setTimeout(() => rs(false), 1000); });
126
+ if (check) { break; }
125
127
  } catch {}
126
- log("OK", "Pan Router 已启动(端口 50816)", "green");
127
- console.log("\n 现在可以运行: \x1b[33mclaude \"你好\"\x1b[0m\n");
128
- }, 2000);
128
+ await new Promise(rs => setTimeout(rs, 1000));
129
+ }
130
+
131
+ log("OK", "Pan Router 已启动(端口 50816)", "green");
132
+ console.log("\n 现在可以运行: \x1b[33mclaude \"你好\"\x1b[0m\n");
129
133
  }
130
134
 
131
135
  // ─── 主流程 ──────────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "panrouter",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "让 Claude Code 免费使用 DeepSeek 等模型,无需 API Key",
5
5
  "type": "module",
6
6
  "bin": {