xjzh-component 0.1.0
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/README.md +24 -0
- package/dist/demo.html +1 -0
- package/dist/xjzh-component.common.906.js +74 -0
- package/dist/xjzh-component.common.js +2316 -0
- package/dist/xjzh-component.umd.600.js +85 -0
- package/dist/xjzh-component.umd.js +2327 -0
- package/dist/xjzh-component.umd.min.221.js +2 -0
- package/dist/xjzh-component.umd.min.js +2 -0
- package/jsconfig.json +19 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# component-library
|
|
2
|
+
|
|
3
|
+
## Project setup
|
|
4
|
+
```
|
|
5
|
+
npm install
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
### Compiles and hot-reloads for development
|
|
9
|
+
```
|
|
10
|
+
npm run serve
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Compiles and minifies for production
|
|
14
|
+
```
|
|
15
|
+
npm run build
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Lints and fixes files
|
|
19
|
+
```
|
|
20
|
+
npm run lint
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Customize configuration
|
|
24
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|
package/dist/demo.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><meta charset="utf-8"><title>xjzh-component demo</title><script src="./xjzh-component.umd.js"></script><script>console.log(xjzh-component)</script>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/******/ (function() { // webpackBootstrap
|
|
2
|
+
var __webpack_exports__ = {};
|
|
3
|
+
self.onmessage = function (event) {
|
|
4
|
+
const {
|
|
5
|
+
url
|
|
6
|
+
} = event.data;
|
|
7
|
+
let cameraNum = 0;
|
|
8
|
+
let ws = new WebSocket(url);
|
|
9
|
+
// socket 连接
|
|
10
|
+
ws.onopen = function () {
|
|
11
|
+
self.postMessage({
|
|
12
|
+
type: 'open'
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
// socket 接收数据
|
|
16
|
+
ws.onmessage = async function ({
|
|
17
|
+
data
|
|
18
|
+
}) {
|
|
19
|
+
if (data.size == 1) {
|
|
20
|
+
// 摄像头数量 || 是否开启人脸
|
|
21
|
+
cameraNum = await self.convertBlobToNumber(data);
|
|
22
|
+
self.postMessage({
|
|
23
|
+
type: 'message',
|
|
24
|
+
data: cameraNum
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
// 摄像头画面 数据
|
|
28
|
+
let newBlob = new Blob([data], {
|
|
29
|
+
type: 'image/jpeg'
|
|
30
|
+
});
|
|
31
|
+
self.postMessage({
|
|
32
|
+
type: 'message',
|
|
33
|
+
data: newBlob
|
|
34
|
+
});
|
|
35
|
+
newBlob = null;
|
|
36
|
+
}
|
|
37
|
+
data = null;
|
|
38
|
+
};
|
|
39
|
+
// socket 断开
|
|
40
|
+
ws.onclose = function (event) {
|
|
41
|
+
self.postMessage({
|
|
42
|
+
type: 'close',
|
|
43
|
+
event: event
|
|
44
|
+
});
|
|
45
|
+
ws = null;
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
ws = new WebSocket(url);
|
|
48
|
+
}, 1000);
|
|
49
|
+
};
|
|
50
|
+
// socket 错误
|
|
51
|
+
ws.onerror = function (error) {
|
|
52
|
+
self.postMessage({
|
|
53
|
+
type: 'error',
|
|
54
|
+
error: error
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
self.convertBlobToNumber = function (blob) {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
let reader = new FileReader();
|
|
61
|
+
reader.onload = event => {
|
|
62
|
+
resolve(event.target.result.charCodeAt(0));
|
|
63
|
+
reader = null;
|
|
64
|
+
};
|
|
65
|
+
reader.onerror = error => {
|
|
66
|
+
reject(error);
|
|
67
|
+
};
|
|
68
|
+
reader.readAsText(blob);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
module.exports = __webpack_exports__;
|
|
72
|
+
/******/ })()
|
|
73
|
+
;
|
|
74
|
+
//# sourceMappingURL=xjzh-component.common.906.js.map
|