新增e2e测试脚本,修复部分问题

This commit was merged in pull request #51.
This commit is contained in:
2026-07-22 20:00:13 +08:00
parent 53d1ce6fb2
commit 4c07ec5455
105 changed files with 21700 additions and 318 deletions
+44
View File
@@ -0,0 +1,44 @@
const fs = require('fs');
const path = require('path');
const { PNG } = require('pngjs');
const jsQR = require('jsqr');
// Find the QR code file
const baseDir = path.resolve(__dirname, '..');
const files = fs.readdirSync(baseDir).filter(f => f.includes('瑜伽') && f.endsWith('.png'));
console.log('Found files:', files);
if (files.length === 0) {
console.log('No QR code file found');
process.exit(0);
}
const filePath = path.join(baseDir, files[0]);
console.log('Reading:', filePath);
const buf = fs.readFileSync(filePath);
console.log('File size:', buf.length, 'bytes');
const png = PNG.sync.read(buf);
console.log('Image:', png.width, 'x', png.height);
const code = jsQR(new Uint8ClampedArray(png.data), png.width, png.height);
if (code) {
console.log('QR Code Data:', code.data);
} else {
console.log('No QR code found at original resolution');
// Try with different inversion
const inverted = Buffer.alloc(png.data.length);
for (let i = 0; i < png.data.length; i += 4) {
inverted[i] = 255 - png.data[i];
inverted[i+1] = 255 - png.data[i+1];
inverted[i+2] = 255 - png.data[i+2];
inverted[i+3] = png.data[i+3];
}
const code2 = jsQR(new Uint8ClampedArray(inverted), png.width, png.height);
if (code2) {
console.log('Inverted QR Code Data:', code2.data);
} else {
console.log('Still no QR code found');
}
}