vite-uni-dev-tool 0.0.7 → 0.0.8

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 (46) hide show
  1. package/README.md +9 -1
  2. package/dev/components/Code/index.vue +227 -0
  3. package/dev/components/ConsoleList/Code.vue +1 -1
  4. package/dev/components/ConsoleList/ConsoleItem.vue +38 -12
  5. package/dev/components/ConsoleList/RunJSInput.vue +59 -0
  6. package/dev/components/ConsoleList/index.vue +24 -8
  7. package/dev/components/DevTool/index.vue +1 -1
  8. package/dev/components/DevToolButton/index.vue +10 -10
  9. package/dev/components/DevToolWindow/index.vue +21 -2
  10. package/dev/components/FilterInput/index.vue +1 -1
  11. package/dev/components/JsonPretty/components/CheckController/index.vue +22 -5
  12. package/dev/components/JsonPretty/components/TreeNode/index.vue +16 -15
  13. package/dev/components/JsonPretty/index.vue +77 -75
  14. package/dev/components/JsonPretty/type.ts +2 -0
  15. package/dev/components/NetworkList/NetworkDetail.vue +1 -1
  16. package/dev/components/RunJS/index.vue +128 -0
  17. package/dev/components/SettingList/index.vue +1 -1
  18. package/dev/components/UniEvent/UniEventItem.vue +72 -3
  19. package/dev/components/UniEvent/index.vue +10 -1
  20. package/dev/components/UploadList/UploadDetail.vue +1 -1
  21. package/dev/components/VirtualList/index.vue +112 -0
  22. package/dev/components/WebSocket/WebSocketList.vue +1 -1
  23. package/dev/const.ts +97 -26
  24. package/dev/core.ts +0 -2
  25. package/dev/devConsole/index.ts +21 -4
  26. package/dev/devEvent/index.ts +85 -1
  27. package/dev/devIntercept/index.ts +27 -21
  28. package/dev/devRunJS/index.ts +170 -0
  29. package/dev/devStore/index.ts +13 -3
  30. package/dev/index.d.ts +3 -2
  31. package/dev/index.js +1 -1
  32. package/dev/plugins/uniDevTool/uniDevTool.d.ts +2 -1
  33. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  34. package/dev/plugins/uniDevTool/uniDevTool.js +36 -38
  35. package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +2 -1
  36. package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
  37. package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -9
  38. package/dev/plugins/utils/index.d.ts +10 -2
  39. package/dev/plugins/utils/index.d.ts.map +1 -1
  40. package/dev/plugins/utils/index.js +1 -1
  41. package/dev/type.ts +38 -2
  42. package/dev/utils/index.ts +10 -1
  43. package/dev/utils/language.ts +53 -0
  44. package/dev/utils/object.ts +64 -1
  45. package/dev/utils/string.ts +5 -5
  46. package/package.json +2 -2
package/README.md CHANGED
@@ -151,7 +151,15 @@ uni.__dev__console.log('hello vite-uni-dev-tool');
151
151
 
152
152
  ## 更新日志
153
153
 
154
- ### 0.0.07
154
+ ### 0.0.8
155
+
156
+ - 修复多 template 注入调试工具异常
157
+ - 修复 json pretty 逗号位置
158
+ - 修复 json pretty symbol 类型转换异常
159
+ - json pretty 自动判断虚拟列表
160
+ - 虚拟列表抽离到独立文件
161
+
162
+ ### 0.0.7
155
163
 
156
164
  - 监听uni.$on
157
165
  - 监听uni.%once
