tt-help-cli-ycl 1.3.75 → 1.3.77

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tt-help-cli-ycl",
3
- "version": "1.3.75",
3
+ "version": "1.3.77",
4
4
  "description": "TikTok user & video data scraper - extract ttSeller, verified, locationCreated from HTML source",
5
5
  "type": "module",
6
6
  "bin": {
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
- /* ignore */
101
+ } catch (e) {
102
+ console.error(`[SIGINT] 关闭浏览器时出错: ${e.message}`);
101
103
  }
102
104
  console.error("浏览器已关闭");
103
105
  process.exit(0);
@@ -108,13 +108,20 @@ function killEdgeProcesses(targetDir) {
108
108
  const escapedDir = targetDir.replace(/'/g, "''");
109
109
  const ps1Content =
110
110
  `$procs = Get-CimInstance Win32_Process -Filter "Name='msedge.exe'" 2>$null; ` +
111
+ `Write-Output "TOTAL_MSEDGE_PROCS: $($procs.Count)"; ` +
112
+ `foreach ($p in $procs) { ` +
113
+ ` Write-Output "PROC_PID=$($p.ProcessId) CMD=$($p.CommandLine)"; ` +
114
+ `}; ` +
111
115
  `$count = 0; ` +
116
+ `$pids = @(); ` +
112
117
  `foreach ($p in $procs) { ` +
113
118
  ` if ($p.CommandLine -and $p.CommandLine -like "*${escapedDir}*") { ` +
114
- ` taskkill /F /T /PID $p.ProcessId 2>$null; ` +
119
+ ` $pids += $p.ProcessId; ` +
120
+ ` Stop-Process -Id $p.ProcessId -Force -ErrorAction SilentlyContinue; ` +
115
121
  ` $count++ ` +
116
122
  ` } ` +
117
123
  `}; ` +
124
+ `Write-Output "KILLED_PIDS: $($pids -join ',')"; ` +
118
125
  `Start-Sleep -Milliseconds 500; ` +
119
126
  `Get-ChildItem "$env:LOCALAPPDATA\\Microsoft\\Edge\\Singleton*" -ErrorAction SilentlyContinue | Remove-Item -Force; ` +
120
127
  `Write-Output $count`;
@@ -124,9 +131,11 @@ function killEdgeProcesses(targetDir) {
124
131
  )
125
132
  .toString()
126
133
  .trim();
134
+ console.error(`[killEdgeProcesses] Windows PS result: ${result}`);
127
135
  try { fs.unlinkSync(ps1Path); } catch {}
128
136
  command = "exit 0";
129
- } catch {
137
+ } catch (e) {
138
+ console.error(`[killEdgeProcesses] Windows PS failed: ${e.message}`);
130
139
  command = "taskkill /F /IM msedge.exe 2>nul || exit 0";
131
140
  }
132
141
  } else {