cicy-desktop 2.1.99 → 2.1.100

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": "cicy-desktop",
3
- "version": "2.1.99",
3
+ "version": "2.1.100",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -387,15 +387,44 @@ async function installDocker({ emit, dest } = {}) {
387
387
  await ensureDownloaded(DOCKER_DESKTOP_URL, target, DOCKER_DESKTOP_MIRROR, {
388
388
  emit, phase: "install-docker", label: "下载 Docker Desktop",
389
389
  });
390
- e({ phase: "install-docker", status: "running", message: "安装 Docker Desktop(请在弹出的授权框点「是」,装完可能需重启)…" });
391
- await new Promise((resolve) => {
390
+ e({ phase: "install-docker", status: "running", message: "安装 Docker Desktop(请在弹出的管理员授权框点「是」,装完可能需重启)…" });
391
+ await launchElevated(target, ["install", "--quiet", "--accept-license"], { emit: e });
392
+ }
393
+
394
+ // Run an admin-manifest exe (Docker Desktop Installer) ELEVATED. A plain
395
+ // child_process.spawn of a requireAdministrator exe from a non-elevated process
396
+ // fails with ERROR_ELEVATION_REQUIRED (740) and never shows UAC — which is why
397
+ // the installer "downloaded but didn't auto-install". ShellExecute with the
398
+ // "runas" verb is the only way to raise the UAC prompt + elevate. We drive it
399
+ // via VBScript/cscript because PowerShell is blocked by 360 on these machines.
400
+ // ShellExecute returns immediately (installer runs in the background); bootstrap
401
+ // then polls dockerOk(). Falls back to a direct spawn if cscript is unavailable.
402
+ function launchElevated(exe, args, { emit } = {}) {
403
+ return new Promise((resolve) => {
392
404
  try {
393
- const child = spawn(target, ["install", "--quiet", "--accept-license"], {
394
- windowsHide: false, detached: true, stdio: "ignore",
405
+ const vbs = path.join(os.tmpdir(), "cicy-docker-elevate.vbs");
406
+ const argStr = args.join(" ").replace(/"/g, '""');
407
+ const exeEsc = String(exe).replace(/"/g, '""');
408
+ // chr(34) = a literal double-quote inside the VBS string literals.
409
+ fs.writeFileSync(vbs,
410
+ `Set s = CreateObject("Shell.Application")\r\n` +
411
+ `s.ShellExecute "${exeEsc}", "${argStr}", "", "runas", 1\r\n`,
412
+ "utf8");
413
+ const child = spawn("cscript", ["//nologo", vbs], { windowsHide: true, detached: true, stdio: "ignore" });
414
+ let done = false;
415
+ const fin = (ok) => { if (done) return; done = true; resolve(ok); };
416
+ child.on("error", () => {
417
+ // cscript missing/blocked → best-effort direct spawn (works if elevated).
418
+ try {
419
+ emit && emit({ phase: "install-docker", status: "running", message: "提权脚本不可用,尝试直接启动安装包…" });
420
+ const c2 = spawn(exe, args, { windowsHide: false, detached: true, stdio: "ignore" });
421
+ c2.on("error", () => fin(false));
422
+ c2.on("spawn", () => fin(true));
423
+ c2.on("exit", () => fin(true));
424
+ } catch { fin(false); }
395
425
  });
396
- child.on("error", () => resolve());
397
- child.on("exit", () => resolve());
398
- } catch { resolve(); }
426
+ child.on("exit", () => fin(true));
427
+ } catch { resolve(false); }
399
428
  });
400
429
  }
401
430