优化聊天室特效加载与移动端性能

This commit is contained in:
2026-04-25 03:34:19 +08:00
parent 128b52d0aa
commit e3cba255f9
6 changed files with 158 additions and 25 deletions
+3 -1
View File
@@ -102,7 +102,9 @@ const GoldRainEffect = (() => {
const w = canvas.width;
const h = canvas.height;
const DURATION = 8600;
const COIN_COUNT = Math.min(58, Math.max(28, Math.floor(w / 28)));
const isMobile = window.matchMedia?.("(max-width: 640px)")?.matches || window.innerWidth <= 640;
const densityScale = isMobile ? 0.72 : 1;
const COIN_COUNT = Math.round(Math.min(58, Math.max(28, Math.floor(w / 28))) * densityScale);
const coins = Array.from({ length: COIN_COUNT }, () => new Coin(w, h));
const startTime = performance.now();
let animId = null;