@atooyu/uxto-ui 1.1.29 → 1.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +227 -298
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +227 -298
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +4 -4
- package/package.json +3 -2
- package/src/components/u-qrcode/u-qrcode.vue +266 -255
package/dist/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
3
|
const vue = require("vue");
|
|
7
4
|
const _hoisted_1$H = ["disabled", "hover-class"];
|
|
@@ -5049,139 +5046,148 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5049
5046
|
setup(__props) {
|
|
5050
5047
|
const props = __props;
|
|
5051
5048
|
const modules = vue.ref([]);
|
|
5052
|
-
const qrSize = vue.ref(0);
|
|
5053
5049
|
const cellSize = vue.computed(() => {
|
|
5054
|
-
if (
|
|
5055
|
-
return props.size /
|
|
5050
|
+
if (modules.value.length === 0) return 0;
|
|
5051
|
+
return props.size / modules.value.length;
|
|
5056
5052
|
});
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5053
|
+
const QRCode = (() => {
|
|
5054
|
+
const ECC_LEVELS = { L: 1, M: 0, Q: 3, H: 2 };
|
|
5055
|
+
const ECC_CODEWORDS = [
|
|
5056
|
+
[-1, 7, 10, 13, 17],
|
|
5057
|
+
[-1, 10, 16, 22, 28],
|
|
5058
|
+
[-1, 15, 26, 36, 44],
|
|
5059
|
+
[-1, 20, 36, 52, 64],
|
|
5060
|
+
[-1, 26, 48, 72, 88],
|
|
5061
|
+
[-1, 36, 64, 96, 112],
|
|
5062
|
+
[-1, 40, 72, 108, 130],
|
|
5063
|
+
[-1, 48, 88, 132, 156],
|
|
5064
|
+
[-1, 60, 110, 160, 192],
|
|
5065
|
+
[-1, 72, 130, 192, 224],
|
|
5066
|
+
[-1, 80, 150, 224, 264],
|
|
5067
|
+
[-1, 96, 176, 260, 308],
|
|
5068
|
+
[-1, 104, 198, 288, 352],
|
|
5069
|
+
[-1, 120, 216, 320, 384],
|
|
5070
|
+
[-1, 132, 240, 360, 432],
|
|
5071
|
+
[-1, 144, 280, 408, 480],
|
|
5072
|
+
[-1, 168, 308, 448, 532],
|
|
5073
|
+
[-1, 180, 338, 504, 588],
|
|
5074
|
+
[-1, 196, 364, 546, 650],
|
|
5075
|
+
[-1, 224, 416, 600, 700],
|
|
5076
|
+
[-1, 224, 442, 644, 750],
|
|
5077
|
+
[-1, 252, 476, 690, 816],
|
|
5078
|
+
[-1, 270, 504, 750, 900],
|
|
5079
|
+
[-1, 300, 560, 810, 960],
|
|
5080
|
+
[-1, 312, 588, 870, 1050],
|
|
5081
|
+
[-1, 336, 644, 952, 1110],
|
|
5082
|
+
[-1, 360, 700, 1020, 1200],
|
|
5083
|
+
[-1, 390, 728, 1050, 1260],
|
|
5084
|
+
[-1, 420, 784, 1140, 1350],
|
|
5085
|
+
[-1, 450, 812, 1200, 1440],
|
|
5086
|
+
[-1, 480, 868, 1290, 1530],
|
|
5087
|
+
[-1, 510, 924, 1350, 1620],
|
|
5088
|
+
[-1, 540, 980, 1440, 1710],
|
|
5089
|
+
[-1, 570, 1036, 1530, 1800],
|
|
5090
|
+
[-1, 570, 1064, 1590, 1890],
|
|
5091
|
+
[-1, 600, 1120, 1680, 1980],
|
|
5092
|
+
[-1, 630, 1204, 1770, 2100],
|
|
5093
|
+
[-1, 660, 1260, 1860, 2220],
|
|
5094
|
+
[-1, 720, 1316, 1950, 2310],
|
|
5095
|
+
[-1, 750, 1372, 2040, 2430]
|
|
5096
|
+
];
|
|
5097
|
+
const CAPACITIES = [
|
|
5098
|
+
[-1, 17, 14, 11, 7],
|
|
5099
|
+
[-1, 32, 26, 20, 14],
|
|
5100
|
+
[-1, 53, 42, 32, 24],
|
|
5101
|
+
[-1, 78, 62, 46, 34],
|
|
5102
|
+
[-1, 106, 84, 60, 44],
|
|
5103
|
+
[-1, 134, 106, 74, 58],
|
|
5104
|
+
[-1, 154, 122, 86, 64],
|
|
5105
|
+
[-1, 192, 152, 108, 84],
|
|
5106
|
+
[-1, 230, 180, 130, 98],
|
|
5107
|
+
[-1, 271, 213, 151, 119],
|
|
5108
|
+
[-1, 321, 251, 177, 137],
|
|
5109
|
+
[-1, 367, 287, 203, 155],
|
|
5110
|
+
[-1, 425, 331, 241, 177],
|
|
5111
|
+
[-1, 458, 362, 258, 194],
|
|
5112
|
+
[-1, 520, 412, 292, 220],
|
|
5113
|
+
[-1, 586, 450, 322, 250],
|
|
5114
|
+
[-1, 644, 504, 364, 280],
|
|
5115
|
+
[-1, 718, 560, 394, 310],
|
|
5116
|
+
[-1, 792, 624, 442, 338],
|
|
5117
|
+
[-1, 858, 666, 482, 382],
|
|
5118
|
+
[-1, 929, 711, 509, 403],
|
|
5119
|
+
[-1, 1003, 779, 565, 439],
|
|
5120
|
+
[-1, 1091, 857, 611, 461],
|
|
5121
|
+
[-1, 1171, 911, 661, 511],
|
|
5122
|
+
[-1, 1273, 997, 715, 535],
|
|
5123
|
+
[-1, 1367, 1059, 751, 593],
|
|
5124
|
+
[-1, 1465, 1125, 805, 625],
|
|
5125
|
+
[-1, 1528, 1190, 868, 658],
|
|
5126
|
+
[-1, 1628, 1264, 908, 698],
|
|
5127
|
+
[-1, 1732, 1370, 982, 742],
|
|
5128
|
+
[-1, 1840, 1452, 1030, 790],
|
|
5129
|
+
[-1, 1952, 1538, 1112, 842],
|
|
5130
|
+
[-1, 2068, 1628, 1168, 898],
|
|
5131
|
+
[-1, 2188, 1722, 1228, 958],
|
|
5132
|
+
[-1, 2303, 1809, 1283, 983],
|
|
5133
|
+
[-1, 2431, 1911, 1351, 1051],
|
|
5134
|
+
[-1, 2563, 1989, 1423, 1093],
|
|
5135
|
+
[-1, 2699, 2099, 1499, 1139],
|
|
5136
|
+
[-1, 2809, 2213, 1579, 1219],
|
|
5137
|
+
[-1, 2953, 2331, 1663, 1273]
|
|
5138
|
+
];
|
|
5139
|
+
const GF_EXP = new Array(512);
|
|
5140
|
+
const GF_LOG = new Array(256);
|
|
5141
|
+
let x = 1;
|
|
5142
|
+
for (let i = 0; i < 255; i++) {
|
|
5143
|
+
GF_EXP[i] = x;
|
|
5144
|
+
GF_LOG[x] = i;
|
|
5145
|
+
x = x * 2;
|
|
5146
|
+
if (x >= 256) x ^= 285;
|
|
5147
|
+
}
|
|
5148
|
+
for (let i = 255; i < 512; i++) {
|
|
5149
|
+
GF_EXP[i] = GF_EXP[i - 255];
|
|
5150
|
+
}
|
|
5151
|
+
const gfMul = (a, b) => {
|
|
5074
5152
|
if (a === 0 || b === 0) return 0;
|
|
5075
|
-
return
|
|
5076
|
-
}
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
for (let
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
// 生成二维码
|
|
5085
|
-
static generate(data) {
|
|
5086
|
-
this.initGF();
|
|
5087
|
-
const version = this.getVersion(data.length);
|
|
5088
|
-
const size = version * 4 + 17;
|
|
5089
|
-
const matrix = [];
|
|
5090
|
-
for (let i = 0; i < size; i++) {
|
|
5091
|
-
matrix[i] = new Array(size).fill(-1);
|
|
5092
|
-
}
|
|
5093
|
-
this.addFinderPatterns(matrix, size);
|
|
5094
|
-
this.addTimingPatterns(matrix, size);
|
|
5095
|
-
this.addDarkModule(matrix, size);
|
|
5096
|
-
if (version >= 2) {
|
|
5097
|
-
this.addAlignmentPatterns(matrix, version, size);
|
|
5098
|
-
}
|
|
5099
|
-
const codewords = this.encodeData(data, version);
|
|
5100
|
-
this.fillData(matrix, codewords, size);
|
|
5101
|
-
this.applyMask(matrix, size, 0);
|
|
5102
|
-
this.addFormatInfo(matrix, size, 0);
|
|
5103
|
-
for (let row = 0; row < size; row++) {
|
|
5104
|
-
for (let col = 0; col < size; col++) {
|
|
5105
|
-
if (matrix[row][col] === -1) matrix[row][col] = 0;
|
|
5106
|
-
}
|
|
5107
|
-
}
|
|
5108
|
-
return { size, modules: matrix };
|
|
5109
|
-
}
|
|
5110
|
-
// 添加定位图案
|
|
5111
|
-
static addFinderPatterns(matrix, size) {
|
|
5112
|
-
const positions = [[0, 0], [size - 7, 0], [0, size - 7]];
|
|
5113
|
-
for (const [startRow, startCol] of positions) {
|
|
5114
|
-
for (let r = 0; r < 7; r++) {
|
|
5115
|
-
for (let c = 0; c < 7; c++) {
|
|
5116
|
-
const row = startRow + r;
|
|
5117
|
-
const col = startCol + c;
|
|
5118
|
-
if (row >= 0 && row < size && col >= 0 && col < size) {
|
|
5119
|
-
if (r === 0 || r === 6 || c === 0 || c === 6 || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
|
|
5120
|
-
matrix[row][col] = 1;
|
|
5121
|
-
} else {
|
|
5122
|
-
matrix[row][col] = 0;
|
|
5123
|
-
}
|
|
5124
|
-
}
|
|
5125
|
-
}
|
|
5126
|
-
}
|
|
5127
|
-
for (let i = 0; i < 8; i++) {
|
|
5128
|
-
if (startCol + 7 < size && startRow + i < size && startRow + i >= 0) {
|
|
5129
|
-
matrix[startRow + i][startCol + 7] = 0;
|
|
5130
|
-
}
|
|
5131
|
-
if (startRow + 7 < size && startCol + i < size && startCol + i >= 0) {
|
|
5132
|
-
matrix[startRow + 7][startCol + i] = 0;
|
|
5133
|
-
}
|
|
5153
|
+
return GF_EXP[GF_LOG[a] + GF_LOG[b]];
|
|
5154
|
+
};
|
|
5155
|
+
const rsEncode = (data, eccCount) => {
|
|
5156
|
+
const gen = [1];
|
|
5157
|
+
for (let i = 0; i < eccCount; i++) {
|
|
5158
|
+
const temp = new Array(gen.length + 1).fill(0);
|
|
5159
|
+
for (let j = 0; j < gen.length; j++) {
|
|
5160
|
+
temp[j] ^= gen[j];
|
|
5161
|
+
temp[j + 1] ^= gfMul(gen[j], GF_EXP[i]);
|
|
5134
5162
|
}
|
|
5163
|
+
gen.length = 0;
|
|
5164
|
+
gen.push(...temp);
|
|
5135
5165
|
}
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
}
|
|
5144
|
-
// 添加暗模块
|
|
5145
|
-
static addDarkModule(matrix, size) {
|
|
5146
|
-
matrix[size - 8][8] = 1;
|
|
5147
|
-
}
|
|
5148
|
-
// 添加定位图案
|
|
5149
|
-
static addAlignmentPatterns(matrix, version, size) {
|
|
5150
|
-
const positions = this.getAlignmentPositions(version, size);
|
|
5151
|
-
for (const row of positions) {
|
|
5152
|
-
for (const col of positions) {
|
|
5153
|
-
if (matrix[row][col] !== -1) continue;
|
|
5154
|
-
for (let r = -2; r <= 2; r++) {
|
|
5155
|
-
for (let c = -2; c <= 2; c++) {
|
|
5156
|
-
const tr = row + r;
|
|
5157
|
-
const tc = col + c;
|
|
5158
|
-
if (tr >= 0 && tr < size && tc >= 0 && tc < size && matrix[tr][tc] === -1) {
|
|
5159
|
-
if (Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0) {
|
|
5160
|
-
matrix[tr][tc] = 1;
|
|
5161
|
-
} else {
|
|
5162
|
-
matrix[tr][tc] = 0;
|
|
5163
|
-
}
|
|
5164
|
-
}
|
|
5165
|
-
}
|
|
5166
|
-
}
|
|
5166
|
+
const ecc = new Array(eccCount).fill(0);
|
|
5167
|
+
for (const byte of data) {
|
|
5168
|
+
const factor = byte ^ ecc[0];
|
|
5169
|
+
ecc.shift();
|
|
5170
|
+
ecc.push(0);
|
|
5171
|
+
for (let i = 0; i < eccCount; i++) {
|
|
5172
|
+
ecc[i] ^= gfMul(gen[i], factor);
|
|
5167
5173
|
}
|
|
5168
5174
|
}
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
const
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
let pos = size - 7;
|
|
5177
|
-
while (pos > 6) {
|
|
5178
|
-
positions.unshift(pos);
|
|
5179
|
-
pos -= step;
|
|
5175
|
+
return ecc;
|
|
5176
|
+
};
|
|
5177
|
+
const getVersion = (data, ecl) => {
|
|
5178
|
+
const eclIdx = ECC_LEVELS[ecl];
|
|
5179
|
+
const len = data.length;
|
|
5180
|
+
for (let v = 1; v <= 40; v++) {
|
|
5181
|
+
if (CAPACITIES[v][eclIdx] >= len) return v;
|
|
5180
5182
|
}
|
|
5181
|
-
return
|
|
5182
|
-
}
|
|
5183
|
-
|
|
5184
|
-
|
|
5183
|
+
return 40;
|
|
5184
|
+
};
|
|
5185
|
+
const encodeData = (data, version, ecl) => {
|
|
5186
|
+
const eclIdx = ECC_LEVELS[ecl];
|
|
5187
|
+
const eccCount = ECC_CODEWORDS[version][eclIdx];
|
|
5188
|
+
const size = version * 4 + 17;
|
|
5189
|
+
const totalBits = size * size - 225 - (version > 1 ? 25 : 0) - 31 * 2;
|
|
5190
|
+
const dataCodewords = Math.floor(totalBits / 8) - eccCount;
|
|
5185
5191
|
const bits = [];
|
|
5186
5192
|
bits.push(0, 1, 0, 0);
|
|
5187
5193
|
const cciBits = version <= 9 ? 8 : 16;
|
|
@@ -5194,52 +5200,87 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5194
5200
|
bits.push(code2 >> i & 1);
|
|
5195
5201
|
}
|
|
5196
5202
|
}
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
for (let i = 0; i < termLen; i++) bits.push(0);
|
|
5200
|
-
while (bits.length % 8 !== 0) bits.push(0);
|
|
5203
|
+
while (bits.length < dataCodewords * 8 && bits.length % 8 !== 0) bits.push(0);
|
|
5204
|
+
while (bits.length < dataCodewords * 8) bits.push(0);
|
|
5201
5205
|
const padBytes = [236, 17];
|
|
5202
5206
|
let padIdx = 0;
|
|
5203
|
-
while (bits.length <
|
|
5207
|
+
while (bits.length < dataCodewords * 8) {
|
|
5204
5208
|
for (let i = 7; i >= 0; i--) {
|
|
5205
5209
|
bits.push(padBytes[padIdx] >> i & 1);
|
|
5206
5210
|
}
|
|
5207
5211
|
padIdx = (padIdx + 1) % 2;
|
|
5208
5212
|
}
|
|
5209
|
-
const
|
|
5213
|
+
const bytes = [];
|
|
5210
5214
|
for (let i = 0; i < bits.length; i += 8) {
|
|
5211
5215
|
let b = 0;
|
|
5212
5216
|
for (let j = 0; j < 8; j++) b = b << 1 | bits[i + j];
|
|
5213
|
-
|
|
5217
|
+
bytes.push(b);
|
|
5214
5218
|
}
|
|
5215
|
-
const
|
|
5216
|
-
return [...
|
|
5217
|
-
}
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
const
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5219
|
+
const ecc = rsEncode(bytes, eccCount);
|
|
5220
|
+
return [...bytes, ...ecc];
|
|
5221
|
+
};
|
|
5222
|
+
const generate = (data, ecl) => {
|
|
5223
|
+
const version = getVersion(data, ecl);
|
|
5224
|
+
const size = version * 4 + 17;
|
|
5225
|
+
const matrix = [];
|
|
5226
|
+
for (let i = 0; i < size; i++) {
|
|
5227
|
+
matrix[i] = new Array(size).fill(-1);
|
|
5228
|
+
}
|
|
5229
|
+
const addFinder = (row, col) => {
|
|
5230
|
+
for (let r = -1; r <= 7; r++) {
|
|
5231
|
+
for (let c = -1; c <= 7; c++) {
|
|
5232
|
+
const tr = row + r, tc = col + c;
|
|
5233
|
+
if (tr >= 0 && tr < size && tc >= 0 && tc < size) {
|
|
5234
|
+
if (r === -1 || r === 7 || c === -1 || c === 7) {
|
|
5235
|
+
matrix[tr][tc] = 0;
|
|
5236
|
+
} else if (r === 0 || r === 6 || c === 0 || c === 6 || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
|
|
5237
|
+
matrix[tr][tc] = 1;
|
|
5238
|
+
} else {
|
|
5239
|
+
matrix[tr][tc] = 0;
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
}
|
|
5226
5243
|
}
|
|
5227
|
-
|
|
5228
|
-
|
|
5244
|
+
};
|
|
5245
|
+
addFinder(0, 0);
|
|
5246
|
+
addFinder(size - 7, 0);
|
|
5247
|
+
addFinder(0, size - 7);
|
|
5248
|
+
for (let i = 8; i < size - 8; i++) {
|
|
5249
|
+
matrix[6][i] = i % 2 === 0 ? 1 : 0;
|
|
5250
|
+
matrix[i][6] = i % 2 === 0 ? 1 : 0;
|
|
5229
5251
|
}
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
const
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5252
|
+
if (version >= 2) {
|
|
5253
|
+
const positions = [6];
|
|
5254
|
+
const step = Math.ceil((size - 13) / (Math.floor(version / 7) + 1));
|
|
5255
|
+
let pos = size - 7;
|
|
5256
|
+
while (pos > 6) {
|
|
5257
|
+
positions.unshift(pos);
|
|
5258
|
+
pos -= step;
|
|
5259
|
+
}
|
|
5260
|
+
for (const row of positions) {
|
|
5261
|
+
for (const col of positions) {
|
|
5262
|
+
if (matrix[row][col] !== -1) continue;
|
|
5263
|
+
for (let r = -2; r <= 2; r++) {
|
|
5264
|
+
for (let c = -2; c <= 2; c++) {
|
|
5265
|
+
const tr = row + r, tc = col + c;
|
|
5266
|
+
if (tr >= 0 && tr < size && tc >= 0 && tc < size && matrix[tr][tc] === -1) {
|
|
5267
|
+
matrix[tr][tc] = Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0 ? 1 : 0;
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5271
|
+
}
|
|
5237
5272
|
}
|
|
5238
5273
|
}
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5274
|
+
matrix[size - 8][8] = 1;
|
|
5275
|
+
for (let i = 0; i < 9; i++) {
|
|
5276
|
+
if (matrix[8][i] === -1) matrix[8][i] = 0;
|
|
5277
|
+
if (matrix[i][8] === -1) matrix[i][8] = 0;
|
|
5278
|
+
}
|
|
5279
|
+
for (let i = 0; i < 8; i++) {
|
|
5280
|
+
if (matrix[8][size - 1 - i] === -1) matrix[8][size - 1 - i] = 0;
|
|
5281
|
+
if (matrix[size - 1 - i][8] === -1) matrix[size - 1 - i][8] = 0;
|
|
5282
|
+
}
|
|
5283
|
+
const codewords = encodeData(data, version, ecl);
|
|
5243
5284
|
let bitIdx = 0;
|
|
5244
5285
|
let upward = true;
|
|
5245
5286
|
for (let col = size - 1; col >= 0; col -= 2) {
|
|
@@ -5259,164 +5300,52 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5259
5300
|
}
|
|
5260
5301
|
upward = !upward;
|
|
5261
5302
|
}
|
|
5262
|
-
}
|
|
5263
|
-
// 应用掩码
|
|
5264
|
-
static applyMask(matrix, size, mask) {
|
|
5265
5303
|
for (let row = 0; row < size; row++) {
|
|
5266
5304
|
for (let col = 0; col < size; col++) {
|
|
5267
|
-
if (matrix[row][col] >= 0) {
|
|
5268
|
-
|
|
5269
|
-
if (mask === 0) invert = (row + col) % 2 === 0;
|
|
5270
|
-
if (invert) {
|
|
5271
|
-
matrix[row][col] = matrix[row][col] === 1 ? 0 : 1;
|
|
5272
|
-
}
|
|
5305
|
+
if (matrix[row][col] >= 0 && (row + col) % 2 === 0) {
|
|
5306
|
+
matrix[row][col] = matrix[row][col] === 1 ? 0 : 1;
|
|
5273
5307
|
}
|
|
5274
5308
|
}
|
|
5275
5309
|
}
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
const ecl = 0;
|
|
5280
|
-
const data = ecl << 3 | mask;
|
|
5281
|
-
let rem = data;
|
|
5310
|
+
const eclBits = ECC_LEVELS[ecl];
|
|
5311
|
+
const format = (eclBits << 3 | 0) << 10;
|
|
5312
|
+
let rem = format >> 10;
|
|
5282
5313
|
for (let i = 0; i < 10; i++) {
|
|
5283
5314
|
rem = rem << 1 ^ (rem >> 14) * 1335;
|
|
5284
5315
|
}
|
|
5285
|
-
const
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5316
|
+
const formatBits = (format | rem) ^ 21522;
|
|
5317
|
+
for (let i = 0; i < 6; i++) matrix[8][i] = formatBits >> 14 - i & 1;
|
|
5318
|
+
matrix[8][7] = formatBits >> 8 & 1;
|
|
5319
|
+
matrix[8][8] = formatBits >> 7 & 1;
|
|
5320
|
+
matrix[7][8] = formatBits >> 6 & 1;
|
|
5321
|
+
for (let i = 9; i < 15; i++) matrix[14 - i][8] = formatBits >> 14 - i & 1;
|
|
5322
|
+
for (let i = 0; i < 8; i++) matrix[8][size - 8 + i] = formatBits >> i & 1;
|
|
5323
|
+
for (let i = 8; i < 15; i++) matrix[size - 15 + i][8] = formatBits >> i & 1;
|
|
5324
|
+
const result = [];
|
|
5325
|
+
for (let row = 0; row < size; row++) {
|
|
5326
|
+
result[row] = [];
|
|
5327
|
+
for (let col = 0; col < size; col++) {
|
|
5328
|
+
result[row][col] = matrix[row][col] === 1;
|
|
5329
|
+
}
|
|
5289
5330
|
}
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
for (let i = 9; i < 15; i++) matrix[14 - i][8] = bits[i];
|
|
5295
|
-
for (let i = 0; i < 8; i++) matrix[8][size - 8 + i] = bits[14 - i];
|
|
5296
|
-
for (let i = 8; i < 15; i++) matrix[size - 15 + i][8] = bits[14 - i];
|
|
5297
|
-
}
|
|
5298
|
-
}
|
|
5299
|
-
// 纠错级别
|
|
5300
|
-
__publicField(QRCodeGenerator, "ECC_LEVEL", { L: 1, M: 0, Q: 3, H: 2 });
|
|
5301
|
-
// 每个版本的纠错码字数(M级别)
|
|
5302
|
-
__publicField(QRCodeGenerator, "ECC_CODEWORDS", [
|
|
5303
|
-
0,
|
|
5304
|
-
10,
|
|
5305
|
-
16,
|
|
5306
|
-
22,
|
|
5307
|
-
28,
|
|
5308
|
-
36,
|
|
5309
|
-
44,
|
|
5310
|
-
52,
|
|
5311
|
-
64,
|
|
5312
|
-
72,
|
|
5313
|
-
80,
|
|
5314
|
-
96,
|
|
5315
|
-
108,
|
|
5316
|
-
120,
|
|
5317
|
-
132,
|
|
5318
|
-
144,
|
|
5319
|
-
168,
|
|
5320
|
-
180,
|
|
5321
|
-
196,
|
|
5322
|
-
216,
|
|
5323
|
-
240,
|
|
5324
|
-
260,
|
|
5325
|
-
288,
|
|
5326
|
-
320,
|
|
5327
|
-
344,
|
|
5328
|
-
376,
|
|
5329
|
-
412,
|
|
5330
|
-
452,
|
|
5331
|
-
492,
|
|
5332
|
-
536
|
|
5333
|
-
]);
|
|
5334
|
-
// 每个版本的总码字数
|
|
5335
|
-
__publicField(QRCodeGenerator, "TOTAL_CODEWORDS", [
|
|
5336
|
-
0,
|
|
5337
|
-
26,
|
|
5338
|
-
44,
|
|
5339
|
-
70,
|
|
5340
|
-
100,
|
|
5341
|
-
134,
|
|
5342
|
-
172,
|
|
5343
|
-
196,
|
|
5344
|
-
242,
|
|
5345
|
-
292,
|
|
5346
|
-
346,
|
|
5347
|
-
404,
|
|
5348
|
-
466,
|
|
5349
|
-
532,
|
|
5350
|
-
581,
|
|
5351
|
-
625,
|
|
5352
|
-
733,
|
|
5353
|
-
815,
|
|
5354
|
-
901,
|
|
5355
|
-
993,
|
|
5356
|
-
1079,
|
|
5357
|
-
1157,
|
|
5358
|
-
1253,
|
|
5359
|
-
1353,
|
|
5360
|
-
1453,
|
|
5361
|
-
1553,
|
|
5362
|
-
1673,
|
|
5363
|
-
1793,
|
|
5364
|
-
1913,
|
|
5365
|
-
2033
|
|
5366
|
-
]);
|
|
5367
|
-
// 每个版本的容量(字节模式,M级别)
|
|
5368
|
-
__publicField(QRCodeGenerator, "CAPACITY", [
|
|
5369
|
-
0,
|
|
5370
|
-
16,
|
|
5371
|
-
28,
|
|
5372
|
-
44,
|
|
5373
|
-
64,
|
|
5374
|
-
86,
|
|
5375
|
-
108,
|
|
5376
|
-
124,
|
|
5377
|
-
154,
|
|
5378
|
-
186,
|
|
5379
|
-
216,
|
|
5380
|
-
252,
|
|
5381
|
-
290,
|
|
5382
|
-
334,
|
|
5383
|
-
365,
|
|
5384
|
-
415,
|
|
5385
|
-
453,
|
|
5386
|
-
507,
|
|
5387
|
-
563,
|
|
5388
|
-
623,
|
|
5389
|
-
669,
|
|
5390
|
-
719,
|
|
5391
|
-
783,
|
|
5392
|
-
843,
|
|
5393
|
-
909,
|
|
5394
|
-
969,
|
|
5395
|
-
1047,
|
|
5396
|
-
1119,
|
|
5397
|
-
1193,
|
|
5398
|
-
1273
|
|
5399
|
-
]);
|
|
5400
|
-
// Galois Field 查找表
|
|
5401
|
-
__publicField(QRCodeGenerator, "GF_EXP", []);
|
|
5402
|
-
__publicField(QRCodeGenerator, "GF_LOG", []);
|
|
5331
|
+
return result;
|
|
5332
|
+
};
|
|
5333
|
+
return { generate };
|
|
5334
|
+
})();
|
|
5403
5335
|
const generateQRCode = () => {
|
|
5404
5336
|
if (!props.value) {
|
|
5405
5337
|
modules.value = [];
|
|
5406
|
-
qrSize.value = 0;
|
|
5407
5338
|
return;
|
|
5408
5339
|
}
|
|
5409
5340
|
try {
|
|
5410
|
-
|
|
5411
|
-
modules.value = result.modules;
|
|
5412
|
-
qrSize.value = result.size;
|
|
5341
|
+
modules.value = QRCode.generate(props.value, props.errorCorrectLevel);
|
|
5413
5342
|
} catch (e) {
|
|
5414
5343
|
console.error("QR Code generation failed:", e);
|
|
5415
5344
|
modules.value = [];
|
|
5416
|
-
qrSize.value = 0;
|
|
5417
5345
|
}
|
|
5418
5346
|
};
|
|
5419
5347
|
vue.watch(() => props.value, generateQRCode);
|
|
5348
|
+
vue.watch(() => props.errorCorrectLevel, generateQRCode);
|
|
5420
5349
|
vue.onMounted(() => {
|
|
5421
5350
|
generateQRCode();
|
|
5422
5351
|
});
|
|
@@ -5441,7 +5370,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5441
5370
|
style: vue.normalizeStyle({
|
|
5442
5371
|
width: `${cellSize.value}px`,
|
|
5443
5372
|
height: `${cellSize.value}px`,
|
|
5444
|
-
backgroundColor: cell
|
|
5373
|
+
backgroundColor: cell ? __props.color : __props.bgColor
|
|
5445
5374
|
})
|
|
5446
5375
|
}, null, 4);
|
|
5447
5376
|
}), 128))
|
|
@@ -5452,7 +5381,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5452
5381
|
};
|
|
5453
5382
|
}
|
|
5454
5383
|
});
|
|
5455
|
-
const uQrcode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
5384
|
+
const uQrcode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-dbfcf21e"]]);
|
|
5456
5385
|
const _hoisted_1 = { class: "u-barcode" };
|
|
5457
5386
|
const _hoisted_2 = ["canvas-id"];
|
|
5458
5387
|
const _hoisted_3 = ["src"];
|