yh-hiprint 2.6.11 → 2.6.13
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/libs/hiprint.bundle.js +2430 -1239
- package/libs/plugins/qrcode.js +46 -18
- package/package.json +3 -3
package/libs/plugins/qrcode.js
CHANGED
|
@@ -63,24 +63,52 @@ function chooseBestMode ({ mode, content, charset }) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export default
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
export default class QRCode {
|
|
67
|
+
constructor (dom, options) {
|
|
68
|
+
this.dom = dom;
|
|
69
|
+
this.options = options;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
makeCode (content) {
|
|
73
|
+
const { colorDark = '#000000', useSVG, correctLevel, mode = 4 } = this.options;
|
|
74
|
+
|
|
75
|
+
const data = {
|
|
76
|
+
level: correctLevel,
|
|
77
|
+
version: undefined,
|
|
78
|
+
content,
|
|
79
|
+
mode,
|
|
80
|
+
charset: 'UTF-8',
|
|
81
|
+
moduleSize: 2,
|
|
82
|
+
quietZone: 1,
|
|
83
|
+
background: '#FFFFFF',
|
|
84
|
+
foreground: colorDark
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const encoder = new Encoder({
|
|
88
|
+
level: data.level,
|
|
89
|
+
version: data.version,
|
|
90
|
+
hints: getHints(data),
|
|
82
91
|
});
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const qrcode = encoder.encode(chooseBestMode(data));
|
|
95
|
+
const { moduleSize, quietZone, background, foreground } = data;
|
|
96
|
+
const dataURL = qrcode.toDataURL(moduleSize, {
|
|
97
|
+
margin: quietZone,
|
|
98
|
+
background: hex2rgb(background),
|
|
99
|
+
foreground: hex2rgb(foreground),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// 渲染二维码到DOM
|
|
103
|
+
const img = document.createElement('img');
|
|
104
|
+
img.src = dataURL;
|
|
105
|
+
img.style.width = '100%';
|
|
106
|
+
img.style.height = '100%';
|
|
107
|
+
this.dom.innerHTML = '';
|
|
108
|
+
this.dom.appendChild(img);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error('QRCode generation error:', error);
|
|
111
|
+
this.dom.innerHTML = '二维码生成失败';
|
|
112
|
+
}
|
|
85
113
|
}
|
|
86
114
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yh-hiprint",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.13",
|
|
4
4
|
"description": "Hiprint for Vue3 by NoahLiu in ForceCon in Hunan Changesha",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "npm run pub:aliyun && npm run pub:npm",
|
|
9
|
-
"pub:aliyun": "npm publish --registry https://packages.aliyun.com/60765e0161a945067837bb5f/npm/npm-registry/ --no-git-checks",
|
|
10
|
-
"pub:npm": "npm publish --registry https://registry.npmjs.org/ --no-git-checks"
|
|
9
|
+
"pub:aliyun": "npm publish --registry https://packages.aliyun.com/60765e0161a945067837bb5f/npm/npm-registry/ --tag latest --no-git-checks",
|
|
10
|
+
"pub:npm": "npm publish --registry https://registry.npmjs.org/ --tag latest --no-git-checks"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@nuintun/qrcode": "^5.0.1",
|