@we-debug/miniprogram 0.42.1 → 0.42.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.42.3](https://github.com/dlhandsome/we-debug/compare/v0.42.2...v0.42.3) (2025-03-09)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **miniprogram:** fixed json view update ([0a519b9](https://github.com/dlhandsome/we-debug/commit/0a519b9b4c3f7e45c65572a2ca01120fd7d7f792))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.42.2](https://github.com/dlhandsome/we-debug/compare/v0.42.1...v0.42.2) (2025-03-09)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **miniprogram:** fixed json view scroll ([2f720f5](https://github.com/dlhandsome/we-debug/commit/2f720f55cf9329db3f19c1641e8181a61c2b8c24))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.42.1](https://github.com/dlhandsome/we-debug/compare/v0.42.0...v0.42.1) (2025-03-09)
7
29
 
8
30
 
@@ -7,8 +7,13 @@
7
7
  </view>
8
8
 
9
9
  <block wx:if="{{jsonviews.length > 0}}">
10
+ <view class="w-mask__modal-search">
11
+ <input value="{{searchStr}}" placeholder="搜索" catchinput="searchInputHandler"/>
12
+ <image class="search-icon--search" />
13
+ <image class="search-icon--close" src="../icon/close.svg" wx:if="{{searchStr}}" catchtap="searchCleanHandler"/>
14
+ </view>
10
15
  <view style="height:{{modal.scrollHeight}}rpx;">
11
- <w-json-view json-data="{{jsonviews[0].data}}" editable="{{jsonviews[0].editable}}" expand-level="{{jsonviews[0].expandLevel}}" bind:change="handleJsonViewChange"/>
16
+ <w-json-view data="{{jsonviews[0].data}}" editable="{{jsonviews[0].editable}}" expand-level="{{jsonviews[0].expandLevel}}" bind:change="handleJsonViewChange"/>
12
17
  </view>
13
18
  </block>
14
19
  <block wx:else>
@@ -1,34 +1,41 @@
1
+ import Debug from '@we-debug/core';
2
+
3
+ const store = Debug.store;
4
+ const { isFunc } = Debug.util;
5
+
6
+ const prefix = 'debug:jsonview-';
7
+
1
8
  Component({
2
9
  properties: {
3
- jsonData: {
4
- type: null,
5
- value: null,
6
- observer: function (newVal) {
7
- if (newVal) {
8
- const formatted = this.formatJson(newVal);
9
- this.setData({ formattedData: formatted });
10
- if (this.data.expandLevel >= 0) {
11
- this.updateExpandLevel(this.data.expandLevel);
12
- }
13
- }
14
- }
10
+ config: {
11
+ type: Object,
12
+ value: {}
13
+ }
14
+ },
15
+ observers: {
16
+ 'config.id'(v) {
17
+ const id = isFunc(v) ? v() : v;
18
+ this.setData({ prefix: prefix + id });
15
19
  },
16
- editable: {
17
- type: Boolean,
18
- value: false
20
+ 'config.data'(v) {
21
+ const jsonData = isFunc(v) ? v() : v;
22
+ this.onDataChange(jsonData);
23
+ this.setData({ jsonData });
19
24
  },
20
- expandLevel: {
21
- type: Number,
22
- value: -1, // -1 表示全部展开,0 表示全部折叠,正数表示展开的层级数
23
- observer: function (newVal) {
24
- if (this.data.formattedData.length > 0) {
25
- this.updateExpandLevel(newVal);
26
- }
27
- }
25
+ 'config.editable'(v) {
26
+ const editable = isFunc(v) ? v() : v;
27
+ this.setData({ editable });
28
+ },
29
+ 'config.expandLevel'(v) {
30
+ const expandLevel = isFunc(v) ? v() : v;
31
+ this.setData({ expandLevel });
28
32
  }
29
33
  },
30
-
31
34
  data: {
35
+ prefix,
36
+ jsonData: null,
37
+ editable: false,
38
+ expandLevel: -1,
32
39
  formattedData: [],
33
40
  editingIndex: -1,
34
41
  editValue: '',
@@ -42,6 +49,33 @@ Component({
42
49
  },
43
50
 
44
51
  methods: {
52
+ addListeners() {
53
+ const prefix = this.data.prefix;
54
+ store.event.on(prefix + ':emit', this.emit.bind(this));
55
+ },
56
+ removeListeners() {
57
+ const prefix = this.data.prefix;
58
+ store.event.off(prefix + ':emit', this.emit.bind(this));
59
+ },
60
+ emit(opt) {
61
+ this.setData({
62
+ ...this.properties.config,
63
+ ...opt
64
+ });
65
+
66
+ if (opt.data) {
67
+ this.onDataChange(opt.data);
68
+ }
69
+ },
70
+ onDataChange(jsonData) {
71
+ if (jsonData) {
72
+ const formatted = this.formatJson(jsonData);
73
+ this.setData({ formattedData: formatted });
74
+ if (this.data.expandLevel >= 0) {
75
+ this.updateExpandLevel(this.data.expandLevel);
76
+ }
77
+ }
78
+ },
45
79
  updateExpandLevel(level) {
46
80
  const { formattedData } = this.data;
47
81
  const stack = [];
@@ -682,5 +716,11 @@ Component({
682
716
  formattedData: restoredData
683
717
  });
684
718
  }
719
+ },
720
+ attached() {
721
+ this.addListeners();
722
+ },
723
+ detached() {
724
+ this.removeListeners();
685
725
  }
686
726
  });
@@ -2,6 +2,7 @@
2
2
  <scroll-view
3
3
  class="json-viewer"
4
4
  scroll-x="{{true}}"
5
+ scroll-y="{{true}}"
5
6
  scroll-left="{{scrollLeft}}"
6
7
  bindtouchstart="handleTouchStart"
7
8
  bindtouchmove="handleTouchMove"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@we-debug/miniprogram",
3
- "version": "0.42.1",
3
+ "version": "0.42.3",
4
4
  "description": "we-debug miniprogram component",
5
5
  "author": {
6
6
  "name": "dlhandsome"
@@ -31,5 +31,5 @@
31
31
  "readme": "ERROR: No README data found!",
32
32
  "_id": "@we-debug/core@0.3.5",
33
33
  "_commitid": "6c3f04b",
34
- "gitHead": "867ff92f78902e223a7ef84d2d955a6a4acd6284"
34
+ "gitHead": "a1bdb84b02181ee9a634ac03e51f9dc90217e6b9"
35
35
  }