@jx3box/jx3box-common-ui 7.4.7 → 7.4.8
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/package.json +1 -1
- package/assets/js/stat.js +0 -92
package/package.json
CHANGED
package/assets/js/stat.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Reporter
|
|
3
|
-
} from "@jx3box/reporter"
|
|
4
|
-
import { __Domain } from "@jx3box/jx3box-common/data/jx3box.json"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 16进制转int
|
|
8
|
-
* @param {string} str
|
|
9
|
-
* @returns
|
|
10
|
-
* @memberof stat
|
|
11
|
-
*/
|
|
12
|
-
function int162hex(str) {
|
|
13
|
-
let hex = str.toString(16);
|
|
14
|
-
return hex.length == 1 ? "0" + hex : hex;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 二进制转hex
|
|
19
|
-
* @param {string} str
|
|
20
|
-
*/
|
|
21
|
-
function bin2hex(str) {
|
|
22
|
-
let result = "";
|
|
23
|
-
for (let i = 0; i < str.length; i++) {
|
|
24
|
-
result += int162hex(str.charCodeAt(i));
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 获取uuid
|
|
31
|
-
*/
|
|
32
|
-
function getUUID(domain = __Domain) {
|
|
33
|
-
const canvas = document.createElement("canvas");
|
|
34
|
-
const ctx = canvas.getContext("2d");
|
|
35
|
-
const txt = domain;
|
|
36
|
-
ctx.textBaseline = "top";
|
|
37
|
-
ctx.font = "14px 'Arial'";
|
|
38
|
-
ctx.textBaseline = "alphabetic";
|
|
39
|
-
ctx.fillStyle = "#f60";
|
|
40
|
-
ctx.fillRect(125, 1, 62, 20);
|
|
41
|
-
ctx.fillStyle = "#069";
|
|
42
|
-
ctx.fillText(txt, 2, 15);
|
|
43
|
-
ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
|
|
44
|
-
ctx.fillText(txt, 4, 17);
|
|
45
|
-
|
|
46
|
-
const b64 = canvas.toDataURL().replace("data:image/png;base64,", "");
|
|
47
|
-
const bin = atob(b64);
|
|
48
|
-
const crc = bin2hex(bin.slice(-16, -12));
|
|
49
|
-
return crc;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 统计指令
|
|
53
|
-
const stat = {
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 上报指令 vue2
|
|
57
|
-
* @param {string} user_id 用户id 使用User.getInfo().uid获取
|
|
58
|
-
* @param {boolean} use_query 是否上报当前页面中url中的参数 默认false
|
|
59
|
-
* @param {string} caller 上报来源
|
|
60
|
-
* @param {object} data 上报数据
|
|
61
|
-
*/
|
|
62
|
-
install(Vue) {
|
|
63
|
-
Vue.directive("stat", {
|
|
64
|
-
bind: function (el, binding, vnode) {
|
|
65
|
-
el.clickHandler = function () {
|
|
66
|
-
const {
|
|
67
|
-
user_id,
|
|
68
|
-
use_query = false,
|
|
69
|
-
caller,
|
|
70
|
-
data
|
|
71
|
-
} = binding.value;
|
|
72
|
-
|
|
73
|
-
const R = new Reporter({
|
|
74
|
-
caller,
|
|
75
|
-
use_query, // 上报当前页面中url中的参数 默认false
|
|
76
|
-
useId: user_id // 当前登录用户id
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
R.p({ uuid: getUUID(), ...data })
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
el.addEventListener("click", el.clickHandler);
|
|
83
|
-
},
|
|
84
|
-
unbind: function (el, binding, vnode) {
|
|
85
|
-
el.removeEventListener("click", el.clickHandler);
|
|
86
|
-
el.clickHandler = null;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export default stat;
|