panrouter 1.5.0 → 1.5.1

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.
package/cli.mjs CHANGED
@@ -141,28 +141,29 @@ async function startServer() {
141
141
  // ─── 4. 以托盘模式启动 ──────────────────────────────────────────────────
142
142
 
143
143
  /**
144
- * 启动策略 (Windows BAT 原生方式):
144
+ * VBS 隐藏启动 server + PS tray (Windows 原生, 最可靠)
145
145
  *
146
- * cli.mjs ─spawn(detached)──→ cmd /c panrouter-tray.bat
147
- * ├─ start /B → node server.mjs (后台隐藏)
148
- * └─ start /B powershell tray-daemon.ps1 (后台无窗口)
149
- * └─ NotifyIcon
146
+ * panrouter --tray
147
+ * └─ wscript.exe panrouter-tray.vbs (WScript.Shell.Run, 隐藏)
148
+ * ├─ node server.mjs (run 0 = 完全隐藏)
149
+ * └─ powershell tray-daemon.ps1 (run 0 = 完全隐藏)
150
+ * └─ NotifyIcon ✓
150
151
  *
151
- * cmd /c start /B 是 Windows 最原生的后台/隐藏启动方式,
152
- * 不依赖 detached vs non-detachedWindow Station 差异。
152
+ * WScript.Shell.Run 0 是 Windows 最可靠的隐藏启动方式,
153
+ * 不依赖 spawn detached/Window Station 行为。
153
154
  */
154
155
  function startTray() {
155
- const batPath = path.join(__dirname, "panrouter-tray.bat");
156
+ const vbsPath = path.join(__dirname, "panrouter-tray.vbs");
156
157
 
157
- if (!fs.existsSync(batPath)) {
158
- log("!!", "未找到 panrouter-tray.bat", "red");
158
+ if (!fs.existsSync(vbsPath)) {
159
+ log("!!", "未找到 panrouter-tray.vbs", "red");
159
160
  process.exit(1);
160
161
  }
161
162
 
162
163
  log("..", "正在以托盘模式启动 Pan Router...", "yellow");
163
164
 
164
- const child = spawn("cmd.exe", ["/c", batPath], {
165
- cwd: __dirname,
165
+ // wscript //B = 批处理模式 (无窗口, 无交互)
166
+ const child = spawn("wscript.exe", ["//B", "//NoLogo", vbsPath], {
166
167
  stdio: "ignore",
167
168
  windowsHide: true,
168
169
  detached: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "panrouter",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "让 Claude Code 免费使用 DeepSeek 等模型,无需 API Key",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "cli.mjs",
11
11
  "server.mjs",
12
12
  "tray-daemon.ps1",
13
- "panrouter-tray.bat"
13
+ "panrouter-tray.vbs"
14
14
  ],
15
15
  "license": "MIT"
16
16
  }
@@ -0,0 +1,18 @@
1
+ ' Pan Router 隐藏启动器
2
+ ' 用 WScript.Shell.Run 的 0 (隐藏) 启动后台进程
3
+ ' Windows 原生, 最可靠的方式
4
+
5
+ Dim WshShell, FSO, ScriptDir
6
+ Set WshShell = CreateObject("WScript.Shell")
7
+ Set FSO = CreateObject("Scripting.FileSystemObject")
8
+
9
+ ScriptDir = FSO.GetParentFolderName(WScript.ScriptFullName)
10
+
11
+ ' 0 = 隐藏窗口, False = 不等待返回
12
+ WshShell.Run "node """ & ScriptDir & "\server.mjs""", 0, False
13
+
14
+ ' 等 3 秒让服务器启动
15
+ WScript.Sleep 3000
16
+
17
+ ' 启动 PS 托盘 (无窗口)
18
+ WshShell.Run "powershell -ExecutionPolicy Bypass -WindowStyle Hidden -STA -File """ & ScriptDir & "\tray-daemon.ps1""", 0, False
@@ -1,26 +0,0 @@
1
- @echo off
2
- rem Pan Router Tray Launcher (Windows 原生 BAT, 最可靠方式)
3
-
4
- setlocal
5
- set "SCRIPT_DIR=%~dp0"
6
-
7
- rem 1. 清理旧 server.mjs 进程
8
- for /f "tokens=2 delims=," %%a in ('wmic process where "name='node.exe'" get ProcessId^,CommandLine /format:csv 2^>nul ^| findstr "server.mjs"') do (
9
- taskkill /f /pid %%a >nul 2>&1
10
- )
11
-
12
- rem 2. 后台隐藏启动 server.mjs (start /B = 不创建新窗口, 同一控制台后台)
13
- start /B node "%SCRIPT_DIR%server.mjs"
14
-
15
- rem 3. 等待服务器就绪 (最久 5 秒)
16
- for /l %%i in (1,1,5) do (
17
- >nul 2>&1 %WINDIR%\System32\curl.exe -s http://127.0.0.1:50816/health && goto :ready
18
- >nul 2>&1 %WINDIR%\System32\timeout.exe /t 1 /nobreak
19
- )
20
-
21
- :ready
22
-
23
- rem 4. 启动 PS 托盘 (无窗口后台)
24
- start /B powershell -ExecutionPolicy Bypass -WindowStyle Hidden -STA -File "%SCRIPT_DIR%tray-daemon.ps1"
25
-
26
- rem 5. BAT 立即结束 (不影响后台进程)