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