tt-help-cli-ycl 1.3.75 → 1.3.76
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/package.json +1 -1
- package/src/cli/open.js +4 -2
- package/src/lib/browser/cdp.js +7 -2
package/package.json
CHANGED
package/src/cli/open.js
CHANGED
|
@@ -94,10 +94,12 @@ export async function handleOpen(parsed) {
|
|
|
94
94
|
process.on("SIGINT", async () => {
|
|
95
95
|
console.error("\n正在关闭浏览器...");
|
|
96
96
|
try {
|
|
97
|
+
console.error(`[SIGINT] 正在终止 Edge 进程 (userDataDir: ${userDataDir})`);
|
|
97
98
|
await killEdgeProcesses(userDataDir);
|
|
99
|
+
console.error("[SIGINT] Edge 进程已终止,正在关闭浏览器连接...");
|
|
98
100
|
await browser.close();
|
|
99
|
-
} catch {
|
|
100
|
-
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(`[SIGINT] 关闭浏览器时出错: ${e.message}`);
|
|
101
103
|
}
|
|
102
104
|
console.error("浏览器已关闭");
|
|
103
105
|
process.exit(0);
|
package/src/lib/browser/cdp.js
CHANGED
|
@@ -109,12 +109,15 @@ function killEdgeProcesses(targetDir) {
|
|
|
109
109
|
const ps1Content =
|
|
110
110
|
`$procs = Get-CimInstance Win32_Process -Filter "Name='msedge.exe'" 2>$null; ` +
|
|
111
111
|
`$count = 0; ` +
|
|
112
|
+
`$pids = @(); ` +
|
|
112
113
|
`foreach ($p in $procs) { ` +
|
|
113
114
|
` if ($p.CommandLine -and $p.CommandLine -like "*${escapedDir}*") { ` +
|
|
114
|
-
`
|
|
115
|
+
` $pids += $p.ProcessId; ` +
|
|
116
|
+
` Stop-Process -Id $p.ProcessId -Force -ErrorAction SilentlyContinue; ` +
|
|
115
117
|
` $count++ ` +
|
|
116
118
|
` } ` +
|
|
117
119
|
`}; ` +
|
|
120
|
+
`Write-Output "KILLED_PIDS: $($pids -join ',')"; ` +
|
|
118
121
|
`Start-Sleep -Milliseconds 500; ` +
|
|
119
122
|
`Get-ChildItem "$env:LOCALAPPDATA\\Microsoft\\Edge\\Singleton*" -ErrorAction SilentlyContinue | Remove-Item -Force; ` +
|
|
120
123
|
`Write-Output $count`;
|
|
@@ -124,9 +127,11 @@ function killEdgeProcesses(targetDir) {
|
|
|
124
127
|
)
|
|
125
128
|
.toString()
|
|
126
129
|
.trim();
|
|
130
|
+
console.error(`[killEdgeProcesses] Windows PS result: ${result}`);
|
|
127
131
|
try { fs.unlinkSync(ps1Path); } catch {}
|
|
128
132
|
command = "exit 0";
|
|
129
|
-
} catch {
|
|
133
|
+
} catch (e) {
|
|
134
|
+
console.error(`[killEdgeProcesses] Windows PS failed: ${e.message}`);
|
|
130
135
|
command = "taskkill /F /IM msedge.exe 2>nul || exit 0";
|
|
131
136
|
}
|
|
132
137
|
} else {
|