vite-uni-dev-tool 0.0.10 → 0.0.12

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 (45) hide show
  1. package/README.md +65 -1
  2. package/dev/components/AppInfo/index.vue +36 -0
  3. package/dev/components/CaptureScreen/index.vue +62 -0
  4. package/dev/components/Code/index.vue +7 -4
  5. package/dev/components/ConsoleList/ConsoleItem.vue +24 -3
  6. package/dev/components/ConsoleList/RunJSInput.vue +180 -2
  7. package/dev/components/ConsoleList/index.vue +17 -2
  8. package/dev/components/ConsoleList/staticTips.ts +1145 -0
  9. package/dev/components/DevTool/index.vue +37 -31
  10. package/dev/components/DevToolButton/index.vue +9 -12
  11. package/dev/components/DevToolTitle/index.vue +2 -2
  12. package/dev/components/DevToolWindow/index.vue +230 -112
  13. package/dev/components/JsonPretty/components/Carets/index.vue +10 -14
  14. package/dev/components/JsonPretty/index.vue +2 -0
  15. package/dev/components/NetworkList/NetworkDetail.vue +3 -6
  16. package/dev/components/NetworkList/NetworkItem.vue +21 -8
  17. package/dev/components/NetworkList/index.vue +15 -2
  18. package/dev/components/RouteList/index.vue +12 -1
  19. package/dev/components/SettingList/index.vue +2 -5
  20. package/dev/components/SourceCode/index.vue +231 -0
  21. package/dev/components/Tabs/index.vue +23 -10
  22. package/dev/components/UniEvent/UniEventItem.vue +4 -2
  23. package/dev/components/UniEvent/index.vue +7 -3
  24. package/dev/components/UploadList/UploadDetail.vue +3 -7
  25. package/dev/components/UploadList/UploadItem.vue +7 -1
  26. package/dev/components/UploadList/index.vue +15 -2
  27. package/dev/components/VirtualListPro/index.vue +72 -3
  28. package/dev/components/VuexList/index.vue +2 -2
  29. package/dev/components/WebSocket/WebSocketItem.vue +7 -2
  30. package/dev/components/WebSocket/WebSocketList.vue +3 -6
  31. package/dev/components/WebSocket/index.vue +15 -2
  32. package/dev/const.ts +10 -14
  33. package/dev/devEvent/index.ts +49 -18
  34. package/dev/devIntercept/index.ts +18 -0
  35. package/dev/devStore/index.ts +60 -13
  36. package/dev/devToolInfo/index.ts +26 -0
  37. package/dev/plugins/uniDevTool/uniDevTool.d.ts +9 -1
  38. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  39. package/dev/plugins/uniDevTool/uniDevTool.js +36 -36
  40. package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
  41. package/dev/type.ts +34 -0
  42. package/dev/utils/index.ts +5 -0
  43. package/dev/utils/language.ts +8 -3
  44. package/dev/utils/object.ts +10 -2
  45. package/package.json +1 -1
@@ -1,13 +1,19 @@
1
1
  <template>
2
2
  <scroll-view
3
3
  :lower-threshold="preLodeHeight"
4
+ :scroll-with-animation="scrollWithAnimation"
4
5
  :class="['virtual-list', className]"
6
+ :style="style"
7
+ :scroll-into-view="innerScrollIntoView"
5
8
  scroll-y
6
9
  @scroll="onScroll"
7
10
  @scrolltolower="onScrollToLower"
8
11
  >
9
12
  <!-- 阈值判断 -->
10
- <view :style="{ height: `${state.currentHeight}px` }"></view>
13
+ <view
14
+ :id="placeholderId"
15
+ :style="{ height: `${state.currentHeight}px` }"
16
+ ></view>
11
17
  <view>
12
18
  <!-- 将可视数据传入到slot -->
13
19
  <slot
@@ -16,10 +22,20 @@
16
22
  :start="(state.current - 1) * props.pageSize"
17
23
  ></slot>
18
24
  </view>
25
+
26
+ <view
27
+ v-if="state.currentHeight > props.height && showBackTop"
28
+ class="virtual-back-top"
29
+ @click="onBackTop"
30
+ >
31
+
32
+ </view>
19
33
  </scroll-view>
