vite-uni-dev-tool 0.0.13 → 0.0.14

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 (109) hide show
  1. package/dist/v2/AppInfo/index.vue +41 -0
  2. package/dist/v2/AutoSizer/index.vue +189 -0
  3. package/dist/v2/AutoSizer/index1.vue +193 -0
  4. package/dist/v2/AutoSizer/utils.ts +49 -0
  5. package/dist/v2/CaptureScreen/index.vue +78 -0
  6. package/dist/v2/CloseButton/index.vue +32 -0
  7. package/dist/v2/Connection/index.vue +94 -0
  8. package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
  9. package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
  10. package/dist/v2/ConsoleList/index.vue +164 -0
  11. package/dist/v2/ConsoleList/staticTips.js +1144 -0
  12. package/dist/v2/DevTool/index.vue +162 -0
  13. package/dist/v2/DevToolButton/index.vue +228 -0
  14. package/dist/v2/DevToolTitle/index.vue +28 -0
  15. package/dist/v2/DevToolWindow/index.vue +1051 -0
  16. package/dist/v2/DeviceInfo/index.vue +48 -0
  17. package/dist/v2/Empty/empty.png +0 -0
  18. package/dist/v2/Empty/index.vue +40 -0
  19. package/dist/v2/FilterInput/index.vue +100 -0
  20. package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
  21. package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
  22. package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
  23. package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
  24. package/dist/v2/JsonPretty/hooks/useClipboard.ts +21 -0
  25. package/dist/v2/JsonPretty/hooks/useError.ts +21 -0
  26. package/dist/v2/JsonPretty/index.vue +531 -0
  27. package/dist/v2/JsonPretty/type.ts +125 -0
  28. package/dist/v2/JsonPretty/utils/index.js +211 -0
  29. package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
  30. package/dist/v2/NetworkList/NetworkItem.vue +135 -0
  31. package/dist/v2/NetworkList/index.vue +148 -0
  32. package/dist/v2/PiniaList/index.vue +79 -0
  33. package/dist/v2/RouteList/index.vue +137 -0
  34. package/dist/v2/RunJS/index.vue +128 -0
  35. package/dist/v2/SettingList/index.vue +318 -0
  36. package/dist/v2/SourceCode/index.vue +237 -0
  37. package/dist/v2/StorageList/index.vue +165 -0
  38. package/dist/v2/SystemInfo/index.vue +49 -0
  39. package/dist/v2/Tabs/index.vue +127 -0
  40. package/dist/v2/Tag/index.vue +91 -0
  41. package/dist/v2/UniEvent/UniEventItem.vue +157 -0
  42. package/dist/v2/UniEvent/index.vue +127 -0
  43. package/dist/v2/UploadList/UploadDetail.vue +204 -0
  44. package/dist/v2/UploadList/UploadItem.vue +134 -0
  45. package/dist/v2/UploadList/index.vue +143 -0
  46. package/dist/v2/VirtualList/index.vue +140 -0
  47. package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
  48. package/dist/v2/VirtualListPro/index.vue +255 -0
  49. package/dist/v2/VirtualListPro/readme.md +40 -0
  50. package/dist/v2/VuexList/index.vue +80 -0
  51. package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
  52. package/dist/v2/WebSocket/WebSocketList.vue +183 -0
  53. package/dist/v2/WebSocket/index.vue +155 -0
  54. package/dist/v2/WindowInfo/index.vue +49 -0
  55. package/dist/v3/AppInfo/index.vue +35 -0
  56. package/dist/v3/AutoSizer/index.vue +193 -0
  57. package/dist/v3/AutoSizer/index1.vue +186 -0
  58. package/dist/v3/AutoSizer/utils.ts +49 -0
  59. package/dist/v3/CaptureScreen/index.vue +62 -0
  60. package/dist/v3/CloseButton/index.vue +29 -0
  61. package/dist/v3/Connection/index.vue +88 -0
  62. package/dist/v3/ConsoleList/ConsoleItem.vue +208 -0
  63. package/dist/v3/ConsoleList/RunJSInput.vue +240 -0
  64. package/dist/v3/ConsoleList/index.vue +139 -0
  65. package/dist/v3/ConsoleList/staticTips.ts +1145 -0
  66. package/dist/v3/DevTool/index.vue +217 -0
  67. package/dist/v3/DevToolButton/index.vue +210 -0
  68. package/dist/v3/DevToolTitle/index.vue +21 -0
  69. package/dist/v3/DevToolWindow/index.vue +1116 -0
  70. package/dist/v3/DeviceInfo/index.vue +32 -0
  71. package/dist/v3/Empty/empty.png +0 -0
  72. package/dist/v3/Empty/index.vue +28 -0
  73. package/dist/v3/FilterInput/index.vue +87 -0
  74. package/dist/v3/JsonPretty/components/Brackets/index.vue +23 -0
  75. package/dist/v3/JsonPretty/components/Carets/index.vue +59 -0
  76. package/dist/v3/JsonPretty/components/CheckController/index.vue +125 -0
  77. package/dist/v3/JsonPretty/components/TreeNode/index.vue +349 -0
  78. package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
  79. package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
  80. package/dist/v3/JsonPretty/index.vue +476 -0
  81. package/dist/v3/JsonPretty/type.ts +125 -0
  82. package/dist/v3/JsonPretty/utils/index.ts +172 -0
  83. package/dist/v3/NetworkList/NetworkDetail.vue +194 -0
  84. package/dist/v3/NetworkList/NetworkItem.vue +120 -0
  85. package/dist/v3/NetworkList/index.vue +128 -0
  86. package/dist/v3/PiniaList/index.vue +64 -0
  87. package/dist/v3/RouteList/index.vue +121 -0
  88. package/dist/v3/RunJS/index.vue +128 -0
  89. package/dist/v3/SettingList/index.vue +313 -0
  90. package/dist/v3/SourceCode/index.vue +231 -0
  91. package/dist/v3/StorageList/index.vue +170 -0
  92. package/dist/v3/SystemInfo/index.vue +34 -0
  93. package/dist/v3/Tabs/index.vue +123 -0
  94. package/dist/v3/Tag/index.vue +89 -0
  95. package/dist/v3/UniEvent/UniEventItem.vue +126 -0
  96. package/dist/v3/UniEvent/index.vue +98 -0
  97. package/dist/v3/UploadList/UploadDetail.vue +192 -0
  98. package/dist/v3/UploadList/UploadItem.vue +117 -0
  99. package/dist/v3/UploadList/index.vue +117 -0
  100. package/dist/v3/VirtualList/index.vue +112 -0
  101. package/dist/v3/VirtualListPro/AutoSize.vue +43 -0
  102. package/dist/v3/VirtualListPro/index.vue +238 -0
  103. package/dist/v3/VirtualListPro/readme.md +40 -0
  104. package/dist/v3/VuexList/index.vue +54 -0
  105. package/dist/v3/WebSocket/WebSocketItem.vue +103 -0
  106. package/dist/v3/WebSocket/WebSocketList.vue +161 -0
  107. package/dist/v3/WebSocket/index.vue +124 -0
  108. package/dist/v3/WindowInfo/index.vue +33 -0
  109. package/package.json +1 -1
