@we-debug/miniprogram 0.44.2 → 0.45.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.
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.45.1](https://github.com/dlhandsome/we-debug/compare/v0.45.0...v0.45.1) (2025-03-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fixed wxml error ([64d9590](https://github.com/dlhandsome/we-debug/commit/64d9590f0fd69f147e9ea2689638441cd0cdae2c))
12
+
13
+
14
+
15
+
16
+
17
+ # [0.45.0](https://github.com/dlhandsome/we-debug/compare/v0.44.2...v0.45.0) (2025-03-11)
18
+
19
+
20
+ ### Features
21
+
22
+ * support tableview ([26f8d0d](https://github.com/dlhandsome/we-debug/commit/26f8d0d0a3b42d7a63e900ad8b2ca09805edb2fb))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.44.2](https://github.com/dlhandsome/we-debug/compare/v0.44.1...v0.44.2) (2025-03-10)
7
29
 
8
30
  **Note:** Version bump only for package @we-debug/miniprogram
@@ -61,6 +61,7 @@ Component({
61
61
  sys: store.sys.get(),
62
62
  rules: store.rules.get(),
63
63
  jsonviews: store.jsonviews.get(),
64
+ tableviews: store.tableviews.get(),
64
65
  badges: store.badges.get(),
65
66
  modal: {
66
67
  logo: LOGO_BASE64,
@@ -91,7 +92,8 @@ Component({
91
92
  const groupStores = this.getGroupStores();
92
93
  this.setData({
93
94
  rules: groupStores.filter(i => !i.isJsonView),
94
- jsonviews: groupStores.filter(i => i.isJsonView)
95
+ jsonviews: groupStores.filter(i => i.isJsonView),
96
+ tableviews: groupStores.filter(i => i.isTableView)
95
97
  });
96
98
  },
97
99
  setBadges() {
@@ -12,6 +12,7 @@
12
12
  "w-rule": "../rule/index",
13
13
  "w-badge": "../badge/index",
14
14
  "w-json-view": "../json-view/index",
15
+ "w-table-view": "../table-view/index",
15
16
  "w-ui-check": "@we-debug/plugin-ui-check/index"
16
17
  }
17
18
  }
@@ -5,8 +5,12 @@
5
5
  <view class="w-mask__modal-header">
6
6
  <image class="w-mask__modal-logo" src="{{modal.logo}}" mode="aspectFit" lazy-load="false" binderror="" bindload=""></image>
7
7
  </view>
8
-
9
- <block wx:if="{{jsonviews.length > 0}}">
8
+ <block wx:if="{{tableviews.length > 0}}">
9
+ <view style="height:{{modal.scrollHeight}}rpx; margin-top: 12px;">
10
+ <w-table-view data="{{tableviews[0]}}"/>
11
+ </view>
12
+ </block>
13
+ <block wx:elif="{{jsonviews.length > 0}}">
10
14
  <view class="w-mask__modal-search">
11
15
  <input value="{{searchStr}}" placeholder="搜索" catchinput="searchInputHandler"/>
12
16
  <image class="search-icon--search" />
@@ -1,3 +1,10 @@
1
+ import Debug from '@we-debug/core';
2
+
3
+ const store = Debug.store;
4
+ const { isFunc } = Debug.util;
5
+
6
+ const prefix = 'debug:tableview-';
7
+
1
8
  Component({
2
9
  properties: {
3
10
  data: {
@@ -7,6 +14,7 @@ Component({
7
14
  },
8
15
 
9
16
  data: {
17
+ prefix,
10
18
  searchText: '',
11
19
  showDrawer: false,
12
20
  selectedItem: null,
@@ -17,6 +25,12 @@ Component({
17
25
 
18
26
  observers: {
19
27
  data: function (data) {
28
+ this.onDataChange(data);
29
+ }
30
+ },
31
+
32
+ methods: {
33
+ onDataChange(data) {
20
34
  if (!Array.isArray(data)) {
21
35
  console.error('TableView: data must be an array');
22
36
  return;
@@ -73,10 +87,7 @@ Component({
73
87
  parsedData,
74
88
  filteredData: parsedData
75
89
  });
76
- }
77
- },
78
-
79
- methods: {
90
+ },
80
91
  calculateDataSize(data) {
81
92
  try {
82
93
  const jsonString = JSON.stringify(data);
@@ -109,64 +120,13 @@ Component({
109
120
  },
110
121
 
111
122
  handleClear() {
112
- this.setData({
113
- searchText: '',
114
- filteredData: this.data.parsedData,
115
- dataSize: '0 B'
116
- });
123
+ this.bindClearHandler();
124
+ this.triggerEvent('clear');
117
125
  },
118
126
 
119
127
  handleRefresh() {
120
- // 重新解析数据
121
- const parsedData = this.data.data.map(item => {
122
- const key = Object.keys(item)[0];
123
- const value = item[key];
124
-
125
- let type = typeof value;
126
- if (Array.isArray(value)) {
127
- type = 'array';
128
- } else if (value === null) {
129
- type = 'null';
130
- } else if (type === 'object') {
131
- type = 'object';
132
- }
133
-
134
- let serializedValue = value;
135
- if (type === 'object' || type === 'array') {
136
- try {
137
- serializedValue = JSON.stringify(value, null, 2);
138
- } catch (e) {
139
- console.error('TableView: failed to serialize value:', e);
140
- serializedValue = String(value);
141
- }
142
- }
143
-
144
- return {
145
- key,
146
- value,
147
- type,
148
- serializedValue,
149
- highlight: true
150
- };
151
- });
152
-
153
- // 更新数据大小
154
- const dataSize = this.calculateDataSize(this.data.data);
155
-
156
- this.setData({
157
- parsedData,
158
- filteredData: parsedData,
159
- dataSize
160
- });
161
-
162
- // 3秒后移除高亮效果
163
- setTimeout(() => {
164
- const filteredData = this.data.filteredData.map(item => ({
165
- ...item,
166
- highlight: false
167
- }));
168
- this.setData({ filteredData });
169
- }, 3000);
128
+ this.bindRefreshHandler();
129
+ this.triggerEvent('refresh');
170
130
  },
171
131
 
172
132
  handleValueClick(e) {
@@ -213,6 +173,39 @@ Component({
213
173
  });
214
174
  }
215
175
  });
176
+ },
177
+ addListeners() {
178
+ const prefix = this.data.prefix;
179
+ store.event.on(prefix + ':emit', this.emit.bind(this));
180
+ },
181
+ removeListeners() {
182
+ const prefix = this.data.prefix;
183
+ store.event.off(prefix + ':emit', this.emit.bind(this));
184
+ },
185
+ emit(opt) {
186
+ if (opt.data) {
187
+ this.onDataChange(opt.data);
188
+ }
189
+ },
190
+ bindClearHandler() {
191
+ const handler = this.properties.config.handler;
192
+
193
+ if (handler && handler.bindClear && isFunc(handler.bindClear)) {
194
+ handler.bindClear.call(this);
195
+ }
196
+ },
197
+ bindRefreshHandler() {
198
+ const handler = this.properties.config.handler;
199
+
200
+ if (handler && handler.bindRefresh && isFunc(handler.bindRefresh)) {
201
+ handler.bindRefresh.call(this);
202
+ }
216
203
  }
204
+ },
205
+ attached() {
206
+ this.addListeners();
207
+ },
208
+ detached() {
209
+ this.removeListeners();
217
210
  }
218
211
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "component": true,
3
3
  "usingComponents": {
4
- "json-viewer": "../json-view/index"
4
+ "w-json-view": "../json-view/index"
5
5
  }
6
6
  }
@@ -68,9 +68,8 @@
68
68
  </view>
69
69
  </view>
70
70
  <block wx:if="{{selectedItem.type === 'object' || selectedItem.type === 'array'}}">
71
- <json-view
72
- json-data="{{selectedItem.value}}"
73
- expand-level="1"
71
+ <w-json-view
72
+ config="{{ { data: selectedItem.value } }}"
74
73
  />
75
74
  </block>
76
75
  <block wx:else>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@we-debug/miniprogram",
3
- "version": "0.44.2",
3
+ "version": "0.45.1",
4
4
  "description": "we-debug miniprogram component",
5
5
  "author": {
6
6
  "name": "dlhandsome"
@@ -26,10 +26,10 @@
26
26
  },
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@we-debug/core": "0.44.2"
29
+ "@we-debug/core": "0.45.0"
30
30
  },
31
31
  "readme": "ERROR: No README data found!",
32
32
  "_id": "@we-debug/core@0.3.5",
33
33
  "_commitid": "6c3f04b",
34
- "gitHead": "3a4399d3b313fcc56a5e77ab0631a5602b9341b6"
34
+ "gitHead": "763f120a79b0d8bc8a3cedc19617ba9aff8ab3d0"
35
35
  }