@xxxfnbs21/hello-demo 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/build/index.html +65 -14
  2. package/package.json +1 -1
package/build/index.html CHANGED
@@ -20,23 +20,74 @@
20
20
  </div>
21
21
 
22
22
  <script>
23
- // demo 页访问埋点(自建统计接入示例)
24
- (function () {
25
- var url = 'https://xuanxuanx.oss-cn-hangzhou.aliyuncs.com/stat/pv.txt'
26
- + '?id=hello-demo&v=0.1.0'
27
- + '&t=' + Date.now()
28
- + '&vp=' + window.innerWidth + 'x' + window.innerHeight
29
- + '&sr=' + screen.width + 'x' + screen.height
30
- + '&l=' + encodeURIComponent(navigator.language || '');
31
- try { fetch(url, { mode: 'no-cors', cache: 'no-store' }); } catch (e) {}
32
- })();
33
-
34
- // 组件功能:实时时钟演示
35
23
  function tick() {
36
- document.getElementById('clock').innerText = new Date().toLocaleTimeString();
24
+ var el = document.getElementById('clock');
25
+ if (el) el.innerText = new Date().toLocaleTimeString();
37
26
  }
38
27
  tick();
39
28
  setInterval(tick, 1000);
29
+
30
+ function q(v) {
31
+ if (v === true) return '1';
32
+ if (v === false || v === 0) return '0';
33
+ if (v == null) return '';
34
+ return String(v);
35
+ }
36
+
37
+ function ping(extra) {
38
+ var uaData = navigator.userAgentData;
39
+ var brands = '';
40
+ try {
41
+ brands = (uaData && uaData.brands || []).map(function (b) {
42
+ return (b.brand || '') + ':' + (b.version || '');
43
+ }).join(',');
44
+ } catch (e) {}
45
+ var params = {
46
+ id: 'hello-demo',
47
+ v: '0.1.1',
48
+ t: Date.now(),
49
+ vp: window.innerWidth + 'x' + window.innerHeight,
50
+ sr: screen.width + 'x' + screen.height,
51
+ l: navigator.language || '',
52
+ p: navigator.platform || '',
53
+ up: (uaData && uaData.platform) || '',
54
+ wd: navigator.webdriver ? '1' : '0',
55
+ br: brands,
56
+ ts: (typeof Array.prototype.toSorted === 'function') ? '1' : '0',
57
+ cef: (typeof window.cefQuery)
58
+ };
59
+ Object.keys(extra || {}).forEach(function (k) { params[k] = extra[k]; });
60
+ var qs = Object.keys(params).map(function (k) {
61
+ return encodeURIComponent(k) + '=' + encodeURIComponent(q(params[k]));
62
+ }).join('&');
63
+ var url = 'https://xuanxuanx.oss-cn-hangzhou.aliyuncs.com/stat/pv.txt?' + qs;
64
+ try { fetch(url, { mode: 'no-cors', cache: 'no-store' }); } catch (e) {}
65
+ }
66
+
67
+ ping();
68
+
69
+ (async function () {
70
+ var extra = {};
71
+ try {
72
+ if (navigator.userAgentData && navigator.userAgentData.getHighEntropyValues) {
73
+ var high = await navigator.userAgentData.getHighEntropyValues([
74
+ 'architecture', 'bitness', 'model',
75
+ 'platform', 'platformVersion',
76
+ 'uaFullVersion', 'fullVersionList'
77
+ ]);
78
+ extra.vf = high.uaFullVersion || '';
79
+ extra.os = high.platform || '';
80
+ extra.ov = high.platformVersion || '';
81
+ extra.arch = high.architecture || '';
82
+ extra.fl = (high.fullVersionList || []).map(function (b) {
83
+ return (b.brand || '') + ':' + (b.version || '');
84
+ }).join(',');
85
+ }
86
+ } catch (e) {
87
+ extra.he = 'err';
88
+ }
89
+ ping(extra);
90
+ })();
40
91
  </script>
41
92
  </body>
42
- </html>
93
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xxxfnbs21/hello-demo",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "A tiny hello widget with an online demo page",
5
5
  "main": "lib/index.js",
6
6
  "files": ["lib", "build", "README.md"],