cicy-desktop 2.1.241 → 2.1.242
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 +1 -1
- package/src/main.js +13 -0
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -1136,6 +1136,19 @@ electronApp.whenReady().then(async () => {
|
|
|
1136
1136
|
.catch((e) => log.warn(`[cloud] device-info/register (on launch) failed: ${e.message}`));
|
|
1137
1137
|
} catch (e) { log.warn(`[cloud] device-info launch hook failed: ${e.message}`); }
|
|
1138
1138
|
|
|
1139
|
+
// Periodic device heartbeat → lets the ops backend show per-device liveness.
|
|
1140
|
+
// Re-POST /api/device/register every 60s (idempotent upsert by owner+deviceId;
|
|
1141
|
+
// cloud records last_seen on each call → "active if now - last_seen < N min").
|
|
1142
|
+
// Runs in MAIN, not the renderer, so it keeps beating even when the homepage
|
|
1143
|
+
// window is hidden/minimized. Best-effort, no-op when not logged in;
|
|
1144
|
+
// registerDevice reads cached deviceInfo (no network detection per beat).
|
|
1145
|
+
try {
|
|
1146
|
+
const cc = require("./cloud/cloud-client");
|
|
1147
|
+
const HEARTBEAT_MS = Math.max(15000, Number(process.env.CICY_DEVICE_HEARTBEAT_MS || 60000));
|
|
1148
|
+
const beat = setInterval(() => { try { cc.registerDevice().catch(() => {}); } catch (_) {} }, HEARTBEAT_MS);
|
|
1149
|
+
if (beat && typeof beat.unref === "function") beat.unref();
|
|
1150
|
+
} catch (e) { log.warn(`[cloud] device heartbeat setup failed: ${e.message}`); }
|
|
1151
|
+
|
|
1139
1152
|
// Cloud↔desktop title reconcile. The homepage drives the FAST cadence by window
|
|
1140
1153
|
// visibility (聚焦 ~3s / 切回立即,见 App.jsx + localTeams:syncCloud IPC). This
|
|
1141
1154
|
// 30s timer is just the SLOW fallback for when no homepage window is open / it's
|