vite-uni-dev-tool 0.0.11 → 0.0.13
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 +55 -1
- package/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/dev/components/AppInfo/index.vue +0 -36
- package/dev/components/AutoSizer/index.vue +0 -193
- package/dev/components/AutoSizer/index1.vue +0 -186
- package/dev/components/AutoSizer/utils.ts +0 -49
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/CaptureScreen/index.vue +0 -62
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/CloseButton/index.vue +0 -26
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/Connection/index.vue +0 -88
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
- package/dev/components/ConsoleList/RunJSInput.vue +0 -235
- package/dev/components/ConsoleList/index.vue +0 -130
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -182
- package/dev/components/DevToolButton/index.vue +0 -213
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1037
- package/dev/components/DeviceInfo/index.vue +0 -32
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +0 -28
- package/dev/components/FilterInput/index.vue +0 -86
- package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
- package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
- package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
- package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
- package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
- package/dev/components/JsonPretty/hooks/useError.ts +0 -21
- package/dev/components/JsonPretty/index.vue +0 -474
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -197
- package/dev/components/NetworkList/NetworkItem.vue +0 -106
- package/dev/components/NetworkList/index.vue +0 -115
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -110
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -225
- package/dev/components/StorageList/index.vue +0 -170
- package/dev/components/SystemInfo/index.vue +0 -34
- package/dev/components/Tabs/index.vue +0 -123
- package/dev/components/Tag/index.vue +0 -89
- package/dev/components/UniEvent/UniEventItem.vue +0 -124
- package/dev/components/UniEvent/index.vue +0 -94
- package/dev/components/UploadList/UploadDetail.vue +0 -208
- package/dev/components/UploadList/UploadItem.vue +0 -111
- package/dev/components/UploadList/index.vue +0 -104
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -175
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -98
- package/dev/components/WebSocket/WebSocketList.vue +0 -176
- package/dev/components/WebSocket/index.vue +0 -111
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -166
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -806
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -718
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -264
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -46
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -72
- package/dev/utils/object.ts +0 -298
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :id="id" :class="`console-item console-item-${consoleItem.type}`">
|
|
3
|
-
<view class="console-info">
|
|
4
|
-
<view class="console-args">
|
|
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>
|
|
21
|
-
</view>
|
|
22
|
-
<view class="console-position">
|
|
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
|
-
|
|
36
|
-
<view>
|
|
37
|
-
<view class="console-time">{{ consoleItem.time }}</view>
|
|
38
|
-
<view class="console-other" v-html="consoleItem.position"></view>
|
|
39
|
-
<view
|
|
40
|
-
:class="`console-other ${isUseDevSource ? 'console-stack' : ''}`"
|
|
41
|
-
v-if="consoleItem.stack"
|
|
42
|
-
v-html="consoleItem.stack"
|
|
43
|
-
@click="onStackClick"
|
|
44
|
-
></view>
|
|
45
|
-
</view>
|
|
46
|
-
</view>
|
|
47
|
-
</view>
|
|
48
|
-
<!-- <view class="console-copy">C</view> -->
|
|
49
|
-
<Code
|
|
50
|
-
v-if="openCode && consoleItem.stack"
|
|
51
|
-
:url="consoleItem.stack"
|
|
52
|
-
:sourceFileServers="sourceFileServers"
|
|
53
|
-
:mode="mode"
|
|
54
|
-
@close="onCloseCode"
|
|
55
|
-
/>
|
|
56
|
-
</view>
|
|
57
|
-
</template>
|
|
58
|
-
|
|
59
|
-
<script setup lang="ts">
|
|
60
|
-
import { ref, computed } from 'vue';
|
|
61
|
-
import Tag from '../Tag/index.vue';
|
|
62
|
-
import Code from '../Code/index.vue';
|
|
63
|
-
import type { DevTool } from '../../type';
|
|
64
|
-
import { isAndroid, isMockWX } from '../../utils';
|
|
65
|
-
import JsonPretty from '../JsonPretty/index.vue';
|
|
66
|
-
const props = defineProps<{
|
|
67
|
-
consoleItem: DevTool.ConsoleItem;
|
|
68
|
-
sourceFileServers?: string[];
|
|
69
|
-
mode?: string;
|
|
70
|
-
useDevSource?: boolean;
|
|
71
|
-
id: string;
|
|
72
|
-
}>();
|
|
73
|
-
|
|
74
|
-
const openCode = ref(false);
|
|
75
|
-
|
|
76
|
-
const isUseDevSource = computed(() => {
|
|
77
|
-
return (
|
|
78
|
-
!isMockWX(props?.consoleItem?.stack ?? '') &&
|
|
79
|
-
props.mode === 'development' &&
|
|
80
|
-
props.useDevSource
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const isWXLink = computed(() => {
|
|
85
|
-
return (
|
|
86
|
-
isMockWX(props?.consoleItem?.stack ?? '') || props.mode !== 'development'
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
function onStackClick() {
|
|
91
|
-
if (isWXLink.value) {
|
|
92
|
-
uni.showToast({
|
|
93
|
-
icon: 'none',
|
|
94
|
-
title: '[DevTool] 请在小程序真机调试模式下查看源码',
|
|
95
|
-
});
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!isUseDevSource.value) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (isAndroid()) {
|
|
104
|
-
if (props.sourceFileServers && props.sourceFileServers.length > 0) {
|
|
105
|
-
openCode.value = true;
|
|
106
|
-
} else {
|
|
107
|
-
uni.showToast({
|
|
108
|
-
icon: 'none',
|
|
109
|
-
title: '[DevTool] sourceFileServers 配置异常',
|
|
110
|
-
});
|
|
111
|
-
uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
openCode.value = true;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function onCloseCode() {
|
|
119
|
-
openCode.value = false;
|
|
120
|
-
}
|
|
121
|
-
</script>
|
|
122
|
-
<style scoped>
|
|
123
|
-
.console-item {
|
|
124
|
-
display: flex;
|
|
125
|
-
padding: 16px;
|
|
126
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
127
|
-
font-size: var(--dev-tool-base-font-size);
|
|
128
|
-
}
|
|
129
|
-
.console-info {
|
|
130
|
-
flex: 1;
|
|
131
|
-
}
|
|
132
|
-
.console-args {
|
|
133
|
-
display: flex;
|
|
134
|
-
flex-wrap: wrap;
|
|
135
|
-
color: #000;
|
|
136
|
-
}
|
|
137
|
-
.console-arg {
|
|
138
|
-
margin-right: 4px;
|
|
139
|
-
white-space: pre-line;
|
|
140
|
-
word-break: break-all;
|
|
141
|
-
}
|
|
142
|
-
.console-position {
|
|
143
|
-
display: flex;
|
|
144
|
-
align-items: flex-start;
|
|
145
|
-
justify-content: space-between;
|
|
146
|
-
margin-top: 4px;
|
|
147
|
-
color: #616161;
|
|
148
|
-
text-align: right;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.console-tags {
|
|
152
|
-
display: flex;
|
|
153
|
-
align-items: center;
|
|
154
|
-
}
|
|
155
|
-
.console-time {
|
|
156
|
-
margin-right: auto;
|
|
157
|
-
word-break: break-all;
|
|
158
|
-
}
|
|
159
|
-
.console-other {
|
|
160
|
-
word-break: break-all;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
.console-stack {
|
|
164
|
-
text-decoration: underline;
|
|
165
|
-
cursor: pointer;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.console-copy {
|
|
169
|
-
flex-shrink: 0;
|
|
170
|
-
margin-left: 16px;
|
|
171
|
-
display: flex;
|
|
172
|
-
align-items: center;
|
|
173
|
-
justify-content: center;
|
|
174
|
-
width: 24px;
|
|
175
|
-
height: 24px;
|
|
176
|
-
color: #fff;
|
|
177
|
-
border-radius: 50%;
|
|
178
|
-
background-color: var(--dev-tool-success-color);
|
|
179
|
-
}
|
|
180
|
-
.console-item-info {
|
|
181
|
-
color: #9c9c9c;
|
|
182
|
-
}
|
|
183
|
-
.console-item-log {
|
|
184
|
-
color: #f9f9f9;
|
|
185
|
-
}
|
|
186
|
-
</style>
|
|
@@ -1,235 +0,0 @@
|
|
|
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
|
-
@input="onChange"
|
|
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>
|
|
20
|
-
</view>
|
|
21
|
-
</template>
|
|
22
|
-
<script lang="ts" setup>
|
|
23
|
-
import { ref } from 'vue';
|
|
24
|
-
import {
|
|
25
|
-
staticTips,
|
|
26
|
-
singleTips,
|
|
27
|
-
flatStaticTips,
|
|
28
|
-
baseSymbols,
|
|
29
|
-
type Tip,
|
|
30
|
-
} from './staticTips';
|
|
31
|
-
|
|
32
|
-
const emit = defineEmits<{
|
|
33
|
-
(e: 'run', value: string): void;
|
|
34
|
-
}>();
|
|
35
|
-
|
|
36
|
-
const code = ref('');
|
|
37
|
-
|
|
38
|
-
const tips = ref<Tip[]>([]);
|
|
39
|
-
|
|
40
|
-
function onConfirm() {
|
|
41
|
-
tips.value = [];
|
|
42
|
-
const value = code.value;
|
|
43
|
-
if (!value) return;
|
|
44
|
-
code.value = '';
|
|
45
|
-
setTimeout(() => {
|
|
46
|
-
emit('run', value);
|
|
47
|
-
}, 100);
|
|
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
|
-
}
|
|
178
|
-
</script>
|
|
179
|
-
<style scoped>
|
|
180
|
-
.run-js-input-wrapper {
|
|
181
|
-
position: relative;
|
|
182
|
-
display: flex;
|
|
183
|
-
padding: 0 16px;
|
|
184
|
-
min-height: 28px;
|
|
185
|
-
border-top: 1px solid var(--dev-tool-border-color);
|
|
186
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.run-js-input-icon {
|
|
190
|
-
margin: 10px 0 10px -4px;
|
|
191
|
-
width: 8px;
|
|
192
|
-
height: 8px;
|
|
193
|
-
border: 1px solid #000;
|
|
194
|
-
border-bottom-color: transparent;
|
|
195
|
-
border-left-color: transparent;
|
|
196
|
-
overflow: hidden;
|
|
197
|
-
transform: rotate(45deg);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.run-js-input {
|
|
201
|
-
margin: 1px 0 1px 16px;
|
|
202
|
-
min-height: 26px;
|
|
203
|
-
width: 100%;
|
|
204
|
-
border: 1px solid transparent;
|
|
205
|
-
font-size: var(--dev-tool-base-font-size);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.run-js-tips {
|
|
209
|
-
position: absolute;
|
|
210
|
-
bottom: 31px;
|
|
211
|
-
left: 0;
|
|
212
|
-
background-color: #fff;
|
|
213
|
-
width: 100%;
|
|
214
|
-
max-height: 200px;
|
|
215
|
-
padding: 0 16px 0 36px;
|
|
216
|
-
box-sizing: border-box;
|
|
217
|
-
overflow-y: auto;
|
|
218
|
-
overflow-x: hidden;
|
|
219
|
-
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
|
|
220
|
-
}
|
|
221
|
-
.run-js-tips-item {
|
|
222
|
-
display: flex;
|
|
223
|
-
align-items: center;
|
|
224
|
-
height: 28px;
|
|
225
|
-
width: 100%;
|
|
226
|
-
white-space: nowrap;
|
|
227
|
-
border: 1px solid transparent;
|
|
228
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
229
|
-
overflow: hidden;
|
|
230
|
-
text-overflow: ellipsis;
|
|
231
|
-
}
|
|
232
|
-
.run-js-tips-item-active {
|
|
233
|
-
border: 1px solid var(--dev-tool-main-color);
|
|
234
|
-
}
|
|
235
|
-
</style>
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="console-content">
|
|
3
|
-
<view class="console-control">
|
|
4
|
-
<FilterInput
|
|
5
|
-
:modelValue="modelValue"
|
|
6
|
-
@search="emit('search', $event)"
|
|
7
|
-
@update:modelValue="emit('update:modelValue', $event)"
|
|
8
|
-
/>
|
|
9
|
-
<Tag
|
|
10
|
-
v-for="item in consoleFilterItems"
|
|
11
|
-
:mode="item.value"
|
|
12
|
-
:key="item.value"
|
|
13
|
-
:active="currentConsoleType === item.value"
|
|
14
|
-
@click="emit('choose', item.value)"
|
|
15
|
-
>
|
|
16
|
-
{{ item.label }}
|
|
17
|
-
</Tag>
|
|
18
|
-
</view>
|
|
19
|
-
|
|
20
|
-
<VirtualListPro
|
|
21
|
-
:data="consoleList"
|
|
22
|
-
:pageSize="10"
|
|
23
|
-
:scrollIntoView="scrollIntoView"
|
|
24
|
-
:scrollWithAnimation="true"
|
|
25
|
-
className="console-list"
|
|
26
|
-
>
|
|
27
|
-
<template v-slot="{ list, start }">
|
|
28
|
-
<AutoSize
|
|
29
|
-
v-for="(item, index) in list"
|
|
30
|
-
:index="start + index"
|
|
31
|
-
:key="start + index"
|
|
32
|
-
>
|
|
33
|
-
<ConsoleItem
|
|
34
|
-
:consoleItem="item"
|
|
35
|
-
:sourceFileServers="sourceFileServers"
|
|
36
|
-
:mode="mode"
|
|
37
|
-
:useDevSource="useDevSource"
|
|
38
|
-
:id="`dev-console-${index}`"
|
|
39
|
-
/>
|
|
40
|
-
</AutoSize>
|
|
41
|
-
<Empty v-if="!consoleList || consoleList.length === 0" />
|
|
42
|
-
</template>
|
|
43
|
-
</VirtualListPro>
|
|
44
|
-
<RunJSInput @run="emit('run', $event)" />
|
|
45
|
-
</view>
|
|
46
|
-
</template>
|
|
47
|
-
<script setup lang="ts">
|
|
48
|
-
import ConsoleItem from './ConsoleItem.vue';
|
|
49
|
-
import Tag from '../Tag/index.vue';
|
|
50
|
-
import Empty from '../Empty/index.vue';
|
|
51
|
-
import FilterInput from '../FilterInput/index.vue';
|
|
52
|
-
import RunJSInput from './RunJSInput.vue';
|
|
53
|
-
import type { DevTool } from '../../type';
|
|
54
|
-
import { ref, watch } from 'vue';
|
|
55
|
-
import { debounce } from '../../utils';
|
|
56
|
-
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
57
|
-
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
58
|
-
|
|
59
|
-
type ConsoleType = 'all' | 'log' | 'info' | 'warn' | 'error' | 'clear';
|
|
60
|
-
const props = defineProps<{
|
|
61
|
-
consoleList: DevTool.ConsoleItem[];
|
|
62
|
-
currentConsoleType: string;
|
|
63
|
-
modelValue: string;
|
|
64
|
-
sourceFileServers?: string[];
|
|
65
|
-
mode?: string;
|
|
66
|
-
useDevSource?: boolean;
|
|
67
|
-
}>();
|
|
68
|
-
const emit = defineEmits<{
|
|
69
|
-
(e: 'choose', type: ConsoleType): void;
|
|
70
|
-
(e: 'search', value: string): void;
|
|
71
|
-
(e: 'update:modelValue', value: string): void;
|
|
72
|
-
(e: 'run', value: string): void;
|
|
73
|
-
}>();
|
|
74
|
-
const consoleFilterItems: {
|
|
75
|
-
label: string;
|
|
76
|
-
value: ConsoleType;
|
|
77
|
-
}[] = [
|
|
78
|
-
{
|
|
79
|
-
label: '全部',
|
|
80
|
-
value: 'all',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
label: 'info',
|
|
84
|
-
value: 'info',
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
label: 'log',
|
|
88
|
-
value: 'log',
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: 'warn',
|
|
92
|
-
value: 'warn',
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
label: 'error',
|
|
96
|
-
value: 'error',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
label: '清除',
|
|
100
|
-
value: 'clear',
|
|
101
|
-
},
|
|
102
|
-
];
|
|
103
|
-
|
|
104
|
-
const scrollIntoView = ref('');
|
|
105
|
-
|
|
106
|
-
const debounceWatch = debounce(() => {
|
|
107
|
-
scrollIntoView.value = `dev-console-${props.consoleList.length - 1}`;
|
|
108
|
-
}, 200);
|
|
109
|
-
|
|
110
|
-
watch(() => props.consoleList, debounceWatch);
|
|
111
|
-
</script>
|
|
112
|
-
<style scoped>
|
|
113
|
-
.console-content {
|
|
114
|
-
height: 100%;
|
|
115
|
-
font-size: var(--dev-tool-base-font-size);
|
|
116
|
-
}
|
|
117
|
-
.console-list {
|
|
118
|
-
height: calc(100% - 32px - 32px);
|
|
119
|
-
}
|
|
120
|
-
.console-control {
|
|
121
|
-
display: flex;
|
|
122
|
-
align-items: center;
|
|
123
|
-
justify-content: space-between;
|
|
124
|
-
gap: 8px;
|
|
125
|
-
padding: 0 16px;
|
|
126
|
-
height: 32px;
|
|
127
|
-
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
128
|
-
box-sizing: border-box;
|
|
129
|
-
}
|
|
130
|
-
</style>
|