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.
- package/README.md +65 -1
- package/dev/components/AppInfo/index.vue +36 -0
- package/dev/components/CaptureScreen/index.vue +62 -0
- package/dev/components/Code/index.vue +7 -4
- package/dev/components/ConsoleList/ConsoleItem.vue +24 -3
- package/dev/components/ConsoleList/RunJSInput.vue +180 -2
- package/dev/components/ConsoleList/index.vue +17 -2
- package/dev/components/ConsoleList/staticTips.ts +1145 -0
- package/dev/components/DevTool/index.vue +37 -31
- package/dev/components/DevToolButton/index.vue +9 -12
- package/dev/components/DevToolTitle/index.vue +2 -2
- package/dev/components/DevToolWindow/index.vue +230 -112
- package/dev/components/JsonPretty/components/Carets/index.vue +10 -14
- package/dev/components/JsonPretty/index.vue +2 -0
- package/dev/components/NetworkList/NetworkDetail.vue +3 -6
- package/dev/components/NetworkList/NetworkItem.vue +21 -8
- package/dev/components/NetworkList/index.vue +15 -2
- package/dev/components/RouteList/index.vue +12 -1
- package/dev/components/SettingList/index.vue +2 -5
- package/dev/components/SourceCode/index.vue +231 -0
- package/dev/components/Tabs/index.vue +23 -10
- package/dev/components/UniEvent/UniEventItem.vue +4 -2
- package/dev/components/UniEvent/index.vue +7 -3
- package/dev/components/UploadList/UploadDetail.vue +3 -7
- package/dev/components/UploadList/UploadItem.vue +7 -1
- package/dev/components/UploadList/index.vue +15 -2
- package/dev/components/VirtualListPro/index.vue +72 -3
- package/dev/components/VuexList/index.vue +2 -2
- package/dev/components/WebSocket/WebSocketItem.vue +7 -2
- package/dev/components/WebSocket/WebSocketList.vue +3 -6
- package/dev/components/WebSocket/index.vue +15 -2
- package/dev/const.ts +10 -14
- package/dev/devEvent/index.ts +49 -18
- package/dev/devIntercept/index.ts +18 -0
- package/dev/devStore/index.ts +60 -13
- package/dev/devToolInfo/index.ts +26 -0
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +9 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +36 -36
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/dev/type.ts +34 -0
- package/dev/utils/index.ts +5 -0
- package/dev/utils/language.ts +8 -3
- package/dev/utils/object.ts +10 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,10 @@ import * as path from 'path';
|
|
|
27
27
|
|
|
28
28
|
// https://vitejs.dev/config/
|
|
29
29
|
export default defineConfig({
|
|
30
|
+
optimizeDeps: {
|
|
31
|
+
// 预构建排除 vite-uni-dev-tool 模块,防止 eventBus 冲突
|
|
32
|
+
exclude: ['vite-uni-dev-tool'],
|
|
33
|
+
},
|
|
30
34
|
plugins: [
|
|
31
35
|
// 一定要在 uni() 之前调用 否则微信小程序将无法正常编译组件
|
|
32
36
|
uniDevTool({
|
|
@@ -46,6 +50,28 @@ export default defineConfig({
|
|
|
46
50
|
});
|
|
47
51
|
```
|
|
48
52
|
|
|
53
|
+
### uniDevTool 配置项
|
|
54
|
+
|
|
55
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
56
|
+
| ---------------------------- | ---------------------------------------------------------------------------------------------- | -------- | ---------------------- |
|
|
57
|
+
| pages | 配置pages.json | object | {} |
|
|
58
|
+
| enableInterceptPromiseReject | 是否拦截Promise.reject 最好不要拦截 默认禁用 | boolean | false |
|
|
59
|
+
| consoleMaxSize | 最大的console条数 | number | 1000 |
|
|
60
|
+
| networkMaxSize | 最大的网络请求条数 | number | 1000 |
|
|
61
|
+
| uploadMaxSize | 最大的上传文件条数 | number | 1000 |
|
|
62
|
+
| wsDataMaxSize | 最大的套接字消息条数 | number | 1000 |
|
|
63
|
+
| captureScreenMaxSize | 最大的截图记录条数 | number | 1000 |
|
|
64
|
+
| cacheMaxSize | 最大占用缓存空间 bytes | number | 8\*1024\*1024\*10 |
|
|
65
|
+
| buttonSize | 按钮大小 | number | 50 |
|
|
66
|
+
| buttonText | 按钮文本 | string | 🐜 |
|
|
67
|
+
| buttonFontSize | 按钮字体大小 | string | 16px |
|
|
68
|
+
| buttonBackgroundColor | 按钮背景颜色 | string | rgba(255, 255, 255, 0) |
|
|
69
|
+
| initShowDevTool | 初始化时是否显示调试按钮,默认显示 | boolean | true |
|
|
70
|
+
| zIndex | 调试按钮的zIndex,默认1000 | number | 1000 |
|
|
71
|
+
| useDevSource | 该属性处于实验当中,谨慎使用,读取开发环境 source file,source map,默认 禁用 | boolean | false |
|
|
72
|
+
| sourceFileServers | 该属性处于实验当中,谨慎使用,开发环境 source file 服务器地址,默认 [] ,配合 useDevSource 使用 | string[] | [] |
|
|
73
|
+
| importConsole | 是否导入 console 默认不导入, 只会捕获error 和 warn | boolean | false |
|
|
74
|
+
|
|
49
75
|
### 为什么不用 subPackages?
|
|
50
76
|
|
|
51
77
|
- 从当前页跳转到subPackages页面时,会触发 uni-app 页面生命周期,有时是不希望如此的,比如在开发过程中,希望可以直接在当前页面进行调试。
|
|
@@ -53,7 +79,6 @@ export default defineConfig({
|
|
|
53
79
|
### 如何将 console 日志输出到控制台
|
|
54
80
|
|
|
55
81
|
- 0.0.5版本之后为了在生产环境中移除插件,开发环境中插件将会自动导入 `console`,无需手动导入
|
|
56
|
-
|
|
57
82
|
- 0.0.5版本之后不推荐使用 `uni.__dev__console` , 在未来版本中可能会进行移除
|
|
58
83
|
|
|
59
84
|
```ts
|
|
@@ -67,6 +92,24 @@ console.log('hello vite-uni-dev-tool');
|
|
|
67
92
|
uni.__dev__console.log('hello vite-uni-dev-tool');
|
|
68
93
|
```
|
|
69
94
|
|
|
95
|
+
### 0.0.12 版本在插件中增加了 `importConsole` 属性,默认不导入,只捕获`error`, `warn`, 用户手动调用的`console` 将不再进行捕获,如需捕获传入`true`即可
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
uniDevTool({
|
|
99
|
+
pages,
|
|
100
|
+
importConsole: true
|
|
101
|
+
}),
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### vite 预加载导致的 `eventBus` 事件冲突 , 预加载排除 `vite-uni-dev-tool` 即可
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
optimizeDeps: {
|
|
108
|
+
// 预构建排除 vite-uni-dev-tool 模块,防止 eventBus 冲突
|
|
109
|
+
exclude: ['vite-uni-dev-tool'],
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
70
113
|
### 注意事项
|
|
71
114
|
|
|
72
115
|
### 兼容性说明
|
|
@@ -151,6 +194,27 @@ uni.__dev__console.log('hello vite-uni-dev-tool');
|
|
|
151
194
|
|
|
152
195
|
## 更新日志
|
|
153
196
|
|
|
197
|
+
### 0.0.12
|
|
198
|
+
|
|
199
|
+
- 修复 network url显示长度
|
|
200
|
+
- 修复部分样式
|
|
201
|
+
- 修复列表高度异常
|
|
202
|
+
- 修复销毁之后操作
|
|
203
|
+
- 刷新之后隐藏调试弹窗
|
|
204
|
+
- 列表返回到顶部
|
|
205
|
+
- 增加层级属性,默认层级1000
|
|
206
|
+
- 构建导致的 eventBus 冲突
|
|
207
|
+
|
|
208
|
+
### 0.0.11
|
|
209
|
+
|
|
210
|
+
- 新增 console run 简易提示
|
|
211
|
+
- 新增 appInfo
|
|
212
|
+
- 新增 captureScreen(h5端不支持)
|
|
213
|
+
- 新增滑动切换
|
|
214
|
+
- 修复 console 滚动到指定位置
|
|
215
|
+
- 修复调用栈起始行
|
|
216
|
+
- 修复 json pretty 折叠icon
|
|
217
|
+
|
|
154
218
|
### 0.0.10
|
|
155
219
|
|
|
156
220
|
- 修复 console 过滤异常
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="app-info-content">
|
|
3
|
+
<JsonPretty v-if="showJson" :data="appInfo" />
|
|
4
|
+
<Empty v-else />
|
|
5
|
+
</view>
|
|
6
|
+
</template>
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
import JsonPretty from '../JsonPretty/index.vue';
|
|
10
|
+
|
|
11
|
+
import Empty from '../Empty/index.vue';
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
appInfo: Record<string, any>;
|
|
14
|
+
}>();
|
|
15
|
+
|
|
16
|
+
const showJson = computed(() => {
|
|
17
|
+
try {
|
|
18
|
+
const str = JSON.stringify(props.appInfo);
|
|
19
|
+
if (typeof props.appInfo === 'object' && (str === '' || str === '{}')) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
<style scoped>
|
|
29
|
+
.app-info-content {
|
|
30
|
+
padding: 16px;
|
|
31
|
+
font-size: var(--dev-tool-base-font-size);
|
|
32
|
+
|
|
33
|
+
height: calc(100% - 32px);
|
|
34
|
+
overflow: auto;
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="capture-screen-content">
|
|
3
|
+
<view class="capture-screen-control">
|
|
4
|
+
<Tag style="margin-left: auto" mode="clear" @click="emit('clear')">
|
|
5
|
+
清空
|
|
6
|
+
</Tag>
|
|
7
|
+
</view>
|
|
8
|
+
|
|
9
|
+
<view class="capture-screen-list">
|
|
10
|
+
<view class="capture-screen-item" v-for="item in captureScreenList">
|
|
11
|
+
<view class="info-row">时间:{{ item.timer }} </view>
|
|
12
|
+
<view class="info-row">页面:{{ item.position }}</view>
|
|
13
|
+
</view>
|
|
14
|
+
|
|
15
|
+
<Empty v-if="!captureScreenList || captureScreenList.length === 0" />
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</template>
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import type { DevTool } from '../../type';
|
|
21
|
+
import Empty from '../Empty/index.vue';
|
|
22
|
+
import Tag from '../Tag/index.vue';
|
|
23
|
+
|
|
24
|
+
defineProps<{
|
|
25
|
+
captureScreenList: DevTool.CaptureScreenItem[];
|
|
26
|
+
}>();
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits<{
|
|
29
|
+
(e: 'clear'): void;
|
|
30
|
+
}>();
|
|
31
|
+
</script>
|
|
32
|
+
<style scoped>
|
|
33
|
+
.capture-screen-content {
|
|
34
|
+
height: 100%;
|
|
35
|
+
font-size: var(--dev-tool-base-font-size);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.capture-screen-list {
|
|
39
|
+
height: calc(100% - 32px);
|
|
40
|
+
overflow: auto;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.capture-screen-control {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
padding: 0 16px;
|
|
49
|
+
height: 32px;
|
|
50
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
51
|
+
box-sizing: border-box;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.capture-screen-item {
|
|
55
|
+
padding: 16px;
|
|
56
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
57
|
+
}
|
|
58
|
+
.info-row {
|
|
59
|
+
height: 28px;
|
|
60
|
+
line-height: 28px;
|
|
61
|
+
}
|
|
62
|
+
</style>
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
:key="index"
|
|
24
24
|
:class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
|
|
25
25
|
>
|
|
26
|
-
<view class="dev-tool-code-item-index">
|
|
26
|
+
<view class="dev-tool-code-item-index">
|
|
27
|
+
{{ start + index + 1 }}
|
|
28
|
+
</view>
|
|
27
29
|
|
|
28
30
|
<view class="dev-tool-code-item-content" v-html="code"></view>
|
|
29
31
|
</view>
|
|
@@ -62,6 +64,10 @@ const codes = ref<string[]>([]);
|
|
|
62
64
|
|
|
63
65
|
const scrollIntoView = ref('');
|
|
64
66
|
|
|
67
|
+
const start = computed(() => {
|
|
68
|
+
return activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
|
|
69
|
+
});
|
|
70
|
+
|
|
65
71
|
function onClose() {
|
|
66
72
|
emit('close');
|
|
67
73
|
}
|
|
@@ -172,9 +178,6 @@ onMounted(() => {
|
|
|
172
178
|
top: 0;
|
|
173
179
|
left: 0;
|
|
174
180
|
padding: 0 16px;
|
|
175
|
-
/* #ifdef H5 */
|
|
176
|
-
padding: 50px 16px;
|
|
177
|
-
/* #endif */
|
|
178
181
|
|
|
179
182
|
background-color: rgba(255, 255, 255, 0.95);
|
|
180
183
|
box-sizing: border-box;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<template v-for="(item, index) in consoleItem.args">
|
|
6
6
|
<view
|
|
7
7
|
v-if="item.type !== 'array' && item.type !== 'object'"
|
|
8
|
-
class="console-arg"
|
|
8
|
+
:class="`console-arg console-arg-${item.type}`"
|
|
9
9
|
:key="index"
|
|
10
10
|
v-html="item.value"
|
|
11
11
|
>
|
|
@@ -46,11 +46,12 @@
|
|
|
46
46
|
</view>
|
|
47
47
|
</view>
|
|
48
48
|
<!-- <view class="console-copy">C</view> -->
|
|
49
|
-
<
|
|
49
|
+
<SourceCode
|
|
50
50
|
v-if="openCode && consoleItem.stack"
|
|
51
51
|
:url="consoleItem.stack"
|
|
52
52
|
:sourceFileServers="sourceFileServers"
|
|
53
53
|
:mode="mode"
|
|
54
|
+
:zIndex="zIndex"
|
|
54
55
|
@close="onCloseCode"
|
|
55
56
|
/>
|
|
56
57
|
</view>
|
|
@@ -59,7 +60,7 @@
|
|
|
59
60
|
<script setup lang="ts">
|
|
60
61
|
import { ref, computed } from 'vue';
|
|
61
62
|
import Tag from '../Tag/index.vue';
|
|
62
|
-
import
|
|
63
|
+
import SourceCode from '../SourceCode/index.vue';
|
|
63
64
|
import type { DevTool } from '../../type';
|
|
64
65
|
import { isAndroid, isMockWX } from '../../utils';
|
|
65
66
|
import JsonPretty from '../JsonPretty/index.vue';
|
|
@@ -68,6 +69,7 @@ const props = defineProps<{
|
|
|
68
69
|
sourceFileServers?: string[];
|
|
69
70
|
mode?: string;
|
|
70
71
|
useDevSource?: boolean;
|
|
72
|
+
zIndex?: number;
|
|
71
73
|
id: string;
|
|
72
74
|
}>();
|
|
73
75
|
|
|
@@ -183,4 +185,23 @@ function onCloseCode() {
|
|
|
183
185
|
.console-item-log {
|
|
184
186
|
color: #f9f9f9;
|
|
185
187
|
}
|
|
188
|
+
|
|
189
|
+
.console-arg-null {
|
|
190
|
+
color: #020201;
|
|
191
|
+
}
|
|
192
|
+
.console-arg-undefined {
|
|
193
|
+
color: #020201;
|
|
194
|
+
}
|
|
195
|
+
.console-arg-string {
|
|
196
|
+
color: #888888;
|
|
197
|
+
}
|
|
198
|
+
.console-arg-number {
|
|
199
|
+
color: #1d8ce0;
|
|
200
|
+
}
|
|
201
|
+
.console-arg-boolean {
|
|
202
|
+
color: #1d8ce0;
|
|
203
|
+
}
|
|
204
|
+
.console-arg-symbol {
|
|
205
|
+
color: bisque;
|
|
206
|
+
}
|
|
186
207
|
</style>
|
|
@@ -6,11 +6,28 @@
|
|
|
6
6
|
class="run-js-input"
|
|
7
7
|
placeholder="run..."
|
|
8
8
|
@confirm="onConfirm"
|
|
9
|
+
@input="onChange"
|
|
9
10
|
/>
|
|
11
|
+
<view class="run-js-tips">
|
|
12
|
+
<view
|
|
13
|
+
class="run-js-tips-item"
|
|
14
|
+
v-for="(item, index) in tips"
|
|
15
|
+
@click="onChoose(item.name)"
|
|
16
|
+
>
|
|
17
|
+
{{ item.name }}{{ item.description ? ': ' : ' ' }}{{ item.description }}
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
10
20
|
</view>
|
|
11
21
|
</template>
|
|
12
22
|
<script lang="ts" setup>
|
|
13
23
|
import { ref } from 'vue';
|
|
24
|
+
import {
|
|
25
|
+
staticTips,
|
|
26
|
+
singleTips,
|
|
27
|
+
flatStaticTips,
|
|
28
|
+
baseSymbols,
|
|
29
|
+
type Tip,
|
|
30
|
+
} from './staticTips';
|
|
14
31
|
|
|
15
32
|
const emit = defineEmits<{
|
|
16
33
|
(e: 'run', value: string): void;
|
|
@@ -18,7 +35,10 @@ const emit = defineEmits<{
|
|
|
18
35
|
|
|
19
36
|
const code = ref('');
|
|
20
37
|
|
|
38
|
+
const tips = ref<Tip[]>([]);
|
|
39
|
+
|
|
21
40
|
function onConfirm() {
|
|
41
|
+
tips.value = [];
|
|
22
42
|
const value = code.value;
|
|
23
43
|
if (!value) return;
|
|
24
44
|
code.value = '';
|
|
@@ -26,16 +46,146 @@ function onConfirm() {
|
|
|
26
46
|
emit('run', value);
|
|
27
47
|
}, 100);
|
|
28
48
|
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 1.对象,方法,变量 在 ; ( , =,==,=== , + , - , * , / , && , || ?? 之后 开始提示
|
|
52
|
+
*
|
|
53
|
+
* Math
|
|
54
|
+
* console
|
|
55
|
+
*
|
|
56
|
+
* 2.在 . 之后 提示
|
|
57
|
+
*
|
|
58
|
+
* Math.a
|
|
59
|
+
* console.a
|
|
60
|
+
*
|
|
61
|
+
*
|
|
62
|
+
* 3.对方法,属性返回值进行提示
|
|
63
|
+
*
|
|
64
|
+
* Math.abc().
|
|
65
|
+
*
|
|
66
|
+
*
|
|
67
|
+
* any, void 不进行提示
|
|
68
|
+
*
|
|
69
|
+
* 4. [] 数组提示
|
|
70
|
+
*
|
|
71
|
+
* [1,2].concat([2,3].map(parseInt))
|
|
72
|
+
*
|
|
73
|
+
* 5. (值) 推断提示
|
|
74
|
+
* ({}).valueOf()
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* @param e 输入框内容
|
|
78
|
+
*/
|
|
79
|
+
function onChange(e: any) {
|
|
80
|
+
const { value, cursor } = e.detail as { value: string; cursor: number };
|
|
81
|
+
// 光标之前的内容
|
|
82
|
+
const content = value.slice(0, cursor);
|
|
83
|
+
|
|
84
|
+
// 获取符号之后的内容
|
|
85
|
+
const lastIndex = getBaseSymbolLastIndex(content);
|
|
86
|
+
|
|
87
|
+
const con = lastIndex > -1 ? value.substring(lastIndex + 1) : value;
|
|
88
|
+
|
|
89
|
+
if (!con) {
|
|
90
|
+
// 不存在内容
|
|
91
|
+
tips.value = [];
|
|
92
|
+
} else {
|
|
93
|
+
// 存在内容
|
|
94
|
+
|
|
95
|
+
// 一级点之后的内容
|
|
96
|
+
const [main, sub] = con.split('.');
|
|
97
|
+
|
|
98
|
+
if (singleTips.includes(main) && con.includes('.')) {
|
|
99
|
+
const list = [
|
|
100
|
+
...(staticTips[main]?.attr ?? []),
|
|
101
|
+
...(staticTips[main]?.fun ?? []),
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
if (sub) {
|
|
105
|
+
tips.value = list.filter((item) => item.name.startsWith(sub));
|
|
106
|
+
} else {
|
|
107
|
+
tips.value = list;
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
if (main.includes(')') && con.includes('.')) {
|
|
111
|
+
// 方法调用之后的提示
|
|
112
|
+
|
|
113
|
+
// 获取方法名称 倒数第二个 . 到最后一个 ( 之间为方法名称
|
|
114
|
+
const s = getSecondLastDotPosition(content);
|
|
115
|
+
const e = content.lastIndexOf('(');
|
|
116
|
+
const methodName = content.substring(s + 1, e);
|
|
117
|
+
|
|
118
|
+
const fn = findFunction(methodName);
|
|
119
|
+
// 获取方法返回值
|
|
120
|
+
const result = fn?.[0]?.result?.[0];
|
|
121
|
+
if (result && result !== 'any' && result !== 'void') {
|
|
122
|
+
tips.value = Object.values(staticTips?.[result] ?? {}).flat(2);
|
|
123
|
+
} else {
|
|
124
|
+
tips.value = [];
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
// 基础提示
|
|
128
|
+
tips.value = singleTips
|
|
129
|
+
.filter((item) => item.startsWith(con))
|
|
130
|
+
.map((item) => ({
|
|
131
|
+
name: item,
|
|
132
|
+
description: '',
|
|
133
|
+
result: ['any'],
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function onChoose(name: string) {
|
|
140
|
+
// TODO 选择提示
|
|
141
|
+
// const lastIndex = code.value.lastIndexOf(';');
|
|
142
|
+
// const con =
|
|
143
|
+
// lastIndex > -1 ? code.value?.substring(lastIndex + 1) : code.value;
|
|
144
|
+
// const lastCon = con.lastIndexOf('.');
|
|
145
|
+
// if (lastCon > -1) {
|
|
146
|
+
// code.value = con.substring(0, lastCon + 1) + name;
|
|
147
|
+
// } else {
|
|
148
|
+
// code.value = name;
|
|
149
|
+
// }
|
|
150
|
+
// tips.value = [];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function getBaseSymbolLastIndex(code: string) {
|
|
154
|
+
for (let i = code.length - 1; i >= 0; i--) {
|
|
155
|
+
if (baseSymbols.includes(code[i])) {
|
|
156
|
+
return i; // 找到最后一个符号的位置
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return -1; // 未找到任何符号
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function getSecondLastDotPosition(str: string) {
|
|
163
|
+
let dotCount = 0;
|
|
164
|
+
for (let i = str.length - 1; i >= 0; i--) {
|
|
165
|
+
if (str[i] === '.') {
|
|
166
|
+
dotCount++;
|
|
167
|
+
if (dotCount === 2) {
|
|
168
|
+
return i;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return -1; // 未找到足够的点号
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function findFunction(fn: string) {
|
|
176
|
+
return flatStaticTips.filter((item) => item.name.startsWith(fn));
|
|
177
|
+
}
|
|
29
178
|
</script>
|
|
30
179
|
<style scoped>
|
|
31
180
|
.run-js-input-wrapper {
|
|
32
181
|
position: relative;
|
|
33
182
|
display: flex;
|
|
183
|
+
align-items: center;
|
|
34
184
|
padding: 0 16px;
|
|
35
|
-
|
|
185
|
+
height: 32px;
|
|
36
186
|
border-top: 1px solid var(--dev-tool-border-color);
|
|
37
187
|
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
38
|
-
|
|
188
|
+
box-sizing: border-box;
|
|
39
189
|
}
|
|
40
190
|
|
|
41
191
|
.run-js-input-icon {
|
|
@@ -56,4 +206,32 @@ function onConfirm() {
|
|
|
56
206
|
border: 1px solid transparent;
|
|
57
207
|
font-size: var(--dev-tool-base-font-size);
|
|
58
208
|
}
|
|
209
|
+
|
|
210
|
+
.run-js-tips {
|
|
211
|
+
position: absolute;
|
|
212
|
+
bottom: 31px;
|
|
213
|
+
left: 0;
|
|
214
|
+
background-color: #fff;
|
|
215
|
+
width: 100%;
|
|
216
|
+
max-height: 200px;
|
|
217
|
+
padding: 0 16px 0 36px;
|
|
218
|
+
box-sizing: border-box;
|
|
219
|
+
overflow-y: auto;
|
|
220
|
+
overflow-x: hidden;
|
|
221
|
+
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
|
|
222
|
+
}
|
|
223
|
+
.run-js-tips-item {
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
height: 28px;
|
|
227
|
+
width: 100%;
|
|
228
|
+
white-space: nowrap;
|
|
229
|
+
border: 1px solid transparent;
|
|
230
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
231
|
+
overflow: hidden;
|
|
232
|
+
text-overflow: ellipsis;
|
|
233
|
+
}
|
|
234
|
+
.run-js-tips-item-active {
|
|
235
|
+
border: 1px solid var(--dev-tool-main-color);
|
|
236
|
+
}
|
|
59
237
|
</style>
|
|
@@ -17,7 +17,14 @@
|
|
|
17
17
|
</Tag>
|
|
18
18
|
</view>
|
|
19
19
|
|
|
20
|
-
<VirtualListPro
|
|
20
|
+
<VirtualListPro
|
|
21
|
+
:data="consoleList"
|
|
22
|
+
:pageSize="15"
|
|
23
|
+
:scrollIntoView="scrollIntoView"
|
|
24
|
+
:scrollWithAnimation="true"
|
|
25
|
+
:height="height"
|
|
26
|
+
className="console-list"
|
|
27
|
+
>
|
|
21
28
|
<template v-slot="{ list, start }">
|
|
22
29
|
<AutoSize
|
|
23
30
|
v-for="(item, index) in list"
|
|
@@ -30,6 +37,7 @@
|
|
|
30
37
|
:mode="mode"
|
|
31
38
|
:useDevSource="useDevSource"
|
|
32
39
|
:id="`dev-console-${index}`"
|
|
40
|
+
:zIndex="zIndex"
|
|
33
41
|
/>
|
|
34
42
|
</AutoSize>
|
|
35
43
|
<Empty v-if="!consoleList || consoleList.length === 0" />
|
|
@@ -45,7 +53,7 @@ import Empty from '../Empty/index.vue';
|
|
|
45
53
|
import FilterInput from '../FilterInput/index.vue';
|
|
46
54
|
import RunJSInput from './RunJSInput.vue';
|
|
47
55
|
import type { DevTool } from '../../type';
|
|
48
|
-
import { ref, watch } from 'vue';
|
|
56
|
+
import { onMounted, ref, watch } from 'vue';
|
|
49
57
|
import { debounce } from '../../utils';
|
|
50
58
|
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
51
59
|
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
@@ -58,6 +66,7 @@ const props = defineProps<{
|
|
|
58
66
|
sourceFileServers?: string[];
|
|
59
67
|
mode?: string;
|
|
60
68
|
useDevSource?: boolean;
|
|
69
|
+
zIndex?: number;
|
|
61
70
|
}>();
|
|
62
71
|
const emit = defineEmits<{
|
|
63
72
|
(e: 'choose', type: ConsoleType): void;
|
|
@@ -102,6 +111,12 @@ const debounceWatch = debounce(() => {
|
|
|
102
111
|
}, 200);
|
|
103
112
|
|
|
104
113
|
watch(() => props.consoleList, debounceWatch);
|
|
114
|
+
|
|
115
|
+
const height = ref(0);
|
|
116
|
+
onMounted(() => {
|
|
117
|
+
const { windowHeight } = uni.getWindowInfo();
|
|
118
|
+
height.value = windowHeight - 32 - 32 - 32;
|
|
119
|
+
});
|
|
105
120
|
</script>
|
|
106
121
|
<style scoped>
|
|
107
122
|
.console-content {
|