@jx3box/jx3box-vue3-ui 0.2.2 → 0.2.4

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.
@@ -0,0 +1,92 @@
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
+ mounted: function (el, binding) {
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
+ unmounted: function (el) {
85
+ el.removeEventListener("click", el.clickHandler);
86
+ el.clickHandler = null;
87
+ }
88
+ });
89
+ }
90
+ }
91
+
92
+ export default stat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-vue3-ui",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "JX3BOX Vue3 UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,6 +29,7 @@
29
29
  "@jx3box/jx3box-common": "^7.9.3",
30
30
  "@jx3box/jx3box-data": "^3.3.0",
31
31
  "@jx3box/jx3box-emotion": "^1.2.3",
32
+ "@jx3box/reporter": "^0.0.4",
32
33
  "@vueuse/core": "^9.13.0",
33
34
  "@vueuse/head": "^0.7.6",
34
35
  "axios": "^1.3.4",
@@ -1,11 +1,11 @@
1
- import { $helper } from "@jx3box/jx3box-common/js/https_v2.js";
1
+ import { $cms } from "@jx3box/jx3box-common/js/https_v2.js";
2
2
 
3
3
  function getBreadcrumb(name) {
4
- return $helper().get(`/api/breadcrumb/${name}`);
4
+ return $cms().get(`/api/cms/breadcrumb/${name}`);
5
5
  }
6
6
 
7
7
  function getBreadcrumbs(params) {
8
- return $helper().get(`/api/breadcrumbs`, {
8
+ return $cms().get(`/api/cms/breadcrumb`, {
9
9
  params: params,
10
10
  });
11
11
  }
package/src/App.vue CHANGED
@@ -8,6 +8,7 @@
8
8
  :publishEnable="true"
9
9
  :feedbackEnable="true"
10
10
  :adminEnable="true"
11
+ :crumbEnable="true"
11
12
  >
12
13
  <template #logo>
13
14
  <img svg-inline src="../assets/img/jx3.svg" />
@@ -16,7 +16,7 @@ export default {
16
16
  mounted() {
17
17
  getBreadcrumb(this.name).then((res) => {
18
18
  res = res.data;
19
- this.html = res.data.breadcrumb?.html || "";
19
+ this.html = res.data?.html || "";
20
20
  });
21
21
  },
22
22
  };
@@ -32,7 +32,11 @@
32
32
  >盒币
33
33
  </el-radio>
34
34
  <el-radio label="custom" border>自定义</el-radio>
35
- <el-input v-model="amount" v-show="count === 'custom'" placeholder="输入自定义数量"></el-input>
35
+ <el-input
36
+ v-model="amount"
37
+ v-show="count === 'custom'"
38
+ placeholder="输入自定义数量"
39
+ ></el-input>
36
40
  </el-radio-group>
37
41
  </div>
38
42
  </div>
@@ -64,7 +68,7 @@
64
68
 
65
69
  <script>
66
70
  import { grantBoxcoin } from "../../service/thx.js";
67
- import { getBreadcrumb } from "../../service/helper.js";
71
+ import { getBreadcrumb } from "../../service/breadcrumb.js";
68
72
  import User from "@jx3box/jx3box-common/js/user";
69
73
  import Contributors from "./Contributors.vue";
70
74
  export default {
@@ -157,7 +161,7 @@ export default {
157
161
  this.fetchingCurrentRelease = true;
158
162
  getBreadcrumb(`current-release-${this.hostClient}`)
159
163
  .then((res) => {
160
- this.remark += res;
164
+ this.remark += res.data.data.html;
161
165
  })
162
166
  .catch(() => {
163
167
  this.$message({
package/service/helper.js DELETED
@@ -1,16 +0,0 @@
1
- import { $helper } from "@jx3box/jx3box-common/js/https_v2";
2
-
3
- function getCollection(id) {
4
- return $helper().get(`/api/post/collection/${id}`);
5
- }
6
-
7
- // 面包屑
8
- function getBreadcrumb(key) {
9
- return $helper()
10
- .get(`/api/breadcrumb/${key}`)
11
- .then((res) => {
12
- return res.data.data.breadcrumb.html || "";
13
- });
14
- }
15
-
16
- export { getCollection, getBreadcrumb };