@we-debug/miniprogram 0.49.2 → 0.50.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.
- package/CHANGELOG.md +12 -0
- package/dist/api-view/index.js +277 -0
- package/dist/api-view/index.json +6 -0
- package/dist/api-view/index.less +1 -0
- package/dist/api-view/index.wxml +154 -0
- package/dist/api-view/index.wxss +592 -0
- package/dist/api-view/utils.js +90 -0
- package/dist/index/index.js +9 -2
- package/dist/index/index.json +2 -0
- package/dist/index/index.wxml +11 -1
- package/dist/json-view/index.js +2 -1
- package/dist/json-view/index.wxml +2 -1
- package/dist/less/api-view.less +14 -0
- package/dist/less/network-view.less +685 -0
- package/dist/network-view/index.js +300 -0
- package/dist/network-view/index.json +6 -0
- package/dist/network-view/index.less +1 -0
- package/dist/network-view/index.wxml +209 -0
- package/dist/network-view/index.wxss +582 -0
- package/dist/network-view/utils.js +240 -0
- package/dist/table-view/index.js +11 -18
- package/package.json +3 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import Debug from '@we-debug/core';
|
|
2
|
+
import {
|
|
3
|
+
TYPE_FILTERS,
|
|
4
|
+
DETAIL_TABS,
|
|
5
|
+
formatSize,
|
|
6
|
+
formatTime,
|
|
7
|
+
formatClock,
|
|
8
|
+
parseUrl,
|
|
9
|
+
parseQuery,
|
|
10
|
+
toSummary,
|
|
11
|
+
matchFilter,
|
|
12
|
+
toKeyValueList,
|
|
13
|
+
stringify,
|
|
14
|
+
truncate,
|
|
15
|
+
toJsonPreview,
|
|
16
|
+
toCurl,
|
|
17
|
+
toTimingPhases,
|
|
18
|
+
toProfileList
|
|
19
|
+
} from './utils';
|
|
20
|
+
|
|
21
|
+
const store = Debug.store;
|
|
22
|
+
const { isFunc } = Debug.util;
|
|
23
|
+
|
|
24
|
+
const prefix = 'debug:networkview-';
|
|
25
|
+
const RENDER_THROTTLE = 200;
|
|
26
|
+
|
|
27
|
+
const getDetailKey = record => `${record.id}:${record.status}:${record.endTime}`;
|
|
28
|
+
|
|
29
|
+
Component({
|
|
30
|
+
properties: {
|
|
31
|
+
config: {
|
|
32
|
+
type: Object,
|
|
33
|
+
value: {}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
data: {
|
|
38
|
+
typeFilters: TYPE_FILTERS,
|
|
39
|
+
detailTabs: DETAIL_TABS,
|
|
40
|
+
activeType: 'all',
|
|
41
|
+
keyword: '',
|
|
42
|
+
recording: true,
|
|
43
|
+
preserveLog: false,
|
|
44
|
+
list: [],
|
|
45
|
+
summary: {
|
|
46
|
+
count: 0,
|
|
47
|
+
total: 0,
|
|
48
|
+
transferred: '0 B',
|
|
49
|
+
finish: '0 ms'
|
|
50
|
+
},
|
|
51
|
+
selectedId: 0,
|
|
52
|
+
activeTab: 'Headers',
|
|
53
|
+
detail: null
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
observers: {
|
|
57
|
+
'config.id'(id) {
|
|
58
|
+
this.bindView(id);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
methods: {
|
|
63
|
+
getView() {
|
|
64
|
+
return store.networkviews.getById(this.properties.config.id);
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
callHandler(name, ...args) {
|
|
68
|
+
const view = this.getView();
|
|
69
|
+
const fn = view && view.handler && view.handler[name];
|
|
70
|
+
return isFunc(fn) ? fn(...args) : undefined;
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
getRecords() {
|
|
74
|
+
return this.callHandler('getRecords') || [];
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
bindView(id) {
|
|
78
|
+
this.unbindView();
|
|
79
|
+
if (!id) return;
|
|
80
|
+
this._eventKey = prefix + id + ':emit';
|
|
81
|
+
this._onEmit = () => this.scheduleRender();
|
|
82
|
+
store.event.on(this._eventKey, this._onEmit);
|
|
83
|
+
this.render();
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
unbindView() {
|
|
87
|
+
if (this._eventKey && this._onEmit) {
|
|
88
|
+
store.event.off(this._eventKey, this._onEmit);
|
|
89
|
+
}
|
|
90
|
+
this._eventKey = null;
|
|
91
|
+
this._onEmit = null;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
scheduleRender() {
|
|
95
|
+
if (!this._visible) {
|
|
96
|
+
this._dirty = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (this._renderTimer) return;
|
|
100
|
+
this._renderTimer = setTimeout(() => {
|
|
101
|
+
this._renderTimer = null;
|
|
102
|
+
this.render();
|
|
103
|
+
}, RENDER_THROTTLE);
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
render() {
|
|
107
|
+
this._dirty = false;
|
|
108
|
+
const records = this.getRecords();
|
|
109
|
+
const state = this.callHandler('getState') || {};
|
|
110
|
+
const { activeType, keyword, selectedId } = this.data;
|
|
111
|
+
const filtered = records.filter(r => matchFilter(r, activeType, keyword));
|
|
112
|
+
|
|
113
|
+
let transferred = 0;
|
|
114
|
+
let firstStart = 0;
|
|
115
|
+
let lastEnd = 0;
|
|
116
|
+
filtered.forEach(r => {
|
|
117
|
+
transferred += r.size || 0;
|
|
118
|
+
if (!firstStart || r.startTime < firstStart) firstStart = r.startTime;
|
|
119
|
+
if (r.endTime > lastEnd) lastEnd = r.endTime;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const nextData = {
|
|
123
|
+
recording: state.recording !== false,
|
|
124
|
+
preserveLog: !!state.preserveLog,
|
|
125
|
+
list: filtered.map(toSummary),
|
|
126
|
+
summary: {
|
|
127
|
+
count: filtered.length,
|
|
128
|
+
total: records.length,
|
|
129
|
+
transferred: formatSize(transferred),
|
|
130
|
+
finish: lastEnd && firstStart ? formatTime(lastEnd - firstStart) : '0 ms'
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
if (selectedId) {
|
|
135
|
+
const record = records.find(r => r.id === selectedId);
|
|
136
|
+
if (!record) {
|
|
137
|
+
nextData.selectedId = 0;
|
|
138
|
+
nextData.detail = null;
|
|
139
|
+
} else if (getDetailKey(record) !== this._detailKey) {
|
|
140
|
+
// 详情未变化时不重新 setData,避免 json-view 被重置而丢失展开状态
|
|
141
|
+
this._detailKey = getDetailKey(record);
|
|
142
|
+
nextData.detail = this.toDetail(record);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this.setData(nextData);
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
toDetail(record) {
|
|
150
|
+
const { query } = parseUrl(record.url);
|
|
151
|
+
const requestText = truncate(stringify(record.requestData));
|
|
152
|
+
const responseText = truncate(stringify(record.responseData));
|
|
153
|
+
const requestJson = toJsonPreview(record.requestData);
|
|
154
|
+
const responseJson = toJsonPreview(record.responseData);
|
|
155
|
+
const statusText =
|
|
156
|
+
record.status === 'pending'
|
|
157
|
+
? '(pending)'
|
|
158
|
+
: record.status === 'fail'
|
|
159
|
+
? `(failed) ${record.errMsg}`
|
|
160
|
+
: String(record.statusCode);
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
id: record.id,
|
|
164
|
+
name: toSummary(record).name,
|
|
165
|
+
general: [
|
|
166
|
+
{ key: 'Request URL', value: record.url },
|
|
167
|
+
{ key: 'Request Method', value: record.method },
|
|
168
|
+
{ key: 'Status Code', value: statusText },
|
|
169
|
+
{ key: 'API', value: 'wx.' + record.api }
|
|
170
|
+
],
|
|
171
|
+
isError: record.status === 'fail' || record.statusCode >= 400,
|
|
172
|
+
responseHeaders: toKeyValueList(record.responseHeaders),
|
|
173
|
+
requestHeaders: toKeyValueList(record.requestHeaders),
|
|
174
|
+
queryParams: parseQuery(query),
|
|
175
|
+
hasPayload: !!requestText.text,
|
|
176
|
+
requestJson,
|
|
177
|
+
requestText: requestText.text,
|
|
178
|
+
requestTruncated: requestText.truncated,
|
|
179
|
+
isPending: record.status === 'pending',
|
|
180
|
+
responseJson,
|
|
181
|
+
responseText: responseText.text,
|
|
182
|
+
responseTruncated: responseText.truncated,
|
|
183
|
+
errMsg: record.errMsg,
|
|
184
|
+
timing: {
|
|
185
|
+
startTime: formatClock(record.startTime),
|
|
186
|
+
endTime: formatClock(record.endTime),
|
|
187
|
+
duration: record.status === 'pending' ? 'Pending' : formatTime(record.duration),
|
|
188
|
+
size: formatSize(record.size),
|
|
189
|
+
phases: toTimingPhases(record.profile),
|
|
190
|
+
profile: toProfileList(record.profile)
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
handleToggleRecord() {
|
|
196
|
+
this.callHandler('bindRecordChange', !this.data.recording);
|
|
197
|
+
this.render();
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
handleClear() {
|
|
201
|
+
this.callHandler('bindClear');
|
|
202
|
+
this.setData({ selectedId: 0, detail: null });
|
|
203
|
+
this.render();
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
handleTogglePreserveLog() {
|
|
207
|
+
this.callHandler('bindPreserveLogChange', !this.data.preserveLog);
|
|
208
|
+
this.render();
|
|
209
|
+
},
|
|
210
|
+
|
|
211
|
+
handleSearch(e) {
|
|
212
|
+
this.setData({ keyword: e.detail.value });
|
|
213
|
+
this.render();
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
handleTypeTap(e) {
|
|
217
|
+
this.setData({ activeType: e.currentTarget.dataset.type });
|
|
218
|
+
this.render();
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
handleRowTap(e) {
|
|
222
|
+
const id = e.currentTarget.dataset.id;
|
|
223
|
+
const record = this.getRecords().find(r => r.id === id);
|
|
224
|
+
if (!record) return;
|
|
225
|
+
this._detailKey = getDetailKey(record);
|
|
226
|
+
this.setData({
|
|
227
|
+
selectedId: id,
|
|
228
|
+
detail: this.toDetail(record)
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
handleCloseDetail() {
|
|
233
|
+
this.setData({ selectedId: 0, detail: null });
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
handleTabTap(e) {
|
|
237
|
+
this.setData({ activeTab: e.currentTarget.dataset.tab });
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
copy(data) {
|
|
241
|
+
Debug.silent(() =>
|
|
242
|
+
wx.setClipboardData({
|
|
243
|
+
data,
|
|
244
|
+
success: () => Debug.silent(() => wx.showToast({ title: '已复制', icon: 'none' }))
|
|
245
|
+
})
|
|
246
|
+
);
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
handleCopyUrl() {
|
|
250
|
+
const record = this.getRecords().find(r => r.id === this.data.selectedId);
|
|
251
|
+
record && this.copy(record.url);
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
handleCopyCurl() {
|
|
255
|
+
const record = this.getRecords().find(r => r.id === this.data.selectedId);
|
|
256
|
+
record && this.copy(toCurl(record));
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
handleCopyResponse() {
|
|
260
|
+
const record = this.getRecords().find(r => r.id === this.data.selectedId);
|
|
261
|
+
record && this.copy(stringify(record.responseData));
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
handleCopyPayload() {
|
|
265
|
+
const record = this.getRecords().find(r => r.id === this.data.selectedId);
|
|
266
|
+
record && this.copy(stringify(record.requestData));
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
onMaskShow() {
|
|
270
|
+
this._visible = true;
|
|
271
|
+
if (this._dirty) this.render();
|
|
272
|
+
},
|
|
273
|
+
|
|
274
|
+
onMaskHide() {
|
|
275
|
+
this._visible = false;
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
lifetimes: {
|
|
280
|
+
attached() {
|
|
281
|
+
this._visible = true;
|
|
282
|
+
this._onMaskShow = this.onMaskShow.bind(this);
|
|
283
|
+
this._onMaskHide = this.onMaskHide.bind(this);
|
|
284
|
+
store.event.on('debug:mask:show-modal', this._onMaskShow);
|
|
285
|
+
store.event.on('debug:mask:hide-modal', this._onMaskHide);
|
|
286
|
+
if (!this._eventKey && this.properties.config.id) {
|
|
287
|
+
this.bindView(this.properties.config.id);
|
|
288
|
+
} else if (this._dirty) {
|
|
289
|
+
this.render();
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
detached() {
|
|
293
|
+
this.unbindView();
|
|
294
|
+
store.event.off('debug:mask:show-modal', this._onMaskShow);
|
|
295
|
+
store.event.off('debug:mask:hide-modal', this._onMaskHide);
|
|
296
|
+
clearTimeout(this._renderTimer);
|
|
297
|
+
this._renderTimer = null;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import '../less/network-view.less';
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<view class="nv">
|
|
2
|
+
<!-- 操作栏 -->
|
|
3
|
+
<view class="nv-toolbar">
|
|
4
|
+
<view class="nv-btn" bindtap="handleToggleRecord">
|
|
5
|
+
<view class="nv-record {{recording ? 'on' : ''}}"></view>
|
|
6
|
+
</view>
|
|
7
|
+
<view class="nv-search">
|
|
8
|
+
<input class="nv-search-input" placeholder="过滤 URL" value="{{keyword}}" bindinput="handleSearch" />
|
|
9
|
+
</view>
|
|
10
|
+
<view class="nv-btn" bindtap="handleClear">
|
|
11
|
+
<view class="nv-icon trash"></view>
|
|
12
|
+
</view>
|
|
13
|
+
<view class="nv-chip {{preserveLog ? 'active' : ''}}" bindtap="handleTogglePreserveLog">
|
|
14
|
+
<view class="nv-checkbox {{preserveLog ? 'checked' : ''}}"></view>
|
|
15
|
+
<text>Preserve log</text>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
|
|
19
|
+
<!-- 类型筛选 -->
|
|
20
|
+
<scroll-view class="nv-types" scroll-x="{{true}}">
|
|
21
|
+
<view
|
|
22
|
+
wx:for="{{typeFilters}}"
|
|
23
|
+
wx:key="key"
|
|
24
|
+
class="nv-type {{activeType === item.key ? 'active' : ''}}"
|
|
25
|
+
data-type="{{item.key}}"
|
|
26
|
+
bindtap="handleTypeTap"
|
|
27
|
+
>{{item.label}}</view>
|
|
28
|
+
</scroll-view>
|
|
29
|
+
|
|
30
|
+
<!-- 请求列表 -->
|
|
31
|
+
<view class="nv-table">
|
|
32
|
+
<view class="nv-row nv-head">
|
|
33
|
+
<view class="nv-col name">Name</view>
|
|
34
|
+
<view class="nv-col status">Status</view>
|
|
35
|
+
<view class="nv-col method">Method</view>
|
|
36
|
+
<view class="nv-col size">Size</view>
|
|
37
|
+
<view class="nv-col time">Time</view>
|
|
38
|
+
</view>
|
|
39
|
+
<scroll-view class="nv-body" scroll-y="{{true}}">
|
|
40
|
+
<view
|
|
41
|
+
wx:for="{{list}}"
|
|
42
|
+
wx:key="id"
|
|
43
|
+
class="nv-row {{item.isError ? 'error' : ''}} {{item.isPending ? 'pending' : ''}} {{selectedId === item.id ? 'selected' : ''}}"
|
|
44
|
+
data-id="{{item.id}}"
|
|
45
|
+
bindtap="handleRowTap"
|
|
46
|
+
>
|
|
47
|
+
<view class="nv-col name">
|
|
48
|
+
<view class="nv-name">{{item.name}}</view>
|
|
49
|
+
<view class="nv-dir">{{item.dir}}</view>
|
|
50
|
+
</view>
|
|
51
|
+
<view class="nv-col status">{{item.statusText}}</view>
|
|
52
|
+
<view class="nv-col method">{{item.method}}</view>
|
|
53
|
+
<view class="nv-col size">{{item.size}}</view>
|
|
54
|
+
<view class="nv-col time">{{item.time}}</view>
|
|
55
|
+
</view>
|
|
56
|
+
<view wx:if="{{list.length === 0}}" class="nv-empty">
|
|
57
|
+
<block wx:if="{{recording}}">
|
|
58
|
+
<view>Recording network activity...</view>
|
|
59
|
+
<view class="nv-empty-sub">发起请求后将在此展示</view>
|
|
60
|
+
</block>
|
|
61
|
+
<block wx:else>
|
|
62
|
+
<view>Recording paused</view>
|
|
63
|
+
<view class="nv-empty-sub">点击左上角录制按钮恢复抓包</view>
|
|
64
|
+
</block>
|
|
65
|
+
</view>
|
|
66
|
+
</scroll-view>
|
|
67
|
+
</view>
|
|
68
|
+
|
|
69
|
+
<!-- 状态栏 -->
|
|
70
|
+
<view class="nv-statusbar">
|
|
71
|
+
<view class="nv-stat"><text class="nv-stat-label">Requests:</text><text class="nv-stat-value">{{summary.count}} / {{summary.total}}</text></view>
|
|
72
|
+
<view class="nv-stat"><text class="nv-stat-label">Transferred:</text><text class="nv-stat-value">{{summary.transferred}}</text></view>
|
|
73
|
+
<view class="nv-stat"><text class="nv-stat-label">Finish:</text><text class="nv-stat-value">{{summary.finish}}</text></view>
|
|
74
|
+
</view>
|
|
75
|
+
|
|
76
|
+
<!-- 详情抽屉 -->
|
|
77
|
+
<view class="nv-drawer {{detail ? 'show' : ''}}">
|
|
78
|
+
<block wx:if="{{detail}}">
|
|
79
|
+
<view class="nv-drawer-header">
|
|
80
|
+
<view class="nv-drawer-title {{detail.isError ? 'error' : ''}}">{{detail.name}}</view>
|
|
81
|
+
<view class="nv-drawer-close" bindtap="handleCloseDetail"></view>
|
|
82
|
+
</view>
|
|
83
|
+
<view class="nv-tabs">
|
|
84
|
+
<view
|
|
85
|
+
wx:for="{{detailTabs}}"
|
|
86
|
+
wx:key="*this"
|
|
87
|
+
class="nv-tab {{activeTab === item ? 'active' : ''}}"
|
|
88
|
+
data-tab="{{item}}"
|
|
89
|
+
bindtap="handleTabTap"
|
|
90
|
+
>{{item}}</view>
|
|
91
|
+
</view>
|
|
92
|
+
|
|
93
|
+
<!-- Headers -->
|
|
94
|
+
<scroll-view wx:if="{{activeTab === 'Headers'}}" class="nv-drawer-body" scroll-y="{{true}}">
|
|
95
|
+
<view class="nv-card">
|
|
96
|
+
<view class="nv-card-title">General</view>
|
|
97
|
+
<view class="nv-kv" wx:for="{{detail.general}}" wx:key="key">
|
|
98
|
+
<text class="nv-k">{{item.key}}</text>
|
|
99
|
+
<text class="nv-v {{item.key === 'Status Code' && detail.isError ? 'error' : ''}}" user-select>{{item.value}}</text>
|
|
100
|
+
</view>
|
|
101
|
+
</view>
|
|
102
|
+
<view class="nv-card">
|
|
103
|
+
<view class="nv-card-title">Response Headers<text class="nv-count">{{detail.responseHeaders.length}}</text></view>
|
|
104
|
+
<view class="nv-kv" wx:for="{{detail.responseHeaders}}" wx:key="key">
|
|
105
|
+
<text class="nv-k">{{item.key}}</text>
|
|
106
|
+
<text class="nv-v" user-select>{{item.value}}</text>
|
|
107
|
+
</view>
|
|
108
|
+
<view wx:if="{{detail.responseHeaders.length === 0}}" class="nv-none">无</view>
|
|
109
|
+
</view>
|
|
110
|
+
<view class="nv-card">
|
|
111
|
+
<view class="nv-card-title">Request Headers<text class="nv-count">{{detail.requestHeaders.length}}</text></view>
|
|
112
|
+
<view class="nv-kv" wx:for="{{detail.requestHeaders}}" wx:key="key">
|
|
113
|
+
<text class="nv-k">{{item.key}}</text>
|
|
114
|
+
<text class="nv-v" user-select>{{item.value}}</text>
|
|
115
|
+
</view>
|
|
116
|
+
<view wx:if="{{detail.requestHeaders.length === 0}}" class="nv-none">无</view>
|
|
117
|
+
</view>
|
|
118
|
+
<view class="nv-actions">
|
|
119
|
+
<view class="nv-action" bindtap="handleCopyUrl"><view class="nv-icon copy"></view>复制 URL</view>
|
|
120
|
+
<view class="nv-action" bindtap="handleCopyCurl"><view class="nv-icon copy"></view>复制 cURL</view>
|
|
121
|
+
</view>
|
|
122
|
+
</scroll-view>
|
|
123
|
+
|
|
124
|
+
<!-- Payload -->
|
|
125
|
+
<view wx:elif="{{activeTab === 'Payload'}}" class="nv-drawer-body nv-flex">
|
|
126
|
+
<view wx:if="{{detail.queryParams.length > 0}}" class="nv-card">
|
|
127
|
+
<view class="nv-card-title">Query String Parameters</view>
|
|
128
|
+
<view class="nv-kv" wx:for="{{detail.queryParams}}" wx:key="index">
|
|
129
|
+
<text class="nv-k">{{item.key}}</text>
|
|
130
|
+
<text class="nv-v" user-select>{{item.value}}</text>
|
|
131
|
+
</view>
|
|
132
|
+
</view>
|
|
133
|
+
<view wx:if="{{detail.hasPayload}}" class="nv-card nv-card-fill">
|
|
134
|
+
<view class="nv-card-title">
|
|
135
|
+
<text>Request Payload</text>
|
|
136
|
+
<view class="nv-copy-btn" bindtap="handleCopyPayload"><view class="nv-icon copy"></view></view>
|
|
137
|
+
</view>
|
|
138
|
+
<view wx:if="{{detail.requestJson}}" class="nv-json">
|
|
139
|
+
<w-json-view config="{{ { data: detail.requestJson, expandLevel: 2 } }}" />
|
|
140
|
+
</view>
|
|
141
|
+
<scroll-view wx:else class="nv-json" scroll-y="{{true}}">
|
|
142
|
+
<text class="nv-code" user-select>{{detail.requestText}}</text>
|
|
143
|
+
</scroll-view>
|
|
144
|
+
</view>
|
|
145
|
+
<view wx:if="{{!detail.hasPayload && detail.queryParams.length === 0}}" class="nv-placeholder">This request has no payload</view>
|
|
146
|
+
</view>
|
|
147
|
+
|
|
148
|
+
<!-- Preview -->
|
|
149
|
+
<view wx:elif="{{activeTab === 'Preview'}}" class="nv-drawer-body nv-flex">
|
|
150
|
+
<view wx:if="{{detail.isPending}}" class="nv-placeholder">Pending...</view>
|
|
151
|
+
<view wx:elif="{{detail.errMsg && !detail.responseText}}" class="nv-placeholder error">{{detail.errMsg}}</view>
|
|
152
|
+
<view wx:elif="{{detail.responseJson}}" class="nv-card nv-card-fill">
|
|
153
|
+
<view class="nv-json">
|
|
154
|
+
<w-json-view config="{{ { data: detail.responseJson, expandLevel: 1 } }}" />
|
|
155
|
+
</view>
|
|
156
|
+
</view>
|
|
157
|
+
<view wx:elif="{{detail.responseText}}" class="nv-card nv-card-fill">
|
|
158
|
+
<scroll-view class="nv-json" scroll-y="{{true}}">
|
|
159
|
+
<text class="nv-code" user-select>{{detail.responseText}}</text>
|
|
160
|
+
</scroll-view>
|
|
161
|
+
</view>
|
|
162
|
+
<view wx:else class="nv-placeholder">This request has no response data available</view>
|
|
163
|
+
</view>
|
|
164
|
+
|
|
165
|
+
<!-- Response -->
|
|
166
|
+
<scroll-view wx:elif="{{activeTab === 'Response'}}" class="nv-drawer-body" scroll-y="{{true}}">
|
|
167
|
+
<view wx:if="{{detail.isPending}}" class="nv-placeholder">Pending...</view>
|
|
168
|
+
<view wx:elif="{{detail.errMsg && !detail.responseText}}" class="nv-placeholder error">{{detail.errMsg}}</view>
|
|
169
|
+
<view wx:elif="{{detail.responseText}}" class="nv-card">
|
|
170
|
+
<view class="nv-card-title">
|
|
171
|
+
<text>Response</text>
|
|
172
|
+
<view class="nv-copy-btn" bindtap="handleCopyResponse"><view class="nv-icon copy"></view></view>
|
|
173
|
+
</view>
|
|
174
|
+
<text class="nv-code" user-select>{{detail.responseText}}</text>
|
|
175
|
+
<view wx:if="{{detail.responseTruncated}}" class="nv-none">内容过长已截断,可点击右上角复制完整内容</view>
|
|
176
|
+
</view>
|
|
177
|
+
<view wx:else class="nv-placeholder">This request has no response data available</view>
|
|
178
|
+
</scroll-view>
|
|
179
|
+
|
|
180
|
+
<!-- Timing -->
|
|
181
|
+
<scroll-view wx:elif="{{activeTab === 'Timing'}}" class="nv-drawer-body" scroll-y="{{true}}">
|
|
182
|
+
<view class="nv-card">
|
|
183
|
+
<view class="nv-card-title">Overview</view>
|
|
184
|
+
<view class="nv-kv"><text class="nv-k">Started at</text><text class="nv-v">{{detail.timing.startTime}}</text></view>
|
|
185
|
+
<view class="nv-kv"><text class="nv-k">Finished at</text><text class="nv-v">{{detail.timing.endTime}}</text></view>
|
|
186
|
+
<view class="nv-kv"><text class="nv-k">Duration</text><text class="nv-v">{{detail.timing.duration}}</text></view>
|
|
187
|
+
<view class="nv-kv"><text class="nv-k">Size</text><text class="nv-v">{{detail.timing.size}}</text></view>
|
|
188
|
+
</view>
|
|
189
|
+
<view wx:if="{{detail.timing.phases.length > 0}}" class="nv-card">
|
|
190
|
+
<view class="nv-card-title">Request Timing</view>
|
|
191
|
+
<view class="nv-phase" wx:for="{{detail.timing.phases}}" wx:key="label">
|
|
192
|
+
<view class="nv-phase-label">{{item.label}}</view>
|
|
193
|
+
<view class="nv-phase-track">
|
|
194
|
+
<view class="nv-phase-bar" style="left: {{item.left}}%; width: {{item.width}}%; background: {{item.color}};"></view>
|
|
195
|
+
</view>
|
|
196
|
+
<view class="nv-phase-time">{{item.duration}}</view>
|
|
197
|
+
</view>
|
|
198
|
+
</view>
|
|
199
|
+
<view wx:if="{{detail.timing.profile.length > 0}}" class="nv-card">
|
|
200
|
+
<view class="nv-card-title">Profile</view>
|
|
201
|
+
<view class="nv-kv" wx:for="{{detail.timing.profile}}" wx:key="key">
|
|
202
|
+
<text class="nv-k">{{item.key}}</text>
|
|
203
|
+
<text class="nv-v">{{item.value}}</text>
|
|
204
|
+
</view>
|
|
205
|
+
</view>
|
|
206
|
+
</scroll-view>
|
|
207
|
+
</block>
|
|
208
|
+
</view>
|
|
209
|
+
</view>
|