cicy-desktop 2.1.232 → 2.1.233
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
|
@@ -293,6 +293,12 @@ class TabManager {
|
|
|
293
293
|
return true;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
// 让窗口「可见但不抢前台」:已显示 → 什么都不做;隐藏 → showInactive(绝不 focus)。
|
|
297
|
+
// 程序化/agent 驱动的开 tab、reload、activate 都用它 —— win.focus() 只有在 cicy-desktop 不
|
|
298
|
+
// 在前台时才有效(= 从用户当前 app 抢焦点),用户在 cicy-desktop 内操作时它本就是 no-op。
|
|
299
|
+
// 所以这些非「用户明确要打开 app」的路径一律不抢焦点,避免用户在微信等窗口时被莫名跳到前台。
|
|
300
|
+
surfaceQuiet() { try { if (!this.win.isVisible()) this.win.showInactive(); } catch (e) {} }
|
|
301
|
+
|
|
296
302
|
close(id) {
|
|
297
303
|
const i = this.tabs.findIndex((x) => x.id === id);
|
|
298
304
|
if (i < 0) return false;
|
|
@@ -341,7 +347,7 @@ class TabManager {
|
|
|
341
347
|
if (ignoreCache) tab.view.webContents.reloadIgnoringCache();
|
|
342
348
|
else tab.view.webContents.reload();
|
|
343
349
|
} catch (e) {}
|
|
344
|
-
try { this.activate(tab.id); this.
|
|
350
|
+
try { this.activate(tab.id); this.surfaceQuiet(); } catch (e) {}
|
|
345
351
|
return true;
|
|
346
352
|
}
|
|
347
353
|
|
|
@@ -372,7 +378,7 @@ function findManagerByTab(webContentsId) {
|
|
|
372
378
|
async function openTab(accountIdx, url, opts = {}) {
|
|
373
379
|
const m = ensureManager(accountIdx);
|
|
374
380
|
const id = m.addTab(url, { trusted: !!opts.trusted, home: !!opts.home, title: opts.title || "", navigate: !!opts.navigate, avatar: opts.avatar || "", team: !!opts.team, colorKey: opts.colorKey || "" });
|
|
375
|
-
try { m.
|
|
381
|
+
try { m.surfaceQuiet(); } catch (e) {}
|
|
376
382
|
// 记下这个团队 tab 的 webContentsId(打开 → set;关闭/销毁 → delete)。
|
|
377
383
|
try {
|
|
378
384
|
const tab = m.tabs.find((t) => t.id === id);
|
|
@@ -401,7 +407,9 @@ function openHomeWindow(accountIdx, homeUrl, opts = {}) {
|
|
|
401
407
|
} else {
|
|
402
408
|
const id = m.addTab(homeUrl, { home: true }); tab = m.tabs.find((t) => t.id === id);
|
|
403
409
|
}
|
|
404
|
-
|
|
410
|
+
// 只有明确要求(tray「打开首页」/ 启动,activate!==false)才把窗口抢到前台;deeplink /
|
|
411
|
+
// second-instance 顺带触发(activate:false)只静默显示,绝不从用户当前 app 抢焦点。
|
|
412
|
+
if (opts.activate !== false) { try { m.win.show(); m.win.focus(); } catch (e) {} } else m.surfaceQuiet();
|
|
405
413
|
let wc = null; try { wc = tab ? tab.view.webContents : null; } catch (e) {}
|
|
406
414
|
return { win: m.win, wc };
|
|
407
415
|
}
|
|
@@ -462,7 +470,7 @@ function registerTabBrowserTools(registerTool) {
|
|
|
462
470
|
try {
|
|
463
471
|
const m = ensureManager(accountIdx);
|
|
464
472
|
if (m.tabs.length === 0 && accountIdx !== 0) m.addTab();
|
|
465
|
-
try { m.
|
|
473
|
+
try { m.surfaceQuiet(); } catch (e) {}
|
|
466
474
|
return ok({ success: true, accountIdx, winId: m.win.id });
|
|
467
475
|
} catch (e) { return ok({ error: e.message }, true); }
|
|
468
476
|
},
|
|
@@ -610,7 +618,7 @@ async function reloadTabByUrl(accountIdx, url, opts = {}) {
|
|
|
610
618
|
const tab = m.tabs.find((t) => stripVol(t.url) === key);
|
|
611
619
|
if (tab) {
|
|
612
620
|
try { tab.view.webContents.reload(); } catch (e) {}
|
|
613
|
-
try { m.activate(tab.id); m.
|
|
621
|
+
try { m.activate(tab.id); m.surfaceQuiet(); } catch (e) {}
|
|
614
622
|
return { ok: true, winId: m.win.id, reloaded: true };
|
|
615
623
|
}
|
|
616
624
|
}
|
|
@@ -633,7 +641,7 @@ function reloadTabIfOpen(accountIdx, url, opts = {}) {
|
|
|
633
641
|
if (mm && !mm.win.isDestroyed()) {
|
|
634
642
|
try {
|
|
635
643
|
const tab = mm.tabs.find((t) => { try { return t.view.webContents.id === wcId; } catch (e) { return false; } });
|
|
636
|
-
if (tab) { mm.activate(tab.id); mm.
|
|
644
|
+
if (tab) { mm.activate(tab.id); mm.surfaceQuiet(); }
|
|
637
645
|
} catch (e) {}
|
|
638
646
|
}
|
|
639
647
|
return { ok: true, winId: mm ? mm.win.id : undefined, reloaded: true, byWcId: true };
|
|
@@ -660,7 +668,7 @@ function activateTabIfOpen(accountIdx, url) {
|
|
|
660
668
|
if (mm && !mm.win.isDestroyed()) {
|
|
661
669
|
try {
|
|
662
670
|
const tab = mm.tabs.find((t) => { try { return t.view.webContents.id === wcId; } catch (e) { return false; } });
|
|
663
|
-
if (tab) { mm.activate(tab.id); mm.
|
|
671
|
+
if (tab) { mm.activate(tab.id); mm.surfaceQuiet(); return { ok: true, active: true }; }
|
|
664
672
|
} catch (e) {}
|
|
665
673
|
}
|
|
666
674
|
}
|