Scan: throttled Erfolgs-Log + sichtbare Decode-Fehler statt stillem catch
All checks were successful
Pin to IPFS / pin (push) Successful in 10s
All checks were successful
Pin to IPFS / pin (push) Successful in 10s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
753e210b15
commit
1dbeb16e86
1 changed files with 16 additions and 3 deletions
19
app.js
19
app.js
|
|
@ -135,6 +135,12 @@
|
||||||
const c = $(canvasId);
|
const c = $(canvasId);
|
||||||
const ctx = c.getContext('2d', { willReadFrequently: true });
|
const ctx = c.getContext('2d', { willReadFrequently: true });
|
||||||
let lastScan = 0;
|
let lastScan = 0;
|
||||||
|
let lastLog = 0;
|
||||||
|
const logThrottled = (now, msg) => {
|
||||||
|
if (now - lastLog < 1000) return;
|
||||||
|
lastLog = now;
|
||||||
|
addPairingLog(msg);
|
||||||
|
};
|
||||||
|
|
||||||
const detect = barcodeDetector
|
const detect = barcodeDetector
|
||||||
? async () => {
|
? async () => {
|
||||||
|
|
@ -153,13 +159,20 @@
|
||||||
if (!v.videoWidth) { camRaf = requestAnimationFrame(tick); return; }
|
if (!v.videoWidth) { camRaf = requestAnimationFrame(tick); return; }
|
||||||
if (now - lastScan < 100) { camRaf = requestAnimationFrame(tick); return; }
|
if (now - lastScan < 100) { camRaf = requestAnimationFrame(tick); return; }
|
||||||
lastScan = now;
|
lastScan = now;
|
||||||
|
let raw = null;
|
||||||
try {
|
try {
|
||||||
const raw = await detect();
|
raw = await detect();
|
||||||
if (raw) {
|
if (raw) {
|
||||||
const p = await unpack(raw);
|
const p = await unpack(raw);
|
||||||
if (p.v === 1) { callback(p, raw); return; }
|
if (p.v === 1) {
|
||||||
|
logThrottled(now, 'QR gescannt ✓');
|
||||||
|
callback(p, raw);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (e) {
|
||||||
|
if (raw) logThrottled(now, `QR gescannt, aber ungültige Daten: ${e.message}`);
|
||||||
|
}
|
||||||
camRaf = requestAnimationFrame(tick);
|
camRaf = requestAnimationFrame(tick);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue