tauri-android-tax/tests/fixtures/generate-qr.mjs
2026-07-09 20:03:35 +08:00

17 lines
645 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 生成测试用二维码图片PNG便于用「从图片扫描」功能验证。
// 用法node tests/fixtures/generate-qr.mjs [网址] [输出路径]
import QRCode from "qrcode";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const url = process.argv[2] || "https://fapiao.example.com/open?id=20240701";
const out = resolve(__dirname, process.argv[3] || "sample-qr.png");
await QRCode.toFile(out, url, {
errorCorrectionLevel: "M",
margin: 4,
scale: 8,
});
console.log(`已生成二维码图片: ${out}\n内容: ${url}`);