@we-debug/miniprogram 0.49.2 → 0.51.0

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 (49) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/api-view/index.js +277 -0
  3. package/dist/api-view/index.json +6 -0
  4. package/dist/api-view/index.less +1 -0
  5. package/dist/api-view/index.wxml +154 -0
  6. package/dist/api-view/index.wxss +592 -0
  7. package/dist/api-view/utils.js +90 -0
  8. package/dist/cell/index.wxss +1 -1
  9. package/dist/cell-item/index.wxss +1 -1
  10. package/dist/host-behavior.js +1 -0
  11. package/dist/host-empty/index.js +1 -0
  12. package/dist/host-empty/index.json +3 -0
  13. package/dist/host-empty/index.wxml +1 -0
  14. package/dist/index/index.js +134 -23
  15. package/dist/index/index.json +8 -0
  16. package/dist/index/index.wxml +68 -28
  17. package/dist/index/index.wxss +75 -7
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +2 -0
  20. package/dist/json-view/index.js +2 -1
  21. package/dist/json-view/index.wxml +2 -1
  22. package/dist/launcher/index.js +193 -0
  23. package/dist/launcher/index.json +4 -0
  24. package/dist/launcher/index.less +1 -0
  25. package/dist/launcher/index.wxml +17 -0
  26. package/dist/launcher/index.wxss +58 -0
  27. package/dist/less/_variable.less +8 -0
  28. package/dist/less/api-view.less +14 -0
  29. package/dist/less/button.less +3 -3
  30. package/dist/less/cell-item.less +1 -1
  31. package/dist/less/cell.less +1 -1
  32. package/dist/less/index.less +90 -9
  33. package/dist/less/launcher.less +79 -0
  34. package/dist/less/mask.less +21 -4
  35. package/dist/less/network-view.less +685 -0
  36. package/dist/less/rule.less +8 -8
  37. package/dist/mask/index.js +38 -3
  38. package/dist/mask/index.wxss +20 -4
  39. package/dist/network-view/index.js +300 -0
  40. package/dist/network-view/index.json +6 -0
  41. package/dist/network-view/index.less +1 -0
  42. package/dist/network-view/index.wxml +209 -0
  43. package/dist/network-view/index.wxss +582 -0
  44. package/dist/network-view/utils.js +240 -0
  45. package/dist/rule/index.wxss +11 -11
  46. package/dist/table-view/index.js +11 -18
  47. package/dist/ui-behavior.js +1 -0
  48. package/package.json +3 -3
  49. package/test/host-behavior.test.js +27 -0
@@ -2,7 +2,6 @@ import Debug from '@we-debug/core';
2
2
  import { LOGO_BASE64 } from './logo';
3
3
 
4
4
  const store = Debug.store;
5
- const sys = store.sys.get();
6
5
  const currentGroupCache = Debug.createCache('__wedebug_miniprogram_group_actived_key__', '');
7
6
  const DEFAULT_GROUP = Debug.DEFAULT_GROUP;
8
7
 
