vite-uni-dev-tool 0.0.12 → 0.0.14
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/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 +7 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- 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/AppInfo/index.vue +41 -0
- package/dist/v2/AutoSizer/index.vue +189 -0
- package/dist/v2/AutoSizer/index1.vue +193 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/CaptureScreen/index.vue +78 -0
- package/dist/v2/CloseButton/index.vue +32 -0
- package/dist/v2/Connection/index.vue +94 -0
- package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
- package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
- package/dist/v2/ConsoleList/index.vue +164 -0
- package/dist/v2/ConsoleList/staticTips.js +1144 -0
- package/dist/v2/DevTool/index.vue +162 -0
- package/dist/v2/DevToolButton/index.vue +228 -0
- package/dist/v2/DevToolTitle/index.vue +28 -0
- package/dist/v2/DevToolWindow/index.vue +1051 -0
- package/dist/v2/DeviceInfo/index.vue +48 -0
- package/dist/v2/Empty/index.vue +40 -0
- package/dist/v2/FilterInput/index.vue +100 -0
- package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
- package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
- package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
- package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -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/index.vue +531 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v2/JsonPretty/utils/index.js +211 -0
- package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
- package/dist/v2/NetworkList/NetworkItem.vue +135 -0
- package/dist/v2/NetworkList/index.vue +148 -0
- package/dist/v2/PiniaList/index.vue +79 -0
- package/dist/v2/RouteList/index.vue +137 -0
- package/dist/v2/SettingList/index.vue +318 -0
- package/dist/v2/SourceCode/index.vue +237 -0
- package/dist/v2/StorageList/index.vue +165 -0
- package/dist/v2/SystemInfo/index.vue +49 -0
- package/dist/v2/Tabs/index.vue +127 -0
- package/dist/v2/Tag/index.vue +91 -0
- package/dist/v2/UniEvent/UniEventItem.vue +157 -0
- package/dist/v2/UniEvent/index.vue +127 -0
- package/dist/v2/UploadList/UploadDetail.vue +204 -0
- package/dist/v2/UploadList/UploadItem.vue +134 -0
- package/dist/v2/UploadList/index.vue +143 -0
- package/dist/v2/VirtualList/index.vue +140 -0
- package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
- package/dist/v2/VirtualListPro/index.vue +255 -0
- package/dist/v2/VuexList/index.vue +80 -0
- package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
- package/dist/v2/WebSocket/WebSocketList.vue +183 -0
- package/dist/v2/WebSocket/index.vue +155 -0
- package/dist/v2/WindowInfo/index.vue +49 -0
- package/{dev/components → dist/v3}/AppInfo/index.vue +0 -1
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.ts +49 -0
- package/{dev/components → dist/v3}/CloseButton/index.vue +5 -2
- package/{dev/components → dist/v3}/ConsoleList/ConsoleItem.vue +10 -9
- package/{dev/components → dist/v3}/ConsoleList/RunJSInput.vue +5 -2
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/{dev/components → dist/v3}/DevTool/index.vue +33 -4
- package/{dev/components → dist/v3}/DevToolWindow/index.vue +67 -4
- package/dist/v3/Empty/empty.png +0 -0
- package/{dev/components → dist/v3}/FilterInput/index.vue +5 -4
- 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/useClipboard.ts +21 -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/hooks/useError.ts +21 -0
- package/{dev/components → dist/v3}/JsonPretty/index.vue +10 -10
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.ts +125 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/{dev/components → dist/v3}/NetworkList/NetworkDetail.vue +2 -2
- package/{dev/components → dist/v3}/NetworkList/NetworkItem.vue +2 -1
- package/dist/v3/RunJS/index.vue +128 -0
- package/{dev/components → dist/v3}/SettingList/index.vue +128 -37
- package/{dev/components → dist/v3}/SourceCode/index.vue +2 -2
- package/{dev/components → dist/v3}/Tag/index.vue +4 -4
- package/{dev/components → dist/v3}/UploadList/UploadDetail.vue +3 -15
- package/{dev/components → dist/v3}/UploadList/UploadItem.vue +1 -1
- package/dist/v3/VirtualListPro/readme.md +40 -0
- package/{dev/components → dist/v3}/WebSocket/WebSocketItem.vue +1 -1
- package/{dev/components → dist/v3}/WebSocket/WebSocketList.vue +3 -15
- package/package.json +5 -5
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/const.ts +0 -164
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -810
- 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 -732
- package/dev/devToolInfo/index.ts +0 -26
- 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 -291
- 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 -51
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -77
- package/dev/utils/object.ts +0 -306
- 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
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
- /package/{dev/components → dist/v2}/AutoSizer/utils.ts +0 -0
- /package/{dev/components → dist/v2}/Empty/empty.png +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/hooks/useClipboard.ts +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/hooks/useError.ts +0 -0
- /package/{dev/components → dist/v2}/JsonPretty/type.ts +0 -0
- /package/{dev/components → dist/v2}/RunJS/index.vue +0 -0
- /package/{dev/components → dist/v2}/VirtualListPro/readme.md +0 -0
- /package/{dev/components → dist/v3}/AutoSizer/index.vue +0 -0
- /package/{dev/components → dist/v3}/AutoSizer/index1.vue +0 -0
- /package/{dev/components → dist/v3}/CaptureScreen/index.vue +0 -0
- /package/{dev/components → dist/v3}/Connection/index.vue +0 -0
- /package/{dev/components → dist/v3}/ConsoleList/index.vue +0 -0
- /package/{dev/components → dist/v3}/ConsoleList/staticTips.ts +0 -0
- /package/{dev/components → dist/v3}/DevToolButton/index.vue +0 -0
- /package/{dev/components → dist/v3}/DevToolTitle/index.vue +0 -0
- /package/{dev/components → dist/v3}/DeviceInfo/index.vue +0 -0
- /package/{dev/components → dist/v3}/Empty/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/Brackets/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/Carets/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/CheckController/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/components/TreeNode/index.vue +0 -0
- /package/{dev/components → dist/v3}/JsonPretty/utils/index.ts +0 -0
- /package/{dev/components → dist/v3}/NetworkList/index.vue +0 -0
- /package/{dev/components → dist/v3}/PiniaList/index.vue +0 -0
- /package/{dev/components → dist/v3}/RouteList/index.vue +0 -0
- /package/{dev/components → dist/v3}/StorageList/index.vue +0 -0
- /package/{dev/components → dist/v3}/SystemInfo/index.vue +0 -0
- /package/{dev/components → dist/v3}/Tabs/index.vue +0 -0
- /package/{dev/components → dist/v3}/UniEvent/UniEventItem.vue +0 -0
- /package/{dev/components → dist/v3}/UniEvent/index.vue +0 -0
- /package/{dev/components → dist/v3}/UploadList/index.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualList/index.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualListPro/AutoSize.vue +0 -0
- /package/{dev/components → dist/v3}/VirtualListPro/index.vue +0 -0
- /package/{dev/components → dist/v3}/VuexList/index.vue +0 -0
- /package/{dev/components → dist/v3}/WebSocket/index.vue +0 -0
- /package/{dev/components → dist/v3}/WindowInfo/index.vue +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
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 console-arg-${item.type}`"
|
|
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
|
+
<SourceCode
|
|
49
|
+
v-if="openCode && consoleItem.stack"
|
|
50
|
+
:url="consoleItem.stack"
|
|
51
|
+
:sourceFileServers="sourceFileServers"
|
|
52
|
+
:mode="mode"
|
|
53
|
+
:zIndex="zIndex"
|
|
54
|
+
@close="onCloseCode"
|
|
55
|
+
/>
|
|
56
|
+
</view>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<script>
|
|
60
|
+
import Tag from '../Tag/index.vue';
|
|
61
|
+
import SourceCode from '../SourceCode/index.vue';
|
|
62
|
+
import JsonPretty from '../JsonPretty/index.vue';
|
|
63
|
+
import { isAndroid, isMockWX } from '../../utils';
|
|
64
|
+
|
|
65
|
+
export default {
|
|
66
|
+
components: {
|
|
67
|
+
Tag,
|
|
68
|
+
SourceCode,
|
|
69
|
+
JsonPretty,
|
|
70
|
+
},
|
|
71
|
+
props: {
|
|
72
|
+
consoleItem: {
|
|
73
|
+
type: Object,
|
|
74
|
+
required: true,
|
|
75
|
+
},
|
|
76
|
+
sourceFileServers: {
|
|
77
|
+
type: Array,
|
|
78
|
+
default: () => [],
|
|
79
|
+
},
|
|
80
|
+
mode: {
|
|
81
|
+
type: String,
|
|
82
|
+
default: '',
|
|
83
|
+
},
|
|
84
|
+
useDevSource: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: false,
|
|
87
|
+
},
|
|
88
|
+
zIndex: {
|
|
89
|
+
type: Number,
|
|
90
|
+
default: 0,
|
|
91
|
+
},
|
|
92
|
+
id: {
|
|
93
|
+
type: String,
|
|
94
|
+
required: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
openCode: false,
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
computed: {
|
|
103
|
+
isUseDevSource() {
|
|
104
|
+
return (
|
|
105
|
+
!isMockWX(this.consoleItem?.stack ?? '') &&
|
|
106
|
+
this.mode === 'development' &&
|
|
107
|
+
this.useDevSource
|
|
108
|
+
);
|
|
109
|
+
},
|
|
110
|
+
isWXLink() {
|
|
111
|
+
return (
|
|
112
|
+
isMockWX(this.consoleItem?.stack ?? '') || this.mode !== 'development'
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
methods: {
|
|
117
|
+
onStackClick() {
|
|
118
|
+
if (this.isWXLink) {
|
|
119
|
+
uni.showToast({
|
|
120
|
+
icon: 'none',
|
|
121
|
+
title: '[DevTool] 请在小程序真机调试模式下查看源码',
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!this.isUseDevSource) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (isAndroid()) {
|
|
131
|
+
if (this.sourceFileServers && this.sourceFileServers.length > 0) {
|
|
132
|
+
this.openCode = true;
|
|
133
|
+
} else {
|
|
134
|
+
uni.showToast({
|
|
135
|
+
icon: 'none',
|
|
136
|
+
title: '[DevTool] sourceFileServers 配置异常',
|
|
137
|
+
});
|
|
138
|
+
uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
this.openCode = true;
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
onCloseCode() {
|
|
145
|
+
this.openCode = false;
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<style scoped>
|
|
152
|
+
.console-item {
|
|
153
|
+
display: flex;
|
|
154
|
+
padding: 16px;
|
|
155
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
156
|
+
font-size: var(--dev-tool-base-font-size);
|
|
157
|
+
}
|
|
158
|
+
.console-info {
|
|
159
|
+
flex: 1;
|
|
160
|
+
}
|
|
161
|
+
.console-args {
|
|
162
|
+
display: flex;
|
|
163
|
+
flex-wrap: wrap;
|
|
164
|
+
/* color: #000; */
|
|
165
|
+
/* color: var(--dev-tool-text-color); */
|
|
166
|
+
}
|
|
167
|
+
.console-arg {
|
|
168
|
+
margin-right: 4px;
|
|
169
|
+
white-space: pre-line;
|
|
170
|
+
word-break: break-all;
|
|
171
|
+
}
|
|
172
|
+
.console-position {
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: flex-start;
|
|
175
|
+
justify-content: space-between;
|
|
176
|
+
margin-top: 4px;
|
|
177
|
+
/* color: #616161; */
|
|
178
|
+
text-align: right;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.console-tags {
|
|
182
|
+
display: flex;
|
|
183
|
+
align-items: center;
|
|
184
|
+
}
|
|
185
|
+
.console-time {
|
|
186
|
+
margin-right: auto;
|
|
187
|
+
word-break: break-all;
|
|
188
|
+
}
|
|
189
|
+
.console-other {
|
|
190
|
+
word-break: break-all;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.console-stack {
|
|
194
|
+
text-decoration: underline;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.console-copy {
|
|
199
|
+
flex-shrink: 0;
|
|
200
|
+
margin-left: 16px;
|
|
201
|
+
display: flex;
|
|
202
|
+
align-items: center;
|
|
203
|
+
justify-content: center;
|
|
204
|
+
width: 24px;
|
|
205
|
+
height: 24px;
|
|
206
|
+
color: #fff;
|
|
207
|
+
border-radius: 50%;
|
|
208
|
+
background-color: var(--dev-tool-success-color);
|
|
209
|
+
}
|
|
210
|
+
.console-item-info {
|
|
211
|
+
color: var(--dev-tool-log-color);
|
|
212
|
+
}
|
|
213
|
+
.console-item-log {
|
|
214
|
+
color: #f9f9f9;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.console-arg-null {
|
|
218
|
+
color: var(--dev-tool-nil-color);
|
|
219
|
+
}
|
|
220
|
+
.console-arg-undefined {
|
|
221
|
+
color: var(--dev-tool-nil-color);
|
|
222
|
+
}
|
|
223
|
+
.console-arg-string {
|
|
224
|
+
color: var(--dev-tool-string-color);
|
|
225
|
+
}
|
|
226
|
+
.console-arg-number {
|
|
227
|
+
color: var(--dev-tool-number-color);
|
|
228
|
+
}
|
|
229
|
+
.console-arg-boolean {
|
|
230
|
+
color: var(--dev-tool-boolean-color);
|
|
231
|
+
}
|
|
232
|
+
.console-arg-symbol {
|
|
233
|
+
color: var(--dev-tool-symbol-color);
|
|
234
|
+
}
|
|
235
|
+
</style>
|
|
@@ -0,0 +1,243 @@
|
|
|
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
|
+
:key="index"
|
|
16
|
+
@click="onChoose(item.name)"
|
|
17
|
+
>
|
|
18
|
+
{{ item.name }}{{ item.description ? ': ' : ' ' }}{{ item.description }}
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import {
|
|
26
|
+
staticTips,
|
|
27
|
+
singleTips,
|
|
28
|
+
flatStaticTips,
|
|
29
|
+
baseSymbols,
|
|
30
|
+
} from './staticTips.js';
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
data() {
|
|
34
|
+
return {
|
|
35
|
+
code: '',
|
|
36
|
+
tips: [],
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
onConfirm() {
|
|
41
|
+
this.tips = [];
|
|
42
|
+
const value = this.code;
|
|
43
|
+
if (!value) return;
|
|
44
|
+
this.code = '';
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
this.$emit('run', value);
|
|
47
|
+
}, 100);
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* 1.对象,方法,变量 在 ; ( , =,==,=== , + , - , * , / , && , || ?? 之后 开始提示
|
|
51
|
+
*
|
|
52
|
+
* Math
|
|
53
|
+
* console
|
|
54
|
+
*
|
|
55
|
+
* 2.在 . 之后 提示
|
|
56
|
+
*
|
|
57
|
+
* Math.a
|
|
58
|
+
* console.a
|
|
59
|
+
*
|
|
60
|
+
*
|
|
61
|
+
* 3.对方法,属性返回值进行提示
|
|
62
|
+
*
|
|
63
|
+
* Math.abc().
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* any, void 不进行提示
|
|
67
|
+
*
|
|
68
|
+
* 4. [] 数组提示
|
|
69
|
+
*
|
|
70
|
+
* [1,2].concat([2,3].map(parseInt))
|
|
71
|
+
*
|
|
72
|
+
* 5. (值) 推断提示
|
|
73
|
+
* ({}).valueOf()
|
|
74
|
+
*
|
|
75
|
+
*
|
|
76
|
+
* @param e 输入框内容
|
|
77
|
+
*/
|
|
78
|
+
onChange(e) {
|
|
79
|
+
const { value, cursor } = e.detail;
|
|
80
|
+
// 光标之前的内容
|
|
81
|
+
const content = value.slice(0, cursor);
|
|
82
|
+
|
|
83
|
+
// 获取符号之后的内容
|
|
84
|
+
const lastIndex = this.getBaseSymbolLastIndex(content);
|
|
85
|
+
|
|
86
|
+
const con = lastIndex > -1 ? value.substring(lastIndex + 1) : value;
|
|
87
|
+
|
|
88
|
+
if (!con) {
|
|
89
|
+
// 不存在内容
|
|
90
|
+
this.tips = [];
|
|
91
|
+
} else {
|
|
92
|
+
// 存在内容
|
|
93
|
+
|
|
94
|
+
// 一级点之后的内容
|
|
95
|
+
const [main, sub] = con.split('.');
|
|
96
|
+
|
|
97
|
+
if (singleTips.includes(main) && con.includes('.')) {
|
|
98
|
+
const list = [
|
|
99
|
+
...(staticTips[main]?.attr ?? []),
|
|
100
|
+
...(staticTips[main]?.fun ?? []),
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
if (sub) {
|
|
104
|
+
this.tips = list.filter((item) => item.name.startsWith(sub));
|
|
105
|
+
} else {
|
|
106
|
+
this.tips = list;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
if (main.includes(')') && con.includes('.')) {
|
|
110
|
+
// 方法调用之后的提示
|
|
111
|
+
|
|
112
|
+
// 获取方法名称 倒数第二个 . 到最后一个 ( 之间为方法名称
|
|
113
|
+
const s = this.getSecondLastDotPosition(content);
|
|
114
|
+
const e = content.lastIndexOf('(');
|
|
115
|
+
const methodName = content.substring(s + 1, e);
|
|
116
|
+
|
|
117
|
+
const fn = this.findFunction(methodName);
|
|
118
|
+
// 获取方法返回值
|
|
119
|
+
const result = fn?.[0]?.result?.[0];
|
|
120
|
+
if (result && result !== 'any' && result !== 'void') {
|
|
121
|
+
this.tips = Object.values(staticTips?.[result] ?? {}).flat(2);
|
|
122
|
+
} else {
|
|
123
|
+
this.tips = [];
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
// 基础提示
|
|
127
|
+
this.tips = singleTips
|
|
128
|
+
.filter((item) => item.startsWith(con))
|
|
129
|
+
.map((item) => ({
|
|
130
|
+
name: item,
|
|
131
|
+
description: '',
|
|
132
|
+
result: ['any'],
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
onChoose(name) {
|
|
140
|
+
// 选择提示项的逻辑
|
|
141
|
+
// 原逻辑注释保留,可根据实际需求完善
|
|
142
|
+
// const lastIndex = this.code.lastIndexOf(';');
|
|
143
|
+
// const con = lastIndex > -1 ? this.code.substring(lastIndex + 1) : this.code;
|
|
144
|
+
// const lastCon = con.lastIndexOf('.');
|
|
145
|
+
// if (lastCon > -1) {
|
|
146
|
+
// this.code = con.substring(0, lastCon + 1) + name;
|
|
147
|
+
// } else {
|
|
148
|
+
// this.code = name;
|
|
149
|
+
// }
|
|
150
|
+
// this.tips = [];
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
getBaseSymbolLastIndex(code) {
|
|
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
|
+
getSecondLastDotPosition(str) {
|
|
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
|
+
findFunction(fn) {
|
|
176
|
+
return flatStaticTips.filter((item) => item.name.startsWith(fn));
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<style scoped>
|
|
183
|
+
.run-js-input-wrapper {
|
|
184
|
+
position: relative;
|
|
185
|
+
display: flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
padding: 0 16px;
|
|
188
|
+
height: 32px;
|
|
189
|
+
border-top: 1px solid var(--dev-tool-border-color);
|
|
190
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
191
|
+
box-sizing: border-box;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.run-js-input-icon {
|
|
195
|
+
margin: 10px 0 10px -4px;
|
|
196
|
+
width: 8px;
|
|
197
|
+
height: 8px;
|
|
198
|
+
border: 1px solid var(--dev-tool-text-color);
|
|
199
|
+
border-bottom-color: transparent;
|
|
200
|
+
border-left-color: transparent;
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
transform: rotate(45deg);
|
|
203
|
+
transition: border 0.3s;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.run-js-input {
|
|
207
|
+
margin: 1px 0 1px 16px;
|
|
208
|
+
min-height: 26px;
|
|
209
|
+
width: 100%;
|
|
210
|
+
border: 1px solid transparent;
|
|
211
|
+
font-size: var(--dev-tool-base-font-size);
|
|
212
|
+
color: var(--dev-tool-text-color);
|
|
213
|
+
transition: color 0.3s;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.run-js-tips {
|
|
217
|
+
position: absolute;
|
|
218
|
+
bottom: 31px;
|
|
219
|
+
left: 0;
|
|
220
|
+
background-color: var(--dev-tool-bg-color);
|
|
221
|
+
width: 100%;
|
|
222
|
+
max-height: 200px;
|
|
223
|
+
padding: 0 16px 0 36px;
|
|
224
|
+
box-sizing: border-box;
|
|
225
|
+
overflow-y: auto;
|
|
226
|
+
overflow-x: hidden;
|
|
227
|
+
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.1);
|
|
228
|
+
}
|
|
229
|
+
.run-js-tips-item {
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
height: 28px;
|
|
233
|
+
width: 100%;
|
|
234
|
+
white-space: nowrap;
|
|
235
|
+
border: 1px solid transparent;
|
|
236
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
237
|
+
overflow: hidden;
|
|
238
|
+
text-overflow: ellipsis;
|
|
239
|
+
}
|
|
240
|
+
.run-js-tips-item-active {
|
|
241
|
+
border: 1px solid var(--dev-tool-main-color);
|
|
242
|
+
}
|
|
243
|
+
</style>
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
:dataSource="consoleList"
|
|
22
|
+
:pageSize="15"
|
|
23
|
+
:scrollIntoView="scrollIntoView"
|
|
24
|
+
:scrollWithAnimation="true"
|
|
25
|
+
:height="height"
|
|
26
|
+
className="console-list"
|
|
27
|
+
>
|
|
28
|
+
<template #default="{ list, current, start }">
|
|
29
|
+
<AutoSize
|
|
30
|
+
v-for="(item, index) in list"
|
|
31
|
+
:index="start + index"
|
|
32
|
+
:key="start + index"
|
|
33
|
+
>
|
|
34
|
+
<ConsoleItem
|
|
35
|
+
:consoleItem="item"
|
|
36
|
+
:sourceFileServers="sourceFileServers"
|
|
37
|
+
:mode="mode"
|
|
38
|
+
:useDevSource="useDevSource"
|
|
39
|
+
:id="`dev-console-${start + index}`"
|
|
40
|
+
:zIndex="zIndex"
|
|
41
|
+
/>
|
|
42
|
+
</AutoSize>
|
|
43
|
+
<Empty v-if="!consoleList || consoleList.length === 0" />
|
|
44
|
+
</template>
|
|
45
|
+
</VirtualListPro>
|
|
46
|
+
<RunJSInput @run="$emit('run', $event)" />
|
|
47
|
+
</view>
|
|
48
|
+
</template>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
import ConsoleItem from './ConsoleItem.vue';
|
|
52
|
+
import Tag from '../Tag/index.vue';
|
|
53
|
+
import Empty from '../Empty/index.vue';
|
|
54
|
+
import FilterInput from '../FilterInput/index.vue';
|
|
55
|
+
import RunJSInput from './RunJSInput.vue';
|
|
56
|
+
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
57
|
+
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
58
|
+
import { debounce } from '../../utils';
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
components: {
|
|
62
|
+
ConsoleItem,
|
|
63
|
+
Tag,
|
|
64
|
+
Empty,
|
|
65
|
+
FilterInput,
|
|
66
|
+
RunJSInput,
|
|
67
|
+
VirtualListPro,
|
|
68
|
+
AutoSize,
|
|
69
|
+
},
|
|
70
|
+
props: {
|
|
71
|
+
consoleList: {
|
|
72
|
+
type: Array,
|
|
73
|
+
default: () => [],
|
|
74
|
+
},
|
|
75
|
+
currentConsoleType: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'all',
|
|
78
|
+
},
|
|
79
|
+
modelValue: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: '',
|
|
82
|
+
},
|
|
83
|
+
sourceFileServers: {
|
|
84
|
+
type: Array,
|
|
85
|
+
default: () => [],
|
|
86
|
+
},
|
|
87
|
+
mode: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: '',
|
|
90
|
+
},
|
|
91
|
+
useDevSource: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false,
|
|
94
|
+
},
|
|
95
|
+
zIndex: {
|
|
96
|
+
type: Number,
|
|
97
|
+
default: 0,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
data() {
|
|
101
|
+
return {
|
|
102
|
+
scrollIntoView: '',
|
|
103
|
+
height: 0,
|
|
104
|
+
consoleFilterItems: [
|
|
105
|
+
{ label: '全部', value: 'all' },
|
|
106
|
+
{ label: 'info', value: 'info' },
|
|
107
|
+
{ label: 'log', value: 'log' },
|
|
108
|
+
{ label: 'warn', value: 'warn' },
|
|
109
|
+
{ label: 'error', value: 'error' },
|
|
110
|
+
{ label: '清除', value: 'clear' },
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
},
|
|
114
|
+
mounted() {
|
|
115
|
+
const { windowHeight } = uni.getWindowInfo();
|
|
116
|
+
|
|
117
|
+
this.height = windowHeight - 32 - 32 - 32;
|
|
118
|
+
|
|
119
|
+
// this.initWatch();
|
|
120
|
+
},
|
|
121
|
+
watch: {
|
|
122
|
+
consoleList: {
|
|
123
|
+
handler(val) {
|
|
124
|
+
// console.log('val: ', val);
|
|
125
|
+
// this.consoleList = val;
|
|
126
|
+
},
|
|
127
|
+
deep: true,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
methods: {
|
|
131
|
+
// initWatch() {
|
|
132
|
+
// // Vue2 中使用 $watch 监听 props 变化
|
|
133
|
+
// this.$watch(
|
|
134
|
+
// 'consoleList',
|
|
135
|
+
// debounce(() => {
|
|
136
|
+
// if (this.consoleList.length) {
|
|
137
|
+
// this.scrollIntoView = `dev-console-${this.consoleList.length - 1}`;
|
|
138
|
+
// }
|
|
139
|
+
// }, 200),
|
|
140
|
+
// );
|
|
141
|
+
// },
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<style scoped>
|
|
147
|
+
.console-content {
|
|
148
|
+
height: 100%;
|
|
149
|
+
font-size: var(--dev-tool-base-font-size);
|
|
150
|
+
}
|
|
151
|
+
.console-list {
|
|
152
|
+
height: calc(100% - 32px - 32px);
|
|
153
|
+
}
|
|
154
|
+
.console-control {
|
|
155
|
+
display: flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: space-between;
|
|
158
|
+
gap: 8px;
|
|
159
|
+
padding: 0 16px;
|
|
160
|
+
height: 32px;
|
|
161
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
}
|
|
164
|
+
</style>
|