vite-uni-dev-tool 0.0.10 → 0.0.11

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.
@@ -16,99 +16,138 @@
16
16
  <view style="margin-left: 6px">{{ sizeFormat }}</view>
17
17
  </template> -->
18
18
  </Tabs>
19
- <view class="dev-tool-window-container">
20
- <ConsoleList
21
- :currentConsoleType="currentConsoleType"
22
- :consoleList="consoleList"
23
- :sourceFileServers="sourceFileServers"
24
- :mode="mode"
25
- :useDevSource="useDevSource"
26
- v-if="activeTab === 'Console'"
27
- v-model="searchConsole"
28
- @choose="onConsoleChoose"
29
- @search="onSearchConsole"
30
- @run="onRunJS"
31
- />
32
- <NetworkList
33
- :currentNetworkType="currentNetworkType"
34
- :networkList="networkList"
35
- v-model="searchNetwork"
36
- v-if="activeTab === 'Network'"
37
- @choose="onNetworkChoose"
38
- @search="onSearchNetwork"
39
- />
40
- <UploadList
41
- :currentUploadType="currentUploadType"
42
- :uploadList="uploadList"
43
- v-model="searchUpload"
44
- v-if="activeTab === 'Upload'"
45
- @choose="onUploadChoose"
46
- @search="onSearchUpload"
47
- />
48
- <WebSocket
49
- :wsList="wsList"
50
- :currentWebSocketType="currentWebSocketType"
51
- v-model="searchWs"
52
- v-if="activeTab === 'WebSocket'"
53
- @choose="onWebSocketChoose"
54
- @search="onSearchWs"
55
- />
56
- <Connection
57
- v-if="activeTab === 'Connection'"
58
- :netWorkStatus="netWorkStatus"
59
- />
60
- <RouteList
61
- v-if="activeTab === 'Route'"
62
- :routeList="routeList"
63
- v-model="searchRoute"
64
- @goTo="onGoTo"
65
- @search="onSearchRoute"
66
- @routeRefresh="onRouteRefresh"
67
- />
68
- <UniEvent
69
- v-if="activeTab === 'UniEvent'"
70
- :eventList="eventList"
71
- :eventCount="eventCount"
72
- :mode="mode"
73
- :useDevSource="useDevSource"
74
- :sourceFileServers="sourceFileServers"
75
- @clear="onUniEventClear"
76
- />
77
- <SettingList
78
- v-if="activeTab === 'Setting'"
79
- :devToolVisible="devToolVisible"
80
- :sizeFormat="sizeFormat"
81
- @showDevButton="onShowDevButton"
82
- @restartDevTool="onRestartDevTool"
83
- @restartApp="onRestartApp"
84
- @exportLog="onExportLog"
85
- @screenshot="onScreenshot"
86
- @clearCache="onClearCache"
87
- @destroyDevTool="onDestroyDevTool"
88
- />
89
- <StorageList
90
- v-if="activeTab === 'Storage'"
91
- v-model:storage-list="storageList"
92
- v-model="searchStorage"
93
- @choose="onStorageChoose"
94
- @remove="onStorageRemove"
95
- @diff-value="onChangeStorage"
96
- @search="onSearchStorage"
97
- />
98
- <VuexList
99
- v-if="activeTab === 'Vuex'"
100
- v-model:vuexList="vuexList"
101
- @diff-value="onChangeVuex"
102
- />
103
- <PiniaList
104
- v-if="activeTab === 'Pinia'"
105
- v-model:pinia-list="piniaList"
106
- @diff-value="onChangePinia"
107
- />
108
- <SystemInfo v-if="activeTab === 'System'" :systemInfo="systemInfo" />
109
- <DeviceInfo v-if="activeTab === 'Device'" :deviceInfo="deviceInfo" />
110
- <WindowInfo v-if="activeTab === 'Window'" :windowInfo="windowInfo" />
111
- </view>
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>
112
151
  </view>
113
152
  </template>
114
153
 