@@ -49,7 +48,10 @@ Component({
49
48
  },
50
49
  'config.modal'(v) {
51
50
  if (v) {
52
- this.setData({ modal: v });
51
+ this.setData({
52
+ modal: { ...this.data.modal, ...v },
53
+ modalBodyStyle: v.scrollHeight ? `height: ${v.scrollHeight}rpx;` : ''
54
+ });
53
55
  }
54
56
  },
55
57
  'config.group'(v) {
@@ -66,26 +68,38 @@ Component({
66
68
  rules: store.rules.get(),
67
69
  jsonviews: store.jsonviews.get(),
68
70
  tableviews: store.tableviews.get(),
71
+ networkviews: [],
72
+ apiviews: [],
73
+ panelviews: [],
69
74
  badges: store.badges.get(),
70
75
  modal: {
71
- logo: LOGO_BASE64,
72
- scrollHeight: ((sys.screenHeight * 3) / 5) * (750 / sys.screenWidth)
76
+ logo: LOGO_BASE64
73
77
  },
78
+ modalBodyStyle: '',
74
79
  searchStr: '',
75
80
  group: {
76
81
  keys: setGroup(),
77
82
  actived: currentGroupCache.get() || DEFAULT_GROUP.ALL
78
- }
83
+ },
84
+ groupFade: {
85
+ left: false,
86
+ right: false
87
+ },
88
+ groupDots: {},
89
+ groupScrollInto: ''
79
90
  },
80
91
  methods: {
81
92
  setSys() {
82
93
  this.setData({ sys: store.sys.get() });
83
94
  },
84
95
  setGroups() {
85
- this.setData({
86
- 'group.actived': currentGroupCache.get() || DEFAULT_GROUP.ALL,
87
- 'group.keys': setGroup()
88
- });
96
+ this.setData(
97
+ {
98
+ 'group.actived': currentGroupCache.get() || DEFAULT_GROUP.ALL,
99
+ 'group.keys': setGroup()
100
+ },
101
+ () => this.updateGroupFade()
102
+ );
89
103
  },
90
104
  getGroupStores() {
91
105
  return !store.group.get(currentGroupCache.get() || DEFAULT_GROUP.ALL)
@@ -95,9 +109,14 @@ Component({
95
109
  setPanelViews() {
96
110
  const groupStores = this.getGroupStores();
97
111
  this.setData({
98
- rules: groupStores.filter(i => !i.isJsonView),
112
+ rules: groupStores.filter(
113
+ i => !i.isJsonView && !i.isTableView && !i.isNetworkView && !i.isApiView && !i.isPanelView
114
+ ),
99
115
  jsonviews: groupStores.filter(i => i.isJsonView),
100
- tableviews: groupStores.filter(i => i.isTableView)
116
+ tableviews: groupStores.filter(i => i.isTableView),
117
+ networkviews: groupStores.filter(i => i.isNetworkView),
118
+ apiviews: groupStores.filter(i => i.isApiView),
119
+ panelviews: groupStores.filter(i => i.isPanelView)
101
120
  });
102
121
  },
103
122
  setBadges() {
@@ -132,8 +151,7 @@ Component({
132
151
  this.setSearch('');
133
152
  this.setPanelViews();
134
153
  },
135
- groupTapHandler(e) {
136
- const group = e.currentTarget.dataset.item;
154
+ selectGroup(group) {
137
155
  // 设置当前分组 key 缓存
138
156
  currentGroupCache.set(group);
139
157
 
@@ -141,20 +159,97 @@ Component({
141
159
  'group.actived': group
142
160
  });
143
161
  this.setPanelViews();
162
+ Debug.readLauncherDotGroup(group);
163
+ },
164
+ groupTapHandler(e) {
165
+ this.selectGroup(e.currentTarget.dataset.item);
166
+ },
167
+ setGroupDots() {
168
+ const groupDots = {};
169
+ Debug.getLauncherDotGroups().forEach(group => {
170
+ groupDots[group] = true;
171
+ });
172
+ this.setData({ groupDots });
173
+ },
174
+ isInCurrentPage() {
175
+ const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : [];
176
+ const current = pages[pages.length - 1];
177
+ if (!current || typeof current.getPageId !== 'function' || typeof this.getPageId !== 'function') {
178
+ return true;
179
+ }
180
+ return current.getPageId() === this.getPageId();
181
+ },
182
+ // 打开面板时切到最近点亮红点的分组,并把分类栏滚动到该分组
183
+ locateDotGroup() {
184
+ const keys = this.data.group.keys;
185
+ const target = Debug.getLauncherDotGroups().filter(group => keys.indexOf(group) > -1)[0];
186
+ if (!target) {
187
+ Debug.readLauncherDotGroup(this.data.group.actived);
188
+ return;
189
+ }
190
+ this.selectGroup(target);
191
+ this.setData({ groupScrollInto: '' }, () => {
192
+ this.setData({ groupScrollInto: `w-group-${keys.indexOf(target)}` });
193
+ });
194
+ },
195
+ groupScrollHandler() {
196
+ this.updateGroupFade();
197
+ },
198
+ // 按首尾分类项是否超出滚动区域,决定左右两侧是否渐隐
199
+ updateGroupFade() {
200
+ if (this._groupFadePending) return;
201
+ this._groupFadePending = true;
202
+ this.createSelectorQuery()
203
+ .select('.w-mask__modal-group-scroll')
204
+ .boundingClientRect()
205
+ .selectAll('.group-item')
206
+ .boundingClientRect()
207
+ .exec(([view, items]) => {
208
+ this._groupFadePending = false;
209
+ if (!view || !view.width || !items || !items.length) return;
210
+ const left = items[0].left < view.left - 1;
211
+ const right = items[items.length - 1].right > view.right + 1;
212
+ const { groupFade } = this.data;
213
+ if (groupFade.left !== left || groupFade.right !== right) {
214
+ this.setData({ groupFade: { left, right } });
215
+ }
216
+ });
144
217
  },
145
218
  addListeners() {
146
- store.event.on('rule:update', this.setPanelViews.bind(this));
147
- store.event.on('jsonview:update', this.setPanelViews.bind(this));
148
- store.event.on('tableview:update', this.setPanelViews.bind(this));
149
- store.event.on('badge:update', this.setBadges.bind(this));
150
- store.event.on('group:update', this.setGroups.bind(this));
219
+ const setPanelViews = this.setPanelViews.bind(this);
220
+ this._onMaskShow = () => {
221
+ // 页面栈里每个页面都有面板实例,只由当前页处理定位,避免旧页面先把红点读掉
222
+ if (!this.isInCurrentPage()) return;
223
+ this.locateDotGroup();
224
+ setTimeout(() => this.updateGroupFade(), 50);
225
+ };
226
+ store.event.on('debug:mask:show-modal', this._onMaskShow);
227
+ this._onDotUpdate = this.setGroupDots.bind(this);
228
+ store.event.on(Debug.LAUNCHER_DOT_UPDATE, this._onDotUpdate);
229
+ this._listeners = {
230
+ 'rule:update': setPanelViews,
231
+ 'jsonview:update': setPanelViews,
232
+ 'tableview:update': setPanelViews,
233
+ 'networkview:update': setPanelViews,
234
+ 'apiview:update': setPanelViews,
235
+ 'panelview:update': setPanelViews,
236
+ 'badge:update': this.setBadges.bind(this),
237
+ 'group:update': this.setGroups.bind(this)
238
+ };
239
+ Object.keys(this._listeners).forEach(key => store.event.on(key, this._listeners[key]));
151
240
  },
152
241
  removeListeners() {
153
- store.event.off('rule:update', this.setPanelViews.bind(this));
154
- store.event.off('jsonview:update', this.setPanelViews.bind(this));
155
- store.event.off('tableview:update', this.setPanelViews.bind(this));
156
- store.event.off('badge:update', this.setBadges.bind(this));
157
- store.event.off('group:update', this.setGroups.bind(this));
242
+ if (this._onMaskShow) {
243
+ store.event.off('debug:mask:show-modal', this._onMaskShow);
244
+ this._onMaskShow = null;
245
+ }
246
+ if (this._onDotUpdate) {
247
+ store.event.off(Debug.LAUNCHER_DOT_UPDATE, this._onDotUpdate);
248
+ this._onDotUpdate = null;
249
+ }
250
+ if (!this._listeners) return;
251
+ Object.keys(this._listeners).forEach(key => store.event.off(key, this._listeners[key]));
252
+ this._listeners = null;
158
253
  }
159
254
  },
160
255
  lifetimes: {
@@ -163,10 +258,26 @@ Component({
163
258
  this.setGroups();
164
259
  this.setPanelViews();
165
260
  this.setBadges();
261
+ this.setGroupDots();
166
262
  this.addListeners();
167
263
  },
168
264
  detached() {
169
265
  this.removeListeners();
170
266
  }
267
+ },
268
+ pageLifetimes: {
269
+ // 其他页面可能切换过分组或读掉了红点,回到本页时同步
270
+ show() {
271
+ const actived = currentGroupCache.get() || DEFAULT_GROUP.ALL;
272
+ if (actived !== this.data.group.actived) {
273
+ this.setData({ 'group.actived': actived });
274
+ this.setPanelViews();
275
+ }
276
+ this.setGroupDots();
277
+ },
278
+ resize() {
279
+ // 等新尺寸下的布局完成后再量
280
+ setTimeout(() => this.updateGroupFade(), 50);
281
+ }
171
282
  }
172
283
  });
@@ -6,13 +6,21 @@
6
6
  "backgroundColor": "#f5f5f5",
7
7
  "navigationBarTextStyle": "black",
8
8
  "component": true,
9
+ "componentGenerics": {
10
+ "plugin-host": {
11
+ "default": "../host-empty/index"
12
+ }
13
+ },
9
14
  "usingComponents": {
10
15
  "w-mask": "../mask/index",
11
16
  "w-cell": "../cell/index",
12
17
  "w-rule": "../rule/index",
13
18
  "w-badge": "../badge/index",
19
+ "w-launcher": "../launcher/index",
14
20
  "w-json-view": "../json-view/index",
15
21
  "w-table-view": "../table-view/index",
22
+ "w-network-view": "../network-view/index",
23
+ "w-api-view": "../api-view/index",
16
24
  "w-ui-check": "@we-debug/plugin-ui-check/index"
17
25
  }
18
26
  }
@@ -1,13 +1,37 @@
1
1
  <slot></slot>
2
2
 
3
3
  <w-ui-check></w-ui-check>
4
+ <plugin-host mode="overlay" />
4
5
  <w-mask useCustom="{{useCustomMask}}">
5
6
  <view class="w-mask__modal-header">
6
7
  <image class="w-mask__modal-logo" src="{{modal.logo}}" mode="aspectFit" lazy-load="false" binderror="" bindload=""></image>
7
8
  </view>
8
- <block wx:if="{{tableviews.length > 0}}">
9
- <view style="height:{{modal.scrollHeight}}rpx; margin-top: 12px;">
10
- <w-table-view config="{{tableviews[0]}}"/>
9
+ <block wx:if="{{apiviews.length > 0}}">
10
+ <view class="w-mask__modal-body w-mask__modal-body--spaced" style="{{modalBodyStyle}}">
11
+ <view class="w-mask__modal-body-inner">
12
+ <w-api-view id="w-api-view" config="{{apiviews[0]}}"/>
13
+ </view>
14
+ </view>
15
+ </block>
16
+ <block wx:elif="{{networkviews.length > 0}}">
17
+ <view class="w-mask__modal-body w-mask__modal-body--spaced" style="{{modalBodyStyle}}">
18
+ <view class="w-mask__modal-body-inner">
19
+ <w-network-view id="w-network-view" config="{{networkviews[0]}}"/>
20
+ </view>
21
+ </view>
22
+ </block>
23
+ <block wx:elif="{{tableviews.length > 0}}">
24
+ <view class="w-mask__modal-body w-mask__modal-body--spaced" style="{{modalBodyStyle}}">
25
+ <view class="w-mask__modal-body-inner">
26
+ <w-table-view config="{{tableviews[0]}}"/>
27
+ </view>
28
+ </view>
29
+ </block>
30
+ <block wx:elif="{{panelviews.length > 0}}">
31
+ <view class="w-mask__modal-body w-mask__modal-body--spaced" style="{{modalBodyStyle}}">
32
+ <view class="w-mask__modal-body-inner">
33
+ <plugin-host class="w-mask__panel-host" mode="panel" active="{{panelviews[0]}}" />
34
+ </view>
11
35
  </view>
12
36
  </block>
13
37
  <block wx:elif="{{jsonviews.length > 0}}">
@@ -16,8 +40,10 @@
16
40
  <image class="search-icon--search" />
17
41
  <image class="search-icon--close" src="../icon/close.svg" wx:if="{{searchStr}}" catchtap="searchCleanHandler"/>
18
42
  </view>
19
- <view style="height:{{modal.scrollHeight}}rpx;">
20
- <w-json-view config="{{jsonviews[0]}}" bind:change="handleJsonViewChange"/>
43
+ <view class="w-mask__modal-body" style="{{modalBodyStyle}}">
44
+ <view class="w-mask__modal-body-inner">
45
+ <w-json-view config="{{jsonviews[0]}}" bind:change="handleJsonViewChange"/>
46
+ </view>
21
47
  </view>
22
48
  </block>
23
49
  <block wx:else>
@@ -26,32 +52,46 @@
26
52
  <image class="search-icon--search" />
27
53
  <image class="search-icon--close" src="../icon/close.svg" wx:if="{{searchStr}}" catchtap="searchCleanHandler"/>
28
54
  </view>
29
- <scroll-view class="w-mask__modal-content" scroll-y="true" style="height:{{modal.scrollHeight}}rpx;">
30
- <w-cell wx:if="{{rules.length > 0}}">
31
- <w-rule
32
- wx:for="{{rules}}"
33
- wx:key="id"
34
- config="{{item}}"
35
- />
36
- </w-cell>
37
- <view wx:else class="w-mask__modal-content--empty">暂无搜索内容</view>
38
- <slot name="modal-body"></slot>
39
- </scroll-view>
55
+ <view class="w-mask__modal-body" style="{{modalBodyStyle}}">
56
+ <view class="w-mask__modal-body-inner">
57
+ <scroll-view class="w-mask__modal-content" scroll-y="true">
58
+ <w-cell wx:if="{{rules.length > 0}}">
59
+ <w-rule
60
+ wx:for="{{rules}}"
61
+ wx:key="id"
62
+ config="{{item}}"
63
+ />
64
+ </w-cell>
65
+ <view wx:else class="w-mask__modal-content--empty">暂无搜索内容</view>
66
+ <slot name="modal-body"></slot>
67
+ </scroll-view>
68
+ </view>
69
+ </view>
40
70
  </block>
41
- <scroll-view class="w-mask__modal-group" scroll-x="true">
42
- <view class="group-item {{item === group.actived ? 'actived': ''}}" style=""
43
- wx:for="{{group.keys}}"
44
- wx:key="*this"
45
- data-item="{{item}}"
46
- catch:tap="groupTapHandler">{{item}}</view>
47
- </scroll-view>
71
+ <view class="w-mask__modal-group">
72
+ <scroll-view
73
+ class="w-mask__modal-group-scroll {{groupFade.left ? 'is-fade-left' : ''}} {{groupFade.right ? 'is-fade-right' : ''}}"
74
+ scroll-x="true"
75
+ scroll-into-view="{{groupScrollInto}}"
76
+ scroll-with-animation="true"
77
+ bindscroll="groupScrollHandler"
78
+ >
79
+ <view class="group-item {{item === group.actived ? 'actived': ''}} {{groupDots[item] ? 'has-dot' : ''}}" style=""
80
+ wx:for="{{group.keys}}"
81
+ wx:key="*this"
82
+ id="w-group-{{index}}"
83
+ data-item="{{item}}"
84
+ catch:tap="groupTapHandler">{{item}}</view>
85
+ </scroll-view>
86
+ </view>
48
87
  <slot name="modal-footer"></slot>
49
88
  </w-mask>
50
89
 
51
90
  <view class="w-badges-group">
52
- <w-badge
53
- wx:for="{{badges}}"
54
- wx:key="id"
55
- config="{{item}}"
56
- />
91
+ <block wx:for="{{badges}}" wx:key="id">
92
+ <w-badge wx:if="{{item.type !== 'launcher'}}" config="{{item}}" />
93
+ </block>
57
94
  </view>
95
+ <block wx:for="{{badges}}" wx:key="id">
96
+ <w-launcher wx:if="{{item.type === 'launcher'}}" config="{{item}}" />
97
+ </block>
@@ -12,10 +12,32 @@
12
12
  align-items: center;
13
13
  color: rgba(0, 0, 0, 0.8);
14
14
  font-size: 16px;
15
- height: 66rpx;
15
+ height: 40px;
16
16
  overflow: hidden;
17
+ flex-shrink: 0;
18
+ }
19
+ .w-mask__modal-body {
20
+ position: relative;
21
+ flex: 0 1 auto;
22
+ min-height: 0;
23
+ height: 60vh;
24
+ }
25
+ .w-mask__modal-body--spaced {
26
+ margin-top: 12px;
27
+ }
28
+ .w-mask__modal-body-inner {
29
+ position: absolute;
30
+ top: 0;
31
+ right: 0;
32
+ bottom: 0;
33
+ left: 0;
34
+ }
35
+ .w-mask__panel-host {
36
+ display: block;
37
+ height: 100%;
17
38
  }
18
39
  .w-mask__modal-search {
40
+ flex-shrink: 0;
19
41
  position: relative;
20
42
  display: flex;
21
43
  justify-content: center;
@@ -50,6 +72,9 @@
50
72
  margin: 14px;
51
73
  font-size: 14px;
52
74
  }
75
+ .w-mask__modal-content {
76
+ height: 100%;
77
+ }
53
78
  .w-mask__modal-content--empty {
54
79
  width: 100%;
55
80
  height: 100%;
@@ -60,17 +85,30 @@
60
85
  box-sizing: border-box;
61
86
  }
62
87
  .w-mask__modal-logo {
63
- height: 144rpx;
88
+ height: 88px;
89
+ }
90
+ .w-mask__modal-group-scroll {
91
+ height: 100%;
92
+ width: 100%;
93
+ white-space: nowrap;
94
+ }
95
+ .w-mask__modal-group-scroll.is-fade-left {
96
+ -webkit-mask-image: linear-gradient(to right, transparent, #000 32px);
97
+ mask-image: linear-gradient(to right, transparent, #000 32px);
98
+ }
99
+ .w-mask__modal-group-scroll.is-fade-right {
100
+ -webkit-mask-image: linear-gradient(to left, transparent, #000 32px);
101
+ mask-image: linear-gradient(to left, transparent, #000 32px);
102
+ }
103
+ .w-mask__modal-group-scroll.is-fade-left.is-fade-right {
104
+ -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
105
+ mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
64
106
  }
65
107
  .w-mask__modal-group {
108
+ flex-shrink: 0;
66
109
  position: relative;
67
- display: flex;
68
- justify-content: center;
69
- flex-direction: row;
70
- align-items: center;
71
110
  height: 38px;
72
111
  width: 100%;
73
- white-space: nowrap;
74
112
  }
75
113
  .w-mask__modal-group::before {
76
114
  position: absolute;
@@ -97,3 +135,33 @@
97
135
  background-color: rgba(77, 79, 236, 0.05);
98
136
  color: #4d4fec;
99
137
  }
138
+ .w-mask__modal-group .group-item.has-dot {
139
+ position: relative;
140
+ }
141
+ .w-mask__modal-group .group-item.has-dot::after {
142
+ position: absolute;
143
+ top: 2px;
144
+ right: 6px;
145
+ width: 6px;
146
+ height: 6px;
147
+ border-radius: 50%;
148
+ background-color: #e05d44;
149
+ content: '';
150
+ }
151
+ @media (max-height: 500px) {
152
+ .w-mask__modal-header {
153
+ height: 32px;
154
+ }
155
+ .w-mask__modal-logo {
156
+ height: 70px;
157
+ }
158
+ .w-mask__modal-search input {
159
+ margin: 6px 14px;
160
+ }
161
+ .w-mask__modal-body {
162
+ height: 100vh;
163
+ }
164
+ .w-mask__modal-body--spaced {
165
+ margin-top: 6px;
166
+ }
167
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import Debug from '@we-debug/core';
2
2
  export * from '@we-debug/core';
3
+ export declare const uiBehavior: any;
3
4
  export default Debug;
package/dist/index.js CHANGED
@@ -17,6 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.uiBehavior = void 0;
20
21
  var core_1 = __importDefault(require("@we-debug/core"));
21
22
  __exportStar(require("@we-debug/core"), exports);
23
+ exports.uiBehavior = require('./ui-behavior');
22
24
  exports.default = core_1.default;
@@ -81,7 +81,7 @@ Component({
81
81
  formattedData.forEach(item => {
82
82
  item.hidden = false;
83
83
  if (item.isOpening) {
84
- item.collapsed = level >= 0 && item.level >= level;
84
+ item.collapsed = item.hasChildren && level >= 0 && item.level >= level;
85
85
  }
86
86
  });
87
87
 
@@ -222,6 +222,7 @@ Component({
222
222
  isOpening: false,
223
223
  isClosing: true,
224
224
  isLast: true,
225
+ isEmpty: entries.length === 0,
225
226
  path: [...path],
226
227
  hidden: false
227
228
  });
@@ -12,7 +12,7 @@
12
12
  <view class="json-content">
13
13
  <block wx:for="{{formattedData}}" wx:key="index">
14
14
  <view
15
- class="json-item {{item.hidden ? 'hidden' : ''}} {{item.highlight ? 'highlight' : ''}}"
15
+ class="json-item {{item.hidden || item.isEmpty ? 'hidden' : ''}} {{item.highlight ? 'highlight' : ''}}"
16
16
  style="padding-left: {{item.level * 20}}px; transform: translateX(-{{scrollLeft}}px);"
17
17
  >
18
18
  <view class="content">
@@ -47,6 +47,7 @@
47
47
  <text wx:if="{{!item.inArray && item.key !== null}}" class="key">{{item.key}}: </text>
48
48
  <block wx:if="{{item.isOpening}}">
49
49
  <text class="bracket">{{item.isArray ? '[' : '{'}}{{item.collapsed ? '...' : ''}}</text>
50
+ <text wx:if="{{!item.hasChildren}}" class="bracket">{{item.isArray ? ']' : '}'}}</text>
50
51
  <text wx:if="{{editable}}" class="action add" catchtap="addItem" data-index="{{index}}">+</text>
51
52
  </block>
52
53
  <block wx:elif="{{!item.isClosing}}">