vite-uni-dev-tool 0.0.5 → 0.0.7
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 +35 -1
- package/dev/components/Connection/index.vue +11 -21
- package/dev/components/ConsoleList/Code.vue +22 -9
- package/dev/components/DevTool/index.vue +9 -8
- package/dev/components/DevToolTitle/index.vue +21 -0
- package/dev/components/DevToolWindow/index.vue +41 -3
- package/dev/components/SettingList/index.vue +9 -19
- package/dev/components/UniEvent/UniEventItem.vue +55 -0
- package/dev/components/UniEvent/index.vue +85 -0
- package/dev/const.ts +4 -2
- package/dev/core.ts +12 -1
- package/dev/devEvent/index.ts +38 -8
- package/dev/devEventBus/index.ts +94 -0
- package/dev/devIntercept/index.ts +37 -0
- package/dev/devStore/index.ts +73 -0
- package/dev/index.d.ts +4 -4
- package/dev/index.js +1 -1
- package/dev/plugins/uniDevTool/uniDevTool.d.ts +71 -71
- package/dev/plugins/uniDevTool/uniDevTool.js +38 -38
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +32 -32
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +9 -9
- package/dev/plugins/utils/index.d.ts +52 -52
- package/dev/plugins/utils/index.js +1 -1
- package/dev/type.ts +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ uni.__dev__console.log('hello vite-uni-dev-tool');
|
|
|
81
81
|
|
|
82
82
|
### 安全性声明
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
插件不收收集任何信息,只供开发人员调试使用
|
|
85
85
|
|
|
86
86
|
- 插件中使用到了 `fs`,用于栈信息获取源代码文件
|
|
87
87
|
- 插件使用了 `uni.request` ,用于栈信息获取源代码文件
|
|
@@ -148,3 +148,37 @@ uni.__dev__console.log('hello vite-uni-dev-tool');
|
|
|
148
148
|
- setting 页,支持重启,导出日志(h5,app)
|
|
149
149
|
|
|
150
150
|

