vite-uni-dev-tool 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dev/components/Code/index.vue +227 -0
- package/dev/components/ConsoleList/Code.vue +1 -1
- package/dev/components/ConsoleList/ConsoleItem.vue +38 -12
- package/dev/components/ConsoleList/RunJSInput.vue +59 -0
- package/dev/components/ConsoleList/index.vue +24 -8
- package/dev/components/DevTool/index.vue +1 -1
- package/dev/components/DevToolButton/index.vue +10 -10
- package/dev/components/DevToolWindow/index.vue +21 -2
- package/dev/components/FilterInput/index.vue +1 -1
- package/dev/components/JsonPretty/components/CheckController/index.vue +22 -5
- package/dev/components/JsonPretty/components/TreeNode/index.vue +16 -15
- package/dev/components/JsonPretty/index.vue +77 -75
- package/dev/components/JsonPretty/type.ts +2 -0
- package/dev/components/NetworkList/NetworkDetail.vue +1 -1
- package/dev/components/RunJS/index.vue +128 -0
- package/dev/components/SettingList/index.vue +1 -1
- package/dev/components/UniEvent/UniEventItem.vue +72 -3
- package/dev/components/UniEvent/index.vue +10 -1
- package/dev/components/UploadList/UploadDetail.vue +1 -1
- package/dev/components/VirtualList/index.vue +112 -0
- package/dev/components/WebSocket/WebSocketList.vue +1 -1
- package/dev/const.ts +97 -26
- package/dev/core.ts +0 -2
- package/dev/devConsole/index.ts +21 -4
- package/dev/devEvent/index.ts +85 -1
- package/dev/devIntercept/index.ts +27 -21
- package/dev/devRunJS/index.ts +170 -0
- package/dev/devStore/index.ts +13 -3
- package/dev/index.d.ts +3 -2
- package/dev/index.js +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +2 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +36 -38
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +2 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -9
- package/dev/plugins/utils/index.d.ts +10 -2
- package/dev/plugins/utils/index.d.ts.map +1 -1
- package/dev/plugins/utils/index.js +1 -1
- package/dev/type.ts +38 -2
- package/dev/utils/index.ts +10 -1
- package/dev/utils/language.ts +53 -0
- package/dev/utils/object.ts +64 -1
- package/dev/utils/string.ts +5 -5
- package/package.json +2 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view
|
|
3
|
+
v-if="autoVirtual"
|
|
4
|
+
scroll-y
|
|
5
|
+
class="virtual-list"
|
|
6
|
+
:style="{
|
|
7
|
+
height: `${props.height}px`,
|
|
8
|
+
}"
|
|
9
|
+
@scroll="onVirtualScroll"
|
|
10
|
+
>
|
|
11
|
+
<view
|
|
12
|
+
class="virtual-list-holder"
|
|
13
|
+
:style="{
|
|
14
|
+
height: `${props.data.length * props.itemHeight}px`,
|
|
15
|
+
}"
|
|
16
|
+
>
|
|
17
|
+
<view
|
|
18
|
+
class="virtual-list-holder-inner"
|
|
19
|
+
:style="{
|
|
20
|
+
transform: `translateY(${state.translateY}px)`,
|
|
21
|
+
}"
|
|
22
|
+
>
|
|
23
|
+
<slot :list="state.visibleData"></slot>
|
|
24
|
+
</view>
|
|
25
|
+
</view>
|
|
26
|
+
</scroll-view>
|
|
27
|
+
<view
|
|
28
|
+
v-else
|
|
29
|
+
class="normal-list"
|
|
30
|
+
:style="{
|
|
31
|
+
height: `${props.height}px`,
|
|
32
|
+
}"
|
|
33
|
+
>
|
|
34
|
+
<slot :list="state.visibleData"></slot>
|
|
35
|
+
</view>
|
|
36
|
+
</template>
|
|
37
|
+
<script lang="ts" setup>
|
|
38
|
+
import { computed, onMounted, reactive, watchEffect } from 'vue';
|
|
39
|
+
const props = defineProps<{
|
|
40
|
+
/** 虚拟列表高度 */
|
|
41
|
+
height: number;
|
|
42
|
+
/** 每一项高度 */
|
|
43
|
+
itemHeight: number;
|
|
44
|
+
/** 渲染的数据列表 */
|
|
45
|
+
data: any[];
|
|
46
|
+
/** 虚拟列表自动开启行数 */
|
|
47
|
+
autoVirtualRow?: number;
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
const state = reactive<{ translateY: number; visibleData: any[] }>({
|
|
51
|
+
translateY: 0,
|
|
52
|
+
visibleData: [],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const autoVirtual = computed(() => {
|
|
56
|
+
if (typeof props.autoVirtualRow === 'number') {
|
|
57
|
+
if (props.data.length > props.autoVirtualRow) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
function updateVisibleData(scrollTop: number = 0) {
|
|
66
|
+
const flatDataValue = props.data ?? [];
|
|
67
|
+
if (autoVirtual.value) {
|
|
68
|
+
const visibleCount = props.height / props.itemHeight;
|
|
69
|
+
const scrollCount = Math.floor(scrollTop / props.itemHeight);
|
|
70
|
+
let start =
|
|
71
|
+
scrollCount < 0
|
|
72
|
+
? 0
|
|
73
|
+
: scrollCount + visibleCount > flatDataValue.length
|
|
74
|
+
? flatDataValue.length - visibleCount
|
|
75
|
+
: scrollCount;
|
|
76
|
+
if (start < 0) {
|
|
77
|
+
start = 0;
|
|
78
|
+
}
|
|
79
|
+
const end = start + visibleCount;
|
|
80
|
+
state.translateY = start * props.itemHeight;
|
|
81
|
+
state.visibleData = state.visibleData = props.data.slice(start, end);
|
|
82
|
+
} else {
|
|
83
|
+
state.visibleData = flatDataValue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function onVirtualScroll(e: { detail: { scrollTop: number } }) {
|
|
88
|
+
updateVisibleData(e?.detail?.scrollTop ?? 0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
watchEffect(() => {
|
|
92
|
+
if (props.data) {
|
|
93
|
+
updateVisibleData();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
onMounted(() => {
|
|
98
|
+
updateVisibleData();
|
|
99
|
+
});
|
|
100
|
+
</script>
|
|
101
|
+
<style scoped>
|
|
102
|
+
.normal-list,
|
|
103
|
+
.virtual-list {
|
|
104
|
+
position: relative;
|
|
105
|
+
width: 100%;
|
|
106
|
+
overflow: auto;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.virtual-list-holder {
|
|
110
|
+
position: relative;
|
|
111
|
+
}
|
|
112
|
+
</style>
|
package/dev/const.ts
CHANGED
|
@@ -10,88 +10,159 @@ export const EVENT_DEV_BUTTON = 'event-dev-button';
|
|
|
10
10
|
*/
|
|
11
11
|
export const EVENT_DEV_WINDOW = 'event-dev-window';
|
|
12
12
|
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* app 发出的信息
|
|
15
|
+
*/
|
|
14
16
|
export const DEV_APP_MESSAGE = 'dev-app-message';
|
|
15
17
|
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* 调试弹窗发出的消息
|
|
20
|
+
*/
|
|
17
21
|
export const DEV_WINDOW_MESSAGE = 'dev-window-message';
|
|
18
22
|
|
|
19
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* 缓存调试按钮信息
|
|
25
|
+
*/
|
|
20
26
|
export const DEV_BUTTON_INFO = 'dev-button-info';
|
|
21
27
|
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* 缓存调试弹窗信息
|
|
30
|
+
*/
|
|
23
31
|
export const DEV_WINDOW_INFO = ' dev-window-info';
|
|
24
32
|
|
|
25
33
|
export const DEV_IS_DESTROY = 'dev-is-destroy';
|
|
26
34
|
|
|
27
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* 清空console
|
|
37
|
+
*/
|
|
28
38
|
export const DEV_CONSOLE_CLEAR = 'dev-console-clear';
|
|
29
39
|
|
|
30
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* 清空network
|
|
42
|
+
*/
|
|
31
43
|
export const DEV_NETWORK_CLEAR = 'dev-network-clear';
|
|
32
44
|
|
|
33
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* 清空websocket
|
|
47
|
+
*/
|
|
34
48
|
export const DEV_WEBSOCKET_CLEAR = 'dev-websocket-clear';
|
|
35
49
|
|
|
36
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* 清空upload
|
|
52
|
+
*/
|
|
37
53
|
export const DEV_UPLOAD_CLEAR = 'dev-upload-clear';
|
|
38
54
|
|
|
39
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* 清空storage
|
|
57
|
+
*/
|
|
40
58
|
export const DEV_STORAGE_CLEAR = 'dev-storage-clear';
|
|
41
59
|
|
|
42
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* 刷新storage
|
|
62
|
+
*/
|
|
43
63
|
export const DEV_STORAGE_REFRESH = 'dev-storage-refresh';
|
|
44
64
|
|
|
45
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* 移除storage
|
|
67
|
+
*/
|
|
46
68
|
export const DEV_STORAGE_REMOVE = 'dev-storage-remove';
|
|
47
69
|
|
|
48
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* 新增storage
|
|
72
|
+
*/
|
|
49
73
|
export const DEV_STORAGE_ADD = 'dev-storage-add';
|
|
50
74
|
|
|
51
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* 更新storage
|
|
77
|
+
*/
|
|
52
78
|
export const DEV_STORAGE_UPDATE = 'dev-storage-update';
|
|
53
79
|
|
|
54
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* 页面跳转
|
|
82
|
+
*/
|
|
55
83
|
export const DEV_PAGE_JUMP = 'dev-page-jump';
|
|
56
84
|
|
|
57
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* 隐藏调试按钮
|
|
87
|
+
*/
|
|
58
88
|
export const DEV_BUTTON_SHOW_OR_HIDE = 'dev-button-show-or-hide';
|
|
59
89
|
|
|
60
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* 重启调试器
|
|
92
|
+
*/
|
|
61
93
|
export const DEV_RESTART_DEBUGGER = 'dev-restart-debugger';
|
|
62
94
|
|
|
63
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* 重启app
|
|
97
|
+
*/
|
|
64
98
|
export const DEV_RESTART_APP = 'dev-restart-app';
|
|
65
99
|
|
|
66
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* 导出日志
|
|
102
|
+
*/
|
|
67
103
|
export const DEV_EXPORT_LOG = 'dev-export-log';
|
|
68
104
|
|
|
69
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* 改变vuex数据
|
|
107
|
+
*/
|
|
70
108
|
export const DEV_VUEX_CHANGE = 'dev-vuex-change';
|
|
71
109
|
|
|
72
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* 改变pinia
|
|
112
|
+
*/
|
|
73
113
|
export const DEV_PINIA_CHANGE = 'dev-pinia-change';
|
|
74
114
|
|
|
75
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* 清除日志缓存
|
|
117
|
+
*/
|
|
76
118
|
export const DEV_LOG_CACHE_CLEAR = 'dev-log-cache-clear';
|
|
77
119
|
|
|
78
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* 销毁调试工具
|
|
122
|
+
*/
|
|
79
123
|
export const DEV_DESTROY = 'dev-destroy';
|
|
80
124
|
|
|
81
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* 显示调试弹窗
|
|
127
|
+
*/
|
|
82
128
|
export const DEV_WINDOW_OPEN = 'dev-window-open';
|
|
83
129
|
|
|
84
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* 显示调试弹窗
|
|
132
|
+
*/
|
|
85
133
|
export const DEV_WINDOW_CLOSE = 'dev-window-close';
|
|
86
134
|
|
|
87
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* 刷新路由列表
|
|
137
|
+
*/
|
|
88
138
|
export const DEV_ROUTE_REFRESH = 'dev-route-refresh';
|
|
89
139
|
|
|
90
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* 获取 dev option
|
|
142
|
+
*/
|
|
91
143
|
export const DEV_OPTION = 'dev-option';
|
|
92
144
|
|
|
145
|
+
/**
|
|
146
|
+
* 获取options
|
|
147
|
+
*/
|
|
93
148
|
export const DEV_OPTION_GET = 'dev-option-get';
|
|
94
149
|
|
|
150
|
+
/**
|
|
151
|
+
* 发送 options
|
|
152
|
+
*/
|
|
95
153
|
export const DEV_OPTION_SEND = 'dev-option-send';
|
|
96
154
|
|
|
155
|
+
/**
|
|
156
|
+
* 清空事件
|
|
157
|
+
*/
|
|
97
158
|
export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 运行js
|
|
162
|
+
*/
|
|
163
|
+
export const DEV_RUN_JS = 'dev-uni-run-js';
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 清空运行的js
|
|
167
|
+
*/
|
|
168
|
+
export const DEV_RUN_JS_CLEAR = 'dev-uni-run-js-clear';
|
package/dev/core.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// import DevToolComponent from './components/DevTool/index.vue';
|
|
2
1
|
import { DevStore } from './devStore';
|
|
3
2
|
import { DevEvent } from './devEvent';
|
|
4
3
|
import { DevIntercept } from './devIntercept';
|
|
@@ -103,7 +102,6 @@ function interceptPiniaStore(context: any) {
|
|
|
103
102
|
uni.__dev__console = console;
|
|
104
103
|
|
|
105
104
|
export {
|
|
106
|
-
// DevToolComponent,
|
|
107
105
|
backup,
|
|
108
106
|
console,
|
|
109
107
|
initDevTool,
|
package/dev/devConsole/index.ts
CHANGED
|
@@ -3,8 +3,9 @@ import type { DevTool } from '../type';
|
|
|
3
3
|
import {
|
|
4
4
|
getCurrentDate,
|
|
5
5
|
getCurrentPagePath,
|
|
6
|
+
transformValueToView,
|
|
6
7
|
isArray,
|
|
7
|
-
|
|
8
|
+
parseValue,
|
|
8
9
|
} from '../utils/index';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -58,7 +59,13 @@ export class DevConsole {
|
|
|
58
59
|
const stackList = new Error()?.stack?.split('\n');
|
|
59
60
|
const stack = stackList?.slice(3)?.[0];
|
|
60
61
|
|
|
61
|
-
let argList = args?.map((item) =>
|
|
62
|
+
let argList = args?.map((item) => {
|
|
63
|
+
return {
|
|
64
|
+
type: transformValueToView(item),
|
|
65
|
+
// 处理 item 循环引用问题
|
|
66
|
+
value: parseValue(item),
|
|
67
|
+
};
|
|
68
|
+
});
|
|
62
69
|
|
|
63
70
|
if (isArray(args) && args.length > 0) {
|
|
64
71
|
this.event.updateConsoleList([
|
|
@@ -153,7 +160,12 @@ export class DevConsole {
|
|
|
153
160
|
type: 'log',
|
|
154
161
|
position,
|
|
155
162
|
time,
|
|
156
|
-
args: [
|
|
163
|
+
args: [
|
|
164
|
+
{
|
|
165
|
+
type: 'string',
|
|
166
|
+
value: `${label ?? '[DevTool timeEnd error]'}: ${duration}ms`,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
157
169
|
stack,
|
|
158
170
|
},
|
|
159
171
|
]);
|
|
@@ -196,7 +208,12 @@ export class DevConsole {
|
|
|
196
208
|
type: 'log',
|
|
197
209
|
position: getCurrentPagePath(),
|
|
198
210
|
time: getCurrentDate(),
|
|
199
|
-
args: [
|
|
211
|
+
args: [
|
|
212
|
+
{
|
|
213
|
+
type: 'string',
|
|
214
|
+
value: `${label}: ${this.countMap.get(label)}`,
|
|
215
|
+
},
|
|
216
|
+
],
|
|
200
217
|
stack,
|
|
201
218
|
},
|
|
202
219
|
]);
|
package/dev/devEvent/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
DEV_OPTION_GET,
|
|
30
30
|
DEV_OPTION_SEND,
|
|
31
31
|
DEV_UNI_EVENT_CLEAR,
|
|
32
|
+
DEV_RUN_JS,
|
|
32
33
|
} from '../const';
|
|
33
34
|
import { DevStore } from '../devStore';
|
|
34
35
|
import type { DevTool } from '../type';
|
|
@@ -39,6 +40,10 @@ import {
|
|
|
39
40
|
saveTxtFileApp,
|
|
40
41
|
saveTextFileH5,
|
|
41
42
|
saveTextFileMicro,
|
|
43
|
+
getCurrentDate,
|
|
44
|
+
isNil,
|
|
45
|
+
transformValueToView,
|
|
46
|
+
parseValue,
|
|
42
47
|
} from '../utils/index';
|
|
43
48
|
import type { EventBus } from '../devEventBus';
|
|
44
49
|
|
|
@@ -315,6 +320,7 @@ export class DevEvent {
|
|
|
315
320
|
exportWindow: boolean;
|
|
316
321
|
exportDevice: boolean;
|
|
317
322
|
exportSystem: boolean;
|
|
323
|
+
code: string;
|
|
318
324
|
[key: string]: any;
|
|
319
325
|
};
|
|
320
326
|
}) => {
|
|
@@ -415,9 +421,15 @@ export class DevEvent {
|
|
|
415
421
|
// 获取dev options 数据
|
|
416
422
|
else if (data.type === DEV_OPTION_GET) {
|
|
417
423
|
this.sendDevToolOption();
|
|
418
|
-
}
|
|
424
|
+
}
|
|
425
|
+
// 清空事件
|
|
426
|
+
else if (data.type === DEV_UNI_EVENT_CLEAR) {
|
|
419
427
|
this.uniEventClear();
|
|
420
428
|
}
|
|
429
|
+
// 运行 js
|
|
430
|
+
else if (data.type === DEV_RUN_JS) {
|
|
431
|
+
this.devRunJS(data.data.code);
|
|
432
|
+
}
|
|
421
433
|
},
|
|
422
434
|
);
|
|
423
435
|
}
|
|
@@ -692,4 +704,76 @@ export class DevEvent {
|
|
|
692
704
|
uni.$emit = backup.$emit;
|
|
693
705
|
uni.$off = backup.$off;
|
|
694
706
|
}
|
|
707
|
+
|
|
708
|
+
execute(code: any): Promise<any> {
|
|
709
|
+
const evalFunction = '_e_v_a_l_'.replace(
|
|
710
|
+
/_/g,
|
|
711
|
+
'',
|
|
712
|
+
) as keyof typeof globalThis;
|
|
713
|
+
|
|
714
|
+
if (!globalThis?.[evalFunction]) {
|
|
715
|
+
return Promise.reject(
|
|
716
|
+
new Error('[DevTool] DevRunJS 当前环境不支持执行js'),
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return Promise.resolve(globalThis?.[evalFunction](code));
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* 运行js
|
|
725
|
+
*
|
|
726
|
+
* @param {string} code
|
|
727
|
+
* @memberof DevEvent
|
|
728
|
+
*/
|
|
729
|
+
devRunJS(code: string) {
|
|
730
|
+
const start = Date.now();
|
|
731
|
+
const consoleItem: DevTool.ConsoleItem = {
|
|
732
|
+
type: 'log',
|
|
733
|
+
args: [
|
|
734
|
+
{
|
|
735
|
+
type: 'string',
|
|
736
|
+
value: code,
|
|
737
|
+
},
|
|
738
|
+
],
|
|
739
|
+
position: 'dev/devEvent/index.ts',
|
|
740
|
+
time: getCurrentDate(),
|
|
741
|
+
stack: 'http://usr/devRunJS',
|
|
742
|
+
mode: 'input',
|
|
743
|
+
};
|
|
744
|
+
console.log(code);
|
|
745
|
+
this.store.updateConsoleList([{ ...consoleItem }]);
|
|
746
|
+
|
|
747
|
+
this.postMessageFn();
|
|
748
|
+
|
|
749
|
+
this.execute(code)
|
|
750
|
+
.then((res) => {
|
|
751
|
+
consoleItem.args = [
|
|
752
|
+
{
|
|
753
|
+
type: transformValueToView(res),
|
|
754
|
+
value: parseValue(res),
|
|
755
|
+
},
|
|
756
|
+
];
|
|
757
|
+
consoleItem.position = `dev/devEvent/index.ts ${Date.now() - start}ms`;
|
|
758
|
+
consoleItem.time = getCurrentDate();
|
|
759
|
+
consoleItem.mode = 'output';
|
|
760
|
+
})
|
|
761
|
+
.catch((err: Error) => {
|
|
762
|
+
console.error(err);
|
|
763
|
+
consoleItem.args = [
|
|
764
|
+
{
|
|
765
|
+
type: 'string',
|
|
766
|
+
value: err.message,
|
|
767
|
+
},
|
|
768
|
+
];
|
|
769
|
+
consoleItem.position = `dev/devEvent/index.ts ${Date.now() - start}ms`;
|
|
770
|
+
consoleItem.time = getCurrentDate();
|
|
771
|
+
consoleItem.type = 'error';
|
|
772
|
+
consoleItem.mode = 'output';
|
|
773
|
+
})
|
|
774
|
+
.finally(() => {
|
|
775
|
+
this.store.updateConsoleList([{ ...consoleItem }]);
|
|
776
|
+
this.postMessageFn();
|
|
777
|
+
});
|
|
778
|
+
}
|
|
695
779
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DEV_APP_MESSAGE } from '../const';
|
|
2
1
|
import { backup } from '../core';
|
|
3
2
|
import { DevEvent } from '../devEvent';
|
|
4
3
|
import type { DevTool } from '../type';
|
|
@@ -6,9 +5,9 @@ import {
|
|
|
6
5
|
escapeHTML,
|
|
7
6
|
getCurrentDate,
|
|
8
7
|
getCurrentPagePath,
|
|
9
|
-
|
|
8
|
+
parseValue,
|
|
10
9
|
} from '../utils/index';
|
|
11
|
-
import {
|
|
10
|
+
import { transformValueToView } from '../utils/language';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* 拦截器
|
|
@@ -75,19 +74,11 @@ export class DevIntercept {
|
|
|
75
74
|
position: path,
|
|
76
75
|
time: getCurrentDate(),
|
|
77
76
|
args: args.map((item: any) => {
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
item === undefined ||
|
|
84
|
-
isNaN(item) ||
|
|
85
|
-
item === Infinity
|
|
86
|
-
) {
|
|
87
|
-
return item + '';
|
|
88
|
-
} else {
|
|
89
|
-
return item;
|
|
90
|
-
}
|
|
77
|
+
// 处理 item 循环引用的问题
|
|
78
|
+
return {
|
|
79
|
+
type: transformValueToView(item),
|
|
80
|
+
value: parseValue(item),
|
|
81
|
+
};
|
|
91
82
|
}),
|
|
92
83
|
stack: line,
|
|
93
84
|
},
|
|
@@ -144,7 +135,12 @@ export class DevIntercept {
|
|
|
144
135
|
this.event.updateConsoleList([
|
|
145
136
|
{
|
|
146
137
|
type: 'error',
|
|
147
|
-
args: [
|
|
138
|
+
args: [
|
|
139
|
+
{
|
|
140
|
+
type: 'string',
|
|
141
|
+
value: info,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
148
144
|
position: getCurrentPagePath(),
|
|
149
145
|
time: getCurrentDate(),
|
|
150
146
|
stack,
|
|
@@ -169,7 +165,12 @@ export class DevIntercept {
|
|
|
169
165
|
this.event.updateConsoleList([
|
|
170
166
|
{
|
|
171
167
|
type: 'error',
|
|
172
|
-
args: [
|
|
168
|
+
args: [
|
|
169
|
+
{
|
|
170
|
+
type: 'string',
|
|
171
|
+
value: error.toString(),
|
|
172
|
+
},
|
|
173
|
+
],
|
|
173
174
|
position: getCurrentPagePath(),
|
|
174
175
|
time: getCurrentDate(),
|
|
175
176
|
stack,
|
|
@@ -204,7 +205,12 @@ export class DevIntercept {
|
|
|
204
205
|
this.event.updateConsoleList([
|
|
205
206
|
{
|
|
206
207
|
type: 'warn',
|
|
207
|
-
args: [
|
|
208
|
+
args: [
|
|
209
|
+
{
|
|
210
|
+
type: 'string',
|
|
211
|
+
value: args,
|
|
212
|
+
},
|
|
213
|
+
],
|
|
208
214
|
position: path,
|
|
209
215
|
time: getCurrentDate(),
|
|
210
216
|
stack,
|
|
@@ -695,14 +701,14 @@ export class DevIntercept {
|
|
|
695
701
|
|
|
696
702
|
uni[`$${type}`] = (eventName: string, callback: (result: any) => void) => {
|
|
697
703
|
const stockList = new Error()?.stack?.split('\n');
|
|
698
|
-
const
|
|
704
|
+
const stack = stockList?.[2];
|
|
699
705
|
backup?.[key]?.(eventName, callback);
|
|
700
706
|
|
|
701
707
|
this.event.updateUniEventList([
|
|
702
708
|
{
|
|
703
709
|
eventName,
|
|
704
710
|
timer: getCurrentDate(),
|
|
705
|
-
|
|
711
|
+
stack,
|
|
706
712
|
type,
|
|
707
713
|
},
|
|
708
714
|
]);
|