cicy-desktop 2.1.203 → 2.1.204
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/app-updater.js +16 -3
- package/src/backends/homepage-react/assets/index-Bf9kuVZb.js +377 -0
- package/src/backends/homepage-react/assets/{index-BShnCn32.css → index-C6Zrdgc0.css} +1 -1
- package/src/backends/homepage-react/index.html +2 -2
- package/src/i18n/locales/en.json +8 -2
- package/src/i18n/locales/fr.json +8 -2
- package/src/i18n/locales/ja.json +8 -2
- package/src/i18n/locales/zh-CN.json +8 -2
- package/workers/render/src/App.css +18 -0
- package/workers/render/src/App.jsx +69 -33
- package/src/backends/homepage-react/assets/index-BjgNk0ef.js +0 -377
package/package.json
CHANGED
package/src/app-updater.js
CHANGED
|
@@ -104,11 +104,24 @@ function download(url, dest, onProgress, redirects = 0) {
|
|
|
104
104
|
}
|
|
105
105
|
if (res.statusCode !== 200) { f.close(); try { fs.unlinkSync(dest); } catch {} return reject(new Error(`HTTP ${res.statusCode}`)); }
|
|
106
106
|
const total = parseInt(res.headers["content-length"] || "0", 10) || 0;
|
|
107
|
-
let transferred = 0,
|
|
107
|
+
let transferred = 0, lastEmit = 0;
|
|
108
|
+
const startT = Date.now();
|
|
109
|
+
let winT = startT, winBytes = 0, bytesPerSec = 0;
|
|
108
110
|
res.on("data", (chunk) => {
|
|
109
111
|
transferred += chunk.length;
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
+
const now = Date.now();
|
|
113
|
+
// 速度按 ~500ms 滑窗算,平滑不抖。
|
|
114
|
+
if (now - winT >= 500) {
|
|
115
|
+
bytesPerSec = (transferred - winBytes) / ((now - winT) / 1000);
|
|
116
|
+
winT = now; winBytes = transferred;
|
|
117
|
+
}
|
|
118
|
+
// 节流:每 ~120ms 或下载完才推一次(够顺滑又不刷爆 IPC)。
|
|
119
|
+
if (now - lastEmit >= 120 || transferred === total) {
|
|
120
|
+
lastEmit = now;
|
|
121
|
+
const percent = total ? Math.min(100, Math.floor((transferred / total) * 100)) : 0;
|
|
122
|
+
const etaSec = bytesPerSec > 0 && total ? Math.max(0, Math.round((total - transferred) / bytesPerSec)) : 0;
|
|
123
|
+
try { onProgress && onProgress({ percent, transferred, total, bytesPerSec, etaSec }); } catch {}
|
|
124
|
+
}
|
|
112
125
|
});
|
|
113
126
|
res.pipe(f);
|
|
114
127
|
f.on("finish", () => f.close(() => resolve()));
|