@@ -0,0 +1,1051 @@
1
+ <template>
2
+ <view
3
+ v-if="open"
4
+ :style="{ zIndex: zIndex }"
5
+ :class="`dev-tool-window dev-tool-window-${theme}`"
6
+ >
7
+ <view class="dev-tool-window-bg"></view>
8
+ <Tabs
9
+ v-model="activeTab"
10
+ :items="items"
11
+ :scroll-left="tabScrollLeft"
12
+ @close="onCloseWindow"
13
+ @scroll="debounceScrollTabs"
14
+ @change="onChangeTabs"
15
+ >
16
+ <!-- 额外内容占位 -->
17
+ </Tabs>
18
+ <swiper
19
+ class="dev-tool-window-container"
20
+ :current="activeTab"
21
+ @change="onChangeSwiper"
22
+ >
23
+ <swiper-item>
24
+ <ConsoleList
25
+ v-if="swiperShow(0)"
26
+ :currentConsoleType="currentConsoleType"
27
+ :consoleList="consoleList"
28
+ :sourceFileServers="sourceFileServers"
29
+ :mode="mode"
30
+ :useDevSource="useDevSource"
31
+ :zIndex="zIndex + 1"
32
+ v-model="searchConsole"
33
+ @choose="onConsoleChoose"
34
+ @search="onSearchConsole"
35
+ @run="onRunJS"
36
+ />
37
+ </swiper-item>
38
+ <swiper-item>
39
+ <Connection v-if="swiperShow(1)" :netWorkStatus="netWorkStatus" />
40
+ </swiper-item>
41
+ <swiper-item>
42
+ <NetworkList
43
+ v-if="swiperShow(2)"
44
+ :currentNetworkType="currentNetworkType"
45
+ :networkList="networkList"
46
+ :zIndex="zIndex + 1"
47
+ v-model="searchNetwork"
48
+ @choose="onNetworkChoose"
49
+ @search="onSearchNetwork"
50
+ />
51
+ </swiper-item>
52
+ <swiper-item>
53
+ <UploadList
54
+ v-if="swiperShow(3)"
55
+ :currentUploadType="currentUploadType"
56
+ :uploadList="uploadList"
57
+ :zIndex="zIndex + 1"
58
+ v-model="searchUpload"
59
+ @choose="onUploadChoose"
60
+ @search="onSearchUpload"
61
+ />
62
+ </swiper-item>
63
+ <swiper-item>
64
+ <WebSocket
65
+ v-if="swiperShow(4)"
66
+ :wsList="wsList"
67
+ :currentWebSocketType="currentWebSocketType"
68
+ :zIndex="zIndex + 1"
69
+ v-model="searchWs"
70
+ @choose="onWebSocketChoose"
71
+ @search="onSearchWs"
72
+ />
73
+ </swiper-item>
74
+ <swiper-item>
75
+ <RouteList
76
+ v-if="swiperShow(5)"
77
+ :routeList="routeList"
78
+ v-model="searchRoute"
79
+ @goTo="onGoTo"
80
+ @search="onSearchRoute"
81
+ @routeRefresh="onRouteRefresh"
82
+ />
83
+ </swiper-item>
84
+ <swiper-item>
85
+ <UniEvent
86
+ v-if="swiperShow(6)"
87
+ :eventList="eventList"
88
+ :eventCount="eventCount"
89
+ :mode="mode"
90
+ :useDevSource="useDevSource"
91
+ :sourceFileServers="sourceFileServers"
92
+ :zIndex="zIndex + 1"
93
+ @clear="onUniEventClear"
94
+ />
95
+ </swiper-item>
96
+ <swiper-item>
97
+ <CaptureScreen
98
+ v-if="swiperShow(7)"
99
+ :captureScreenList="captureScreenList"
100
+ @clear="onCaptureScreenClear"
101
+ />
102
+ </swiper-item>
103
+ <swiper-item>
104
+ <StorageList
105
+ v-if="swiperShow(8)"
106
+ :storage-list.sync="storageList"
107
+ v-model="searchStorage"
108
+ @choose="onStorageChoose"
109
+ @remove="onStorageRemove"
110
+ @diff-value="onChangeStorage"
111
+ @search="onSearchStorage"
112
+ />
113
+ </swiper-item>
114
+ <swiper-item>
115
+ <VuexList
116
+ v-if="swiperShow(9)"
117
+ :vuexList.sync="vuexList"
118
+ @diff-value="onChangeVuex"
119
+ />
120
+ </swiper-item>
121
+ <swiper-item>
122
+ <PiniaList
123
+ v-if="swiperShow(10)"
124
+ :pinia-list.sync="piniaList"
125
+ @diff-value="onChangePinia"
126
+ />
127
+ </swiper-item>
128
+ <swiper-item>
129
+ <WindowInfo v-if="swiperShow(11)" :windowInfo="windowInfo" />
130
+ </swiper-item>
131
+ <swiper-item>
132
+ <DeviceInfo v-if="swiperShow(12)" :deviceInfo="deviceInfo" />
133
+ </swiper-item>
134
+ <swiper-item>
135
+ <SystemInfo v-if="swiperShow(13)" :systemInfo="systemInfo" />
136
+ </swiper-item>
137
+ <swiper-item>
138
+ <AppInfo v-if="swiperShow(14)" :appInfo="appInfo" />
139
+ </swiper-item>
140
+ <swiper-item>
141
+ <SettingList
142
+ v-if="swiperShow(15)"
143
+ :devToolVisible="devToolVisible"
144
+ :sizeFormat="sizeFormat"
145
+ :theme="theme"
146
+ @showDevButton="onShowDevButton"
147
+ @restartDevTool="onRestartDevTool"
148
+ @restartApp="onRestartApp"
149
+ @exportLog="onExportLog"
150
+ @screenshot="onScreenshot"
151
+ @clearCache="onClearCache"
152
+ @destroyDevTool="onDestroyDevTool"
153
+ @changeTheme="onChangeTheme"
154
+ />
155
+ </swiper-item>
156
+ </swiper>
157
+ </view>
158
+ </template>
159
+
160
+ <script>
161
+ import Tabs from '../Tabs/index.vue';
162
+ import ConsoleList from '../ConsoleList/index.vue';
163
+ import NetworkList from '../NetworkList/index.vue';
164
+ import Connection from '../Connection/index.vue';
165
+ import StorageList from '../StorageList/index.vue';
166
+ import RouteList from '../RouteList/index.vue';
167
+ import SettingList from '../SettingList/index.vue';
168
+ import VuexList from '../VuexList/index.vue';
169
+ import PiniaList from '../PiniaList/index.vue';
170
+ import SystemInfo from '../SystemInfo/index.vue';
171
+ import DeviceInfo from '../DeviceInfo/index.vue';
172
+ import WindowInfo from '../WindowInfo/index.vue';
173
+ import WebSocket from '../WebSocket/index.vue';
174
+ import UploadList from '../UploadList/index.vue';
175
+ import UniEvent from '../UniEvent/index.vue';
176
+ import AppInfo from '../AppInfo/index.vue';
177
+ import CaptureScreen from '../CaptureScreen/index.vue';
178
+ import {
179
+ DEV_BUTTON_SHOW_OR_HIDE,
180
+ DEV_CONSOLE_CLEAR,
181
+ DEV_DESTROY,
182
+ DEV_EXPORT_LOG,
183
+ DEV_LOG_CACHE_CLEAR,
184
+ DEV_NETWORK_CLEAR,
185
+ DEV_PAGE_JUMP,
186
+ DEV_PINIA_CHANGE,
187
+ DEV_RESTART_APP,
188
+ DEV_RESTART_DEBUGGER,
189
+ DEV_ROUTE_REFRESH,
190
+ DEV_STORAGE_ADD,
191
+ DEV_STORAGE_CLEAR,
192
+ DEV_STORAGE_REFRESH,
193
+ DEV_STORAGE_REMOVE,
194
+ DEV_STORAGE_UPDATE,
195
+ DEV_UPLOAD_CLEAR,
196
+ DEV_VUEX_CHANGE,
197
+ DEV_WEBSOCKET_CLEAR,
198
+ DEV_APP_MESSAGE,
199
+ DEV_UNI_EVENT_CLEAR,
200
+ DEV_RUN_JS,
201
+ DEV_CAPTURE_SCREEN_CLEAR,
202
+ } from '../../const';
203
+ import { debounce, hightLight } from '../../utils/index';
204
+ import { eventBus } from '../../core';
205
+ import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
206
+
207
+ export default {
208
+ components: {
209
+ Tabs,
210
+ ConsoleList,
211
+ NetworkList,
212
+ Connection,
213
+ StorageList,
214
+ RouteList,
215
+ SettingList,
216
+ VuexList,
217
+ PiniaList,
218
+ SystemInfo,
219
+ DeviceInfo,
220
+ WindowInfo,
221
+ WebSocket,
222
+ UploadList,
223
+ UniEvent,
224
+ AppInfo,
225
+ CaptureScreen,
226
+ },
227
+ emits: ['close', 'sendMessage'],
228
+ props: {
229
+ open: {
230
+ type: Boolean,
231
+ default: false,
232
+ },
233
+ data: {
234
+ type: Object,
235
+ default: () => ({}),
236
+ },
237
+ sourceFileServers: {
238
+ type: Array,
239
+ default: () => [],
240
+ },
241
+ mode: {
242
+ type: String,
243
+ default: '',
244
+ },
245
+ useDevSource: {
246
+ type: Boolean,
247
+ default: false,
248
+ },
249
+ zIndex: {
250
+ type: Number,
251
+ default: 1000,
252
+ },
253
+ },
254
+ data() {
255
+ return {
256
+ // 标签页配置
257
+ items: [
258
+ { key: 'Console', label: 'Console', value: 'Console', index: 0 },
259
+ {
260
+ key: 'Connection',
261
+ label: 'Connection',
262
+ value: 'Connection',
263
+ index: 1,
264
+ },
265
+ { key: 'Network', label: 'Network', value: 'NetWork', index: 2 },
266
+ { key: 'Upload', label: 'Upload', value: 'Upload', index: 3 },
267
+ { key: 'WebSocket', label: 'WebSocket', value: 'WebSocket', index: 4 },
268
+ { key: 'Route', label: 'Route', value: 'Route', index: 5 },
269
+ { key: 'UniEvent', label: 'UniEvent', value: 'UniEvent', index: 6 },
270
+ {
271
+ key: 'CaptureScreen',
272
+ label: 'CaptureScreen',
273
+ value: 'CaptureScreen',
274
+ index: 7,
275
+ },
276
+ { key: 'Storage', label: 'Storage', value: 'Storage', index: 8 },
277
+ { key: 'Vuex', label: 'Vuex', value: 'Vuex', index: 9 },
278
+ { key: 'Pinia', label: 'Pinia', value: 'Pinia', index: 10 },
279
+ { key: 'Window', label: 'Window', value: 'Window', index: 11 },
280
+ { key: 'Device', label: 'Device', value: 'Device', index: 12 },
281
+ { key: 'System', label: 'System', value: 'System', index: 13 },
282
+ { key: 'AppInfo', label: 'AppInfo', value: 'AppInfo', index: 14 },
283
+ { key: 'Setting', label: 'Setting', value: 'Setting', index: 15 },
284
+ ],
285
+ // 备份数据
286
+ backup: {
287
+ consoleList: [],
288
+ networkList: [],
289
+ storageList: [],
290
+ wsList: [],
291
+ uploadList: [],
292
+ routeList: [],
293
+ eventList: [],
294
+ runJSList: [],
295
+ },
296
+ // 响应式数据
297
+ consoleList: [],
298
+ networkList: [],
299
+ uploadList: [],
300
+ storageList: [],
301
+ routeList: [],
302
+ wsList: [],
303
+ vuexList: {},
304
+ piniaList: {},
305
+ systemInfo: {},
306
+ deviceInfo: {},
307
+ windowInfo: {},
308
+ eventList: [],
309
+ eventCount: null,
310
+ appInfo: {},
311
+ captureScreenList: [],
312
+ netWorkStatus: {},
313
+ sizeFormat: '',
314
+ devToolVisible: true,
315
+ activeTab: 0,
316
+ tabScrollLeft: 0,
317
+ currentConsoleType: 'all',
318
+ currentNetworkType: 'all',
319
+ currentUploadType: 'all',
320
+ currentWebSocketType: 'all',
321
+ searchConsole: '',
322
+ searchNetwork: '',
323
+ searchUpload: '',
324
+ searchWs: '',
325
+ searchRoute: '',
326
+ searchStorage: '',
327
+ isActive: false,
328
+ theme: 'light',
329
+ };
330
+ },
331
+ computed: {
332
+ // 计算属性保持不变
333
+ },
334
+ watch: {
335
+ // 监听数据变化
336
+ data: {
337
+ handler(newVal) {
338
+ if (this.open && this.isActive) {
339
+ this.listenPostMessage(newVal);
340
+ }
341
+ },
342
+ deep: true,
343
+ },
344
+ open(newVal) {
345
+ if (newVal && this.data) {
346
+ this.listenPostMessage(this.data);
347
+ }
348
+ },
349
+ },
350
+ created() {
351
+ this.isActive = true;
352
+ // 初始化事件监听
353
+ eventBus.on(DEV_APP_MESSAGE, this.listenPostMessage);
354
+ },
355
+ mounted() {
356
+ // 初始化开发工具信息
357
+ const devToolInfo = getDevToolInfo();
358
+ if (devToolInfo) {
359
+ this.activeTab = devToolInfo.activeTab || 0;
360
+ this.currentConsoleType = devToolInfo.currentConsoleType || 'all';
361
+ this.currentNetworkType = devToolInfo.currentNetworkType || 'all';
362
+ this.currentWebSocketType = devToolInfo.currentWebSocketType || 'all';
363
+ this.tabScrollLeft = devToolInfo.tabScrollLeft || 0;
364
+ this.theme = devToolInfo.theme || 'light';
365
+ }
366
+ if (this.props?.data) {
367
+ this.listenPostMessage(this.props.data);
368
+ }
369
+ uni.onThemeChange((res) => {
370
+ this.theme = res.theme;
371
+ });
372
+ },
373
+
374
+ onUnload() {
375
+ this.isActive = false;
376
+ eventBus.off(DEV_APP_MESSAGE, this.listenPostMessage);
377
+ },
378
+ onShow() {
379
+ this.isActive = true;
380
+ },
381
+ onHide() {
382
+ this.isActive = false;
383
+ setDevToolInfo({
384
+ devToolWindowVisible: false,
385
+ });
386
+ },
387
+ methods: {
388
+ // 控制swiper显示
389
+ swiperShow(index) {
390
+ return (
391
+ index === this.activeTab - 1 ||
392
+ index === this.activeTab ||
393
+ index === this.activeTab + 1
394
+ );
395
+ },
396
+ // 监听消息
397
+ listenPostMessage(data) {
398
+ if (!this.open) return;
399
+
400
+ if (!this.isActive) return;
401
+
402
+ this.devToolVisible = data.devToolVisible ?? false;
403
+
404
+ if (data.consoleList) {
405
+ this.consoleList = [...(data.consoleList ?? [])]
406
+ .filter((item) => {
407
+ if (this.currentConsoleType === 'all') return item;
408
+ if (this.currentConsoleType !== 'clear') {
409
+ return item.type === this.currentConsoleType;
410
+ }
411
+ return item;
412
+ })
413
+ .filter((item) => {
414
+ return (
415
+ item.args?.some(
416
+ (arg) =>
417
+ arg.type === 'string' &&
418
+ arg.value?.includes?.(this.searchConsole),
419
+ ) ||
420
+ item.position.includes(this.searchConsole) ||
421
+ (item?.stack && item.stack.includes(this.searchConsole))
422
+ );
423
+ })
424
+ .map((item) => ({
425
+ ...item,
426
+ position: hightLight(item.position, this.searchConsole),
427
+ stack: hightLight(item.stack, this.searchConsole),
428
+ args: item.args.map((arg) => {
429
+ if (arg.type === 'string') {
430
+ return {
431
+ type: 'string',
432
+ value: hightLight(arg.value, this.searchConsole),
433
+ };
434
+ }
435
+ return arg;
436
+ }),
437
+ }));
438
+ this.backup.consoleList = [...data.consoleList];
439
+ }
440
+
441
+ if (data.networkList) {
442
+ this.networkList = [...(data.networkList ?? [])]
443
+ .filter((item) => {
444
+ if (this.currentNetworkType === 'all') return item;
445
+ if (this.currentNetworkType !== 'clear') {
446
+ return item.method === this.currentNetworkType;
447
+ }
448
+ return item;
449
+ })
450
+ .filter((item) => item?.url?.includes(this.searchNetwork))
451
+ .map((item) => ({
452
+ ...item,
453
+ url: hightLight(item.url, this.searchNetwork),
454
+ }));
455
+
456
+ this.backup.networkList = [...data.networkList];
457
+ }
458
+
459
+ if (data.uploadList) {
460
+ this.uploadList = [...(data.uploadList ?? [])]
461
+ .filter((item) => {
462
+ if (this.currentUploadType === 'all') return item;
463
+ if (this.currentUploadType !== 'clear') {
464
+ return item.status === this.currentUploadType;
465
+ }
466
+ return item;
467
+ })
468
+ .filter((item) => item.url?.includes(this.searchUpload))
469
+ .map((item) => ({
470
+ ...item,
471
+ url: hightLight(item.url, this.searchUpload),
472
+ }));
473
+ this.backup.uploadList = [...data.uploadList];
474
+ }
475
+
476
+ if (data.storageList) {
477
+ this.storageList = [...(data.storageList ?? [])]
478
+ .filter((item) => item._oldKey.includes(this.searchStorage))
479
+ .map((item) => ({
480
+ ...item,
481
+ _oldKey: hightLight(item._oldKey, this.searchStorage),
482
+ }));
483
+ this.backup.storageList = [...data.storageList];
484
+ }
485
+
486
+ if (data.wsList) {
487
+ this.wsList = [...(data.wsList ?? [])]
488
+ .filter((item) => {
489
+ if (this.currentWebSocketType === 'all') return item;
490
+ return item.readyState === this.currentWebSocketType;
491
+ })
492
+ .filter((item) => item.url.includes(this.searchWs))
493
+ .map((item) => ({
494
+ ...item,
495
+ url: hightLight(item.url, this.searchWs),
496
+ }));
497
+ this.backup.wsList = [...data.wsList];
498
+ }
499
+
500
+ if (data.routeList) {
501
+ this.routeList = [...(data.routeList ?? [])]
502
+ .filter(
503
+ (item) =>
504
+ item.path.includes(this.searchRoute) ||
505
+ (item.name && item.name.includes(this.searchRoute)),
506
+ )
507
+ .map((item) => ({
508
+ ...item,
509
+ name: hightLight(item.name, this.searchRoute),
510
+ path: hightLight(item.path, this.searchRoute),
511
+ }));
512
+ this.backup.routeList = [...data.routeList];
513
+ }
514
+
515
+ if (data.eventList) {
516
+ this.eventList = [...data.eventList];
517
+ }
518
+
519
+ if (data.eventCount) {
520
+ this.eventCount = { ...data.eventCount };
521
+ }
522
+
523
+ if (data.vuexList) {
524
+ this.vuexList = data.vuexList;
525
+ }
526
+
527
+ if (data.piniaList) {
528
+ this.piniaList = data.piniaList;
529
+ }
530
+
531
+ if (data.systemInfo) {
532
+ this.systemInfo = data.systemInfo;
533
+ }
534
+
535
+ if (data.deviceInfo) {
536
+ this.deviceInfo = data.deviceInfo;
537
+ }
538
+
539
+ if (data.windowInfo) {
540
+ this.windowInfo = data.windowInfo;
541
+ }
542
+
543
+ if (data.netWorkStatus) {
544
+ this.netWorkStatus = data.netWorkStatus;
545
+ }
546
+
547
+ if (data.sizeFormat) {
548
+ this.sizeFormat = data.sizeFormat;
549
+ }
550
+
551
+ if (data.appInfo) {
552
+ this.appInfo = data.appInfo;
553
+ }
554
+
555
+ if (data.captureScreenList) {
556
+ this.captureScreenList = data.captureScreenList;
557
+ }
558
+ },
559
+ // 发送消息
560
+ basicSendMessage(message) {
561
+ this.$emit('sendMessage', message);
562
+ },
563
+ // 设置窗口信息
564
+ setWindowInfo() {
565
+ setDevToolInfo({
566
+ activeTab: this.activeTab,
567
+ currentConsoleType: this.currentConsoleType,
568
+ currentNetworkType: this.currentNetworkType,
569
+ currentWebSocketType: this.currentWebSocketType,
570
+ tabScrollLeft: this.tabScrollLeft,
571
+ });
572
+ },
573
+ // 防抖设置窗口信息
574
+ debounceSetWindowInfo: debounce(function () {
575
+ this.setWindowInfo();
576
+ }, 200),
577
+ // 关闭窗口
578
+ onCloseWindow() {
579
+ this.$emit('close');
580
+ this.setWindowInfo();
581
+ },
582
+ // 切换标签
583
+ onChangeTabs() {
584
+ this.setWindowInfo();
585
+ },
586
+ // 切换swiper
587
+ onChangeSwiper({ detail }) {
588
+ this.activeTab = detail.current;
589
+ this.setWindowInfo();
590
+ },
591
+ // 滚动标签
592
+ onScrollTabs(e) {
593
+ this.tabScrollLeft = e.detail.scrollLeft;
594
+ this.debounceSetWindowInfo();
595
+ },
596
+ // 防抖滚动标签
597
+ debounceScrollTabs: debounce(function (e) {
598
+ this.onScrollTabs(e);
599
+ }, 200),
600
+ // 控制台选择
601
+ onConsoleChoose(type) {
602
+ if (type === 'clear') {
603
+ this.consoleList = [];
604
+ this.backup.consoleList = [];
605
+ this.basicSendMessage({
606
+ type: DEV_CONSOLE_CLEAR,
607
+ data: {},
608
+ });
609
+ return;
610
+ } else if (type === 'all') {
611
+ this.currentConsoleType = type;
612
+ this.consoleList = this.backup.consoleList;
613
+ } else {
614
+ this.currentConsoleType = type;
615
+ this.consoleList = this.backup.consoleList.filter(
616
+ (item) => item.type === type,
617
+ );
618
+ }
619
+ this.setWindowInfo();
620
+ },
621
+ // 运行JS
622
+ onRunJS(code) {
623
+ this.basicSendMessage({
624
+ type: DEV_RUN_JS,
625
+ data: { code },
626
+ });
627
+ },
628
+ // 搜索控制台
629
+ onSearchConsole(value) {
630
+ this.searchConsole = value;
631
+ this.consoleList = this.backup.consoleList
632
+ .filter((item) => {
633
+ return (
634
+ item.args.some(
635
+ (arg) => arg.type === 'string' && arg.value.includes(value),
636
+ ) ||
637
+ item.position.includes(value) ||
638
+ (item?.stack && item.stack.includes(value))
639
+ );
640
+ })
641
+ .map((item) => ({
642
+ ...item,
643
+ position: hightLight(item.position, value),
644
+ stack: hightLight(item.stack, value),
645
+ args: item.args.map((arg) => {
646
+ if (arg.type === 'string') {
647
+ return {
648
+ type: 'string',
649
+ value: hightLight(arg.value, value),
650
+ };
651
+ }
652
+ return arg;
653
+ }),
654
+ }));
655
+ },
656
+ // 网络选择
657
+ onNetworkChoose(type) {
658
+ if (type === 'clear') {
659
+ this.networkList = [];
660
+ this.backup.networkList = [];
661
+ this.basicSendMessage({
662
+ type: DEV_NETWORK_CLEAR,
663
+ data: {},
664
+ });
665
+ return;
666
+ } else if (type === 'all') {
667
+ this.currentNetworkType = type;
668
+ this.networkList = this.backup.networkList;
669
+ } else if (type === 'error') {
670
+ this.currentNetworkType = type;
671
+ this.networkList = this.backup.networkList.filter((item) => {
672
+ return (
673
+ item.status === 'error' || /[4,5]\d{2,}/.test(item.status + '')
674
+ );
675
+ });
676
+ } else {
677
+ this.currentNetworkType = type;
678
+ this.networkList = this.backup.networkList.filter(
679
+ (item) => item.method === type,
680
+ );
681
+ }
682
+ this.setWindowInfo();
683
+ },
684
+ // 搜索网络
685
+ onSearchNetwork(value) {
686
+ this.searchNetwork = value;
687
+ this.networkList = this.backup.networkList
688
+ .filter((item) => {
689
+ if (this.currentNetworkType === 'all') return item;
690
+ if (this.currentNetworkType !== 'clear') {
691
+ return item.method === this.currentNetworkType;
692
+ }
693
+ return item;
694
+ })
695
+ .filter((item) => item?.url?.includes(value))
696
+ .map((item) => ({
697
+ ...item,
698
+ url: hightLight(item.url, value),
699
+ }));
700
+ },
701
+ // 上传选择
702
+ onUploadChoose(type) {
703
+ if (type === 'clear') {
704
+ this.uploadList = [];
705
+ this.backup.uploadList = [];
706
+ this.basicSendMessage({
707
+ type: DEV_UPLOAD_CLEAR,
708
+ data: {},
709
+ });
710
+ return;
711
+ } else if (type === 'all') {
712
+ this.currentUploadType = type;
713
+ this.uploadList = this.backup.uploadList;
714
+ } else {
715
+ this.currentUploadType = type;
716
+ this.uploadList = this.backup.uploadList.filter(
717
+ (item) => item.status === type,
718
+ );
719
+ }
720
+ },
721
+ // 搜索上传
722
+ onSearchUpload(value) {
723
+ this.searchUpload = value;
724
+ this.uploadList = this.backup.uploadList
725
+ .filter((item) => {
726
+ if (this.currentUploadType === 'all') return item;
727
+ if (this.currentUploadType !== 'clear') {
728
+ return item.status === this.currentUploadType;
729
+ }
730
+ return item;
731
+ })
732
+ .filter((item) => item.url?.includes(value))
733
+ .map((item) => ({
734
+ ...item,
735
+ url: hightLight(item.url, value),
736
+ }));
737
+ },
738
+ // WebSocket选择
739
+ onWebSocketChoose(type) {
740
+ if (type === 'clear') {
741
+ this.wsList = [];
742
+ this.backup.wsList = [];
743
+ this.basicSendMessage({
744
+ type: DEV_WEBSOCKET_CLEAR,
745
+ data: {},
746
+ });
747
+ return;
748
+ } else if (type === 'all') {
749
+ this.currentWebSocketType = type;
750
+ this.wsList = this.backup.wsList;
751
+ } else {
752
+ this.currentWebSocketType = type;
753
+ this.wsList = this.backup.wsList.filter(
754
+ (item) => item.readyState === type,
755
+ );
756
+ }
757
+ this.setWindowInfo();
758
+ },
759
+ // 搜索WebSocket
760
+ onSearchWs(value) {
761
+ this.searchWs = value;
762
+ this.wsList = this.backup.wsList
763
+ .filter((item) => {
764
+ if (this.currentWebSocketType === 'all') return item;
765
+ return item.readyState === this.currentWebSocketType;
766
+ })
767
+ .filter((item) => item.url.includes(value))
768
+ .map((item) => ({
769
+ ...item,
770
+ url: hightLight(item.url, value),
771
+ }));
772
+ },
773
+ // 存储选择
774
+ onStorageChoose(type) {
775
+ if (type === 'clear') {
776
+ this.backup.storageList = [];
777
+ this.storageList = [];
778
+ this.basicSendMessage({
779
+ type: DEV_STORAGE_CLEAR,
780
+ data: {},
781
+ });
782
+ } else if (type === 'refresh') {
783
+ this.basicSendMessage({
784
+ type: DEV_STORAGE_REFRESH,
785
+ data: {},
786
+ });
787
+ } else if (type === 'add') {
788
+ const key = '_new_' + Date.now();
789
+ const newItem = {
790
+ key,
791
+ _oldKey: key,
792
+ value: JSON.stringify(''),
793
+ };
794
+ this.backup.storageList.unshift(newItem);
795
+ this.storageList.unshift(newItem);
796
+ this.basicSendMessage({
797
+ type: DEV_STORAGE_ADD,
798
+ data: {
799
+ key,
800
+ value: JSON.stringify(''),
801
+ },
802
+ });
803
+ }
804
+ },
805
+ // 移除存储
806
+ onStorageRemove(key) {
807
+ this.backup.storageList = this.backup.storageList.filter(
808
+ (item) => item.key !== key,
809
+ );
810
+ this.storageList = this.backup.storageList;
811
+ this.basicSendMessage({
812
+ type: DEV_STORAGE_REMOVE,
813
+ data: { key },
814
+ });
815
+ },
816
+ // 更改存储
817
+ onChangeStorage(data) {
818
+ this.basicSendMessage({
819
+ type: DEV_STORAGE_UPDATE,
820
+ data,
821
+ });
822
+ },
823
+ // 搜索存储
824
+ onSearchStorage(value) {
825
+ this.searchStorage = value;
826
+ this.storageList = this.backup.storageList
827
+ .filter((item) => item._oldKey.includes(value))
828
+ .map((item) => ({
829
+ ...item,
830
+ _oldKey: hightLight(item._oldKey, value),
831
+ }));
832
+ },
833
+ // 清空UniEvent
834
+ onUniEventClear() {
835
+ this.eventList = [];
836
+ this.eventCount = {
837
+ on: 0,
838
+ once: 0,
839
+ emit: 0,
840
+ off: 0,
841
+ };
842
+ this.basicSendMessage({
843
+ type: DEV_UNI_EVENT_CLEAR,
844
+ data: {},
845
+ });
846
+ },
847
+ // 清空截图
848
+ onCaptureScreenClear() {
849
+ this.captureScreenList = [];
850
+ this.basicSendMessage({
851
+ type: DEV_CAPTURE_SCREEN_CLEAR,
852
+ data: {},
853
+ });
854
+ },
855
+ // 跳转页面
856
+ onGoTo(page) {
857
+ this.basicSendMessage({
858
+ type: DEV_PAGE_JUMP,
859
+ data: {
860
+ path: '/' + page.path,
861
+ type: page.type,
862
+ },
863
+ });
864
+ },
865
+ // 刷新路由
866
+ onRouteRefresh() {
867
+ this.basicSendMessage({
868
+ type: DEV_ROUTE_REFRESH,
869
+ data: {},
870
+ });
871
+ },
872
+ // 搜索路由
873
+ onSearchRoute(value) {
874
+ this.searchRoute = value;
875
+ this.routeList = this.backup.routeList
876
+ .filter(
877
+ (item) =>
878
+ item.path.includes(value) ||
879
+ (item.name && item.name.includes(value)),
880
+ )
881
+ .map((item) => ({
882
+ ...item,
883
+ name: hightLight(item.name, this.searchRoute),
884
+ path: hightLight(item.path, this.searchRoute),
885
+ }));
886
+ },
887
+ // 显示开发按钮
888
+ onShowDevButton(show) {
889
+ this.basicSendMessage({
890
+ type: DEV_BUTTON_SHOW_OR_HIDE,
891
+ data: { show },
892
+ });
893
+ },
894
+ // 重启开发工具
895
+ onRestartDevTool() {
896
+ this.basicSendMessage({
897
+ type: DEV_RESTART_DEBUGGER,
898
+ data: {},
899
+ });
900
+ },
901
+ // 重启应用
902
+ onRestartApp() {
903
+ this.basicSendMessage({
904
+ type: DEV_RESTART_APP,
905
+ data: {},
906
+ });
907
+ },
908
+ // 导出日志
909
+ onExportLog(exports) {
910
+ this.basicSendMessage({
911
+ type: DEV_EXPORT_LOG,
912
+ data: { ...exports },
913
+ });
914
+ },
915
+ // 截图
916
+ onScreenshot() {
917
+ this.basicSendMessage({
918
+ type: 'dev-tool-hide-screenshot',
919
+ data: {},
920
+ });
921
+ },
922
+ // 清空缓存
923
+ onClearCache() {
924
+ this.basicSendMessage({
925
+ type: DEV_LOG_CACHE_CLEAR,
926
+ data: {},
927
+ });
928
+ },
929
+ // 销毁开发工具
930
+ onDestroyDevTool() {
931
+ this.basicSendMessage({
932
+ type: DEV_DESTROY,
933
+ data: {},
934
+ });
935
+ },
936
+ onChangeTheme(t) {
937
+ this.theme = t;
938
+ setDevToolInfo({
939
+ theme: t,
940
+ });
941
+ },
942
+ // 更改Vuex
943
+ onChangeVuex(value) {
944
+ this.basicSendMessage({
945
+ type: DEV_VUEX_CHANGE,
946
+ data: value,
947
+ });
948
+ },
949
+ // 更改Pinia
950
+ onChangePinia(value) {
951
+ this.basicSendMessage({
952
+ type: DEV_PINIA_CHANGE,
953
+ data: value,
954
+ });
955
+ },
956
+ },
957
+ };
958
+ </script>
959
+
960
+ <style scoped>
961
+ .dev-tool-window {
962
+ --dev-tool-main-color: #9254de;
963
+ --dev-tool-normal-bg-color: #f9f9f9;
964
+ --dev-tool-warn-color: #ffa940;
965
+ --dev-tool-warn-bg-color: #fff7e6;
966
+ --dev-tool-error-color: #ff4d4f;
967
+ --dev-tool-error-bg-color: #fff1f0;
968
+ --dev-tool-success-color: #bae637;
969
+ --dev-tool-success-bg-color: #fcffe6;
970
+
971
+ --dev-tool-base-font-size: 12px;
972
+ --dev-tool-tag-font-size: 10px;
973
+ --dev-tool-tips-font-size: 10px;
974
+ -webkit-tap-highlight-color: transparent;
975
+
976
+ position: fixed;
977
+ top: 0;
978
+ left: 0;
979
+ z-index: 1001;
980
+ /* #ifdef H5 */
981
+ padding: 50px 0;
982
+ /* #endif */
983
+
984
+ /* #ifdef MP-WEIXIN */
985
+ /* padding-bottom:30px; */
986
+ /* #endif */
987
+
988
+ width: 100vw;
989
+ height: 100vh;
990
+ font-size: 14px;
991
+ color: var(--dev-tool-text-color);
992
+ box-sizing: border-box;
993
+ transition: color 0.3s;
994
+ }
995
+
996
+ .dev-tool-window-light {
997
+ --dev-tool-bg-color: rgba(255, 255, 255, 0.8);
998
+ --dev-tool-bg2-color: rgba(255, 255, 255, 0.95);
999
+
1000
+ --dev-tool-text-color: #000;
1001
+ --dev-tool-border-color: #f0f0f0;
1002
+ --dev-tool-info-color: #9c9c9c;
1003
+ --dev-tool-log-color: #f9f9f9;
1004
+ --dev-tool-nil-color: #020201;
1005
+ --dev-tool-string-color: #888888;
1006
+ --dev-tool-number-color: #1d8ce0;
1007
+ --dev-tool-boolean-color: #1d8ce0;
1008
+ --dev-tool-symbol-color: bisque;
1009
+ }
1010
+ .dev-tool-window-dart {
1011
+ --dev-tool-bg-color: rgba(0, 0, 0, 0.8);
1012
+ --dev-tool-bg2-color: rgba(43, 43, 43, 0.8);
1013
+
1014
+ --dev-tool-text-color: #fff;
1015
+ --dev-tool-border-color: #3d3d3d;
1016
+
1017
+ --dev-tool-log-color: #f9f9f9;
1018
+ }
1019
+
1020
+ .dev-tool-window-bg {
1021
+ position: absolute;
1022
+ z-index: -1;
1023
+ top: 0;
1024
+ left: 0;
1025
+ width: 100vw;
1026
+ height: 100vh;
1027
+ background-color: var(--dev-tool-bg-color);
1028
+ backdrop-filter: blur(6px);
1029
+ transition: background-color 0.3s;
1030
+ }
1031
+ .dev-tool-window-container {
1032
+ height: calc(100% - 32px);
1033
+ overflow: auto;
1034
+ }
1035
+ .dev-tool-window-container ::-webkit-scrollbar {
1036
+ display: none;
1037
+ width: 0;
1038
+ height: 0;
1039
+ background-color: transparent;
1040
+ }
1041
+
1042
+ .dev-tool-window-container ::-webkit-scrollbar-thumb {
1043
+ width: 0;
1044
+ height: 0;
1045
+ background-color: transparent;
1046
+ }
1047
+
1048
+ .dev-tool-window::after {
1049
+ content: '';
1050
+ }
1051
+ </style>