first commit

This commit is contained in:
lingxiao865
2026-02-10 08:05:03 +08:00
commit c5af079d8c
1094 changed files with 97530 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import { QrCode, QrSegment } from '../../common/shared/qrcode/qrcodegen';
import { ERROR_LEVEL_MAP, getImageSettings, getMarginSize } from '../../common/shared/qrcode/utils';
const useQRCode = (opt) => {
const { value, level, minVersion, includeMargin, marginSize, imageSettings, size } = opt;
const qrcode = (() => {
const segments = QrSegment.makeSegments(value);
return QrCode.encodeSegments(segments, ERROR_LEVEL_MAP[level], minVersion);
})();
const cells = qrcode.getModules();
const margin = getMarginSize(includeMargin, marginSize);
const calculatedImageSettings = getImageSettings(cells, size, margin, imageSettings);
return {
cells,
margin,
numCells: cells.length + margin * 2,
calculatedImageSettings,
qrcode,
};
};
export default useQRCode;