vite-uni-dev-tool 0.0.3 → 0.0.5
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 +36 -6
- package/dev/components/CloseButton/index.vue +1 -0
- package/dev/components/ConsoleList/Code.vue +214 -0
- package/dev/components/ConsoleList/ConsoleItem.vue +80 -9
- package/dev/components/ConsoleList/index.vue +6 -0
- package/dev/components/DevTool/index.vue +16 -0
- package/dev/components/DevToolWindow/index.vue +11 -2
- package/dev/components/RouteList/index.vue +1 -1
- package/dev/core.ts +7 -1
- package/dev/devConsole/index.ts +0 -1
- package/dev/devEvent/index.ts +1 -1
- package/dev/devIntercept/index.ts +76 -21
- package/dev/devStore/index.ts +24 -3
- package/dev/index.d.ts +4 -5
- package/dev/index.js +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +71 -65
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +38 -13
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +32 -27
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +9 -5
- package/dev/plugins/utils/index.d.ts +53 -0
- package/dev/plugins/utils/index.d.ts.map +1 -0
- package/dev/plugins/utils/index.js +1 -0
- package/dev/type.ts +13 -1
- package/dev/utils/index.d.ts +6 -0
- package/dev/utils/index.ts +10 -1
- package/dev/utils/platform.ts +14 -0
- package/dev/utils/string.ts +102 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# vite-uni-dev-tool
|
|
2
2
|
|
|
3
|
-
用于 vue3 + ts + uni-app 的开发调试插件
|
|
3
|
+
用于 vue3 + ts + hooks + uni-app 的开发调试插件
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -28,7 +28,7 @@ import * as path from 'path';
|
|
|
28
28
|
// https://vitejs.dev/config/
|
|
29
29
|
export default defineConfig({
|
|
30
30
|
plugins: [
|
|
31
|
-
// 一定要在 uni() 之前调用
|
|
31
|
+
// 一定要在 uni() 之前调用 否则微信小程序将无法正常编译组件
|
|
32
32
|
uniDevTool({
|
|
33
33
|
pages,
|
|
34
34
|
}),
|
|
@@ -46,20 +46,50 @@ export default defineConfig({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
### 为什么不用 subPackages?
|
|
50
|
+
|
|
51
|
+
- 从当前页跳转到subPackages页面时,会触发 uni-app 页面生命周期,有时是不希望如此的,比如在开发过程中,希望可以直接在当前页面进行调试。
|
|
52
|
+
|
|
53
|
+
### 如何将 console 日志输出到控制台
|
|
54
|
+
|
|
55
|
+
- 0.0.5版本之后为了在生产环境中移除插件,开发环境中插件将会自动导入 `console`,无需手动导入
|
|
56
|
+
|
|
57
|
+
- 0.0.5版本之后不推荐使用 `uni.__dev__console` , 在未来版本中可能会进行移除
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
// 方法 1
|
|
61
|
+
import { console } from 'vite-uni-dev-tool/dev/core';
|
|
62
|
+
|
|
63
|
+
console.log('hello vite-uni-dev-tool');
|
|
64
|
+
|
|
65
|
+
// 方法 2
|
|
66
|
+
|
|
67
|
+
uni.__dev__console.log('hello vite-uni-dev-tool');
|
|
68
|
+
```
|
|
69
|
+
|
|
49
70
|
### 注意事项
|
|
50
71
|
|
|
51
72
|
### 兼容性说明
|
|
52
73
|
|
|
53
74
|
| vue2 | vue3 |
|
|
54
75
|
| ---- | ---- |
|
|
55
|
-
|
|
|
76
|
+
| N | Y |
|
|
77
|
+
|
|
78
|
+
| 微信小程序 | 安卓 | 其他 |
|
|
79
|
+
| ---------- | ---- | ------ |
|
|
80
|
+
| Y | Y | 未测试 |
|
|
56
81
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
82
|
+
### 安全性声明
|
|
83
|
+
|
|
84
|
+
插件不收收集任何信息,只开发人员调试使用
|
|
85
|
+
|
|
86
|
+
- 插件中使用到了 `fs`,用于栈信息获取源代码文件
|
|
87
|
+
- 插件使用了 `uni.request` ,用于栈信息获取源代码文件
|
|
60
88
|
|
|
61
89
|
### 预览
|
|
62
90
|
|
|
91
|
+

|
|
92
|
+
|
|
63
93
|
- 支持 console 日志
|
|
64
94
|
|
|
65
95
|

|
|
@@ -0,0 +1,214 @@
|
|
|
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.row ? '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 = props?.url?.split('/')?.pop() ?? '文件名称未知';
|
|
53
|
+
return name;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const activeRowCol = ref({ row: -1, col: -1 });
|
|
57
|
+
|
|
58
|
+
let backupCodes: string[] = [];
|
|
59
|
+
|
|
60
|
+
const codes = ref<string[]>([]);
|
|
61
|
+
|
|
62
|
+
const scrollIntoView = ref('');
|
|
63
|
+
|
|
64
|
+
function onClose() {
|
|
65
|
+
emit('close');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function onSearch(value: string) {
|
|
69
|
+
codes.value = backupCodes.map((code) => {
|
|
70
|
+
return hightLight(code, value);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let index = 0;
|
|
75
|
+
function getCode(url: string, i: number = 0) {
|
|
76
|
+
let allUrl = url;
|
|
77
|
+
// 平台判断
|
|
78
|
+
if (isAndroid()) {
|
|
79
|
+
if (!props.sourceFileServers?.[i]) {
|
|
80
|
+
index = 0;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
allUrl = props.sourceFileServers?.[i] + '/src/' + url;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
uni.showLoading({ mask: true });
|
|
88
|
+
uni.request({
|
|
89
|
+
url: allUrl,
|
|
90
|
+
success: (res) => {
|
|
91
|
+
if (typeof res.data === 'string') {
|
|
92
|
+
// 为什么要注释掉?
|
|
93
|
+
// 在 Android 识别到标签后会进行重启,导致代码无法显示
|
|
94
|
+
// TODO: 还有其它原因导致重启
|
|
95
|
+
const str = res.data
|
|
96
|
+
?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
|
|
97
|
+
?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
|
|
98
|
+
?.replace(/<style/, '// [DevTool] 注释 <style')
|
|
99
|
+
?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
|
|
100
|
+
backupCodes = escapeHTML(str ?? '')
|
|
101
|
+
.toString()
|
|
102
|
+
.split('\n');
|
|
103
|
+
|
|
104
|
+
codes.value = backupCodes;
|
|
105
|
+
|
|
106
|
+
nextTick(() => {
|
|
107
|
+
scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.row}`;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
fail: (err) => {
|
|
112
|
+
index++;
|
|
113
|
+
getCode(url, index);
|
|
114
|
+
uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
|
|
115
|
+
},
|
|
116
|
+
complete: () => {
|
|
117
|
+
uni.hideLoading();
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** 开发环境获取源代码 */
|
|
123
|
+
function getSourceCodeDev(url: string) {
|
|
124
|
+
if (!url) {
|
|
125
|
+
uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
|
|
126
|
+
uni?.__dev__console?.log('[DevTool] url 处理异常');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getCode(url, index);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
onMounted(() => {
|
|
134
|
+
let url = props?.url;
|
|
135
|
+
|
|
136
|
+
const { path, col, row } = parseStock(props?.url ?? '');
|
|
137
|
+
|
|
138
|
+
if (path) {
|
|
139
|
+
url = path;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
activeRowCol.value = {
|
|
143
|
+
col,
|
|
144
|
+
row,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
if (props.mode === 'development') {
|
|
148
|
+
// 开发环境查看源码
|
|
149
|
+
getSourceCodeDev(url);
|
|
150
|
+
} else if (props.mode === 'production') {
|
|
151
|
+
// TODO 生产环境查看源码
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
</script>
|
|
155
|
+
<style scoped>
|
|
156
|
+
.dev-tool-code {
|
|
157
|
+
position: fixed;
|
|
158
|
+
width: 100vw;
|
|
159
|
+
height: 100vh;
|
|
160
|
+
z-index: 10000;
|
|
161
|
+
top: 0;
|
|
162
|
+
left: 0;
|
|
163
|
+
padding: 0 16px;
|
|
164
|
+
/* #ifdef H5 */
|
|
165
|
+
padding: 50px 16px;
|
|
166
|
+
/* #endif */
|
|
167
|
+
|
|
168
|
+
background-color: rgba(255, 255, 255, 0.95);
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
color: #000;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.dev-tool-code-control {
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
gap: 12px;
|
|
177
|
+
height: 32px;
|
|
178
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
179
|
+
box-sizing: border-box;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.dev-tool-code-title {
|
|
183
|
+
height: 32px;
|
|
184
|
+
line-height: 32px;
|
|
185
|
+
margin-bottom: 4px;
|
|
186
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
187
|
+
box-sizing: border-box;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.dev-tool-code-list {
|
|
191
|
+
height: calc(100% - 68px);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.dev-tool-code-item {
|
|
195
|
+
display: flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
height: 28px;
|
|
198
|
+
}
|
|
199
|
+
.dev-tool-code-item-active {
|
|
200
|
+
color: #fff;
|
|
201
|
+
background-color: var(--dev-tool-main-color);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.dev-tool-code-item-index {
|
|
205
|
+
flex-shrink: 0;
|
|
206
|
+
width: 20px;
|
|
207
|
+
margin-right: 8px;
|
|
208
|
+
text-align: right;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.dev-tool-code-item-content {
|
|
212
|
+
white-space: pre;
|
|
213
|
+
}
|
|
214
|
+
</style>
|
|
@@ -18,21 +18,85 @@
|
|
|
18
18
|
<view class="console-time">{{ consoleItem.time }}</view>
|
|
19
19
|
<view class="console-other" v-html="consoleItem.position"></view>
|
|
20
20
|
<view
|
|
21
|
-
class="console-other"
|
|
21
|
+
:class="`console-other ${isUseDevSource ? 'console-stack' : ''}`"
|
|
22
22
|
v-if="consoleItem.stack"
|
|
23
23
|
v-html="consoleItem.stack"
|
|
24
|
+
@click="onStackClick"
|
|
24
25
|
></view>
|
|
25
26
|
</view>
|
|
26
27
|
</view>
|
|
27
28
|
</view>
|
|
28
29
|
<!-- <view class="console-copy">C</view> -->
|
|
30
|
+
<Code
|
|
31
|
+
v-if="openCode && consoleItem.stack"
|
|
32
|
+
:url="consoleItem.stack"
|
|
33
|
+
:sourceFileServers="sourceFileServers"
|
|
34
|
+
:mode="mode"
|
|
35
|
+
@close="onCloseCode"
|
|
36
|
+
/>
|
|
29
37
|
</view>
|
|
30
38
|
</template>
|
|
31
39
|
|
|
32
40
|
<script setup lang="ts">
|
|
41
|
+
import { ref, computed } from 'vue';
|
|
33
42
|
import Tag from '../Tag/index.vue';
|
|
43
|
+
import Code from './Code.vue';
|
|
34
44
|
import type { DevTool } from '../../type';
|
|
35
|
-
|
|
45
|
+
import { isAndroid, isMockWX } from '../../utils';
|
|
46
|
+
const props = defineProps<{
|
|
47
|
+
consoleItem: DevTool.ConsoleItem;
|
|
48
|
+
sourceFileServers?: string[];
|
|
49
|
+
mode?: string;
|
|
50
|
+
useDevSource?: boolean;
|
|
51
|
+
}>();
|
|
52
|
+
|
|
53
|
+
const openCode = ref(false);
|
|
54
|
+
|
|
55
|
+
const isUseDevSource = computed(() => {
|
|
56
|
+
return (
|
|
57
|
+
!isMockWX(props?.consoleItem?.stack ?? '') &&
|
|
58
|
+
props.mode === 'development' &&
|
|
59
|
+
props.useDevSource
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const isWXLink = computed(() => {
|
|
64
|
+
return (
|
|
65
|
+
isMockWX(props?.consoleItem?.stack ?? '') || props.mode !== 'development'
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
function onStackClick() {
|
|
70
|
+
if (isWXLink.value) {
|
|
71
|
+
uni.showToast({
|
|
72
|
+
icon: 'none',
|
|
73
|
+
title: '[DevTool] 请在小程序真机调试模式下查看源码',
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!isUseDevSource.value) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isAndroid()) {
|
|
83
|
+
if (props.sourceFileServers && props.sourceFileServers.length > 0) {
|
|
84
|
+
openCode.value = true;
|
|
85
|
+
} else {
|
|
86
|
+
uni.showToast({
|
|
87
|
+
icon: 'none',
|
|
88
|
+
title: '[DevTool] sourceFileServers 配置异常',
|
|
89
|
+
});
|
|
90
|
+
uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
openCode.value = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function onCloseCode() {
|
|
98
|
+
openCode.value = false;
|
|
99
|
+
}
|
|
36
100
|
</script>
|
|
37
101
|
<style scoped>
|
|
38
102
|
.console-item {
|
|
@@ -41,19 +105,20 @@ defineProps<{ consoleItem: DevTool.ConsoleItem }>();
|
|
|
41
105
|
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
42
106
|
font-size: var(--dev-tool-base-font-size);
|
|
43
107
|
}
|
|
44
|
-
.console-
|
|
108
|
+
.console-info {
|
|
45
109
|
flex: 1;
|
|
46
110
|
}
|
|
47
|
-
.console-
|
|
111
|
+
.console-args {
|
|
48
112
|
display: flex;
|
|
49
113
|
flex-wrap: wrap;
|
|
50
114
|
color: #000;
|
|
51
115
|
}
|
|
52
|
-
.console-
|
|
116
|
+
.console-arg {
|
|
53
117
|
margin-right: 4px;
|
|
118
|
+
white-space: pre-line;
|
|
54
119
|
word-break: break-all;
|
|
55
120
|
}
|
|
56
|
-
.console-
|
|
121
|
+
.console-position {
|
|
57
122
|
display: flex;
|
|
58
123
|
align-items: flex-start;
|
|
59
124
|
justify-content: space-between;
|
|
@@ -61,14 +126,20 @@ defineProps<{ consoleItem: DevTool.ConsoleItem }>();
|
|
|
61
126
|
color: #616161;
|
|
62
127
|
text-align: right;
|
|
63
128
|
}
|
|
64
|
-
.console-
|
|
129
|
+
.console-time {
|
|
65
130
|
margin-right: auto;
|
|
66
131
|
word-break: break-all;
|
|
67
132
|
}
|
|
68
|
-
.console-
|
|
133
|
+
.console-other {
|
|
69
134
|
word-break: break-all;
|
|
70
135
|
}
|
|
71
|
-
|
|
136
|
+
|
|
137
|
+
.console-stack {
|
|
138
|
+
text-decoration: underline;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.console-copy {
|
|
72
143
|
flex-shrink: 0;
|
|
73
144
|
margin-left: 16px;
|
|
74
145
|
display: flex;
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
v-for="(item, index) in consoleList"
|
|
21
21
|
:consoleItem="item"
|
|
22
22
|
:key="index"
|
|
23
|
+
:sourceFileServers="sourceFileServers"
|
|
24
|
+
:mode="mode"
|
|
25
|
+
:useDevSource="useDevSource"
|
|
23
26
|
/>
|
|
24
27
|
<Empty v-if="!consoleList || consoleList.length === 0" />
|
|
25
28
|
</view>
|
|
@@ -36,6 +39,9 @@ defineProps<{
|
|
|
36
39
|
consoleList: DevTool.ConsoleItem[];
|
|
37
40
|
currentConsoleType: string;
|
|
38
41
|
modelValue: string;
|
|
42
|
+
sourceFileServers?: string[];
|
|
43
|
+
mode?: string;
|
|
44
|
+
useDevSource?: boolean;
|
|
39
45
|
}>();
|
|
40
46
|
const emit = defineEmits<{
|
|
41
47
|
(e: 'choose', type: ConsoleType): void;
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
<DevToolWindow
|
|
13
13
|
:open="devToolWindowVisible"
|
|
14
14
|
:data="windowData"
|
|
15
|
+
:sourceFileServers="sourceFileServers"
|
|
16
|
+
:mode="mode"
|
|
17
|
+
:useDevSource="useDevSource"
|
|
15
18
|
@close="onShowDevToolWindow(false)"
|
|
16
19
|
@sendMessage="onSendMessage"
|
|
17
20
|
/>
|
|
@@ -51,6 +54,13 @@ const windowData = ref<DevTool.WindowData>({});
|
|
|
51
54
|
|
|
52
55
|
const devToolWindowVisible = ref(false);
|
|
53
56
|
const devToolButtonVisible = ref(false);
|
|
57
|
+
|
|
58
|
+
const sourceFileServers = ref<string[]>([]);
|
|
59
|
+
|
|
60
|
+
const mode = ref<string>();
|
|
61
|
+
|
|
62
|
+
const useDevSource = ref(false);
|
|
63
|
+
|
|
54
64
|
function onDevToolButtonClick() {
|
|
55
65
|
onShowDevToolWindow(true);
|
|
56
66
|
onSendMessage({
|
|
@@ -83,6 +93,12 @@ function onDevOptionSend(options: DevTool.DevToolOptions) {
|
|
|
83
93
|
buttonProps.buttonFontSize = options.buttonFontSize ?? '16px';
|
|
84
94
|
buttonProps.buttonBackgroundColor =
|
|
85
95
|
options.buttonBackgroundColor ?? 'rgba(255, 255, 255, 0)';
|
|
96
|
+
|
|
97
|
+
sourceFileServers.value = options.sourceFileServers ?? [];
|
|
98
|
+
|
|
99
|
+
mode.value = options.mode ?? '';
|
|
100
|
+
|
|
101
|
+
useDevSource.value = options.useDevSource ?? false;
|
|
86
102
|
}
|
|
87
103
|
}
|
|
88
104
|
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
<ConsoleList
|
|
21
21
|
:currentConsoleType="currentConsoleType"
|
|
22
22
|
:consoleList="consoleList"
|
|
23
|
+
:sourceFileServers="sourceFileServers"
|
|
24
|
+
:mode="mode"
|
|
25
|
+
:useDevSource="useDevSource"
|
|
23
26
|
v-if="activeTab === 'Console'"
|
|
24
27
|
v-model="searchConsole"
|
|
25
28
|
@choose="onConsoleChoose"
|
|
@@ -260,7 +263,13 @@ const searchWs = ref('');
|
|
|
260
263
|
const searchRoute = ref('');
|
|
261
264
|
const searchStorage = ref('');
|
|
262
265
|
|
|
263
|
-
const props = defineProps<{
|
|
266
|
+
const props = defineProps<{
|
|
267
|
+
open?: boolean;
|
|
268
|
+
data?: DevTool.WindowData;
|
|
269
|
+
sourceFileServers?: string[];
|
|
270
|
+
mode?: string;
|
|
271
|
+
useDevSource?: boolean;
|
|
272
|
+
}>();
|
|
264
273
|
|
|
265
274
|
const emits = defineEmits<{
|
|
266
275
|
(e: 'close'): void;
|
|
@@ -700,7 +709,7 @@ function onGoTo(page: DevTool.Page) {
|
|
|
700
709
|
type: DEV_PAGE_JUMP,
|
|
701
710
|
data: {
|
|
702
711
|
path: '/' + page.path,
|
|
703
|
-
|
|
712
|
+
type: page.type,
|
|
704
713
|
},
|
|
705
714
|
});
|
|
706
715
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<view class="route-item" v-for="item in routeList" :key="item.path">
|
|
15
15
|
<view class="route-item-name">
|
|
16
16
|
<view v-html="item.name" />
|
|
17
|
-
<Tag v-if="item.
|
|
17
|
+
<Tag v-if="item.type" mode="info">{{ item.type }}</Tag>
|
|
18
18
|
<Tag mode="warn" v-if="item.index === 4 || item.index === 3">
|
|
19
19
|
当前页
|
|
20
20
|
</Tag>
|
package/dev/core.ts
CHANGED
|
@@ -45,7 +45,13 @@ function getDevToolOptions() {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function initDevTool(options?: DevTool.DevToolOptions) {
|
|
48
|
-
|
|
48
|
+
if (!options?.mode) {
|
|
49
|
+
console.error('[DevTool] 请传入 mode: import.meta.env.MODE');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
store.setDevToolOptions(options || { mode: '' });
|
|
53
|
+
|
|
54
|
+
intercept.interceptVue3(options?.vue3instance);
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
function showDevToolButton() {
|
package/dev/devConsole/index.ts
CHANGED
|
@@ -56,7 +56,6 @@ export class DevConsole {
|
|
|
56
56
|
const time = getCurrentDate();
|
|
57
57
|
// 获取调用栈(从第4行开始,跳过 console.log 和 wrapper 函数)
|
|
58
58
|
const stackList = new Error()?.stack?.split('\n');
|
|
59
|
-
|
|
60
59
|
const stack = stackList?.slice(3)?.[0];
|
|
61
60
|
|
|
62
61
|
let argList = args?.map((item) => serializeCircular(item));
|
package/dev/devEvent/index.ts
CHANGED