@@ -130,7 +169,8 @@ import WindowInfo from '../WindowInfo/index.vue';
130
169
  import WebSocket from '../WebSocket/index.vue';
131
170
  import UploadList from '../UploadList/index.vue';
132
171
  import UniEvent from '../UniEvent/index.vue';
133
- import RunJS from '../RunJS/index.vue';
172
+ import AppInfo from '../AppInfo/index.vue';
173
+ import CaptureScreen from '../CaptureScreen/index.vue';
134
174
  import {
135
175
  DEV_BUTTON_SHOW_OR_HIDE,
136
176
  DEV_CONSOLE_CLEAR,
@@ -154,8 +194,8 @@ import {
154
194
  DEV_WINDOW_INFO,
155
195
  DEV_APP_MESSAGE,
156
196
  DEV_UNI_EVENT_CLEAR,
157
- DEV_RUN_JS_CLEAR,
158
197
  DEV_RUN_JS,
198
+ DEV_CAPTURE_SCREEN_CLEAR,
159
199
  } from '../../const';
160
200
  import { debounce, hightLight } from '../../utils/index';
161
201
  import type { DevTool } from '../../type';
@@ -166,72 +206,98 @@ const items = [
166
206
  key: 'Console',
167
207
  label: 'Console',
168
208
  value: 'Console',
209
+ index: 0,
169
210
  },
170
211
  {
171
212
  key: 'Connection',
172
213
  label: 'Connection',
173
214
  value: 'Connection',
215
+ index: 1,
174
216
  },
175
217
  {
176
218
  key: 'Network',
177
219
  label: 'Network',
178
220
  value: 'NetWork',
221
+ index: 2,
179
222
  },
180
223
  {
181
224
  key: 'Upload',
182
225
  label: 'Upload',
183
226
  value: 'Upload',
227
+ index: 3,
184
228
  },
185
229
  {
186
230
  key: 'WebSocket',
187
231
  label: 'WebSocket',
188
232
  value: 'WebSocket',
233
+ index: 4,
189
234
  },
190
235
  {
191
236
  key: 'Route',
192
237
  label: 'Route',
193
238
  value: 'Route',
239
+ index: 5,
194
240
  },
195
241
  {
196
242
  key: 'UniEvent',
197
243
  label: 'UniEvent',
198
244
  value: 'UniEvent',
245
+ index: 6,
246
+ },
247
+ {
248
+ key: 'CaptureScreen',
249
+ label: 'CaptureScreen',
250
+ value: 'CaptureScreen',
251
+ index: 7,
199
252
  },
200
253
  {
201
254
  key: 'Storage',
202
255
  label: 'Storage',
203
256
  value: 'Storage',
257
+ index: 8,
204
258
  },
205
259
 
206
260
  {
207
261
  key: 'Vuex',
208
262
  label: 'Vuex',
209
263
  value: 'Vuex',
264
+ index: 9,
210
265
  },
211
266
  {
212
267
  key: 'Pinia',
213
268
  label: 'Pinia',
214
269
  value: 'Pinia',
270
+ index: 10,
215
271
  },
216
272
  {
217
273
  key: 'Window',
218
274
  label: 'Window',
219
275
  value: 'Window',
276
+ index: 11,
220
277
  },
221
278
  {
222
279
  key: 'Device',
223
280
  label: 'Device',
224
281
  value: 'Device',
282
+ index: 12,
225
283
  },
226
284
  {
227
285
  key: 'System',
228
286
  label: 'System',
229
287
  value: 'System',
288
+ index: 13,
289
+ },
290
+ {
291
+ key: 'AppInfo',
292
+ label: 'AppInfo',
293
+ value: 'AppInfo',
294
+ index: 14,
230
295
  },
231
296
  {
232
297
  key: 'Setting',
233
298
  label: 'Setting',
234
299
  value: 'Setting',
300
+ index: 15,
235
301
  },
236
302
  ];
237
303
 
