@atooyu/uxto-ui 1.1.32 → 1.1.34
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 +101 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -126
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +4 -4
- package/package.json +1 -1
- package/src/components/u-qrcode/u-qrcode.vue +135 -154
package/dist/index.js
CHANGED
|
@@ -5046,13 +5046,17 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5046
5046
|
setup(__props) {
|
|
5047
5047
|
const props = __props;
|
|
5048
5048
|
const modules = vue.ref([]);
|
|
5049
|
+
const moduleCount = vue.ref(0);
|
|
5049
5050
|
const cellSize = vue.computed(() => {
|
|
5050
|
-
if (
|
|
5051
|
-
return props.size /
|
|
5051
|
+
if (moduleCount.value === 0) return 0;
|
|
5052
|
+
return props.size / moduleCount.value;
|
|
5052
5053
|
});
|
|
5053
|
-
const
|
|
5054
|
+
const ECL_INDEX = { L: 0, M: 1, Q: 2, H: 3 };
|
|
5054
5055
|
const DATA_CAPACITY = [
|
|
5056
|
+
[0, 0, 0, 0],
|
|
5057
|
+
// version 0 (不存在)
|
|
5055
5058
|
[17, 14, 11, 7],
|
|
5059
|
+
// version 1
|
|
5056
5060
|
[32, 26, 20, 14],
|
|
5057
5061
|
[53, 42, 32, 24],
|
|
5058
5062
|
[78, 62, 46, 34],
|
|
@@ -5071,29 +5075,10 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5071
5075
|
[644, 504, 364, 280],
|
|
5072
5076
|
[718, 560, 394, 310],
|
|
5073
5077
|
[792, 624, 442, 338],
|
|
5074
|
-
[858, 666, 482, 382]
|
|
5075
|
-
[929, 711, 509, 403],
|
|
5076
|
-
[1003, 779, 565, 439],
|
|
5077
|
-
[1091, 857, 611, 461],
|
|
5078
|
-
[1171, 911, 661, 511],
|
|
5079
|
-
[1273, 997, 715, 535],
|
|
5080
|
-
[1367, 1059, 751, 593],
|
|
5081
|
-
[1465, 1125, 805, 625],
|
|
5082
|
-
[1528, 1190, 868, 658],
|
|
5083
|
-
[1628, 1264, 908, 698],
|
|
5084
|
-
[1732, 1370, 982, 742],
|
|
5085
|
-
[1840, 1452, 1030, 790],
|
|
5086
|
-
[1952, 1538, 1112, 842],
|
|
5087
|
-
[2068, 1628, 1168, 898],
|
|
5088
|
-
[2188, 1722, 1228, 958],
|
|
5089
|
-
[2303, 1809, 1283, 983],
|
|
5090
|
-
[2431, 1911, 1351, 1051],
|
|
5091
|
-
[2563, 1989, 1423, 1093],
|
|
5092
|
-
[2699, 2099, 1499, 1139],
|
|
5093
|
-
[2809, 2213, 1579, 1219],
|
|
5094
|
-
[2953, 2331, 1663, 1273]
|
|
5078
|
+
[858, 666, 482, 382]
|
|
5095
5079
|
];
|
|
5096
5080
|
const ECC_CODEWORDS = [
|
|
5081
|
+
[0, 0, 0, 0],
|
|
5097
5082
|
[7, 10, 13, 17],
|
|
5098
5083
|
[10, 16, 22, 28],
|
|
5099
5084
|
[15, 26, 36, 44],
|
|
@@ -5113,42 +5098,20 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5113
5098
|
[168, 308, 448, 532],
|
|
5114
5099
|
[180, 338, 504, 588],
|
|
5115
5100
|
[196, 364, 546, 650],
|
|
5116
|
-
[224, 416, 600, 700]
|
|
5117
|
-
[224, 442, 644, 750],
|
|
5118
|
-
[252, 476, 690, 816],
|
|
5119
|
-
[270, 504, 750, 900],
|
|
5120
|
-
[300, 560, 810, 960],
|
|
5121
|
-
[312, 588, 870, 1050],
|
|
5122
|
-
[336, 644, 952, 1110],
|
|
5123
|
-
[360, 700, 1020, 1200],
|
|
5124
|
-
[390, 728, 1050, 1260],
|
|
5125
|
-
[420, 784, 1140, 1350],
|
|
5126
|
-
[450, 812, 1200, 1440],
|
|
5127
|
-
[480, 868, 1290, 1530],
|
|
5128
|
-
[510, 924, 1350, 1620],
|
|
5129
|
-
[540, 980, 1440, 1710],
|
|
5130
|
-
[570, 1036, 1530, 1800],
|
|
5131
|
-
[570, 1064, 1590, 1890],
|
|
5132
|
-
[600, 1120, 1680, 1980],
|
|
5133
|
-
[630, 1204, 1770, 2100],
|
|
5134
|
-
[660, 1260, 1860, 2220],
|
|
5135
|
-
[720, 1316, 1950, 2310],
|
|
5136
|
-
[750, 1372, 2040, 2430]
|
|
5101
|
+
[224, 416, 600, 700]
|
|
5137
5102
|
];
|
|
5138
|
-
const GF_EXP =
|
|
5139
|
-
const GF_LOG =
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
}
|
|
5151
|
-
})();
|
|
5103
|
+
const GF_EXP = new Array(512);
|
|
5104
|
+
const GF_LOG = new Array(256);
|
|
5105
|
+
let _x = 1;
|
|
5106
|
+
for (let _i = 0; _i < 255; _i++) {
|
|
5107
|
+
GF_EXP[_i] = _x;
|
|
5108
|
+
GF_LOG[_x] = _i;
|
|
5109
|
+
_x = _x * 2;
|
|
5110
|
+
if (_x >= 256) _x ^= 285;
|
|
5111
|
+
}
|
|
5112
|
+
for (let _i = 255; _i < 512; _i++) {
|
|
5113
|
+
GF_EXP[_i] = GF_EXP[_i - 255];
|
|
5114
|
+
}
|
|
5152
5115
|
function gfMul(a, b) {
|
|
5153
5116
|
if (a === 0 || b === 0) return 0;
|
|
5154
5117
|
return GF_EXP[GF_LOG[a] + GF_LOG[b]];
|
|
@@ -5156,12 +5119,12 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5156
5119
|
function rsEncode(data, eccCount) {
|
|
5157
5120
|
let gen = [1];
|
|
5158
5121
|
for (let i = 0; i < eccCount; i++) {
|
|
5159
|
-
const
|
|
5122
|
+
const tmp = new Array(gen.length + 1).fill(0);
|
|
5160
5123
|
for (let j = 0; j < gen.length; j++) {
|
|
5161
|
-
|
|
5162
|
-
|
|
5124
|
+
tmp[j] ^= gen[j];
|
|
5125
|
+
tmp[j + 1] ^= gfMul(gen[j], GF_EXP[i]);
|
|
5163
5126
|
}
|
|
5164
|
-
gen =
|
|
5127
|
+
gen = tmp;
|
|
5165
5128
|
}
|
|
5166
5129
|
const ecc = new Array(eccCount).fill(0);
|
|
5167
5130
|
for (const byte of data) {
|
|
@@ -5174,60 +5137,69 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5174
5137
|
}
|
|
5175
5138
|
return ecc;
|
|
5176
5139
|
}
|
|
5177
|
-
function getVersion(
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
if (DATA_CAPACITY[v][eclIdx] >= dataLength) return v + 1;
|
|
5140
|
+
function getVersion(dataLen, eclIdx) {
|
|
5141
|
+
for (let v = 1; v <= 20; v++) {
|
|
5142
|
+
if (DATA_CAPACITY[v][eclIdx] >= dataLen) return v;
|
|
5181
5143
|
}
|
|
5182
|
-
return
|
|
5144
|
+
return 20;
|
|
5145
|
+
}
|
|
5146
|
+
function getAlignmentPositions(version) {
|
|
5147
|
+
if (version === 1) return [];
|
|
5148
|
+
const intervals = Math.floor(version / 7) + 1;
|
|
5149
|
+
const size = version * 4 + 17;
|
|
5150
|
+
const step = Math.ceil((size - 13) / (intervals + 1));
|
|
5151
|
+
const positions = [6];
|
|
5152
|
+
let pos = size - 7;
|
|
5153
|
+
while (pos > 6) {
|
|
5154
|
+
positions.unshift(pos);
|
|
5155
|
+
pos -= step;
|
|
5156
|
+
}
|
|
5157
|
+
return positions;
|
|
5183
5158
|
}
|
|
5184
|
-
function
|
|
5185
|
-
const eclIdx =
|
|
5186
|
-
const version = getVersion(
|
|
5159
|
+
function generateQR(text, errorCorrectionLevel) {
|
|
5160
|
+
const eclIdx = ECL_INDEX[errorCorrectionLevel] ?? 1;
|
|
5161
|
+
const version = getVersion(text.length, eclIdx);
|
|
5187
5162
|
const size = version * 4 + 17;
|
|
5188
5163
|
const matrix = [];
|
|
5189
5164
|
for (let i = 0; i < size; i++) {
|
|
5190
5165
|
matrix[i] = new Array(size).fill(-1);
|
|
5191
5166
|
}
|
|
5192
|
-
function
|
|
5193
|
-
for (let
|
|
5194
|
-
for (let
|
|
5195
|
-
const
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5167
|
+
function drawFinder(r, c) {
|
|
5168
|
+
for (let dr = -1; dr <= 7; dr++) {
|
|
5169
|
+
for (let dc = -1; dc <= 7; dc++) {
|
|
5170
|
+
const nr = r + dr;
|
|
5171
|
+
const nc = c + dc;
|
|
5172
|
+
if (nr < 0 || nr >= size || nc < 0 || nc >= size) continue;
|
|
5173
|
+
if (dr === -1 || dr === 7 || dc === -1 || dc === 7) {
|
|
5174
|
+
matrix[nr][nc] = 0;
|
|
5175
|
+
} else if (dr === 0 || dr === 6 || dc === 0 || dc === 6) {
|
|
5176
|
+
matrix[nr][nc] = 1;
|
|
5177
|
+
} else if (dr >= 2 && dr <= 4 && dc >= 2 && dc <= 4) {
|
|
5178
|
+
matrix[nr][nc] = 1;
|
|
5179
|
+
} else {
|
|
5180
|
+
matrix[nr][nc] = 0;
|
|
5204
5181
|
}
|
|
5205
5182
|
}
|
|
5206
5183
|
}
|
|
5207
5184
|
}
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5185
|
+
drawFinder(0, 0);
|
|
5186
|
+
drawFinder(size - 7, 0);
|
|
5187
|
+
drawFinder(0, size - 7);
|
|
5211
5188
|
for (let i = 8; i < size - 8; i++) {
|
|
5212
|
-
matrix[6][i] = i
|
|
5213
|
-
matrix[i][6] = i
|
|
5189
|
+
matrix[6][i] = (i & 1) === 0 ? 1 : 0;
|
|
5190
|
+
matrix[i][6] = (i & 1) === 0 ? 1 : 0;
|
|
5214
5191
|
}
|
|
5215
5192
|
if (version >= 2) {
|
|
5216
|
-
const
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
for (let r = -2; r <= 2; r++) {
|
|
5227
|
-
for (let c = -2; c <= 2; c++) {
|
|
5228
|
-
const tr = row + r, tc = col + c;
|
|
5229
|
-
if (tr >= 0 && tr < size && tc >= 0 && tc < size && matrix[tr][tc] === -1) {
|
|
5230
|
-
matrix[tr][tc] = Math.abs(r) === 2 || Math.abs(c) === 2 || r === 0 && c === 0 ? 1 : 0;
|
|
5193
|
+
const alignPos = getAlignmentPositions(version);
|
|
5194
|
+
for (const r of alignPos) {
|
|
5195
|
+
for (const c of alignPos) {
|
|
5196
|
+
if (matrix[r][c] !== -1) continue;
|
|
5197
|
+
for (let dr = -2; dr <= 2; dr++) {
|
|
5198
|
+
for (let dc = -2; dc <= 2; dc++) {
|
|
5199
|
+
const nr = r + dr;
|
|
5200
|
+
const nc = c + dc;
|
|
5201
|
+
if (nr >= 0 && nr < size && nc >= 0 && nc < size && matrix[nr][nc] === -1) {
|
|
5202
|
+
matrix[nr][nc] = Math.abs(dr) === 2 || Math.abs(dc) === 2 || dr === 0 && dc === 0 ? 1 : 0;
|
|
5231
5203
|
}
|
|
5232
5204
|
}
|
|
5233
5205
|
}
|
|
@@ -5243,37 +5215,40 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5243
5215
|
if (matrix[8][size - 1 - i] === -1) matrix[8][size - 1 - i] = 0;
|
|
5244
5216
|
if (matrix[size - 1 - i][8] === -1) matrix[size - 1 - i][8] = 0;
|
|
5245
5217
|
}
|
|
5246
|
-
const eccCount = ECC_CODEWORDS[version - 1][eclIdx];
|
|
5247
|
-
const dataCapacity = DATA_CAPACITY[version - 1][eclIdx];
|
|
5248
5218
|
const bits = [];
|
|
5249
5219
|
bits.push(0, 1, 0, 0);
|
|
5250
5220
|
const cciBits = version <= 9 ? 8 : 16;
|
|
5251
5221
|
for (let i = cciBits - 1; i >= 0; i--) {
|
|
5252
|
-
bits.push(
|
|
5222
|
+
bits.push(text.length >> i & 1);
|
|
5253
5223
|
}
|
|
5254
|
-
for (const
|
|
5255
|
-
const code2 =
|
|
5224
|
+
for (const ch of text) {
|
|
5225
|
+
const code2 = ch.charCodeAt(0);
|
|
5256
5226
|
for (let i = 7; i >= 0; i--) {
|
|
5257
5227
|
bits.push(code2 >> i & 1);
|
|
5258
5228
|
}
|
|
5259
5229
|
}
|
|
5230
|
+
const dataCapacity = DATA_CAPACITY[version][eclIdx];
|
|
5260
5231
|
const termLen = Math.min(4, dataCapacity * 8 - bits.length);
|
|
5261
5232
|
for (let i = 0; i < termLen; i++) bits.push(0);
|
|
5262
5233
|
while (bits.length % 8 !== 0) bits.push(0);
|
|
5263
|
-
const
|
|
5234
|
+
const pads = [236, 17];
|
|
5264
5235
|
let padIdx = 0;
|
|
5265
5236
|
while (bits.length < dataCapacity * 8) {
|
|
5237
|
+
const pad = pads[padIdx];
|
|
5266
5238
|
for (let i = 7; i >= 0; i--) {
|
|
5267
|
-
bits.push(
|
|
5239
|
+
bits.push(pad >> i & 1);
|
|
5268
5240
|
}
|
|
5269
5241
|
padIdx = (padIdx + 1) % 2;
|
|
5270
5242
|
}
|
|
5271
5243
|
const dataBytes = [];
|
|
5272
5244
|
for (let i = 0; i < bits.length; i += 8) {
|
|
5273
5245
|
let b = 0;
|
|
5274
|
-
for (let j = 0; j < 8; j++)
|
|
5246
|
+
for (let j = 0; j < 8; j++) {
|
|
5247
|
+
b = b << 1 | bits[i + j];
|
|
5248
|
+
}
|
|
5275
5249
|
dataBytes.push(b);
|
|
5276
5250
|
}
|
|
5251
|
+
const eccCount = ECC_CODEWORDS[version][eclIdx];
|
|
5277
5252
|
const eccBytes = rsEncode(dataBytes, eccCount);
|
|
5278
5253
|
const codewords = [...dataBytes, ...eccBytes];
|
|
5279
5254
|
let bitIdx = 0;
|
|
@@ -5288,6 +5263,9 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5288
5263
|
if (bitIdx < codewords.length * 8) {
|
|
5289
5264
|
bit = codewords[Math.floor(bitIdx / 8)] >> 7 - bitIdx % 8 & 1;
|
|
5290
5265
|
}
|
|
5266
|
+
if ((row + tc & 1) === 0) {
|
|
5267
|
+
bit = bit === 1 ? 0 : 1;
|
|
5268
|
+
}
|
|
5291
5269
|
matrix[row][tc] = bit;
|
|
5292
5270
|
bitIdx++;
|
|
5293
5271
|
}
|
|
@@ -5295,15 +5273,8 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5295
5273
|
}
|
|
5296
5274
|
upward = !upward;
|
|
5297
5275
|
}
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
if (matrix[row][col] >= 0 && (row + col) % 2 === 0) {
|
|
5301
|
-
matrix[row][col] = matrix[row][col] === 1 ? 0 : 1;
|
|
5302
|
-
}
|
|
5303
|
-
}
|
|
5304
|
-
}
|
|
5305
|
-
const eclBits = { L: 1, M: 0, Q: 3, H: 2 }[ecl] ?? 0;
|
|
5306
|
-
let formatData = eclBits << 3 | 0;
|
|
5276
|
+
const eclBits = { L: 1, M: 0, Q: 3, H: 2 }[errorCorrectionLevel] ?? 0;
|
|
5277
|
+
const formatData = eclBits << 3 | 0;
|
|
5307
5278
|
let rem = formatData;
|
|
5308
5279
|
for (let i = 0; i < 10; i++) {
|
|
5309
5280
|
rem = rem << 1 ^ (rem >> 9) * 1335;
|
|
@@ -5321,10 +5292,10 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5321
5292
|
for (let i = 0; i < 8; i++) matrix[8][size - 8 + i] = fb[14 - i];
|
|
5322
5293
|
for (let i = 8; i < 15; i++) matrix[size - 15 + i][8] = fb[14 - i];
|
|
5323
5294
|
const result = [];
|
|
5324
|
-
for (let
|
|
5325
|
-
result[
|
|
5326
|
-
for (let
|
|
5327
|
-
result[
|
|
5295
|
+
for (let r = 0; r < size; r++) {
|
|
5296
|
+
result[r] = [];
|
|
5297
|
+
for (let c = 0; c < size; c++) {
|
|
5298
|
+
result[r][c] = matrix[r][c] === 1;
|
|
5328
5299
|
}
|
|
5329
5300
|
}
|
|
5330
5301
|
return result;
|
|
@@ -5332,13 +5303,17 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5332
5303
|
const generate = () => {
|
|
5333
5304
|
if (!props.value) {
|
|
5334
5305
|
modules.value = [];
|
|
5306
|
+
moduleCount.value = 0;
|
|
5335
5307
|
return;
|
|
5336
5308
|
}
|
|
5337
5309
|
try {
|
|
5338
|
-
|
|
5310
|
+
const result = generateQR(props.value, props.errorCorrectLevel);
|
|
5311
|
+
modules.value = result;
|
|
5312
|
+
moduleCount.value = result.length;
|
|
5339
5313
|
} catch (e) {
|
|
5340
5314
|
console.error("QR Code generation failed:", e);
|
|
5341
5315
|
modules.value = [];
|
|
5316
|
+
moduleCount.value = 0;
|
|
5342
5317
|
}
|
|
5343
5318
|
};
|
|
5344
5319
|
vue.watch(() => props.value, generate);
|
|
@@ -5378,7 +5353,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
|
5378
5353
|
};
|
|
5379
5354
|
}
|
|
5380
5355
|
});
|
|
5381
|
-
const uQrcode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
5356
|
+
const uQrcode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4ef3178d"]]);
|
|
5382
5357
|
const _hoisted_1 = { class: "u-barcode" };
|
|
5383
5358
|
const _hoisted_2 = ["canvas-id"];
|
|
5384
5359
|
const _hoisted_3 = ["src"];
|