vite-uni-dev-tool 0.0.11 → 0.0.13

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