|
|
151
|
+
|
|
152
|
+
## 更新日志
|
|
153
|
+
|
|
154
|
+
### 0.0.07
|
|
155
|
+
|
|
156
|
+
- 监听uni.$on
|
|
157
|
+
- 监听uni.%once
|
|
158
|
+
- 监听uni.$emit
|
|
159
|
+
- 监听uni.$of
|
|
160
|
+
|
|
161
|
+
### 0.0.6
|
|
162
|
+
|
|
163
|
+
- 修复 app 查看 source 重启
|
|
164
|
+
|
|
165
|
+
### 0.0.5
|
|
166
|
+
|
|
167
|
+
- 修复 路由支持跳转 subPackages
|
|
168
|
+
- 增加栈位置查看(实验中功能)
|
|
169
|
+
|
|
170
|
+
### 0.0.4
|
|
171
|
+
|
|
172
|
+
- 修复初始启用状态
|
|
173
|
+
|
|
174
|
+
### 0.0.3
|
|
175
|
+
|
|
176
|
+
- 文档调整
|
|
177
|
+
|
|
178
|
+
### 0.0.2
|
|
179
|
+
|
|
180
|
+
- 文档调整
|
|
181
|
+
|
|
182
|
+
### 0.0.1
|
|
183
|
+
|
|
184
|
+
- 初始版本发布
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="connection-content">
|
|
3
3
|
<view class="connection-item">
|
|
4
|
-
<
|
|
4
|
+
<DevToolTitle>网络连接</DevToolTitle>
|
|
5
5
|
<view class="connection-item-content">
|
|
6
6
|
<view class="connection-row">
|
|
7
7
|
<view>IP地址:</view>
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
netWorkStatus?.isConnected === undefined || netWorkStatus?.ip
|
|
11
11
|
? 'info'
|
|
12
12
|
: netWorkStatus?.isConnected && netWorkStatus?.ip
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
? 'success'
|
|
14
|
+
: 'error'
|
|
15
15
|
"
|
|
16
16
|
>
|
|
17
17
|
{{
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
netWorkStatus?.isConnected === undefined
|
|
29
29
|
? 'info'
|
|
30
30
|
: netWorkStatus?.isConnected
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
? 'success'
|
|
32
|
+
: 'error'
|
|
33
33
|
"
|
|
34
34
|
>
|
|
35
35
|
{{
|
|
36
36
|
netWorkStatus?.isConnected === undefined
|
|
37
37
|
? '未获取'
|
|
38
38
|
: netWorkStatus?.isConnected
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
? '已连接'
|
|
40
|
+
: '已断开'
|
|
41
41
|
}}
|
|
42
42
|
</Tag>
|
|
43
43
|
</view>
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
</template>
|
|
60
60
|
<script lang="ts" setup>
|
|
61
61
|
import Tag from '../Tag/index.vue';
|
|
62
|
+
import DevToolTitle from '../DevToolTitle/index.vue';
|
|
62
63
|
defineProps<{
|
|
63
64
|
netWorkStatus: {
|
|
64
65
|
isConnected?: boolean;
|
|
@@ -73,23 +74,12 @@ defineProps<{
|
|
|
73
74
|
overflow: auto;
|
|
74
75
|
font-size: var(--dev-tool-base-font-size);
|
|
75
76
|
}
|
|
76
|
-
.connection-
|
|
77
|
+
.connection-item {
|
|
77
78
|
padding: 16px 16px 0 16px;
|
|
78
79
|
box-sizing: border-box;
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
align-items: center;
|
|
83
|
-
}
|
|
84
|
-
.connection-content .connection-item .connection-item-title::before {
|
|
85
|
-
content: '';
|
|
86
|
-
margin-right: 8px;
|
|
87
|
-
width: 2px;
|
|
88
|
-
height: 18px;
|
|
89
|
-
border-radius: 2px;
|
|
90
|
-
background-color: var(--dev-tool-main-color);
|
|
91
|
-
}
|
|
92
|
-
.connection-content .connection-item .connection-item-content .connection-row {
|
|
81
|
+
|
|
82
|
+
.connection-row {
|
|
93
83
|
display: flex;
|
|
94
84
|
align-items: center;
|
|
95
85
|
justify-content: space-between;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
v-for="(code, index) in codes"
|
|
22
22
|
:id="`dev-tool-code-item-${index}`"
|
|
23
23
|
:key="index"
|
|
24
|
-
:class="`dev-tool-code-item ${index === activeRowCol.
|
|
24
|
+
:class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
|
|
25
25
|
>
|
|
26
26
|
<view class="dev-tool-code-item-index"> {{ index + 1 }}</view>
|
|
27
27
|
|
|
@@ -49,11 +49,12 @@ const emit = defineEmits<{ (e: 'close'): void }>();
|
|
|
49
49
|
const modelValue = ref('');
|
|
50
50
|
const scrollTop = ref(0);
|
|
51
51
|
const fileName = computed(() => {
|
|
52
|
-
const name =
|
|
52
|
+
const name =
|
|
53
|
+
props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
|
|
53
54
|
return name;
|
|
54
55
|
});
|
|
55
56
|
|
|
56
|
-
const activeRowCol = ref({ row: -1, col: -1 });
|
|
57
|
+
const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
|
|
57
58
|
|
|
58
59
|
let backupCodes: string[] = [];
|
|
59
60
|
|
|
@@ -101,10 +102,22 @@ function getCode(url: string, i: number = 0) {
|
|
|
101
102
|
.toString()
|
|
102
103
|
.split('\n');
|
|
103
104
|
|
|
104
|
-
|
|
105
|
+
const start =
|
|
106
|
+
activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
|
|
107
|
+
|
|
108
|
+
const end =
|
|
109
|
+
activeRowCol.value.row + 20 > backupCodes.length
|
|
110
|
+
? backupCodes.length
|
|
111
|
+
: activeRowCol.value.row + 20;
|
|
112
|
+
|
|
113
|
+
// backupCodes.slice(start, end);
|
|
114
|
+
|
|
115
|
+
codes.value = backupCodes.slice(start, end);
|
|
116
|
+
|
|
117
|
+
activeRowCol.value.activeRow = activeRowCol.value.row - start;
|
|
105
118
|
|
|
106
119
|
nextTick(() => {
|
|
107
|
-
scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.
|
|
120
|
+
scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
|
|
108
121
|
});
|
|
109
122
|
}
|
|
110
123
|
},
|
|
@@ -139,10 +152,8 @@ onMounted(() => {
|
|
|
139
152
|
url = path;
|
|
140
153
|
}
|
|
141
154
|
|
|
142
|
-
activeRowCol.value =
|
|
143
|
-
|
|
144
|
-
row,
|
|
145
|
-
};
|
|
155
|
+
activeRowCol.value.col = col;
|
|
156
|
+
activeRowCol.value.row = row;
|
|
146
157
|
|
|
147
158
|
if (props.mode === 'development') {
|
|
148
159
|
// 开发环境查看源码
|
|
@@ -185,6 +196,8 @@ onMounted(() => {
|
|
|
185
196
|
margin-bottom: 4px;
|
|
186
197
|
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
187
198
|
box-sizing: border-box;
|
|
199
|
+
white-space: nowrap;
|
|
200
|
+
overflow: auto;
|
|
188
201
|
}
|
|
189
202
|
|
|
190
203
|
.dev-tool-code-list {
|
|
@@ -28,6 +28,7 @@ import { onShow, onHide, onUnload, onLoad } from '@dcloudio/uni-app';
|
|
|
28
28
|
import { reactive, ref, nextTick } from 'vue';
|
|
29
29
|
import DevToolButton from '../DevToolButton/index.vue';
|
|
30
30
|
import DevToolWindow from '../DevToolWindow/index.vue';
|
|
31
|
+
import { eventBus } from '../../core';
|
|
31
32
|
|
|
32
33
|
import {
|
|
33
34
|
EVENT_DEV_BUTTON,
|
|
@@ -82,7 +83,7 @@ async function onShowDevToolWindow(show: boolean) {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
function onSendMessage(param: { type: string; data: Record<string, any> }) {
|
|
85
|
-
|
|
86
|
+
eventBus.emit(DEV_WINDOW_MESSAGE, param);
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
function onDevOptionSend(options: DevTool.DevToolOptions) {
|
|
@@ -110,22 +111,22 @@ onLoad(() => {
|
|
|
110
111
|
isActive = true;
|
|
111
112
|
devToolButtonVisible.value = uni.getStorageSync(EVENT_DEV_BUTTON) || false;
|
|
112
113
|
devToolWindowVisible.value = show;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
eventBus.on(EVENT_DEV_BUTTON, onShowDevToolButton);
|
|
115
|
+
eventBus.on(EVENT_DEV_WINDOW, onShowDevToolWindow);
|
|
116
|
+
eventBus.on(DEV_OPTION_SEND, onDevOptionSend);
|
|
116
117
|
|
|
117
118
|
nextTick(() => {
|
|
118
|
-
|
|
119
|
+
eventBus.emit(DEV_WINDOW_MESSAGE, { type: DEV_OPTION_GET, data: {} });
|
|
119
120
|
});
|
|
120
121
|
});
|
|
121
122
|
|
|
122
123
|
onUnload(() => {
|
|
123
|
-
|
|
124
|
+
eventBus.emit(DEV_WINDOW_MESSAGE, {
|
|
124
125
|
type: DEV_WINDOW_CLOSE,
|
|
125
126
|
data: {},
|
|
126
127
|
});
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
eventBus.off(EVENT_DEV_BUTTON, onShowDevToolButton);
|
|
129
|
+
eventBus.off(EVENT_DEV_WINDOW, onShowDevToolWindow);
|
|
129
130
|
});
|
|
130
131
|
|
|
131
132
|
onShow(() => {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dev-tool-title" :style="style"> <slot /> </view>
|
|
3
|
+
</template>
|
|
4
|
+
<script lang="ts" setup>
|
|
5
|
+
defineProps<{ style?: any }>();
|
|
6
|
+
</script>
|
|
7
|
+
<style scoped>
|
|
8
|
+
.dev-tool-title {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
height: 32px;
|
|
12
|
+
}
|
|
13
|
+
.dev-tool-title::before {
|
|
14
|
+
content: '';
|
|
15
|
+
margin-right: 8px;
|
|
16
|
+
width: 2px;
|
|
17
|
+
height: 18px;
|
|
18
|
+
border-radius: 2px;
|
|
19
|
+
background-color: var(--dev-tool-main-color);
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
@@ -64,6 +64,12 @@
|
|
|
64
64
|
@search="onSearchRoute"
|
|
65
65
|
@routeRefresh="onRouteRefresh"
|
|
66
66
|
/>
|
|
67
|
+
<UniEvent
|
|
68
|
+
v-if="activeTab === 'UniEvent'"
|
|
69
|
+
:eventList="eventList"
|
|
70
|
+
:eventCount="eventCount"
|
|
71
|
+
@clear="onUniEventClear"
|
|
72
|
+
/>
|
|
67
73
|
<SettingList
|
|
68
74
|
v-if="activeTab === 'Setting'"
|
|
69
75
|
:devToolVisible="devToolVisible"
|
|
@@ -119,6 +125,7 @@ import DeviceInfo from '../DeviceInfo/index.vue';
|
|
|
119
125
|
import WindowInfo from '../WindowInfo/index.vue';
|
|
120
126
|
import WebSocket from '../WebSocket/index.vue';
|
|
121
127
|
import UploadList from '../UploadList/index.vue';
|
|
128
|
+
import UniEvent from '../UniEvent/index.vue';
|
|
122
129
|
import {
|
|
123
130
|
DEV_BUTTON_SHOW_OR_HIDE,
|
|
124
131
|
DEV_CONSOLE_CLEAR,
|
|
@@ -141,9 +148,11 @@ import {
|
|
|
141
148
|
DEV_WEBSOCKET_CLEAR,
|
|
142
149
|
DEV_WINDOW_INFO,
|
|
143
150
|
DEV_APP_MESSAGE,
|
|
151
|
+
DEV_UNI_EVENT_CLEAR,
|
|
144
152
|
} from '../../const';
|
|
145
153
|
import { debounce, hightLight } from '../../utils/index';
|
|
146
154
|
import type { DevTool } from '../../type';
|
|
155
|
+
import { eventBus } from '../../core';
|
|
147
156
|
|
|
148
157
|
const items = [
|
|
149
158
|
{
|
|
@@ -171,12 +180,16 @@ const items = [
|
|
|
171
180
|
label: 'WebSocket',
|
|
172
181
|
value: 'WebSocket',
|
|
173
182
|
},
|
|
174
|
-
|
|
175
183
|
{
|
|
176
184
|
key: 'Route',
|
|
177
185
|
label: 'Route',
|
|
178
186
|
value: 'Route',
|
|
179
187
|
},
|
|
188
|
+
{
|
|
189
|
+
key: 'UniEvent',
|
|
190
|
+
label: 'UniEvent',
|
|
191
|
+
value: 'UniEvent',
|
|
192
|
+
},
|
|
180
193
|
{
|
|
181
194
|
key: 'Storage',
|
|
182
195
|
label: 'Storage',
|
|
@@ -222,6 +235,7 @@ const backup: {
|
|
|
222
235
|
wsList: DevTool.WS[];
|
|
223
236
|
uploadList: DevTool.UploadItem[];
|
|
224
237
|
routeList: DevTool.Page[];
|
|
238
|
+
eventList: DevTool.EventItem[];
|
|
225
239
|
} = {
|
|
226
240
|
consoleList: [],
|
|
227
241
|
networkList: [],
|
|
@@ -229,6 +243,7 @@ const backup: {
|
|
|
229
243
|
wsList: [],
|
|
230
244
|
uploadList: [],
|
|
231
245
|
routeList: [],
|
|
246
|
+
eventList: [],
|
|
232
247
|
};
|
|
233
248
|
const consoleList = ref<DevTool.ConsoleItem[]>([]);
|
|
234
249
|
const networkList = ref<DevTool.NetworkItem[]>([]);
|
|
@@ -241,6 +256,8 @@ const piniaList = ref<Record<string, any>>({});
|
|
|
241
256
|
const systemInfo = ref<Record<string, any>>({});
|
|
242
257
|
const deviceInfo = ref<Record<string, any>>({});
|
|
243
258
|
const windowInfo = ref<Record<string, any>>({});
|
|
259
|
+
const eventList = ref<DevTool.EventItem[]>([]);
|
|
260
|
+
const eventCount = ref<DevTool.EventCount>();
|
|
244
261
|
const netWorkStatus = ref<{
|
|
245
262
|
isConnected?: boolean;
|
|
246
263
|
networkType?: string;
|
|
@@ -394,6 +411,13 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
394
411
|
});
|
|
395
412
|
backup.routeList = [...data.routeList];
|
|
396
413
|
}
|
|
414
|
+
if (data.eventList) {
|
|
415
|
+
eventList.value = [...data.eventList];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (data.eventCount) {
|
|
419
|
+
eventCount.value = { ...data.eventCount };
|
|
420
|
+
}
|
|
397
421
|
|
|
398
422
|
if (data.vuexList) {
|
|
399
423
|
vuexList.value = data.vuexList;
|
|
@@ -439,11 +463,11 @@ onMounted(() => {
|
|
|
439
463
|
|
|
440
464
|
onLoad(() => {
|
|
441
465
|
isActive = true;
|
|
442
|
-
|
|
466
|
+
eventBus.on(DEV_APP_MESSAGE, listenPostMessage);
|
|
443
467
|
});
|
|
444
468
|
onUnload(() => {
|
|
445
469
|
isActive = false;
|
|
446
|
-
|
|
470
|
+
eventBus.off(DEV_APP_MESSAGE, listenPostMessage);
|
|
447
471
|
});
|
|
448
472
|
|
|
449
473
|
onShow(() => {
|
|
@@ -704,6 +728,20 @@ function onSearchStorage(value: string) {
|
|
|
704
728
|
});
|
|
705
729
|
}
|
|
706
730
|
|
|
731
|
+
function onUniEventClear() {
|
|
732
|
+
eventList.value = [];
|
|
733
|
+
eventCount.value = {
|
|
734
|
+
on: 0,
|
|
735
|
+
once: 0,
|
|
736
|
+
emit: 0,
|
|
737
|
+
off: 0,
|
|
738
|
+
};
|
|
739
|
+
basicSendMessage({
|
|
740
|
+
type: DEV_UNI_EVENT_CLEAR,
|
|
741
|
+
data: {},
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
|
|
707
745
|
function onGoTo(page: DevTool.Page) {
|
|
708
746
|
basicSendMessage({
|
|
709
747
|
type: DEV_PAGE_JUMP,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="setting-content">
|
|
3
3
|
<view class="setting-item">
|
|
4
|
-
<
|
|
4
|
+
<DevToolTitle>DevTool</DevToolTitle>
|
|
5
5
|
<view class="setting-item-content">
|
|
6
6
|
<view class="setting-row">
|
|
7
7
|
<view>显示调试按钮:</view>
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
</view>
|
|
26
26
|
|
|
27
27
|
<view class="setting-tips">
|
|
28
|
-
点击后将会销毁调试器,销毁后不再接收调试信息,需要通过
|
|
29
|
-
|
|
28
|
+
点击后将会销毁调试器,销毁后不再接收调试信息,需要通过 createDevTool()
|
|
29
|
+
重新创建
|
|
30
30
|
</view>
|
|
31
31
|
<DButton class="setting-button" @click="onDestructionDevTool">
|
|
32
32
|
销毁调试器
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
</view>
|
|
53
53
|
</view>
|
|
54
54
|
<view class="setting-item">
|
|
55
|
-
<
|
|
55
|
+
<DevToolTitle>Log</DevToolTitle>
|
|
56
56
|
<view class="setting-item-content">
|
|
57
57
|
<view class="setting-row">
|
|
58
58
|
<view>导出当前日志信息:</view>
|
|
@@ -121,6 +121,7 @@
|
|
|
121
121
|
import { reactive } from 'vue';
|
|
122
122
|
import Checkbox from '../Checkbox/index.vue';
|
|
123
123
|
import DButton from '../Button/index.vue';
|
|
124
|
+
import DevToolTitle from '../DevToolTitle/index.vue';
|
|
124
125
|
const props = defineProps<{
|
|
125
126
|
devToolVisible?: boolean;
|
|
126
127
|
sizeFormat?: string;
|
|
@@ -204,30 +205,19 @@ function onClearCache() {
|
|
|
204
205
|
overflow: auto;
|
|
205
206
|
font-size: var(--dev-tool-base-font-size);
|
|
206
207
|
}
|
|
207
|
-
.setting-
|
|
208
|
+
.setting-item {
|
|
208
209
|
padding: 16px 16px 0 16px;
|
|
209
210
|
box-sizing: border-box;
|
|
210
211
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
align-items: center;
|
|
214
|
-
}
|
|
215
|
-
.setting-content .setting-item .setting-item-title::before {
|
|
216
|
-
content: '';
|
|
217
|
-
margin-right: 8px;
|
|
218
|
-
width: 2px;
|
|
219
|
-
height: 18px;
|
|
220
|
-
border-radius: 2px;
|
|
221
|
-
background-color: var(--dev-tool-main-color);
|
|
222
|
-
}
|
|
223
|
-
.setting-content .setting-item .setting-item-content .setting-row {
|
|
212
|
+
|
|
213
|
+
.setting-row {
|
|
224
214
|
display: flex;
|
|
225
215
|
align-items: center;
|
|
226
216
|
justify-content: space-between;
|
|
227
217
|
margin: 8px 0;
|
|
228
218
|
min-height: 18px;
|
|
229
219
|
}
|
|
230
|
-
.setting-
|
|
220
|
+
.setting-tips {
|
|
231
221
|
color: #616161;
|
|
232
222
|
font-size: var(--dev-tool-tips-font-size);
|
|
233
223
|
margin-bottom: 8px;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-event-item">
|
|
3
|
+
<view class="uni-event-item-row"> {{ eventItem.eventName }} </view>
|
|
4
|
+
<view class="uni-event-item-row">
|
|
5
|
+
<Tag mode="info" v-if="eventItem.type == 'on'">
|
|
6
|
+
{{ eventItem.type }}
|
|
7
|
+
</Tag>
|
|
8
|
+
<Tag mode="warn" v-if="eventItem.type == 'once'">
|
|
9
|
+
{{ eventItem.type }}
|
|
10
|
+
</Tag>
|
|
11
|
+
<Tag mode="main" v-if="eventItem.type == 'emit'">
|
|
12
|
+
{{ eventItem.type }}
|
|
13
|
+
</Tag>
|
|
14
|
+
<Tag mode="error" v-if="eventItem.type == 'off'">
|
|
15
|
+
{{ eventItem.type }}
|
|
16
|
+
</Tag>
|
|
17
|
+
<view class="uni-event-item-right"> {{ eventItem.timer }}</view>
|
|
18
|
+
</view>
|
|
19
|
+
|
|
20
|
+
<view class="uni-event-item-right link">
|
|
21
|
+
{{ eventItem.stock }}
|
|
22
|
+
</view>
|
|
23
|
+
</view>
|
|
24
|
+
</template>
|
|
25
|
+
<script lang="ts" setup>
|
|
26
|
+
import Tag from '../Tag/index.vue';
|
|
27
|
+
import type { DevTool } from '../../type';
|
|
28
|
+
|
|
29
|
+
defineProps<{ eventItem: DevTool.EventItem }>();
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<style scoped>
|
|
33
|
+
.uni-event-item {
|
|
34
|
+
padding: 16px;
|
|
35
|
+
border-bottom: 1px solid var(--dev-tool-border-color);
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.uni-event-item-row {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
height: 28px;
|
|
44
|
+
word-break: break-all;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.uni-event-item-right {
|
|
48
|
+
text-align: right;
|
|
49
|
+
word-break: break-all;
|
|
50
|
+
}
|
|
51
|
+
.link {
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
text-decoration: underline;
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uni-event-content">
|
|
3
|
+
<DevToolTitle style="padding: 0 16px">事件触发统计</DevToolTitle>
|
|
4
|
+
<view class="uni-event-statistics">
|
|
5
|
+
<view class="uni-event-statistics-item">
|
|
6
|
+
<view>on: </view>
|
|
7
|
+
<Tag mode="log" style="flex: 1; justify-content: center">
|
|
8
|
+
{{ eventCount?.on ?? 0 }}
|
|
9
|
+
</Tag>
|
|
10
|
+
</view>
|
|
11
|
+
<view class="uni-event-statistics-item">
|
|
12
|
+
<view>once: </view>
|
|
13
|
+
<Tag mode="warn" style="flex: 1; justify-content: center">
|
|
14
|
+
{{ eventCount?.once ?? 0 }}
|
|
15
|
+
</Tag>
|
|
16
|
+
</view>
|
|
17
|
+
<view class="uni-event-statistics-item">
|
|
18
|
+
<view>emit: </view>
|
|
19
|
+
<Tag mode="main" style="flex: 1; justify-content: center">
|
|
20
|
+
{{ eventCount?.emit ?? 0 }}
|
|
21
|
+
</Tag>
|
|
22
|
+
</view>
|
|
23
|
+
<view class="uni-event-statistics-item">
|
|
24
|
+
<view>off: </view>
|
|
25
|
+
<Tag mode="error" style="flex: 1; justify-content: center">
|
|
26
|
+
{{ eventCount?.off ?? 0 }}
|
|
27
|
+
</Tag>
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
<DevToolTitle style="padding: 0 16px"
|
|
31
|
+
>事件触发列表
|
|
32
|
+
|
|
33
|
+
<Tag mode="clear" style="margin-left: auto" @click="emit('clear')">
|
|
34
|
+
清空
|
|
35
|
+
</Tag>
|
|
36
|
+
</DevToolTitle>
|
|
37
|
+
<view class="uni-event-list">
|
|
38
|
+
<UniEventItem v-for="item in eventList" :eventItem="item" />
|
|
39
|
+
</view>
|
|
40
|
+
</view>
|
|
41
|
+
</template>
|
|
42
|
+
<script lang="ts" setup>
|
|
43
|
+
import DevToolTitle from '../DevToolTitle/index.vue';
|
|
44
|
+
import UniEventItem from './UniEventItem.vue';
|
|
45
|
+
import Tag from '../Tag/index.vue';
|
|
46
|
+
import type { DevTool } from '@/dev/type';
|
|
47
|
+
|
|
48
|
+
defineProps<{
|
|
49
|
+
eventList?: DevTool.EventItem[];
|
|
50
|
+
eventCount?: DevTool.EventCount;
|
|
51
|
+
}>();
|
|
52
|
+
|
|
53
|
+
const emit = defineEmits<{
|
|
54
|
+
(e: 'clear'): void;
|
|
55
|
+
}>();
|
|
56
|
+
</script>
|
|
57
|
+
<style scoped>
|
|
58
|
+
.uni-event-content {
|
|
59
|
+
height: 100%;
|
|
60
|
+
overflow: auto;
|
|
61
|
+
font-size: var(--dev-tool-base-font-size);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.uni-event-statistics {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
justify-content: space-around;
|
|
68
|
+
padding: 0 16px;
|
|
69
|
+
height: 32px;
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
gap: 12px;
|
|
72
|
+
}
|
|
73
|
+
.uni-event-statistics-item {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
width: 25%;
|
|
77
|
+
}
|
|
78
|
+
.uni-event-statistics-item view:first-child {
|
|
79
|
+
margin-right: 8px;
|
|
80
|
+
}
|
|
81
|
+
.uni-event-list {
|
|
82
|
+
height: calc(100% - 32px * 3);
|
|
83
|
+
overflow: auto;
|
|
84
|
+
}
|
|
85
|
+
</style>
|
package/dev/const.ts
CHANGED
|
@@ -90,6 +90,8 @@ export const DEV_ROUTE_REFRESH = 'dev-route-refresh';
|
|
|
90
90
|
/** 获取 dev option */
|
|
91
91
|
export const DEV_OPTION = 'dev-option';
|
|
92
92
|
|
|
93
|
-
export const
|
|
93
|
+
export const DEV_OPTION_GET = 'dev-option-get';
|
|
94
94
|
|
|
95
|
-
export const
|
|
95
|
+
export const DEV_OPTION_SEND = 'dev-option-send';
|
|
96
|
+
|
|
97
|
+
export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
|
package/dev/core.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { DevConsole } from './devConsole';
|
|
|
6
6
|
|
|
7
7
|
import type { DevTool } from './type';
|
|
8
8
|
|
|
9
|
+
import { EventBus } from './devEventBus';
|
|
9
10
|
/**
|
|
10
11
|
* 备份原生方法
|
|
11
12
|
*
|
|
@@ -26,12 +27,21 @@ const backup = {
|
|
|
26
27
|
reject: Promise.reject,
|
|
27
28
|
connectSocket: uni?.connectSocket,
|
|
28
29
|
uploadFile: uni?.uploadFile,
|
|
30
|
+
$on: uni.$on,
|
|
31
|
+
$once: uni.$once,
|
|
32
|
+
$emit: uni.$emit,
|
|
33
|
+
$off: uni.$off,
|
|
29
34
|
__log__: (uni as any).__log__,
|
|
30
35
|
};
|
|
31
36
|
|
|
37
|
+
const eventBus = new EventBus();
|
|
38
|
+
|
|
32
39
|
const store = new DevStore();
|
|
33
40
|
|
|
34
|
-
const event = new DevEvent(
|
|
41
|
+
const event = new DevEvent({
|
|
42
|
+
store,
|
|
43
|
+
eventBus,
|
|
44
|
+
});
|
|
35
45
|
|
|
36
46
|
const console = new DevConsole(event);
|
|
37
47
|
|
|
@@ -106,4 +116,5 @@ export {
|
|
|
106
116
|
getDevToolOptions,
|
|
107
117
|
interceptVuexStorage,
|
|
108
118
|
interceptPiniaStore,
|
|
119
|
+
eventBus,
|
|
109
120
|
};
|