@@ -0,0 +1,227 @@
1
+ <template>
2
+ <view class="dev-tool-code">
3
+ <view class="dev-tool-code-control">
4
+ <FilterInput
5
+ v-model="modelValue"
6
+ style="width: 100%"
7
+ @search="onSearch"
8
+ />
9
+ <CloseButton style="margin-left: auto" @click="onClose" />
10
+ </view>
11
+ <view class="dev-tool-code-title">{{ fileName }}</view>
12
+ <scroll-view
13
+ scroll-y="true"
14
+ scroll-x="true"
15
+ class="dev-tool-code-list"
16
+ scroll-with-animation="true"
17
+ :scroll-top="scrollTop"
18
+ :scroll-into-view="scrollIntoView"
19
+ >
20
+ <view
21
+ v-for="(code, index) in codes"
22
+ :id="`dev-tool-code-item-${index}`"
23
+ :key="index"
24
+ :class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
25
+ >
26
+ <view class="dev-tool-code-item-index"> {{ index + 1 }}</view>
27
+
28
+ <view class="dev-tool-code-item-content" v-html="code"></view>
29
+ </view>
30
+ <Empty v-if="!codes || codes.length === 0" />
31
+ </scroll-view>
32
+ </view>
33
+ </template>
34
+ <script lang="ts" setup>
35
+ import { computed, ref, nextTick, onMounted } from 'vue';
36
+ import FilterInput from '../FilterInput/index.vue';
37
+ import CloseButton from '../CloseButton/index.vue';
38
+ import Empty from '../Empty/index.vue';
39
+ import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
40
+
41
+ const props = defineProps<{
42
+ url: string;
43
+ sourceFileServers?: string[];
44
+ mode?: string;
45
+ }>();
46
+
47
+ const emit = defineEmits<{ (e: 'close'): void }>();
48
+
49
+ const modelValue = ref('');
50
+ const scrollTop = ref(0);
51
+ const fileName = computed(() => {
52
+ const name =
53
+ props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
54
+ return name;
55
+ });
56
+
57
+ const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
58
+
59
+ let backupCodes: string[] = [];
60
+
61
+ const codes = ref<string[]>([]);
62
+
63
+ const scrollIntoView = ref('');
64
+
65
+ function onClose() {
66
+ emit('close');
67
+ }
68
+
69
+ function onSearch(value: string) {
70
+ codes.value = backupCodes.map((code) => {
71
+ return hightLight(code, value);
72
+ });
73
+ }
74
+
75
+ let index = 0;
76
+ function getCode(url: string, i: number = 0) {
77
+ let allUrl = url;
78
+ // 平台判断
79
+ if (isAndroid()) {
80
+ if (!props.sourceFileServers?.[i]) {
81
+ index = 0;
82
+ return;
83
+ }
84
+
85
+ allUrl = props.sourceFileServers?.[i] + '/src/' + url;
86
+ }
87
+
88
+ uni.showLoading({ mask: true });
89
+ uni.request({
90
+ url: allUrl,
91
+ success: (res) => {
92
+ if (typeof res.data === 'string') {
93
+ // 为什么要注释掉?
94
+ // 在 Android 识别到标签后会进行重启,导致代码无法显示
95
+ // TODO: 还有其它原因导致重启
96
+ const str = res.data
97
+ ?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
98
+ ?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
99
+ ?.replace(/<style/, '// [DevTool] 注释 <style')
100
+ ?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
101
+ backupCodes = escapeHTML(str ?? '')
102
+ .toString()
103
+ .split('\n');
104
+
105
+ const start =
106
+ activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
107
+
108
+ const end =
109
+ activeRowCol.value.row + 20 > backupCodes.length
110
+ ? backupCodes.length
111
+ : activeRowCol.value.row + 20;
112
+
113
+ // backupCodes.slice(start, end);
114
+
115
+ codes.value = backupCodes.slice(start, end);
116
+
117
+ activeRowCol.value.activeRow = activeRowCol.value.row - start;
118
+
119
+ nextTick(() => {
120
+ scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
121
+ });
122
+ }
123
+ },
124
+ fail: (err) => {
125
+ index++;
126
+ getCode(url, index);
127
+ uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
128
+ },
129
+ complete: () => {
130
+ uni.hideLoading();
131
+ },
132
+ });
133
+ }
134
+
135
+ /** 开发环境获取源代码 */
136
+ function getSourceCodeDev(url: string) {
137
+ if (!url) {
138
+ uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
139
+ uni?.__dev__console?.log('[DevTool] url 处理异常');
140
+ return;
141
+ }
142
+
143
+ getCode(url, index);
144
+ }
145
+
146
+ onMounted(() => {
147
+ let url = props?.url;
148
+
149
+ const { path, col, row } = parseStock(props?.url ?? '');
150
+
151
+ if (path) {
152
+ url = path;
153
+ }
154
+
155
+ activeRowCol.value.col = col;
156
+ activeRowCol.value.row = row;
157
+
158
+ if (props.mode === 'development') {
159
+ // 开发环境查看源码
160
+ getSourceCodeDev(url);
161
+ } else if (props.mode === 'production') {
162
+ // TODO 生产环境查看源码
163
+ }
164
+ });
165
+ </script>
166
+ <style scoped>
167
+ .dev-tool-code {
168
+ position: fixed;
169
+ width: 100vw;
170
+ height: 100vh;
171
+ z-index: 1000;
172
+ top: 0;
173
+ left: 0;
174
+ padding: 0 16px;
175
+ /* #ifdef H5 */
176
+ padding: 50px 16px;
177
+ /* #endif */
178
+
179
+ background-color: rgba(255, 255, 255, 0.95);
180
+ box-sizing: border-box;
181
+ color: #000;
182
+ }
183
+
184
+ .dev-tool-code-control {
185
+ display: flex;
186
+ align-items: center;
187
+ gap: 12px;
188
+ height: 32px;
189
+ border-bottom: 1px solid var(--dev-tool-border-color);
190
+ box-sizing: border-box;
191
+ }
192
+
193
+ .dev-tool-code-title {
194
+ height: 32px;
195
+ line-height: 32px;
196
+ margin-bottom: 4px;
197
+ border-bottom: 1px solid var(--dev-tool-border-color);
198
+ box-sizing: border-box;
199
+ white-space: nowrap;
200
+ overflow: auto;
201
+ }
202
+
203
+ .dev-tool-code-list {
204
+ height: calc(100% - 68px);
205
+ }
206
+
207
+ .dev-tool-code-item {
208
+ display: flex;
209
+ align-items: center;
210
+ height: 28px;
211
+ }
212
+ .dev-tool-code-item-active {
213
+ color: #fff;
214
+ background-color: var(--dev-tool-main-color);
215
+ }
216
+
217
+ .dev-tool-code-item-index {
218
+ flex-shrink: 0;
219
+ width: 20px;
220
+ margin-right: 8px;
221
+ text-align: right;
222
+ }
223
+
224
+ .dev-tool-code-item-content {
225
+ white-space: pre;
226
+ }
227
+ </style>
@@ -168,7 +168,7 @@ onMounted(() => {
168
168
  position: fixed;
169
169
  width: 100vw;
170
170
  height: 100vh;
171
- z-index: 10000;
171
+ z-index: 1000;
172
172
  top: 0;
173
173
  left: 0;
174
174
  padding: 0 16px;
@@ -1,19 +1,38 @@
1
1
  <template>
2
- <view :class="`console-item console-item-${consoleItem.type}`">
2
+ <view :id="id" :class="`console-item console-item-${consoleItem.type}`">
3
3
  <view class="console-info">
4
4
  <view class="console-args">
5
- <view
6
- class="console-arg"
7
- v-for="(item, index) in consoleItem.args"
8
- :key="index"
9
- v-html="item"
10
- >
11
- </view>
5
+ <template v-for="(item, index) in consoleItem.args">
6
+ <view
7
+ v-if="item.type !== 'array' && item.type !== 'object'"
8
+ class="console-arg"
9
+ :key="index"
10
+ v-html="item.value"
11
+ >
12
+ </view>
13
+ <JsonPretty
14
+ v-else
15
+ :data="item.value"
16
+ collapsed
17
+ showLength
18
+ :autoVirtualRow="100"
19
+ />
20
+ </template>
12
21
  </view>
13
22
  <view class="console-position">
14
- <Tag :mode="consoleItem.type" style="margin: 0 4px">
15
- {{ consoleItem.type }}
16
- </Tag>
23
+ <view class="console-tags">
24
+ <Tag
25
+ v-if="consoleItem.mode"
26
+ mode="log"
27
+ style="margin-right: 6px; justify-content: center"
28
+ >
29
+ {{ consoleItem.mode }}
30
+ </Tag>
31
+ <Tag :mode="consoleItem.type">
32
+ {{ consoleItem.type }}
33
+ </Tag>
34
+ </view>
35
+
17
36
  <view>
18
37
  <view class="console-time">{{ consoleItem.time }}</view>
19
38
  <view class="console-other" v-html="consoleItem.position"></view>
@@ -40,14 +59,16 @@
40
59
  <script setup lang="ts">
41
60
  import { ref, computed } from 'vue';
42
61
  import Tag from '../Tag/index.vue';
43
- import Code from './Code.vue';
62
+ import Code from '../Code/index.vue';
44
63
  import type { DevTool } from '../../type';
45
64
  import { isAndroid, isMockWX } from '../../utils';
65
+ import JsonPretty from '../JsonPretty/index.vue';
46
66
  const props = defineProps<{
47
67
  consoleItem: DevTool.ConsoleItem;
48
68
  sourceFileServers?: string[];
49
69
  mode?: string;
50
70
  useDevSource?: boolean;
71
+ id: string;
51
72
  }>();
52
73
 
53
74
  const openCode = ref(false);
@@ -126,6 +147,11 @@ function onCloseCode() {
126
147
  color: #616161;
127
148
  text-align: right;
128
149
  }
150
+
151
+ .console-tags {
152
+ display: flex;
153
+ align-items: center;
154
+ }
129
155
  .console-time {
130
156
  margin-right: auto;
131
157
  word-break: break-all;
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <view class="run-js-input-wrapper">
3
+ <view class="run-js-input-icon"></view>
4
+ <input
5
+ v-model="code"
6
+ class="run-js-input"
7
+ placeholder="run..."
8
+ @confirm="onConfirm"
9
+ />
10
+ </view>
11
+ </template>
12
+ <script lang="ts" setup>
13
+ import { ref } from 'vue';
14
+
15
+ const emit = defineEmits<{
16
+ (e: 'run', value: string): void;
17
+ }>();
18
+
19
+ const code = ref('');
20
+
21
+ function onConfirm() {
22
+ const value = code.value;
23
+ if (!value) return;
24
+ code.value = '';
25
+ setTimeout(() => {
26
+ emit('run', value);
27
+ }, 100);
28
+ }
29
+ </script>
30
+ <style scoped>
31
+ .run-js-input-wrapper {
32
+ position: relative;
33
+ display: flex;
34
+ padding: 0 16px;
35
+ min-height: 28px;
36
+ border-top: 1px solid var(--dev-tool-border-color);
37
+ border-bottom: 1px solid var(--dev-tool-border-color);
38
+ overflow: hidden;
39
+ }
40
+
41
+ .run-js-input-icon {
42
+ margin: 10px 0 10px -4px;
43
+ width: 8px;
44
+ height: 8px;
45
+ border: 1px solid #000;
46
+ border-bottom-color: transparent;
47
+ border-left-color: transparent;
48
+ overflow: hidden;
49
+ transform: rotate(45deg);
50
+ }
51
+
52
+ .run-js-input {
53
+ margin: 1px 0 1px 16px;
54
+ min-height: 26px;
55
+ width: 100%;
56
+ border: 1px solid transparent;
57
+ font-size: var(--dev-tool-base-font-size);
58
+ }
59
+ </style>
@@ -11,11 +11,16 @@
11
11
  :mode="item.value"
12
12
  :key="item.value"
13
13
  :active="currentConsoleType === item.value"
14
- @click="onChoose(item.value)"
14
+ @click="emit('choose', item.value)"
15
15
  >{{ item.label }}</Tag
16
16
  >
17
17
  </view>
18
- <view class="console-list">
18
+ <scroll-view
19
+ class="console-list"
20
+ scroll-y
21
+ scroll-with-animation="true"
22
+ :scroll-into-view="scrollIntoView"
23
+ >
19
24
  <ConsoleItem
20
25
  v-for="(item, index) in consoleList"
21
26
  :consoleItem="item"
@@ -23,9 +28,11 @@
23
28
  :sourceFileServers="sourceFileServers"
24
29
  :mode="mode"
25
30
  :useDevSource="useDevSource"
31
+ :id="`dev-console-${index}`"
26
32
  />
27
33
  <Empty v-if="!consoleList || consoleList.length === 0" />
28
- </view>
34
+ </scroll-view>
35
+ <RunJSInput @run="emit('run', $event)" />
29
36
  </view>
30
37
  </template>
31
38
  <script setup lang="ts">
@@ -33,9 +40,12 @@ import ConsoleItem from './ConsoleItem.vue';
33
40
  import Tag from '../Tag/index.vue';
34
41
  import Empty from '../Empty/index.vue';
35
42
  import FilterInput from '../FilterInput/index.vue';
43
+ import RunJSInput from './RunJSInput.vue';
36
44
  import type { DevTool } from '../../type';
45
+ import { ref, watch } from 'vue';
46
+ import { debounce } from '../../utils';
37
47
  type ConsoleType = 'all' | 'log' | 'info' | 'warn' | 'error' | 'clear';
38
- defineProps<{
48
+ const props = defineProps<{
39
49
  consoleList: DevTool.ConsoleItem[];
40
50
  currentConsoleType: string;
41
51
  modelValue: string;
@@ -47,6 +57,7 @@ const emit = defineEmits<{
47
57
  (e: 'choose', type: ConsoleType): void;
48
58
  (e: 'search', value: string): void;
49
59
  (e: 'update:modelValue', value: string): void;
60
+ (e: 'run', value: string): void;
50
61
  }>();
51
62
  const consoleFilterItems: {
52
63
  label: string;
@@ -78,9 +89,14 @@ const consoleFilterItems: {
78
89
  },
79
90
  ];
80
91
 
81
- function onChoose(type: ConsoleType) {
82
- emit('choose', type);
83
- }
92
+ const scrollIntoView = ref('');
93
+
94
+ const debounceWatch = debounce(() => {
95
+ scrollIntoView.value = `dev-console-${props.consoleList.length - 1}`;
96
+ console.log('props.consoleList: ', props.consoleList);
97
+ }, 200);
98
+
99
+ watch(() => props.consoleList, debounceWatch);
84
100
  </script>
85
101
  <style scoped>
86
102
  .console-content {
@@ -88,7 +104,7 @@ function onChoose(type: ConsoleType) {
88
104
  font-size: var(--dev-tool-base-font-size);
89
105
  }
90
106
  .console-list {
91
- height: calc(100% - 32px);
107
+ height: calc(100% - 32px - 32px);
92
108
  overflow: auto;
93
109
  }
94
110
  .console-control {
@@ -167,7 +167,7 @@ onHide(() => {
167
167
 
168
168
  .dev-tool-canvas {
169
169
  position: fixed;
170
- z-index: -99999;
170
+ z-index: -1000;
171
171
  top: 0;
172
172
  left: 0;
173
173
  width: 100vw;
@@ -9,7 +9,7 @@
9
9
  width: props.buttonSize + 'px',
10
10
  height: props.buttonSize + 'px',
11
11
  cursor: isDragging ? 'move' : 'pointer',
12
- ...buttonPosition
12
+ ...buttonPosition,
13
13
  }"
14
14
  @touchstart="onTouchStart"
15
15
  @touchmove="onTouchMove"
@@ -33,7 +33,7 @@ const props = withDefaults(
33
33
  buttonFontSize?: string;
34
34
  buttonBackgroundColor?: string;
35
35
  }>(),
36
- { buttonSize: 50 }
36
+ { buttonSize: 50 },
37
37
  );
38
38
  const sizeHalf = props.buttonSize / 2;
39
39
 
@@ -45,7 +45,7 @@ const { windowWidth, windowHeight } = uni.getSystemInfoSync();
45
45
  const buttonPosition = reactive({
46
46
  left: windowWidth - props.buttonSize + 'px',
47
47
  top: '80vh',
48
- transition: 'none'
48
+ transition: 'none',
49
49
  });
50
50
 
51
51
  const isTouchDevice = computed(() => {
@@ -71,7 +71,7 @@ function onTouchMove(touch: TouchEvent) {
71
71
  updatePosition(
72
72
  touch.touches[0].pageX,
73
73
  touch.touches[0].pageY,
74
- isTouchDevice.value
74
+ isTouchDevice.value,
75
75
  );
76
76
  }
77
77
 
@@ -102,7 +102,7 @@ function onMouseDown(event: MouseEvent) {
102
102
  buttonPosition.transition = 'none';
103
103
  }
104
104
 
105
- let timer: NodeJS.Timeout | null = null;
105
+ let timer: number | null = null;
106
106
  function onResize() {
107
107
  const { windowWidth } = uni.getSystemInfoSync();
108
108
 
@@ -116,7 +116,7 @@ function onResize() {
116
116
 
117
117
  uni.setStorageSync(DEV_BUTTON_INFO, {
118
118
  left: buttonPosition.left,
119
- top: buttonPosition.top
119
+ top: buttonPosition.top,
120
120
  });
121
121
  }, 350);
122
122
  }
@@ -124,7 +124,7 @@ function onResize() {
124
124
  onMounted(() => {
125
125
  const { left, top } = uni.getStorageSync(DEV_BUTTON_INFO) || {
126
126
  left: windowWidth - props.buttonSize + 'px',
127
- top: '80vh'
127
+ top: '80vh',
128
128
  };
129
129
  buttonPosition.left = left;
130
130
  buttonPosition.top = top;
@@ -133,7 +133,7 @@ onMounted(() => {
133
133
  onShow(() => {
134
134
  const { left, top } = uni.getStorageSync(DEV_BUTTON_INFO) || {
135
135
  left: windowWidth - props.buttonSize + 'px',
136
- top: '80vh'
136
+ top: '80vh',
137
137
  };
138
138
  buttonPosition.left = left;
139
139
  buttonPosition.top = top;
@@ -164,7 +164,7 @@ function onMouseMove(event: MouseEvent) {
164
164
  updatePosition(mouseX, mouseY);
165
165
  }
166
166
 
167
- let mouseUpTimer: NodeJS.Timeout | null = null;
167
+ let mouseUpTimer: number | null = null;
168
168
  function onMouseUp() {
169
169
  isDragging.value = false; // 鼠标释放时取消拖拽状态
170
170
  if (Date.now() - startTime < 150) {
@@ -195,7 +195,7 @@ function updatePosition(x: number, y: number, isTouch = false) {
195
195
  <style scoped>
196
196
  .dev-tool-button {
197
197
  position: fixed;
198
- z-index: 9999;
198
+ z-index: 1000;
199
199
  top: 80vh;
200
200
  right: 0;
201
201
  display: flex;
@@ -27,6 +27,7 @@
27
27
  v-model="searchConsole"
28
28
  @choose="onConsoleChoose"
29
29
  @search="onSearchConsole"
30
+ @run="onRunJS"
30
31
  />
31
32
  <NetworkList
32
33
  :currentNetworkType="currentNetworkType"
@@ -68,6 +69,9 @@
68
69
  v-if="activeTab === 'UniEvent'"
69
70
  :eventList="eventList"
70
71
  :eventCount="eventCount"
72
+ :mode="mode"
73
+ :useDevSource="useDevSource"
74
+ :sourceFileServers="sourceFileServers"
71
75
  @clear="onUniEventClear"
72
76
  />
73
77
  <SettingList
@@ -126,6 +130,7 @@ import WindowInfo from '../WindowInfo/index.vue';
126
130
  import WebSocket from '../WebSocket/index.vue';
127
131
  import UploadList from '../UploadList/index.vue';
128
132
  import UniEvent from '../UniEvent/index.vue';
133
+ import RunJS from '../RunJS/index.vue';
129
134
  import {
130
135
  DEV_BUTTON_SHOW_OR_HIDE,
131
136
  DEV_CONSOLE_CLEAR,
@@ -149,6 +154,8 @@ import {
149
154
  DEV_WINDOW_INFO,
150
155
  DEV_APP_MESSAGE,
151
156
  DEV_UNI_EVENT_CLEAR,
157
+ DEV_RUN_JS_CLEAR,
158
+ DEV_RUN_JS,
152
159
  } from '../../const';
153
160
  import { debounce, hightLight } from '../../utils/index';
154
161
  import type { DevTool } from '../../type';
@@ -236,6 +243,7 @@ const backup: {
236
243
  uploadList: DevTool.UploadItem[];
237
244
  routeList: DevTool.Page[];
238
245
  eventList: DevTool.EventItem[];
246
+ runJSList: DevTool.RunJSItem[];
239
247
  } = {
240
248
  consoleList: [],
241
249
  networkList: [],
@@ -244,6 +252,7 @@ const backup: {
244
252
  uploadList: [],
245
253
  routeList: [],
246
254
  eventList: [],
255
+ runJSList: [],
247
256
  };
248
257
  const consoleList = ref<DevTool.ConsoleItem[]>([]);
249
258
  const networkList = ref<DevTool.NetworkItem[]>([]);
@@ -258,6 +267,7 @@ const deviceInfo = ref<Record<string, any>>({});
258
267
  const windowInfo = ref<Record<string, any>>({});
259
268
  const eventList = ref<DevTool.EventItem[]>([]);
260
269
  const eventCount = ref<DevTool.EventCount>();
270
+
261
271
  const netWorkStatus = ref<{
262
272
  isConnected?: boolean;
263
273
  networkType?: string;
@@ -309,7 +319,7 @@ const listenPostMessage = (data: DevTool.WindowData) => {
309
319
  })
310
320
  .filter((item) => {
311
321
  return (
312
- item.args.some((arg) => arg.includes(searchConsole.value)) ||
322
+ item.args?.some((arg) => arg?.includes?.(searchConsole.value)) ||
313
323
  item.position.includes(searchConsole.value) ||
314
324
  item?.stack?.includes(searchConsole.value)
315
325
  );
@@ -533,6 +543,15 @@ function onConsoleChoose(
533
543
  setWindowInfo();
534
544
  }
535
545
 
546
+ function onRunJS(code: string) {
547
+ basicSendMessage({
548
+ type: DEV_RUN_JS,
549
+ data: {
550
+ code,
551
+ },
552
+ });
553
+ }
554
+
536
555
  function onSearchConsole(value: string) {
537
556
  consoleList.value = backup.consoleList
538
557
  .filter((item) => {
@@ -848,7 +867,7 @@ function onChangePinia(value: Record<string, any>) {
848
867
  position: fixed;
849
868
  top: 0;
850
869
  left: 0;
851
- z-index: 10000;
870
+ z-index: 1000;
852
871
  /* #ifdef H5 */
853
872
  padding: 50px 0;
854
873
  /* #endif */
@@ -4,7 +4,7 @@
4
4
  :class="`filter-input`"
5
5
  :value="modelValue"
6
6
  :placeholder="placeholder || '请输入'"
7
- @input="debounceInput"
7
+ @confirm="debounceInput"
8
8
  />
9
9
  <view class="filter-input-clear" @click="onClear"> × </view>
10
10
  </view>