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
@@ -7,6 +7,7 @@
7
7
  :buttonColor="buttonProps.buttonColor"
8
8
  :buttonFontSize="buttonProps.buttonFontSize"
9
9
  :buttonBackgroundColor="buttonProps.buttonBackgroundColor"
10
+ :zIndex="zIndex"
10
11
  @click="onDevToolButtonClick"
11
12
  />
12
13
  <DevToolWindow
@@ -15,12 +16,10 @@
15
16
  :sourceFileServers="sourceFileServers"
16
17
  :mode="mode"
17
18
  :useDevSource="useDevSource"
19
+ :zIndex="zIndex + 1"
18
20
  @close="onShowDevToolWindow(false)"
19
21
  @sendMessage="onSendMessage"
20
22
  />
21
- <!-- <view class="devTool-canvas">
22
- <canvas canvas-id="fullscreenCanvas" id="fullscreenCanvas" />
23
- </view> -->
24
23
  </view>
25
24
  </template>
26
25
  <script lang="ts" setup>
@@ -31,8 +30,8 @@ import DevToolWindow from '../DevToolWindow/index.vue';
31
30
  import { eventBus } from '../../core';
32
31
 
33
32
  import {
34
- EVENT_DEV_BUTTON,
35
- EVENT_DEV_WINDOW,
33
+ DEV_BUTTON_VISIBLE,
34
+ DEV_WINDOW_VISIBLE,
36
35
  DEV_WINDOW_MESSAGE,
37
36
  DEV_WINDOW_OPEN,
38
37
  DEV_WINDOW_CLOSE,
@@ -40,6 +39,7 @@ import {
40
39
  DEV_OPTION_SEND,
41
40
  } from '../../const';
42
41
  import type { DevTool } from '../../type';
42
+ import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
43
43
 
44
44
  let isActive = false;
45
45
 
@@ -60,6 +60,8 @@ const sourceFileServers = ref<string[]>([]);
60
60
 
61
61
  const mode = ref<string>();
62
62
 
63
+ const zIndex = ref(1000);
64
+
63
65
  const useDevSource = ref(false);
64
66
 
65
67
  function onDevToolButtonClick() {
@@ -72,14 +74,20 @@ function onDevToolButtonClick() {
72
74
 
73
75
  function onShowDevToolButton(show: boolean) {
74
76
  if (!isActive) return;
75
- devToolButtonVisible.value = show ?? uni.getStorageSync(EVENT_DEV_BUTTON);
77
+
78
+ const { devToolButtonVisible: showButton = false } = getDevToolInfo();
79
+
80
+ devToolButtonVisible.value = show ?? showButton;
76
81
  }
77
82
 
78
83
  async function onShowDevToolWindow(show: boolean) {
79
84
  if (!isActive) return;
80
85
 
81
86
  devToolWindowVisible.value = show;
82
- uni.setStorageSync(EVENT_DEV_WINDOW, show);
87
+
88
+ setDevToolInfo({
89
+ devToolWindowVisible: show,
90
+ });
83
91
  }
84
92
 
85
93
  function onSendMessage(param: { type: string; data: Record<string, any> }) {
@@ -100,19 +108,25 @@ function onDevOptionSend(options: DevTool.DevToolOptions) {
100
108
  mode.value = options.mode ?? '';
101
109
 
102
110
  useDevSource.value = options.useDevSource ?? false;
111
+
112
+ zIndex.value = options.zIndex ?? 1000;
103
113
  }
104
114
  }
105
115
 
106
116
  onLoad(() => {
107
117
  // 共享状态
108
118
 
109
- const show = uni.getStorageSync(EVENT_DEV_WINDOW) || false;
119
+ const {
120
+ devToolButtonVisible: showButton = false,
121
+
122
+ devToolWindowVisible: showWindow = false,
123
+ } = getDevToolInfo();
110
124
 
111
125
  isActive = true;
112
- devToolButtonVisible.value = uni.getStorageSync(EVENT_DEV_BUTTON) || false;
113
- devToolWindowVisible.value = show;
114
- eventBus.on(EVENT_DEV_BUTTON, onShowDevToolButton);
115
- eventBus.on(EVENT_DEV_WINDOW, onShowDevToolWindow);
126
+ devToolButtonVisible.value = showButton;
127
+ devToolWindowVisible.value = showWindow;
128
+ eventBus.on(DEV_BUTTON_VISIBLE, onShowDevToolButton);
129
+ eventBus.on(DEV_WINDOW_VISIBLE, onShowDevToolWindow);
116
130
  eventBus.on(DEV_OPTION_SEND, onDevOptionSend);
117
131
 
118
132
  nextTick(() => {
@@ -125,14 +139,21 @@ onUnload(() => {
125
139
  type: DEV_WINDOW_CLOSE,
126
140
  data: {},
127
141
  });
128
- eventBus.off(EVENT_DEV_BUTTON, onShowDevToolButton);
129
- eventBus.off(EVENT_DEV_WINDOW, onShowDevToolWindow);
142
+ eventBus.off(DEV_BUTTON_VISIBLE, onShowDevToolButton);
143
+ eventBus.off(DEV_WINDOW_VISIBLE, onShowDevToolWindow);
130
144
  });
131
145
 
132
146
  onShow(() => {
133
147
  isActive = true;
134
- devToolWindowVisible.value = uni.getStorageSync(EVENT_DEV_WINDOW) || false;
135
- devToolButtonVisible.value = uni.getStorageSync(EVENT_DEV_BUTTON) || false;
148
+ const {
149
+ devToolButtonVisible: showButton = false,
150
+
151
+ devToolWindowVisible: showWindow = false,
152
+ } = getDevToolInfo();
153
+
154
+ devToolWindowVisible.value = showWindow;
155
+ devToolButtonVisible.value = showButton;
156
+
136
157
  if (devToolWindowVisible.value) {
137
158
  onSendMessage({
138
159
  type: DEV_WINDOW_OPEN,
@@ -164,19 +185,4 @@ onHide(() => {
164
185
 
165
186
  -webkit-tap-highlight-color: transparent;
166
187
  }
167
-
168
- .dev-tool-canvas {
169
- position: fixed;
170
- z-index: -1000;
171
- top: 0;
172
- left: 0;
173
- width: 100vw;
174
- height: 100vh;
175
- opacity: 0;
176
- }
177
-
178
- #fullscreenCanvas {
179
- width: 100vw;
180
- height: 100vh;
181
- }
182
188
  </style>
@@ -9,6 +9,7 @@
9
9
  width: props.buttonSize + 'px',
10
10
  height: props.buttonSize + 'px',
11
11
  cursor: isDragging ? 'move' : 'pointer',
12
+ zIndex: zIndex,
12
13
  ...buttonPosition,
13
14
  }"
14
15
  @touchstart="onTouchStart"
@@ -22,7 +23,7 @@
22
23
  <script lang="ts" setup>
23
24
  import { onShow, onHide } from '@dcloudio/uni-app';
24
25
  import { ref, computed, reactive, onMounted } from 'vue';
25
- import { DEV_BUTTON_INFO } from '../../const';
26
+ import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
26
27
 
27
28
  const emit = defineEmits<{ (e: 'click'): void }>();
28
29
  const props = withDefaults(
@@ -32,8 +33,9 @@ const props = withDefaults(
32
33
  buttonColor?: string;
33
34
  buttonFontSize?: string;
34
35
  buttonBackgroundColor?: string;
36
+ zIndex?: number;
35
37
  }>(),
36
- { buttonSize: 50 },
38
+ { buttonSize: 50, zIndex: 1000 },
37
39
  );
38
40
  const sizeHalf = props.buttonSize / 2;
39
41
 
@@ -113,8 +115,7 @@ function onResize() {
113
115
  }
114
116
  timer = setTimeout(() => {
115
117
  buttonPosition.transition = 'none';
116
-
117
- uni.setStorageSync(DEV_BUTTON_INFO, {
118
+ setDevToolInfo({
118
119
  left: buttonPosition.left,
119
120
  top: buttonPosition.top,
120
121
  });
@@ -122,19 +123,15 @@ function onResize() {
122
123
  }
123
124
 
124
125
  onMounted(() => {
125
- const { left, top } = uni.getStorageSync(DEV_BUTTON_INFO) || {
126
- left: windowWidth - props.buttonSize + 'px',
127
- top: '80vh',
128
- };
126
+ const { left = windowWidth - props.buttonSize + 'px', top = '80vh' } =
127
+ getDevToolInfo();
129
128
  buttonPosition.left = left;
130
129
  buttonPosition.top = top;
131
130
  });
132
131
 
133
132
  onShow(() => {
134
- const { left, top } = uni.getStorageSync(DEV_BUTTON_INFO) || {
135
- left: windowWidth - props.buttonSize + 'px',
136
- top: '80vh',
137
- };
133
+ const { left = windowWidth - props.buttonSize + 'px', top = '80vh' } =
134
+ getDevToolInfo();
138
135
  buttonPosition.left = left;
139
136
  buttonPosition.top = top;
140
137
 
@@ -1,8 +1,8 @@
1
1
  <template>
2
- <view class="dev-tool-title" :style="style"> <slot /> </view>
2
+ <view class="dev-tool-title" :style="innerStyle"> <slot /> </view>
3
3
  </template>
4
4
  <script lang="ts" setup>
5
- defineProps<{ style?: any }>();
5
+ defineProps<{ innerStyle?: any }>();
6
6
  </script>
7
7
  <style scoped>
8
8
  .dev-tool-title {