vite-uni-dev-tool 0.0.21 → 0.0.22
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/README.md +8 -3
- package/dist/const.d.ts +12 -0
- package/dist/const.d.ts.map +1 -1
- package/dist/const.js +23 -20
- package/dist/core.d.ts +3 -3
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +89 -49
- package/dist/devEvent/index.d.ts +34 -0
- package/dist/devEvent/index.d.ts.map +1 -1
- package/dist/devEvent/index.js +71 -27
- package/dist/devIntercept/index.d.ts.map +1 -1
- package/dist/devIntercept/index.js +171 -145
- package/dist/devStore/index.d.ts +9 -0
- package/dist/devStore/index.d.ts.map +1 -1
- package/dist/devStore/index.js +54 -20
- package/dist/plugins/uniDevTool/uniDevTool.d.ts +1 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dist/type.d.ts +18 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/v2/DevTool/index.vue +8 -8
- package/dist/v3/DevTool/index.vue +13 -12
- package/dist/v3/DevToolWindow/const.d.ts +30 -0
- package/dist/v3/DevToolWindow/const.d.ts.map +1 -0
- package/dist/v3/DevToolWindow/const.ts +123 -0
- package/dist/v3/DevToolWindow/index.vue +166 -107
- package/dist/v3/NetworkList/InterceptConfig.vue +835 -0
- package/dist/v3/NetworkList/InterceptItem.vue +132 -0
- package/dist/v3/NetworkList/NetworkDetail.vue +23 -12
- package/dist/v3/NetworkList/NetworkIntercept.vue +85 -0
- package/dist/v3/NetworkList/NetworkItem.vue +18 -18
- package/dist/v3/NetworkList/NetworkSend.vue +61 -45
- package/dist/v3/NetworkList/index.vue +11 -67
- package/dist/v3/SettingList/index.vue +23 -2
- package/dist/v3/SourceCode/index.vue +0 -1
- package/dist/v3/Tag/index.vue +1 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<view class="dev-tool-window-bg"></view>
|
|
12
12
|
<Tabs
|
|
13
13
|
v-model="activeTab"
|
|
14
|
-
:items="
|
|
14
|
+
:items="tabItems"
|
|
15
15
|
:scroll-left="tabScrollLeft"
|
|
16
16
|
@close="onCloseWindow"
|
|
17
17
|
@scroll="debounceScrollTabs"
|
|
@@ -59,6 +59,9 @@
|
|
|
59
59
|
@search="onSearchNetwork"
|
|
60
60
|
@sort="onSortNetwork"
|
|
61
61
|
@openCode="onOpenCode"
|
|
62
|
+
@openSend="onOpenNetworkSend"
|
|
63
|
+
@openDetail="onOpenNetworkDetail"
|
|
64
|
+
@openIntercept="onOpenNetworkIntercept"
|
|
62
65
|
/>
|
|
63
66
|
</swiper-item>
|
|
64
67
|
<swiper-item>
|
|
@@ -171,6 +174,7 @@
|
|
|
171
174
|
:devToolVisible="devToolVisible"
|
|
172
175
|
:sizeFormat="sizeFormat"
|
|
173
176
|
:theme="theme"
|
|
177
|
+
:cacheInterceptConfig="cacheInterceptConfig"
|
|
174
178
|
@showDevButton="onShowDevButton"
|
|
175
179
|
@restartDevTool="onRestartDevTool"
|
|
176
180
|
@restartApp="onRestartApp"
|
|
@@ -179,6 +183,7 @@
|
|
|
179
183
|
@clearCache="onClearCache"
|
|
180
184
|
@destroyDevTool="onDestroyDevTool"
|
|
181
185
|
@changeTheme="onChangeTheme"
|
|
186
|
+
@changeCacheInterceptConfig="onChangeCacheInterceptConfig"
|
|
182
187
|
/>
|
|
183
188
|
</swiper-item>
|
|
184
189
|
</swiper>
|
|
@@ -187,17 +192,55 @@
|
|
|
187
192
|
<SourceCode
|
|
188
193
|
v-if="openCode"
|
|
189
194
|
:url="stack"
|
|
190
|
-
:sourceFileServers="sourceFileServers"
|
|
191
195
|
:mode="mode"
|
|
192
196
|
:zIndex="zIndex"
|
|
197
|
+
:sourceFileServers="sourceFileServers"
|
|
193
198
|
@close="onCloseCode"
|
|
194
199
|
/>
|
|
200
|
+
|
|
201
|
+
<!-- 发起请求 -->
|
|
202
|
+
<NetworkSend
|
|
203
|
+
v-if="showNetworkSend"
|
|
204
|
+
:zIndex="zIndex"
|
|
205
|
+
:network="network"
|
|
206
|
+
:interceptNetworkList="interceptNetworkList"
|
|
207
|
+
@close="onCloseNetworkSend"
|
|
208
|
+
@openDetail="onOpenNetworkDetail"
|
|
209
|
+
/>
|
|
210
|
+
|
|
211
|
+
<!-- 拦截请求 -->
|
|
212
|
+
<NetworkIntercept
|
|
213
|
+
v-if="showNetworkIntercept"
|
|
214
|
+
:zIndex="zIndex"
|
|
215
|
+
:network="network"
|
|
216
|
+
:interceptNetworkList="interceptNetworkList"
|
|
217
|
+
@close="onCloseNetworkIntercept"
|
|
218
|
+
@remove="onRemoveInterceptConfig"
|
|
219
|
+
@openConfig="onOpenInterceptConfig"
|
|
220
|
+
/>
|
|
221
|
+
|
|
222
|
+
<!-- 拦截配置 -->
|
|
223
|
+
<InterceptConfig
|
|
224
|
+
v-if="showInterceptConfig"
|
|
225
|
+
:zIndex="zIndex"
|
|
226
|
+
:network="network"
|
|
227
|
+
@close="onCloseInterceptConfig"
|
|
228
|
+
@confirm="onConfirmInterceptConfig"
|
|
229
|
+
/>
|
|
230
|
+
|
|
231
|
+
<!-- 请求详情 -->
|
|
232
|
+
<NetworkDetail
|
|
233
|
+
v-if="showNetworkDetail"
|
|
234
|
+
:zIndex="zIndex"
|
|
235
|
+
:network="network"
|
|
236
|
+
@close="onCloseNetworkDetail"
|
|
237
|
+
/>
|
|
195
238
|
</view>
|
|
196
239
|
</template>
|
|
197
240
|
|
|
198
241
|
<script setup lang="ts">
|
|
199
242
|
import { onLoad, onUnload, onShow, onHide } from '@dcloudio/uni-app';
|
|
200
|
-
import { ref, onMounted } from 'vue';
|
|
243
|
+
import { ref, onMounted, reactive } from 'vue';
|
|
201
244
|
import Tabs from '../Tabs/index.vue';
|
|
202
245
|
import ConsoleList from '../ConsoleList/index.vue';
|
|
203
246
|
import NetworkList from '../NetworkList/index.vue';
|
|
@@ -217,6 +260,11 @@ import AppInfo from '../AppInfo/index.vue';
|
|
|
217
260
|
import CaptureScreen from '../CaptureScreen/index.vue';
|
|
218
261
|
import SourceCode from '../SourceCode/index.vue';
|
|
219
262
|
|
|
263
|
+
import NetworkSend from '../NetworkList/NetworkSend.vue';
|
|
264
|
+
import NetworkDetail from '../NetworkList/NetworkDetail.vue';
|
|
265
|
+
import NetworkIntercept from '../NetworkList/NetworkIntercept.vue';
|
|
266
|
+
import InterceptConfig from '../NetworkList/InterceptConfig.vue';
|
|
267
|
+
|
|
220
268
|
import {
|
|
221
269
|
DEV_BUTTON_SHOW_OR_HIDE,
|
|
222
270
|
DEV_CONSOLE_CLEAR,
|
|
@@ -241,111 +289,15 @@ import {
|
|
|
241
289
|
DEV_UNI_EVENT_CLEAR,
|
|
242
290
|
DEV_RUN_JS,
|
|
243
291
|
DEV_CAPTURE_SCREEN_CLEAR,
|
|
292
|
+
DEV_INTERCEPT_NETWORK_UPDATE,
|
|
293
|
+
DEV_INTERCEPT_NETWORK_REMOVE,
|
|
294
|
+
DEV_CHANGE_CACHE_INTERCEPT_CONFIG,
|
|
244
295
|
} from '../../const';
|
|
245
296
|
import { debounce, hightLight, isAndroid, isMockWX } from '../../utils/index';
|
|
246
297
|
import type { DevTool } from '../../type';
|
|
247
298
|
import { eventBus } from '../../core';
|
|
248
299
|
import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
|
|
249
|
-
|
|
250
|
-
const items = [
|
|
251
|
-
{
|
|
252
|
-
key: 'Console',
|
|
253
|
-
label: 'Console',
|
|
254
|
-
value: 'Console',
|
|
255
|
-
index: 0,
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
key: 'Connection',
|
|
259
|
-
label: 'Connection',
|
|
260
|
-
value: 'Connection',
|
|
261
|
-
index: 1,
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
key: 'Network',
|
|
265
|
-
label: 'Network',
|
|
266
|
-
value: 'NetWork',
|
|
267
|
-
index: 2,
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
key: 'Upload',
|
|
271
|
-
label: 'Upload',
|
|
272
|
-
value: 'Upload',
|
|
273
|
-
index: 3,
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
key: 'WebSocket',
|
|
277
|
-
label: 'WebSocket',
|
|
278
|
-
value: 'WebSocket',
|
|
279
|
-
index: 4,
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
key: 'Route',
|
|
283
|
-
label: 'Route',
|
|
284
|
-
value: 'Route',
|
|
285
|
-
index: 5,
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
key: 'UniEvent',
|
|
289
|
-
label: 'UniEvent',
|
|
290
|
-
value: 'UniEvent',
|
|
291
|
-
index: 6,
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
key: 'CaptureScreen',
|
|
295
|
-
label: 'CaptureScreen',
|
|
296
|
-
value: 'CaptureScreen',
|
|
297
|
-
index: 7,
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
key: 'Storage',
|
|
301
|
-
label: 'Storage',
|
|
302
|
-
value: 'Storage',
|
|
303
|
-
index: 8,
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
{
|
|
307
|
-
key: 'Vuex',
|
|
308
|
-
label: 'Vuex',
|
|
309
|
-
value: 'Vuex',
|
|
310
|
-
index: 9,
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
key: 'Pinia',
|
|
314
|
-
label: 'Pinia',
|
|
315
|
-
value: 'Pinia',
|
|
316
|
-
index: 10,
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
key: 'Window',
|
|
320
|
-
label: 'Window',
|
|
321
|
-
value: 'Window',
|
|
322
|
-
index: 11,
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
key: 'Device',
|
|
326
|
-
label: 'Device',
|
|
327
|
-
value: 'Device',
|
|
328
|
-
index: 12,
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
key: 'System',
|
|
332
|
-
label: 'System',
|
|
333
|
-
value: 'System',
|
|
334
|
-
index: 13,
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
key: 'AppInfo',
|
|
338
|
-
label: 'AppInfo',
|
|
339
|
-
value: 'AppInfo',
|
|
340
|
-
index: 14,
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
key: 'Setting',
|
|
344
|
-
label: 'Setting',
|
|
345
|
-
value: 'Setting',
|
|
346
|
-
index: 15,
|
|
347
|
-
},
|
|
348
|
-
];
|
|
300
|
+
import { tabItems, emptyNetwork } from './const';
|
|
349
301
|
|
|
350
302
|
const backup: {
|
|
351
303
|
consoleList: DevTool.ConsoleItem[];
|
|
@@ -381,6 +333,7 @@ const eventList = ref<DevTool.EventItem[]>([]);
|
|
|
381
333
|
const eventCount = ref<DevTool.EventCount>();
|
|
382
334
|
const appInfo = ref<Record<string, any>>({});
|
|
383
335
|
const captureScreenList = ref<DevTool.CaptureScreenItem[]>([]);
|
|
336
|
+
const interceptNetworkList = ref<DevTool.NetworkItem[]>([]);
|
|
384
337
|
|
|
385
338
|
const netWorkStatus = ref<{
|
|
386
339
|
isConnected?: boolean;
|
|
@@ -394,7 +347,7 @@ const activeTab = ref(0);
|
|
|
394
347
|
const tabScrollLeft = ref(0);
|
|
395
348
|
const currentConsoleType = ref('all');
|
|
396
349
|
const currentNetworkType = ref('all');
|
|
397
|
-
const currentNetworkSort = ref
|
|
350
|
+
const currentNetworkSort = ref<1 | -1>(1);
|
|
398
351
|
const currentUploadType = ref('all');
|
|
399
352
|
const currentWebSocketType = ref('all');
|
|
400
353
|
|
|
@@ -408,6 +361,15 @@ const theme = ref('light');
|
|
|
408
361
|
const openCode = ref(false);
|
|
409
362
|
const stack = ref('');
|
|
410
363
|
|
|
364
|
+
const network = reactive<DevTool.NetworkItem>({ ...emptyNetwork });
|
|
365
|
+
|
|
366
|
+
const showNetworkSend = ref(false);
|
|
367
|
+
const showNetworkDetail = ref(false);
|
|
368
|
+
const showNetworkIntercept = ref(false);
|
|
369
|
+
const showInterceptConfig = ref(false);
|
|
370
|
+
|
|
371
|
+
const cacheInterceptConfig = ref(true);
|
|
372
|
+
|
|
411
373
|
const props = withDefaults(
|
|
412
374
|
defineProps<{
|
|
413
375
|
open?: boolean;
|
|
@@ -479,12 +441,20 @@ const calcNetworkTimeline = (
|
|
|
479
441
|
}) ?? []
|
|
480
442
|
);
|
|
481
443
|
};
|
|
482
|
-
|
|
444
|
+
/**
|
|
445
|
+
* 禁止在该方法中 禁用调用已拦截的方法,防止递归调用
|
|
446
|
+
* - 禁用 uni.setStorage
|
|
447
|
+
* - 禁用 uni.request
|
|
448
|
+
* - 禁用 uni.upload
|
|
449
|
+
* - 禁用导入的 console
|
|
450
|
+
*/
|
|
483
451
|
const listenPostMessage = (data: DevTool.WindowData) => {
|
|
484
452
|
if (!props.open) return;
|
|
485
453
|
if (!isActive) return;
|
|
486
454
|
devToolVisible.value = data.devToolVisible ?? false;
|
|
487
455
|
|
|
456
|
+
cacheInterceptConfig.value = data.cacheInterceptConfig ?? false;
|
|
457
|
+
|
|
488
458
|
if (data.consoleList) {
|
|
489
459
|
consoleList.value = [...(data.consoleList ?? [])]
|
|
490
460
|
.filter((item) => {
|
|
@@ -645,6 +615,7 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
645
615
|
if (data.deviceInfo) {
|
|
646
616
|
deviceInfo.value = data.deviceInfo;
|
|
647
617
|
}
|
|
618
|
+
|
|
648
619
|
if (data.windowInfo) {
|
|
649
620
|
windowInfo.value = data.windowInfo;
|
|
650
621
|
}
|
|
@@ -664,6 +635,10 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
664
635
|
if (data.captureScreenList) {
|
|
665
636
|
captureScreenList.value = data.captureScreenList;
|
|
666
637
|
}
|
|
638
|
+
|
|
639
|
+
if (data.interceptNetworkMap) {
|
|
640
|
+
interceptNetworkList.value = Array.from(data.interceptNetworkMap.values());
|
|
641
|
+
}
|
|
667
642
|
};
|
|
668
643
|
|
|
669
644
|
let isActive = false;
|
|
@@ -688,11 +663,11 @@ onMounted(() => {
|
|
|
688
663
|
|
|
689
664
|
onLoad(() => {
|
|
690
665
|
isActive = true;
|
|
691
|
-
eventBus
|
|
666
|
+
eventBus?.on(DEV_APP_MESSAGE, listenPostMessage);
|
|
692
667
|
});
|
|
693
668
|
onUnload(() => {
|
|
694
669
|
isActive = false;
|
|
695
|
-
eventBus
|
|
670
|
+
eventBus?.off(DEV_APP_MESSAGE, listenPostMessage);
|
|
696
671
|
});
|
|
697
672
|
|
|
698
673
|
onShow(() => {
|
|
@@ -722,6 +697,8 @@ function setWindowInfo() {
|
|
|
722
697
|
currentNetworkType: currentNetworkType.value,
|
|
723
698
|
currentWebSocketType: currentWebSocketType.value,
|
|
724
699
|
tabScrollLeft: tabScrollLeft.value,
|
|
700
|
+
cacheInterceptConfig: cacheInterceptConfig.value,
|
|
701
|
+
interceptNetworkList: interceptNetworkList.value,
|
|
725
702
|
});
|
|
726
703
|
}
|
|
727
704
|
|
|
@@ -1119,6 +1096,20 @@ function onChangeTheme(t: string) {
|
|
|
1119
1096
|
});
|
|
1120
1097
|
}
|
|
1121
1098
|
|
|
1099
|
+
function onChangeCacheInterceptConfig(value: boolean) {
|
|
1100
|
+
setDevToolInfo({
|
|
1101
|
+
cacheInterceptConfig: value,
|
|
1102
|
+
interceptNetworkList: value ? interceptNetworkList.value : [],
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
basicSendMessage({
|
|
1106
|
+
type: DEV_CHANGE_CACHE_INTERCEPT_CONFIG,
|
|
1107
|
+
data: {
|
|
1108
|
+
cacheInterceptConfig: value,
|
|
1109
|
+
},
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1122
1113
|
function onChangeVuex(value: Record<string, any>) {
|
|
1123
1114
|
basicSendMessage({
|
|
1124
1115
|
type: DEV_VUEX_CHANGE,
|
|
@@ -1171,6 +1162,74 @@ function onOpenCode(value?: string) {
|
|
|
1171
1162
|
openCode.value = true;
|
|
1172
1163
|
}
|
|
1173
1164
|
}
|
|
1165
|
+
|
|
1166
|
+
function onOpenNetworkDetail(ni?: DevTool.NetworkItem) {
|
|
1167
|
+
Object.assign(network, emptyNetwork);
|
|
1168
|
+
Object.assign(network, ni);
|
|
1169
|
+
showNetworkDetail.value = true;
|
|
1170
|
+
}
|
|
1171
|
+
function onCloseNetworkDetail() {
|
|
1172
|
+
showNetworkDetail.value = false;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
function onOpenNetworkSend(ni?: DevTool.NetworkItem) {
|
|
1176
|
+
Object.assign(network, emptyNetwork);
|
|
1177
|
+
Object.assign(network, ni);
|
|
1178
|
+
showNetworkSend.value = true;
|
|
1179
|
+
}
|
|
1180
|
+
function onCloseNetworkSend() {
|
|
1181
|
+
showNetworkSend.value = false;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
function onOpenNetworkIntercept() {
|
|
1185
|
+
showNetworkIntercept.value = true;
|
|
1186
|
+
}
|
|
1187
|
+
function onCloseNetworkIntercept() {
|
|
1188
|
+
showNetworkIntercept.value = false;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
function onOpenInterceptConfig(ni?: DevTool.NetworkItem) {
|
|
1192
|
+
Object.assign(network, emptyNetwork);
|
|
1193
|
+
|
|
1194
|
+
ni && Object.assign(network, ni);
|
|
1195
|
+
|
|
1196
|
+
showInterceptConfig.value = true;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function onCloseInterceptConfig() {
|
|
1200
|
+
showInterceptConfig.value = false;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
function onRemoveInterceptConfig(ni: DevTool.NetworkItem) {
|
|
1204
|
+
basicSendMessage({
|
|
1205
|
+
type: DEV_INTERCEPT_NETWORK_REMOVE,
|
|
1206
|
+
data: ni,
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
function onConfirmInterceptConfig(ni: DevTool.NetworkItem) {
|
|
1211
|
+
const index = interceptNetworkList.value.findIndex((item) => {
|
|
1212
|
+
const key = `${item.method?.toUpperCase()}|${item.url?.split('?')[0]}`;
|
|
1213
|
+
const niKey = `${ni.method?.toUpperCase()}|${ni.url?.split('?')[0]}`;
|
|
1214
|
+
return key === niKey;
|
|
1215
|
+
});
|
|
1216
|
+
const list = [...interceptNetworkList.value];
|
|
1217
|
+
|
|
1218
|
+
if (index > -1) {
|
|
1219
|
+
list[index] = ni;
|
|
1220
|
+
} else {
|
|
1221
|
+
list.unshift(ni);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
setDevToolInfo({
|
|
1225
|
+
cacheInterceptConfig: cacheInterceptConfig.value,
|
|
1226
|
+
interceptNetworkList: cacheInterceptConfig.value ? list : [],
|
|
1227
|
+
});
|
|
1228
|
+
basicSendMessage({
|
|
1229
|
+
type: DEV_INTERCEPT_NETWORK_UPDATE,
|
|
1230
|
+
data: [ni],
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1174
1233
|
</script>
|
|
1175
1234
|
|
|
1176
1235
|
<style scoped>
|