cicy-desktop 2.1.133 → 2.1.134

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.133",
3
+ "version": "2.1.134",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -137,7 +137,7 @@ async function startLogin({ onResult } = {}) {
137
137
  // browser, locked-down shell) openExternal silently fails and the user is
138
138
  // left stuck "等回调" with no recourse — so we ALSO return the url to the
139
139
  // renderer (below) to show a manual "open / copy this link" fallback.
140
- shell.openExternal(url).catch((e) => log.warn(`[auth-loopback] openExternal failed: ${e.message}`));
140
+ require("./open-external").openExternalRobust(url).catch((e) => log.warn(`[auth-loopback] open failed: ${e.message}`));
141
141
 
142
142
  _timeoutHandle = setTimeout(() => {
143
143
  try { onResult && onResult({ error: "timeout" }); } catch {}
@@ -199,10 +199,12 @@ function register(opts = {}) {
199
199
  });
200
200
 
201
201
  // --- shell / app / tos / logs (last rebuild!) ---
202
- ipcMain.handle("shell:open-external", (_e, url) => {
202
+ ipcMain.handle("shell:open-external", async (_e, url) => {
203
203
  if (!url) return false;
204
- shell.openExternal(String(url));
205
- return true;
204
+ // Robust open: shell.openExternal silently fails on some Windows profiles;
205
+ // fall back to rundll32/explorer/start (the "手动打开" button uses this too).
206
+ const { openExternalRobust } = require("./open-external");
207
+ return await openExternalRobust(url);
206
208
  });
207
209
  ipcMain.handle("app:quit", () => {
208
210
  setTimeout(() => app.quit(), 100);
@@ -0,0 +1,50 @@
1
+ // Robust "open this URL in the system browser".
2
+ //
3
+ // electron's shell.openExternal silently fails on some Windows setups — a fresh
4
+ // user profile, a locked-down shell, or console-launched (npx) electron — leaving
5
+ // browser-login stuck ("点了没反应"). When it fails we fall back to the OS URL
6
+ // openers directly. Order matters: rundll32 / explorer / open / xdg-open take the
7
+ // URL as a SINGLE argv (no shell parsing), so the login URL's `&`/`?` query params
8
+ // survive. `cmd start` is last because cmd treats `&` as a command separator.
9
+
10
+ const { shell } = require("electron");
11
+ const { spawn } = require("child_process");
12
+ const log = require("electron-log");
13
+
14
+ function trySpawn(cmd, args) {
15
+ try {
16
+ const child = spawn(cmd, args, { detached: true, stdio: "ignore", windowsHide: true });
17
+ child.on("error", (err) => log.warn(`[open-external] ${cmd} error: ${err.message}`));
18
+ child.unref();
19
+ return true;
20
+ } catch (e) {
21
+ log.warn(`[open-external] spawn ${cmd} threw: ${e.message}`);
22
+ return false;
23
+ }
24
+ }
25
+
26
+ // Returns true if SOME mechanism was dispatched (best-effort — the OS may still
27
+ // have no default browser, which no opener can fix; the renderer always also
28
+ // shows a copy-link fallback).
29
+ async function openExternalRobust(rawUrl) {
30
+ const url = String(rawUrl || "");
31
+ if (!url) return false;
32
+
33
+ try {
34
+ await shell.openExternal(url);
35
+ return true;
36
+ } catch (e) {
37
+ log.warn(`[open-external] shell.openExternal failed, falling back: ${e && e.message}`);
38
+ }
39
+
40
+ if (process.platform === "win32") {
41
+ // FileProtocolHandler + explorer pass the URL untouched (good for query strings).
42
+ if (trySpawn("rundll32", ["url.dll,FileProtocolHandler", url])) return true;
43
+ if (trySpawn("explorer.exe", [url])) return true;
44
+ return trySpawn("cmd", ["/c", "start", "", url]);
45
+ }
46
+ if (process.platform === "darwin") return trySpawn("open", [url]);
47
+ return trySpawn("xdg-open", [url]);
48
+ }
49
+
50
+ module.exports = { openExternalRobust };