@wanghaopeng1148/deskpet 2.0.4 → 2.0.5

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/bin/deskpet.mjs +17 -4
  2. package/package.json +1 -1
package/bin/deskpet.mjs CHANGED
@@ -155,13 +155,16 @@ function waitPort(port, host = '127.0.0.1', timeoutMs = 30000) {
155
155
  }
156
156
 
157
157
  function openUrl(url) {
158
+ // windowsHide 一并加上:这三个都是控制台程序(cmd)或会转交控制台,
159
+ // stdio 又是 ignore + detached,不加就会给浏览器那一跳闪一个黑窗体
160
+ const opts = { stdio: 'ignore', detached: true, windowsHide: true }
158
161
  try {
159
162
  if (isWin) {
160
- spawn('cmd', ['/c', 'start', '', url], { stdio: 'ignore', detached: true }).unref()
163
+ spawn('cmd', ['/c', 'start', '', url], opts).unref()
161
164
  } else if (process.platform === 'darwin') {
162
- spawn('open', [url], { stdio: 'ignore', detached: true }).unref()
165
+ spawn('open', [url], opts).unref()
163
166
  } else {
164
- spawn('xdg-open', [url], { stdio: 'ignore', detached: true }).unref()
167
+ spawn('xdg-open', [url], opts).unref()
165
168
  }
166
169
  } catch {
167
170
  /* 打不开就算了:URL 已经打印出来,用户可自行复制 */
@@ -217,7 +220,17 @@ const logStream = logToFile ? openLogStream() : null
217
220
  const child = spawn(process.execPath, [...server.args, server.entry], {
218
221
  cwd: pkgRoot,
219
222
  stdio: logStream ? ['ignore', 'pipe', 'pipe'] : 'inherit',
220
- env: { ...process.env, DESKPET_PORT: String(port) }
223
+ env: { ...process.env, DESKPET_PORT: String(port) },
224
+ /**
225
+ * windowsHide: true —— 关键的一行。
226
+ *
227
+ * Node 的这个选项默认是 **false**。它只在「父进程没有控制台、且没有继承 stdio」
228
+ * 时才起作用:那种情况下 Windows 会给子进程**新分配一个控制台窗口**,
229
+ * 也就是开机时闪一下的黑窗体。自启链路里 wscript 本身是没有控制台的图形程序,
230
+ * 一旦 stdio 走管道(--log 就是这种情况),子进程就属于这一档。
231
+ * 设为 true 会让 Node 带上 CREATE_NO_WINDOW,任何情况下都不会新建窗口。
232
+ */
233
+ windowsHide: true
221
234
  })
222
235
 
223
236
  if (logStream) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wanghaopeng1148/deskpet",
3
3
  "productName": "DeskPet",
4
- "version": "2.0.4",
4
+ "version": "2.0.5",
5
5
  "description": "DeskPet 2.0 — 本机任务自动化服务 + Web 管理台 (Node + Express + Vue 3 + TypeScript)",
6
6
  "type": "module",
7
7
  "author": "whp",