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 +13 -12
- package/package.json +2 -2
- package/panrouter-tray.vbs +18 -0
- package/panrouter-tray.bat +0 -26
package/cli.mjs
CHANGED
|
@@ -141,28 +141,29 @@ async function startServer() {
|
|
|
141
141
|
// ─── 4. 以托盘模式启动 ──────────────────────────────────────────────────
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* 用 VBS 隐藏启动 server + PS tray (Windows 原生, 最可靠)
|
|
145
145
|
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
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
|
-
*
|
|
152
|
-
* 不依赖
|
|
152
|
+
* WScript.Shell.Run 0 是 Windows 最可靠的隐藏启动方式,
|
|
153
|
+
* 不依赖 spawn 的 detached/Window Station 行为。
|
|
153
154
|
*/
|
|
154
155
|
function startTray() {
|
|
155
|
-
const
|
|
156
|
+
const vbsPath = path.join(__dirname, "panrouter-tray.vbs");
|
|
156
157
|
|
|
157
|
-
if (!fs.existsSync(
|
|
158
|
-
log("!!", "未找到 panrouter-tray.
|
|
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
|
-
|
|
165
|
-
|
|
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.
|
|
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.
|
|
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
|
package/panrouter-tray.bat
DELETED
|
@@ -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 立即结束 (不影响后台进程)
|