@@ -267,6 +333,8 @@ const deviceInfo = ref<Record<string, any>>({});
267
333
  const windowInfo = ref<Record<string, any>>({});
268
334
  const eventList = ref<DevTool.EventItem[]>([]);
269
335
  const eventCount = ref<DevTool.EventCount>();
336
+ const appInfo = ref<Record<string, any>>({});
337
+ const captureScreenList = ref<DevTool.CaptureScreenItem[]>([]);
270
338
 
271
339
  const netWorkStatus = ref<{
272
340
  isConnected?: boolean;
@@ -276,7 +344,7 @@ const sizeFormat = ref('');
276
344
 
277
345
  const devToolVisible = ref(true);
278
346
 
279
- const activeTab = ref('Console');
347
+ const activeTab = ref(0);
280
348
  const tabScrollLeft = ref(0);
281
349
  const currentConsoleType = ref('all');
282
350
  const currentNetworkType = ref('all');
@@ -303,6 +371,14 @@ const emits = defineEmits<{
303
371
  (e: 'sendMessage', data: { type: string; data: Record<string, any> }): void;
304
372
  }>();
305
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
+
306
382
  const listenPostMessage = (data: DevTool.WindowData) => {
307
383
  if (!props.open) return;
308
384
  if (!isActive) return;
@@ -467,13 +543,21 @@ const listenPostMessage = (data: DevTool.WindowData) => {
467
543
  if (data.sizeFormat) {
468
544
  sizeFormat.value = data.sizeFormat;
469
545
  }
546
+
547
+ if (data.appInfo) {
548
+ appInfo.value = data.appInfo;
549
+ }
550
+
551
+ if (data.captureScreenList) {
552
+ captureScreenList.value = data.captureScreenList;
553
+ }
470
554
  };
471
555
 
472
556
  let isActive = false;
473
557
  onMounted(() => {
474
558
  const windowInfo = uni.getStorageSync(DEV_WINDOW_INFO);
475
559
  if (windowInfo) {
476
- activeTab.value = windowInfo?.activeTab || 'Console';
560
+ activeTab.value = windowInfo?.activeTab || 0;
477
561
  currentConsoleType.value = windowInfo?.currentConsoleType || 'all';
478
562
  currentNetworkType.value = windowInfo?.currentNetworkType || 'all';
479
563
  tabScrollLeft.value = windowInfo?.tabScrollLeft || 0;
@@ -527,6 +611,15 @@ function onChangeTabs() {
527
611
  setWindowInfo();
528
612
  }
529
613
 
614
+ function onChangeSwiper({
615
+ detail,
616
+ }: {
617
+ detail: { current: number; source: any };
618
+ }) {
619
+ activeTab.value = detail.current;
620
+ setWindowInfo();
621
+ }
622
+
530
623
  function onScrollTabs(e: any) {
531
624
  tabScrollLeft.value = e.detail.scrollLeft;
532
625
  debounceSetWindowInfo();
@@ -783,6 +876,14 @@ function onUniEventClear() {
783
876
  });
784
877
  }
785
878
 
879
+ function onCaptureScreenClear() {
880
+ captureScreenList.value = [];
881
+ basicSendMessage({
882
+ type: DEV_CAPTURE_SCREEN_CLEAR,
883
+ data: {},
884
+ });
885
+ }
886
+
786
887
  function onGoTo(page: DevTool.Page) {
787
888
  basicSendMessage({
788
889
  type: DEV_PAGE_JUMP,
@@ -929,6 +1030,7 @@ function onChangePinia(value: Record<string, any>) {
929
1030
  height: 0;
930
1031
  background-color: transparent;
931
1032
  }
1033
+
932
1034
  .dev-tool-window::after {
933
1035
  content: '';
934
1036
  }
@@ -1,24 +1,12 @@
1
1
  <template>
2
2
  <view
3
- v-if="isOpen && isClose"
3
+ v-if="isOpen || isClose"
4
4
  :class="`json-pretty-carets json-pretty-carets-${
5
5
  isOpen ? 'open' : 'close'
6
6
  }`"
7
7
  @click="onClick"
8
8
  >
9
- <svg
10
- viewBox="0 0 1024 1024"
11
- focusable="false"
12
- data-icon="caret-down"
13
- width="1em"
14
- height="1em"
15
- fill="currentColor"
16
- aria-hidden="true"
17
- >
18
- <path
19
- d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"
20
- ></path>
21
- </svg>
9
+ <view class="json-pretty-caret-down"></view>
22
10
  </view>
23
11
  </template>
24
12
  <script lang="ts" setup>
@@ -60,4 +48,12 @@ function onClick(e: MouseEvent) {
60
48
  .json-pretty-carets-close {
61
49
  transform: rotate(-90deg);
62
50
  }
51
+
52
+ .json-pretty-caret-down {
53
+ margin: 7px 4px;
54
+ border: 3px solid #000;
55
+ border-top-color: transparent;
56
+ border-left-color: transparent;
57
+ transform: rotate(45deg);
58
+ }
63
59
  </style>
@@ -5,15 +5,18 @@
5
5
  ref="tabsRef"
6
6
  scroll-x="true"
7
7
  enable-flex="true"
8
+ scroll-with-animation
8
9
  :scrollLeft="scrollLeft"
10
+ :scroll-into-view="scrollIntoView"
9
11
  @scroll="onScroll"
10
12
  >
11
13
  <view
12
14
  v-for="item in items"
13
15
  :key="item.key"
14
16
  :class="`tabs-item ${
15
- item.key === modelValue ? 'tabs-item-active' : ''
17
+ item.index === modelValue ? 'tabs-item-active' : ''
16
18
  } `"
19
+ :id="`tabs-item-${item.index}`"
17
20
  @click="onChangeTabs(item)"
18
21
  >
19
22
  {{ item.label }}
@@ -27,12 +30,12 @@
27
30
  </template>
28
31
 
29
32
  <script setup lang="ts">
30
- import { ref } from 'vue';
33
+ import { computed, ref } from 'vue';
31
34
  import CloseButton from '../CloseButton/index.vue';
32
35
  // const activeKey = ref("Console");
33
- defineProps<{
34
- modelValue: string;
35
- items: { label: string; key: string; value: any }[];
36
+ const props = defineProps<{
37
+ modelValue: number;
38
+ items: { label: string; key: string; value: any; index: number }[];
36
39
  scrollLeft?: number;
37
40
  }>();
38
41
 
@@ -40,14 +43,24 @@ const tabsRef = ref();
40
43
 
41
44
  const emit = defineEmits<{
42
45
  (e: 'close'): void;
43
- (e: 'update:modelValue', value: string): void;
44
- (e: 'change', value: string): void;
46
+ (e: 'update:modelValue', value: number): void;
47
+ (e: 'change', value: number): void;
45
48
  (e: 'scroll', value: any): void;
46
49
  }>();
47
- function onChangeTabs(item: { label: string; key: string; value: any }) {
50
+
51
+ const scrollIntoView = computed(() => {
52
+ return `tabs-item-${props.modelValue}`;
53
+ });
54
+
55
+ function onChangeTabs(item: {
56
+ label: string;
57
+ key: string;
58
+ value: any;
59
+ index: number;
60
+ }) {
48
61
  // activeKey.value = item.key;
49
- emit('update:modelValue', item.key);
50
- emit('change', item.key);
62
+ emit('update:modelValue', item.index);
63
+ emit('change', item.index);
51
64
  }
52
65
  function onClose() {
53
66
  emit('close');
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <scroll-view
3
3
  :lower-threshold="preLodeHeight"
4
+ :scroll-into-view="scrollIntoView"
5
+ :scroll-with-animation="scrollWithAnimation"
4
6
  :class="['virtual-list', className]"
5
7
  scroll-y
6
8
  @scroll="onScroll"
@@ -37,6 +39,10 @@ const props = withDefaults(
37
39
  preLodeHeight?: number;
38
40
  /** 类名 */
39
41
  className?: string;
42
+ /** 滚动到指定元素 */
43
+ scrollIntoView?: string;
44
+ /** 滚动动画 */
45
+ scrollWithAnimation?: boolean;
40
46
  }>(),
41
47
  {
42
48
  height: 400,
package/dev/const.ts CHANGED
@@ -162,7 +162,5 @@ export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
162
162
  */
163
163
  export const DEV_RUN_JS = 'dev-uni-run-js';
164
164
 
165
- /**
166
- * 清空运行的js
167
- */
168
- export const DEV_RUN_JS_CLEAR = 'dev-uni-run-js-clear';
165
+ /** 清空截屏列表 */
166
+ export const DEV_CAPTURE_SCREEN_CLEAR = 'dev-capture-screen-clear';
@@ -30,6 +30,7 @@ import {
30
30
  DEV_OPTION_SEND,
31
31
  DEV_UNI_EVENT_CLEAR,
32
32
  DEV_RUN_JS,
33
+ DEV_CAPTURE_SCREEN_CLEAR,
33
34
  } from '../const';
34
35
  import { DevStore } from '../devStore';
35
36
  import type { DevTool } from '../type';
@@ -247,7 +248,8 @@ export class DevEvent {
247
248
  * @memberof DevEvent
248
249
  */
249
250
  switchTo(path: string) {
250
- this.showDevToolButton();
251
+ // this.showDevToolButton();
252
+ this.closeDevToolWindow();
251
253
  uni.switchTab({
252
254
  url: path,
253
255
  });
@@ -260,7 +262,8 @@ export class DevEvent {
260
262
  * @memberof DevEvent
261
263
  */
262
264
  navigateTo(path: string) {
263
- this.showDevToolButton();
265
+ // this.showDevToolButton();
266
+ this.closeDevToolWindow();
264
267
  uni.navigateTo({
265
268
  url: path,
266
269
  });
@@ -430,6 +433,10 @@ export class DevEvent {
430
433
  else if (data.type === DEV_RUN_JS) {
431
434
  this.devRunJS(data.data.code);
432
435
  }
436
+ // 清空截屏列表
437
+ else if (data.type === DEV_CAPTURE_SCREEN_CLEAR) {
438
+ this.store.clearCaptureScreenList();
439
+ }
433
440
  },
434
441
  );
435
442
  }
@@ -776,4 +783,24 @@ export class DevEvent {
776
783
  this.postMessageFn();
777
784
  });
778
785
  }
786
+
787
+ /**
788
+ * 更新截屏列表
789
+ *
790
+ * @param {DevTool.CaptureScreenItem[]} list
791
+ * @memberof DevEvent
792
+ */
793
+ updateCaptureScreenList(list: DevTool.CaptureScreenItem[]) {
794
+ this.store.updateCaptureScreenList(list);
795
+ this.postMessage();
796
+ }
797
+
798
+ /**
799
+ * 清空截屏列表
800
+ *
801
+ * @memberof DevEvent
802
+ */
803
+ clearCaptureScreenList() {
804
+ this.store.clearCaptureScreenList();
805
+ }
779
806
  }
@@ -724,4 +724,22 @@ export class DevIntercept {
724
724
  this.interceptUniEventFactory('emit');
725
725
  this.interceptUniEventFactory('off');
726
726
  }
727
+
728
+ /**
729
+ * 监听截屏
730
+ *
731
+ * @memberof DevIntercept
732
+ */
733
+ interceptCaptureScreen() {
734
+ uni.onUserCaptureScreen(() => {
735
+ if (!this.event.getDevToolDestroy()) {
736
+ this.event.updateCaptureScreenList([
737
+ {
738
+ position: getCurrentPagePath(),
739
+ timer: getCurrentDate(),
740
+ },
741
+ ]);
742
+ }
743
+ });
744
+ }
727
745
  }