20
34
  </template>
21
35
  <script lang="ts" setup>
22
- import { reactive, watch, onBeforeMount, provide } from 'vue';
36
+ import { nextTick } from 'vue';
37
+ import { uniqueId } from '../../utils';
38
+ import { reactive, watch, onBeforeMount, provide, computed, ref } from 'vue';
23
39
 
24
40
  const props = withDefaults(
25
41
  defineProps<{
@@ -37,6 +53,12 @@ const props = withDefaults(
37
53
  preLodeHeight?: number;
38
54
  /** 类名 */
39
55
  className?: string;
56
+ /** 滚动到指定元素 */
57
+ scrollIntoView?: string;
58
+ /** 滚动动画 */
59
+ scrollWithAnimation?: boolean;
60
+ /** 返回顶部 */
61
+ showBackTop?: boolean;
40
62
  }>(),
41
63
  {
42
64
  height: 400,
@@ -51,12 +73,17 @@ const state = reactive<{
51
73
  visitableData: any[];
52
74
  currentHeight: number;
53
75
  height: number;
76
+ scrollTop: number;
54
77
  }>({
55
78
  height: 0,
56
79
  current: 1,
57
80
  visitableData: [],
58
81
  currentHeight: 0,
82
+ scrollTop: 0,
59
83
  });
84
+
85
+ const placeholderId = uniqueId('virtual-placeholder-');
86
+
60
87
  /**
61
88
  * 每一项的高度
62
89
  */
@@ -64,6 +91,19 @@ const itemsHeight: number[] = [];
64
91
 
65
92
  provide('itemsHeight', itemsHeight);
66
93
 
94
+ const style = computed(() => {
95
+ return {
96
+ height:
97
+ typeof props.height === 'string' ? props.height : props.height + 'px',
98
+ };
99
+ });
100
+
101
+ const toView = ref('');
102
+
103
+ const innerScrollIntoView = computed(() => {
104
+ return toView.value || props.scrollIntoView;
105
+ });
106
+
67
107
  onBeforeMount(() => {
68
108
  // 初始渲染数据
69
109
  state.visitableData = props.data.slice(0, props.pageSize * 2);
@@ -165,5 +205,34 @@ function onSizeChange(index: number, height: number) {
165
205
  itemsHeight[index] = height;
166
206
  }
167
207
  provide('onSizeChange', onSizeChange);
208
+
209
+ /** 返回顶部 */
210
+ function onBackTop() {
211
+ toView.value = placeholderId;
212
+
213
+ nextTick(() => {
214
+ state.current = 1;
215
+ state.currentHeight = 0;
216
+ updateVisitableData('up');
217
+
218
+ toView.value = '';
219
+ });
220
+ }
168
221
  </script>
169
- <style scoped></style>
222
+ <style scoped>
223
+ .virtual-list {
224
+ position: relative;
225
+ }
226
+
227
+ .virtual-back-top {
228
+ position: sticky;
229
+ bottom: 20px;
230
+ left: 80%;
231
+ display: flex;
232
+ align-items: center;
233
+ justify-content: center;
234
+ width: 40px;
235
+ height: 40px;
236
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
237
+ }
238
+ </style>
@@ -12,7 +12,7 @@
12
12
  </view>
13
13
  </template>
14
14
  <script lang="ts" setup>
15
- import { computed, ref } from 'vue';
15
+ import { computed } from 'vue';
16
16
  import JsonPretty from '../JsonPretty/index.vue';
17
17
  import Empty from '../Empty/index.vue';
18
18
  const props = defineProps<{
@@ -39,7 +39,7 @@ function onUpdateData(data: Record<string, any>) {
39
39
  const firstKey = currentSelect?.path.split('.')?.slice(1)?.[0];
40
40
  emit('update:vuexList', data);
41
41
  emit('diffValue', {
42
- [firstKey]: data[firstKey]
42
+ [firstKey]: data[firstKey],
43
43
  });
44
44
  }
45
45
  function onNodeClick(node: any) {
@@ -34,7 +34,12 @@
34
34
  }}</view>
35
35
  </view>
36
36
 
37
- <WebSocketList v-if="showDetail" :ws="ws" @close="onClose" />
37
+ <WebSocketList
38
+ v-if="showDetail"
39
+ :ws="ws"
40
+ :zIndex="zIndex"
41
+ @close="onClose"
42
+ />
38
43
  </view>
39
44
  </template>
40
45
  <script lang="ts" setup>
@@ -45,7 +50,7 @@ import WebSocketList from './WebSocketList.vue';
45
50
  import { formatDate } from '../../utils';
46
51
  import type { DevTool } from '../../type';
47
52
 
48
- defineProps<{ ws: DevTool.WS }>();
53
+ defineProps<{ ws: DevTool.WS; zIndex?: number }>();
49
54
  const showDetail = ref(false);
50
55
 
51
56
  function onClose() {
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="web-socket-list-container">
2
+ <view class="web-socket-list-container" :style="{ zIndex: zIndex }">
3
3
  <view class="web-socket-top">
4
4
  请求url:
5
5
 
@@ -48,7 +48,7 @@ import CloseButton from '../CloseButton/index.vue';
48
48
  import { formatDate } from '../../utils/index';
49
49
  import type { DevTool } from '../../type';
50
50
 
51
- defineProps<{ ws: DevTool.WS }>();
51
+ defineProps<{ ws: DevTool.WS; zIndex?: number }>();
52
52
  const emit = defineEmits<{ (e: 'close'): void }>();
53
53
 
54
54
  function onClose() {
@@ -82,13 +82,10 @@ function onClick(item: {
82
82
  position: fixed;
83
83
  width: 100vw;
84
84
  height: 100vh;
85
- z-index: 1000;
85
+ z-index: 1001;
86
86
  top: 0;
87
87
  left: 0;
88
88
  padding: 0 16px;
89
- /* #ifdef H5 */
90
- padding: 50px 16px;
91
- /* #endif */
92
89
 
93
90
  background-color: rgba(255, 255, 255, 0.95);
94
91
  box-sizing: border-box;
@@ -18,14 +18,19 @@
18
18
  </Tag>
19
19
  </view>
20
20
 
21
- <VirtualListPro :data="wsList" :pageSize="10" className="websocket-list">
21
+ <VirtualListPro
22
+ :data="wsList"
23
+ :pageSize="10"
24
+ :height="height"
25
+ className="websocket-list"
26
+ >
22
27
  <template v-slot="{ list, start }">
23
28
  <AutoSize
24
29
  v-for="(item, index) in list"
25
30
  :index="start + index"
26
31
  :key="start + index"
27
32
  >
28
- <WebSocketItem :ws="item" />
33
+ <WebSocketItem :ws="item" :zIndex="zIndex" />
29
34
  </AutoSize>
30
35
  <Empty v-if="!wsList || wsList.length === 0" />
31
36
  </template>
@@ -40,11 +45,13 @@ import FilterInput from '../FilterInput/index.vue';
40
45
  import type { DevTool } from '../../type';
41
46
  import VirtualListPro from '../VirtualListPro/index.vue';
42
47
  import AutoSize from '../VirtualListPro/AutoSize.vue';
48
+ import { onMounted, ref } from 'vue';
43
49
 
44
50
  defineProps<{
45
51
  wsList: DevTool.WS[];
46
52
  currentWebSocketType: string;
47
53
  modelValue: string;
54
+ zIndex?: number;
48
55
  }>();
49
56
  const emit = defineEmits<{
50
57
  (e: 'choose', type: string): void;
@@ -87,6 +94,12 @@ const webSocketFilter = [
87
94
  function onChoose(type: string) {
88
95
  emit('choose', type);
89
96
  }
97
+
98
+ const height = ref(0);
99
+ onMounted(() => {
100
+ const { windowHeight } = uni.getWindowInfo();
101
+ height.value = windowHeight - 32 - 32;
102
+ });
90
103
  </script>
91
104
  <style scoped>
92
105
  .websocket-content {
package/dev/const.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  /**
2
2
  * 调试按钮事件
3
- * 缓存调试按钮显示隐藏
4
3
  */
5
- export const EVENT_DEV_BUTTON = 'event-dev-button';
4
+ export const DEV_BUTTON_VISIBLE = 'dev-button-visible';
6
5
 
7
6
  /**
8
7
  * 调试弹窗事件
9
- * 缓存调试弹窗显示隐藏
10
8
  */
11
- export const EVENT_DEV_WINDOW = 'event-dev-window';
9
+ export const DEV_WINDOW_VISIBLE = 'dev-window-visible';
12
10
 
13
11
  /**
14
12
  * app 发出的信息
@@ -21,15 +19,8 @@ export const DEV_APP_MESSAGE = 'dev-app-message';
21
19
  export const DEV_WINDOW_MESSAGE = 'dev-window-message';
22
20
 
23
21
  /**
24
- * 缓存调试按钮信息
22
+ * 调试器销毁
25
23
  */
26
- export const DEV_BUTTON_INFO = 'dev-button-info';
27
-
28
- /**
29
- * 缓存调试弹窗信息
30
- */
31
- export const DEV_WINDOW_INFO = ' dev-window-info';
32
-
33
24
  export const DEV_IS_DESTROY = 'dev-is-destroy';
34
25
 
35
26
  /**
@@ -163,6 +154,11 @@ export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
163
154
  export const DEV_RUN_JS = 'dev-uni-run-js';
164
155
 
165
156
  /**
166
- * 清空运行的js
157
+ * 清空截屏列表
158
+ */
159
+ export const DEV_CAPTURE_SCREEN_CLEAR = 'dev-capture-screen-clear';
160
+
161
+ /**
162
+ * 存储的dev-tool 信息
167
163
  */
168
- export const DEV_RUN_JS_CLEAR = 'dev-uni-run-js-clear';
164
+ export const DEV_TOOL_INFO = 'dev-tool-info';
@@ -22,14 +22,15 @@ import {
22
22
  DEV_WEBSOCKET_CLEAR,
23
23
  DEV_WINDOW_OPEN,
24
24
  DEV_APP_MESSAGE,
25
- EVENT_DEV_BUTTON,
26
- EVENT_DEV_WINDOW,
25
+ DEV_BUTTON_VISIBLE,
26
+ DEV_WINDOW_VISIBLE,
27
27
  DEV_WINDOW_MESSAGE,
28
28
  DEV_WINDOW_CLOSE,
29
29
  DEV_OPTION_GET,
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';
@@ -71,6 +72,10 @@ export class DevEvent {
71
72
  * @memberof DevEvent
72
73
  */
73
74
  async postMessageFn() {
75
+ if (this.getDevToolDestroy()) {
76
+ return;
77
+ }
78
+
74
79
  const data = await this.store.getDevData();
75
80
  const size = calculateObjectSize(data);
76
81
  const sizeFormat = formatStorageSize(size);
@@ -98,7 +103,7 @@ export class DevEvent {
98
103
  * @memberof DevEvent
99
104
  */
100
105
  createDevTool() {
101
- if (!this.store.getDevToolDestroy()) {
106
+ if (!this.getDevToolDestroy()) {
102
107
  console.warn('[DevTool] 调试器已存在,不在重新创建');
103
108
  return;
104
109
  }
@@ -114,8 +119,8 @@ export class DevEvent {
114
119
  * @memberof DevEvent
115
120
  */
116
121
  destroyDevTool() {
117
- if (this.store.getDevToolDestroy()) {
118
- console.warn('[DevTool] 调试器已存在,不在重新创建');
122
+ if (this.getDevToolDestroy()) {
123
+ console.warn('[DevTool] 调试器已经销毁了,不在重新销毁');
119
124
  return;
120
125
  }
121
126
  this.store.setRequestIndex(-1);
@@ -150,7 +155,7 @@ export class DevEvent {
150
155
 
151
156
  this.store.setDevToolDestroy(true);
152
157
 
153
- this.eventBus.clear();
158
+ // this.eventBus.clear();
154
159
 
155
160
  console.warn('[DevTool] 调试器已销毁');
156
161
  }
@@ -174,10 +179,11 @@ export class DevEvent {
174
179
  * @memberof DevEvent
175
180
  */
176
181
  openDevToolWindow() {
182
+ if (this.getDevToolDestroy()) return;
177
183
  setTimeout(async () => {
178
184
  this.postMessage();
179
185
  }, 100);
180
- this.eventBus.emit(EVENT_DEV_WINDOW, true);
186
+ this.eventBus.emit(DEV_WINDOW_VISIBLE, true);
181
187
  }
182
188
 
183
189
  /**
@@ -186,7 +192,8 @@ export class DevEvent {
186
192
  * @memberof DevEvent
187
193
  */
188
194
  closeDevToolWindow() {
189
- this.eventBus.emit(EVENT_DEV_WINDOW, false);
195
+ if (this.getDevToolDestroy()) return;
196
+ this.eventBus.emit(DEV_WINDOW_VISIBLE, false);
190
197
  }
191
198
 
192
199
  /**
@@ -195,10 +202,10 @@ export class DevEvent {
195
202
  * @export
196
203
  */
197
204
  showDevToolButton() {
198
- const isDestroy = uni.getStorageSync(DEV_IS_DESTROY) ?? false;
199
- if (isDestroy) return;
200
- this.eventBus.emit(EVENT_DEV_BUTTON, true);
201
- uni.setStorageSync(EVENT_DEV_BUTTON, true);
205
+ if (this.getDevToolDestroy()) return;
206
+
207
+ this.eventBus.emit(DEV_BUTTON_VISIBLE, true);
208
+
202
209
  this.store.setDevToolVisible(true);
203
210
  }
204
211
 
@@ -208,10 +215,8 @@ export class DevEvent {
208
215
  * @return {*}
209
216
  */
210
217
  hideDevToolButton() {
211
- const isDestroy = uni.getStorageSync(DEV_IS_DESTROY) ?? false;
212
- if (isDestroy) return;
213
- this.eventBus.emit(EVENT_DEV_BUTTON, false);
214
- uni.setStorageSync(EVENT_DEV_BUTTON, false);
218
+ if (this.getDevToolDestroy()) return;
219
+ this.eventBus.emit(DEV_BUTTON_VISIBLE, false);
215
220
  this.store.setDevToolVisible(false);
216
221
  }
217
222
 
@@ -247,7 +252,8 @@ export class DevEvent {
247
252
  * @memberof DevEvent
248
253
  */
249
254
  switchTo(path: string) {
250
- this.showDevToolButton();
255
+ // this.showDevToolButton();
256
+ this.closeDevToolWindow();
251
257
  uni.switchTab({
252
258
  url: path,
253
259
  });
@@ -260,7 +266,8 @@ export class DevEvent {
260
266
  * @memberof DevEvent
261
267
  */
262
268
  navigateTo(path: string) {
263
- this.showDevToolButton();
269
+ // this.showDevToolButton();
270
+ this.closeDevToolWindow();
264
271
  uni.navigateTo({
265
272
  url: path,
266
273
  });
@@ -430,6 +437,10 @@ export class DevEvent {
430
437
  else if (data.type === DEV_RUN_JS) {
431
438
  this.devRunJS(data.data.code);
432
439
  }
440
+ // 清空截屏列表
441
+ else if (data.type === DEV_CAPTURE_SCREEN_CLEAR) {
442
+ this.store.clearCaptureScreenList();
443
+ }
433
444
  },
434
445
  );
435
446
  }
@@ -776,4 +787,24 @@ export class DevEvent {
776
787
  this.postMessageFn();
777
788
  });
778
789
  }
790
+
791
+ /**
792
+ * 更新截屏列表
793
+ *
794
+ * @param {DevTool.CaptureScreenItem[]} list
795
+ * @memberof DevEvent
796
+ */
797
+ updateCaptureScreenList(list: DevTool.CaptureScreenItem[]) {
798
+ this.store.updateCaptureScreenList(list);
799
+ this.postMessage();
800
+ }
801
+
802
+ /**
803
+ * 清空截屏列表
804
+ *
805
+ * @memberof DevEvent
806
+ */
807
+ clearCaptureScreenList() {
808
+ this.store.clearCaptureScreenList();
809
+ }
779
810
  }
@@ -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
  }
@@ -1,6 +1,6 @@
1
1
  import type { DevTool } from '../type';
2
2
 
3
- import { DEV_IS_DESTROY, EVENT_DEV_BUTTON } from '../const';
3
+ import { DEV_TOOL_INFO } from '../const';
4
4
 
5
5
  import {
6
6
  isNil,
@@ -12,6 +12,7 @@ import {
12
12
  isBoolean,
13
13
  } from '../utils/index';
14
14
  import { backup } from '../core';
15
+ import { getDevToolInfo, setDevToolInfo } from '../devToolInfo';
15
16
 
16
17
  /** 数据存储中心 */
17
18
  export class DevStore {
@@ -26,6 +27,7 @@ export class DevStore {
26
27
  deviceInfo: {},
27
28
  windowInfo: {},
28
29
  systemInfo: {},
30
+ appInfo: {},
29
31
  wsList: [],
30
32
  netWorkStatus: {},
31
33
  uploadList: [],
@@ -36,6 +38,7 @@ export class DevStore {
36
38
  emit: 0,
37
39
  off: 0,
38
40
  },
41
+ captureScreenList: [],
39
42
  };
40
43
 
41
44
  /** 调试配置 */
@@ -50,8 +53,8 @@ export class DevStore {
50
53
  private wsDataMaxSize = 1000;
51
54
  /** 事件列表最大值 */
52
55
  private eventListMaxSize = 1000;
53
- /** js 最大运行条数 */
54
- private runJsMaxSize = 1000;
56
+ /** 截屏最大值 */
57
+ private captureScreenMaxSize = 1000;
55
58
 
56
59
  /** 缓存最大值 */
57
60
  cacheMaxSize = 8 * 1024 * 1024 * 10;
@@ -75,14 +78,22 @@ export class DevStore {
75
78
  /** 是否开启拦截Promise reject错误 */
76
79
  enableInterceptPromiseReject = false;
77
80
 
81
+ private zIndex = 1000;
82
+
78
83
  constructor() {
79
- this.devToolDestroy = uni.getStorageSync(DEV_IS_DESTROY) ?? false;
80
- this.devToolVisible = uni.getStorageSync(EVENT_DEV_BUTTON) ?? false;
84
+ const { devToolDestroy = false, devToolButtonVisible = false } =
85
+ uni.getStorageSync(DEV_TOOL_INFO);
86
+
87
+ this.devToolDestroy = devToolDestroy;
88
+ this.devToolVisible = devToolButtonVisible;
81
89
  }
82
90
 
83
91
  setDevToolVisible(visible: boolean) {
84
92
  this.devToolVisible = visible;
85
- uni.setStorageSync(EVENT_DEV_BUTTON, visible);
93
+
94
+ setDevToolInfo({
95
+ devToolButtonVisible: visible,
96
+ });
86
97
  }
87
98
 
88
99
  getDevToolVisible() {
@@ -146,10 +157,13 @@ export class DevStore {
146
157
  this.wsDataMaxSize = options.wsDataMaxSize || 1000;
147
158
  this.cacheMaxSize = options.cacheMaxSize || 8 * 1024 * 1024 * 10;
148
159
  this.eventListMaxSize = options.eventListMaxSize || 1000;
160
+ this.captureScreenMaxSize = options.captureScreenMaxSize || 1000;
161
+ this.zIndex = options.zIndex || 1000;
162
+
163
+ const { devToolButtonVisible } = getDevToolInfo();
149
164
 
150
- const devToolVisible = uni.getStorageSync(EVENT_DEV_BUTTON);
151
- this.devToolVisible = isBoolean(devToolVisible)
152
- ? devToolVisible
165
+ this.devToolVisible = isBoolean(devToolButtonVisible)
166
+ ? devToolButtonVisible
153
167
  : (options.initShowDevTool ?? true);
154
168
 
155
169
  this.setDevToolVisible(this.devToolVisible);
@@ -185,6 +199,14 @@ export class DevStore {
185
199
  const systemInfo = uni.getSystemInfoSync();
186
200
  const deviceInfo = uni.getDeviceInfo();
187
201
  const windowInfo = uni.getWindowInfo();
202
+
203
+ const appInfo = {
204
+ ...(await uni.getAppBaseInfo()),
205
+
206
+ // #ifndef H5
207
+ ...(await uni.getAppAuthorizeSetting()),
208
+ // #endif
209
+ };
188
210
  const ip = getWifiIp() || getLanIp() || (await getMicroAppIp());
189
211
  return {
190
212
  ...this.state,
@@ -192,6 +214,7 @@ export class DevStore {
192
214
  deviceInfo,
193
215
  windowInfo,
194
216
  devToolVisible: this.getDevToolVisible(),
217
+ appInfo,
195
218
  netWorkStatus: {
196
219
  ip,
197
220
  ...networkType,
@@ -254,8 +277,6 @@ export class DevStore {
254
277
 
255
278
  setValueByPath(this.piniaStore.state.value, key, value);
256
279
 
257
- console.log('this.piniaStore.state.value: ', this.piniaStore.state.value);
258
-
259
280
  this.setPiniaList({
260
281
  ...(this.piniaStore.state.value ?? {}),
261
282
  });
@@ -336,6 +357,7 @@ export class DevStore {
336
357
  this.state.windowInfo = {};
337
358
  this.state.systemInfo = {};
338
359
  this.state.netWorkStatus = {};
360
+ this.state.appInfo = {};
339
361
 
340
362
  this.state.eventList = [];
341
363
  this.state.eventCount = {
@@ -344,6 +366,8 @@ export class DevStore {
344
366
  emit: 0,
345
367
  off: 0,
346
368
  };
369
+
370
+ this.state.captureScreenList = [];
347
371
  }
348
372
 
349
373
  addUploadTask(index: number | string, task: UniApp.UploadTask) {
@@ -613,12 +637,17 @@ export class DevStore {
613
637
  }
614
638
 
615
639
  setDevToolDestroy(destroy: boolean) {
616
- uni.setStorageSync(DEV_IS_DESTROY, destroy);
617
640
  this.devToolDestroy = destroy;
641
+
642
+ setDevToolInfo({
643
+ devToolDestroy: destroy,
644
+ });
618
645
  }
619
646
 
620
647
  getDevToolDestroy() {
621
- return this.devToolDestroy ?? (uni.getStorageSync(DEV_IS_DESTROY) || false);
648
+ const { devToolDestroy = false } = uni.getStorageSync(DEV_TOOL_INFO);
649
+
650
+ return this.devToolDestroy ?? devToolDestroy;
622
651
  }
623
652
 
624
653
  getCurrentPagePath() {
@@ -682,4 +711,22 @@ export class DevStore {
682
711
  };
683
712
  this.state.eventList = [];
684
713
  }
714
+
715
+ updateCaptureScreenList(captureScreenList: DevTool.CaptureScreenItem[]) {
716
+ const len = this.state.captureScreenList?.length ?? 0;
717
+ const max = this.captureScreenMaxSize;
718
+ if (len + captureScreenList.length > max) {
719
+ this.state.captureScreenList?.splice(
720
+ 0,
721
+ len - max - captureScreenList.length,
722
+ );
723
+ }
724
+ this.state.captureScreenList?.push(...captureScreenList);
725
+
726
+ return this.state.captureScreenList;
727
+ }
728
+
729
+ clearCaptureScreenList() {
730
+ this.state.captureScreenList = [];
731
+ }
685
732
  }
@@ -0,0 +1,26 @@
1
+ import { DEV_TOOL_INFO } from '../const';
2
+ import type { DevTool } from '../type';
3
+
4
+ /**
5
+ * 缓存调试工具信息到本地
6
+ *
7
+ * @export
8
+ * @param {DevTool.DevToolInfo} info
9
+ */
10
+ export function setDevToolInfo(info: DevTool.DevToolInfo) {
11
+ const devInfo = uni.getStorageSync(DEV_TOOL_INFO);
12
+ uni.setStorageSync(DEV_TOOL_INFO, {
13
+ ...devInfo,
14
+ ...info,
15
+ });
16
+ }
17
+
18
+ /**
19
+ * 获取本地缓存信息
20
+ *
21
+ * @export
22
+ * @return {*}
23
+ */
24
+ export function getDevToolInfo() {
25
+ return uni.getStorageSync(DEV_TOOL_INFO) as DevTool.DevToolInfo;
26
+ }