vite-uni-dev-tool 0.0.9 → 0.0.11
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 +18 -0
- package/dev/components/AppInfo/index.vue +36 -0
- package/dev/components/AutoSizer/index.vue +193 -0
- package/dev/components/AutoSizer/index1.vue +186 -0
- package/dev/components/AutoSizer/utils.ts +49 -0
- package/dev/components/CaptureScreen/index.vue +62 -0
- package/dev/components/Code/index.vue +7 -4
- package/dev/components/ConsoleList/RunJSInput.vue +177 -1
- package/dev/components/ConsoleList/index.vue +29 -19
- package/dev/components/ConsoleList/staticTips.ts +1145 -0
- package/dev/components/DevToolWindow/index.vue +225 -101
- package/dev/components/JsonPretty/components/Carets/index.vue +10 -14
- package/dev/components/JsonPretty/index.vue +50 -41
- package/dev/components/NetworkList/index.vue +16 -9
- package/dev/components/RouteList/index.vue +31 -19
- package/dev/components/Tabs/index.vue +23 -10
- package/dev/components/UploadList/index.vue +15 -5
- package/dev/components/VirtualListPro/AutoSize.vue +43 -0
- package/dev/components/VirtualListPro/index.vue +175 -0
- package/dev/components/VirtualListPro/readme.md +40 -0
- package/dev/components/WebSocket/index.vue +16 -4
- package/dev/const.ts +2 -4
- package/dev/devEvent/index.ts +29 -2
- package/dev/devIntercept/index.ts +18 -0
- package/dev/devStore/index.ts +33 -0
- package/dev/plugins/uniDevTool/uniDevTool.js +36 -36
- package/dev/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
- package/dev/type.ts +7 -0
- package/dev/utils/array.ts +15 -0
- package/dev/utils/index.ts +3 -0
- package/dev/utils/string.ts +12 -0
- package/package.json +1 -1
|
@@ -17,14 +17,19 @@
|
|
|
17
17
|
{{ item.label }}
|
|
18
18
|
</Tag>
|
|
19
19
|
</view>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
|
|
21
|
+
<VirtualListPro :data="networkList" :pageSize="10" className="network-list">
|
|
22
|
+
<template v-slot="{ list, start }">
|
|
23
|
+
<AutoSize
|
|
24
|
+
v-for="(item, index) in list"
|
|
25
|
+
:index="start + index"
|
|
26
|
+
:key="start + index"
|
|
27
|
+
>
|
|
28
|
+
<NetworkItem :network="item" />
|
|
29
|
+
</AutoSize>
|
|
30
|
+
<Empty v-if="!networkList || networkList.length === 0" />
|
|
31
|
+
</template>
|
|
32
|
+
</VirtualListPro>
|
|
28
33
|
</view>
|
|
29
34
|
</template>
|
|
30
35
|
<script lang="ts" setup>
|
|
@@ -33,6 +38,9 @@ import NetworkItem from './NetworkItem.vue';
|
|
|
33
38
|
import Empty from '../Empty/index.vue';
|
|
34
39
|
import FilterInput from '../FilterInput/index.vue';
|
|
35
40
|
import type { DevTool } from '../../type';
|
|
41
|
+
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
42
|
+
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
43
|
+
|
|
36
44
|
defineProps<{
|
|
37
45
|
currentNetworkType: string;
|
|
38
46
|
networkList: DevTool.NetworkItem[];
|
|
@@ -93,7 +101,6 @@ function onChoose(type: string) {
|
|
|
93
101
|
}
|
|
94
102
|
.network-list {
|
|
95
103
|
height: calc(100% - 32px);
|
|
96
|
-
overflow: auto;
|
|
97
104
|
}
|
|
98
105
|
.network-control {
|
|
99
106
|
display: flex;
|
|
@@ -10,25 +10,34 @@
|
|
|
10
10
|
/>
|
|
11
11
|
<Tag mode="clear" @click="onRefresh">刷新</Tag>
|
|
12
12
|
</view>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
|
|
14
|
+
<VirtualListPro :data="routeList" :pageSize="10" className="route-list">
|
|
15
|
+
<template v-slot="{ list, start }">
|
|
16
|
+
<AutoSize
|
|
17
|
+
v-for="(item, index) in list"
|
|
18
|
+
:index="start + index"
|
|
19
|
+
:key="start + index"
|
|
20
|
+
>
|
|
21
|
+
<view class="route-item">
|
|
22
|
+
<view class="route-item-name">
|
|
23
|
+
<view v-html="item.name" />
|
|
24
|
+
<Tag v-if="item.type" mode="info">{{ item.type }}</Tag>
|
|
25
|
+
<Tag mode="warn" v-if="item.index === 4 || item.index === 3">
|
|
26
|
+
当前页
|
|
27
|
+
</Tag>
|
|
28
|
+
<Tag mode="primary" v-if="item.index === 4 || item.index === 2">
|
|
29
|
+
启动页
|
|
30
|
+
</Tag>
|
|
31
|
+
</view>
|
|
32
|
+
<view class="route-item-path">
|
|
33
|
+
<view v-html="item.path" />
|
|
34
|
+
<Tag mode="main" @click="onGoTo(item)">跳转</Tag>
|
|
35
|
+
</view>
|
|
36
|
+
</view>
|
|
37
|
+
</AutoSize>
|
|
38
|
+
<Empty v-if="!routeList || routeList.length === 0" />
|
|
39
|
+
</template>
|
|
40
|
+
</VirtualListPro>
|
|
32
41
|
</view>
|
|
33
42
|
</template>
|
|
34
43
|
<script lang="ts" setup>
|
|
@@ -36,6 +45,9 @@ import Tag from '../Tag/index.vue';
|
|
|
36
45
|
import Empty from '../Empty/index.vue';
|
|
37
46
|
import FilterInput from '../FilterInput/index.vue';
|
|
38
47
|
import type { DevTool } from '../../type';
|
|
48
|
+
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
49
|
+
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
50
|
+
|
|
39
51
|
defineProps<{ routeList: DevTool.Page[]; modelValue?: string }>();
|
|
40
52
|
const emit = defineEmits<{
|
|
41
53
|
(e: 'goTo', params: DevTool.Page): void;
|
|
@@ -5,15 +5,18 @@
|
|
|
5
5
|
ref="tabsRef"
|
|
6
6
|
scroll-x="true"
|
|
7
7
|
enable-flex="true"
|
|
8
|
+
scroll-with-animation
|
|
8
9
|
:scrollLeft="scrollLeft"
|
|
10
|
+
:scroll-into-view="scrollIntoView"
|
|
9
11
|
@scroll="onScroll"
|
|
10
12
|
>
|
|
11
13
|
<view
|
|
12
14
|
v-for="item in items"
|
|
13
15
|
:key="item.key"
|
|
14
16
|
:class="`tabs-item ${
|
|
15
|
-
item.
|
|
17
|
+
item.index === modelValue ? 'tabs-item-active' : ''
|
|
16
18
|
} `"
|
|
19
|
+
:id="`tabs-item-${item.index}`"
|
|
17
20
|
@click="onChangeTabs(item)"
|
|
18
21
|
>
|
|
19
22
|
{{ item.label }}
|
|
@@ -27,12 +30,12 @@
|
|
|
27
30
|
</template>
|
|
28
31
|
|
|
29
32
|
<script setup lang="ts">
|
|
30
|
-
import { ref } from 'vue';
|
|
33
|
+
import { computed, ref } from 'vue';
|
|
31
34
|
import CloseButton from '../CloseButton/index.vue';
|
|
32
35
|
// const activeKey = ref("Console");
|
|
33
|
-
defineProps<{
|
|
34
|
-
modelValue:
|
|
35
|
-
items: { label: string; key: string; value: any }[];
|
|
36
|
+
const props = defineProps<{
|
|
37
|
+
modelValue: number;
|
|
38
|
+
items: { label: string; key: string; value: any; index: number }[];
|
|
36
39
|
scrollLeft?: number;
|
|
37
40
|
}>();
|
|
38
41
|
|
|
@@ -40,14 +43,24 @@ const tabsRef = ref();
|
|
|
40
43
|
|
|
41
44
|
const emit = defineEmits<{
|
|
42
45
|
(e: 'close'): void;
|
|
43
|
-
(e: 'update:modelValue', value:
|
|
44
|
-
(e: 'change', value:
|
|
46
|
+
(e: 'update:modelValue', value: number): void;
|
|
47
|
+
(e: 'change', value: number): void;
|
|
45
48
|
(e: 'scroll', value: any): void;
|
|
46
49
|
}>();
|
|
47
|
-
|
|
50
|
+
|
|
51
|
+
const scrollIntoView = computed(() => {
|
|
52
|
+
return `tabs-item-${props.modelValue}`;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function onChangeTabs(item: {
|
|
56
|
+
label: string;
|
|
57
|
+
key: string;
|
|
58
|
+
value: any;
|
|
59
|
+
index: number;
|
|
60
|
+
}) {
|
|
48
61
|
// activeKey.value = item.key;
|
|
49
|
-
emit('update:modelValue', item.
|
|
50
|
-
emit('change', item.
|
|
62
|
+
emit('update:modelValue', item.index);
|
|
63
|
+
emit('change', item.index);
|
|
51
64
|
}
|
|
52
65
|
function onClose() {
|
|
53
66
|
emit('close');
|
|
@@ -17,10 +17,18 @@
|
|
|
17
17
|
{{ item.label }}
|
|
18
18
|
</Tag>
|
|
19
19
|
</view>
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
<VirtualListPro :data="uploadList" :pageSize="10" className="upload-list">
|
|
21
|
+
<template v-slot="{ list, start }">
|
|
22
|
+
<AutoSize
|
|
23
|
+
v-for="(item, index) in list"
|
|
24
|
+
:index="start + index"
|
|
25
|
+
:key="start + index"
|
|
26
|
+
>
|
|
27
|
+
<UploadItem :upload="item" />
|
|
28
|
+
</AutoSize>
|
|
29
|
+
<Empty v-if="!uploadList || uploadList.length === 0" />
|
|
30
|
+
</template>
|
|
31
|
+
</VirtualListPro>
|
|
24
32
|
</view>
|
|
25
33
|
</template>
|
|
26
34
|
<script lang="ts" setup>
|
|
@@ -29,6 +37,9 @@ import UploadItem from './UploadItem.vue';
|
|
|
29
37
|
import Empty from '../Empty/index.vue';
|
|
30
38
|
import FilterInput from '../FilterInput/index.vue';
|
|
31
39
|
import type { DevTool } from '../../type';
|
|
40
|
+
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
41
|
+
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
42
|
+
|
|
32
43
|
defineProps<{
|
|
33
44
|
currentUploadType: string;
|
|
34
45
|
uploadList: DevTool.UploadItem[];
|
|
@@ -79,7 +90,6 @@ function onChoose(type: string) {
|
|
|
79
90
|
}
|
|
80
91
|
.upload-list {
|
|
81
92
|
height: calc(100% - 32px);
|
|
82
|
-
overflow: auto;
|
|
83
93
|
}
|
|
84
94
|
.upload-control {
|
|
85
95
|
display: flex;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="className">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import { getCurrentInstance, onMounted, inject, nextTick } from 'vue';
|
|
8
|
+
import { uniqueId } from '../../utils';
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
index: number;
|
|
12
|
+
}>();
|
|
13
|
+
|
|
14
|
+
const className = uniqueId('virtual-');
|
|
15
|
+
|
|
16
|
+
const instance = getCurrentInstance();
|
|
17
|
+
|
|
18
|
+
const query = uni.createSelectorQuery().in(instance);
|
|
19
|
+
|
|
20
|
+
const onSizeChange =
|
|
21
|
+
inject<(index: number, height: number) => void>('onSizeChange');
|
|
22
|
+
|
|
23
|
+
const itemsHeight = inject<number[]>('itemsHeight');
|
|
24
|
+
|
|
25
|
+
onMounted(() => {
|
|
26
|
+
// TODO 可能会存在异步高度的问题
|
|
27
|
+
// TODO image 加载完成之后获取高度
|
|
28
|
+
|
|
29
|
+
if (itemsHeight?.[props.index]) return;
|
|
30
|
+
|
|
31
|
+
nextTick(() => {
|
|
32
|
+
query
|
|
33
|
+
.select('.' + className)
|
|
34
|
+
.boundingClientRect((rect) => {
|
|
35
|
+
if (Array.isArray(rect)) return;
|
|
36
|
+
onSizeChange?.(props.index, rect.height ?? 0);
|
|
37
|
+
})
|
|
38
|
+
.exec();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<style scoped></style>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view
|
|
3
|
+
:lower-threshold="preLodeHeight"
|
|
4
|
+
:scroll-into-view="scrollIntoView"
|
|
5
|
+
:scroll-with-animation="scrollWithAnimation"
|
|
6
|
+
:class="['virtual-list', className]"
|
|
7
|
+
scroll-y
|
|
8
|
+
@scroll="onScroll"
|
|
9
|
+
@scrolltolower="onScrollToLower"
|
|
10
|
+
>
|
|
11
|
+
<!-- 阈值判断 -->
|
|
12
|
+
<view :style="{ height: `${state.currentHeight}px` }"></view>
|
|
13
|
+
<view>
|
|
14
|
+
<!-- 将可视数据传入到slot -->
|
|
15
|
+
<slot
|
|
16
|
+
:list="state.visitableData"
|
|
17
|
+
:current="state.current"
|
|
18
|
+
:start="(state.current - 1) * props.pageSize"
|
|
19
|
+
></slot>
|
|
20
|
+
</view>
|
|
21
|
+
</scroll-view>
|
|
22
|
+
</template>
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { reactive, watch, onBeforeMount, provide } from 'vue';
|
|
25
|
+
|
|
26
|
+
const props = withDefaults(
|
|
27
|
+
defineProps<{
|
|
28
|
+
/** 渲染数据 */
|
|
29
|
+
data: any[];
|
|
30
|
+
/** 虚拟列表高度 */
|
|
31
|
+
height?: number;
|
|
32
|
+
/**
|
|
33
|
+
* 将对传入的data进行分页
|
|
34
|
+
* 如何获取pageSize?
|
|
35
|
+
* 虚拟列表高度 / 预估每条的最小高度 +
|
|
36
|
+
*/
|
|
37
|
+
pageSize?: number;
|
|
38
|
+
/** 预加载高度 */
|
|
39
|
+
preLodeHeight?: number;
|
|
40
|
+
/** 类名 */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** 滚动到指定元素 */
|
|
43
|
+
scrollIntoView?: string;
|
|
44
|
+
/** 滚动动画 */
|
|
45
|
+
scrollWithAnimation?: boolean;
|
|
46
|
+
}>(),
|
|
47
|
+
{
|
|
48
|
+
height: 400,
|
|
49
|
+
pageSize: 10,
|
|
50
|
+
preLodeHeight: 50,
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const state = reactive<{
|
|
55
|
+
/** 加载次数 */
|
|
56
|
+
current: number;
|
|
57
|
+
visitableData: any[];
|
|
58
|
+
currentHeight: number;
|
|
59
|
+
height: number;
|
|
60
|
+
}>({
|
|
61
|
+
height: 0,
|
|
62
|
+
current: 1,
|
|
63
|
+
visitableData: [],
|
|
64
|
+
currentHeight: 0,
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* 每一项的高度
|
|
68
|
+
*/
|
|
69
|
+
const itemsHeight: number[] = [];
|
|
70
|
+
|
|
71
|
+
provide('itemsHeight', itemsHeight);
|
|
72
|
+
|
|
73
|
+
onBeforeMount(() => {
|
|
74
|
+
// 初始渲染数据
|
|
75
|
+
state.visitableData = props.data.slice(0, props.pageSize * 2);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// 数据更新时重置
|
|
79
|
+
watch(
|
|
80
|
+
() => [props.data, props.pageSize],
|
|
81
|
+
() => {
|
|
82
|
+
state.visitableData = props.data.slice(0, props.pageSize * 2);
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
/** 向上滚动和向下滚动 */
|
|
87
|
+
function updateVisitableData(direction: 'up' | 'down') {
|
|
88
|
+
let tempList = [...state.visitableData];
|
|
89
|
+
|
|
90
|
+
if (direction === 'down') {
|
|
91
|
+
// 将最前面的内容进行隐藏
|
|
92
|
+
tempList.splice(0, props.pageSize);
|
|
93
|
+
|
|
94
|
+
// 处理下一页内容
|
|
95
|
+
const start = props.pageSize * state.current;
|
|
96
|
+
let end = props.pageSize * (state.current + 1);
|
|
97
|
+
|
|
98
|
+
if (start >= props.data.length) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (end > props.data.length) {
|
|
103
|
+
end = props.data.length;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const newData = props.data.slice(start, end);
|
|
107
|
+
|
|
108
|
+
tempList.push(...newData);
|
|
109
|
+
} else {
|
|
110
|
+
// 将最末尾的部分进行隐藏
|
|
111
|
+
const delCount =
|
|
112
|
+
tempList.length - props.pageSize > 0
|
|
113
|
+
? props.pageSize
|
|
114
|
+
: tempList.length - props.pageSize;
|
|
115
|
+
|
|
116
|
+
tempList.splice(props.pageSize, delCount);
|
|
117
|
+
|
|
118
|
+
// 处理上一页内容
|
|
119
|
+
let start = props.pageSize * (state.current - 1);
|
|
120
|
+
|
|
121
|
+
const end = props.pageSize * state.current;
|
|
122
|
+
|
|
123
|
+
if (end < 0) return;
|
|
124
|
+
|
|
125
|
+
if (start < 0) {
|
|
126
|
+
start = 0;
|
|
127
|
+
}
|
|
128
|
+
const newData = props.data.slice(start, end);
|
|
129
|
+
tempList.unshift(...newData);
|
|
130
|
+
}
|
|
131
|
+
state.visitableData = tempList;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** 计算合并的高度 */
|
|
135
|
+
function updateCurrentHeight() {
|
|
136
|
+
const total = itemsHeight
|
|
137
|
+
.slice(0, state.current * props.pageSize)
|
|
138
|
+
?.reduce((acc, cur) => acc + cur, 0);
|
|
139
|
+
|
|
140
|
+
state.currentHeight = total;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 滚动到底部 */
|
|
144
|
+
function onScrollToLower() {
|
|
145
|
+
if ((state.current + 1) * props.pageSize < props.data.length) {
|
|
146
|
+
state.current++;
|
|
147
|
+
|
|
148
|
+
updateVisitableData('down');
|
|
149
|
+
|
|
150
|
+
updateCurrentHeight();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** 滚动监听,是否小于合并高度 */
|
|
155
|
+
function onScroll(e: { detail: { scrollTop: number } }) {
|
|
156
|
+
if (
|
|
157
|
+
state.current > 0 &&
|
|
158
|
+
state.currentHeight > 0 &&
|
|
159
|
+
e.detail.scrollTop - props.preLodeHeight < state.currentHeight
|
|
160
|
+
) {
|
|
161
|
+
state.current--;
|
|
162
|
+
|
|
163
|
+
updateVisitableData('up');
|
|
164
|
+
|
|
165
|
+
updateCurrentHeight();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** 暴露给子组件获取子组件容器的高度 */
|
|
170
|
+
function onSizeChange(index: number, height: number) {
|
|
171
|
+
itemsHeight[index] = height;
|
|
172
|
+
}
|
|
173
|
+
provide('onSizeChange', onSizeChange);
|
|
174
|
+
</script>
|
|
175
|
+
<style scoped></style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# VirtualListAutoHeight
|
|
2
|
+
|
|
3
|
+
自适应高度虚拟列表
|
|
4
|
+
|
|
5
|
+
## 核心
|
|
6
|
+
|
|
7
|
+
- 初始加载两页数据
|
|
8
|
+
- 初始获取当前加载的渲染列表的数据 ,得到第一页高度
|
|
9
|
+
- scroll-view
|
|
10
|
+
- 滚动到底部(顶部)current + 1
|
|
11
|
+
- createIntersectionObserver
|
|
12
|
+
- 辅助反向监听节点是否出现再可视范围之内
|
|
13
|
+
- current - 1
|
|
14
|
+
- 数据分页之后确定每页高度,采用合并高度支撑滚动条
|
|
15
|
+
- 合并高度计算逻辑: 第一页高度 = 第一页高度
|
|
16
|
+
- 后续页高度 = 前面所有高度 + 当前页高度.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
一页两条
|
|
20
|
+
|
|
21
|
+
pageSize = 2
|
|
22
|
+
current = 2
|
|
23
|
+
visibleDate = [3,4,5,6]
|
|
24
|
+
|
|
25
|
+
visibleDate.splice(1*2, visibleDate.length - 1*2)
|
|
26
|
+
|
|
27
|
+
const start = cur
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
1
|
|
31
|
+
2
|
|
32
|
+
|
|
33
|
+
3
|
|
34
|
+
4
|
|
35
|
+
|
|
36
|
+
5
|
|
37
|
+
6
|
|
38
|
+
|
|
39
|
+
current = 1
|
|
40
|
+
visibleDate = [1,2,3,4]
|
|
@@ -17,10 +17,19 @@
|
|
|
17
17
|
{{ item.label }}
|
|
18
18
|
</Tag>
|
|
19
19
|
</view>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
|
|
20
|
+
|
|
21
|
+
<VirtualListPro :data="wsList" :pageSize="10" className="websocket-list">
|
|
22
|
+
<template v-slot="{ list, start }">
|
|
23
|
+
<AutoSize
|
|
24
|
+
v-for="(item, index) in list"
|
|
25
|
+
:index="start + index"
|
|
26
|
+
:key="start + index"
|
|
27
|
+
>
|
|
28
|
+
<WebSocketItem :ws="item" />
|
|
29
|
+
</AutoSize>
|
|
30
|
+
<Empty v-if="!wsList || wsList.length === 0" />
|
|
31
|
+
</template>
|
|
32
|
+
</VirtualListPro>
|
|
24
33
|
</view>
|
|
25
34
|
</template>
|
|
26
35
|
<script lang="ts" setup>
|
|
@@ -29,6 +38,9 @@ import Tag from '../Tag/index.vue';
|
|
|
29
38
|
import Empty from '../Empty/index.vue';
|
|
30
39
|
import FilterInput from '../FilterInput/index.vue';
|
|
31
40
|
import type { DevTool } from '../../type';
|
|
41
|
+
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
42
|
+
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
43
|
+
|
|
32
44
|
defineProps<{
|
|
33
45
|
wsList: DevTool.WS[];
|
|
34
46
|
currentWebSocketType: string;
|
package/dev/const.ts
CHANGED
|
@@ -162,7 +162,5 @@ export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
|
|
|
162
162
|
*/
|
|
163
163
|
export const DEV_RUN_JS = 'dev-uni-run-js';
|
|
164
164
|
|
|
165
|
-
/**
|
|
166
|
-
|
|
167
|
-
*/
|
|
168
|
-
export const DEV_RUN_JS_CLEAR = 'dev-uni-run-js-clear';
|
|
165
|
+
/** 清空截屏列表 */
|
|
166
|
+
export const DEV_CAPTURE_SCREEN_CLEAR = 'dev-capture-screen-clear';
|
package/dev/devEvent/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
DEV_OPTION_SEND,
|
|
31
31
|
DEV_UNI_EVENT_CLEAR,
|
|
32
32
|
DEV_RUN_JS,
|
|
33
|
+
DEV_CAPTURE_SCREEN_CLEAR,
|
|
33
34
|
} from '../const';
|
|
34
35
|
import { DevStore } from '../devStore';
|
|
35
36
|
import type { DevTool } from '../type';
|
|
@@ -247,7 +248,8 @@ export class DevEvent {
|
|
|
247
248
|
* @memberof DevEvent
|
|
248
249
|
*/
|
|
249
250
|
switchTo(path: string) {
|
|
250
|
-
this.showDevToolButton();
|
|
251
|
+
// this.showDevToolButton();
|
|
252
|
+
this.closeDevToolWindow();
|
|
251
253
|
uni.switchTab({
|
|
252
254
|
url: path,
|
|
253
255
|
});
|
|
@@ -260,7 +262,8 @@ export class DevEvent {
|
|
|
260
262
|
* @memberof DevEvent
|
|
261
263
|
*/
|
|
262
264
|
navigateTo(path: string) {
|
|
263
|
-
this.showDevToolButton();
|
|
265
|
+
// this.showDevToolButton();
|
|
266
|
+
this.closeDevToolWindow();
|
|
264
267
|
uni.navigateTo({
|
|
265
268
|
url: path,
|
|
266
269
|
});
|
|
@@ -430,6 +433,10 @@ export class DevEvent {
|
|
|
430
433
|
else if (data.type === DEV_RUN_JS) {
|
|
431
434
|
this.devRunJS(data.data.code);
|
|
432
435
|
}
|
|
436
|
+
// 清空截屏列表
|
|
437
|
+
else if (data.type === DEV_CAPTURE_SCREEN_CLEAR) {
|
|
438
|
+
this.store.clearCaptureScreenList();
|
|
439
|
+
}
|
|
433
440
|
},
|
|
434
441
|
);
|
|
435
442
|
}
|
|
@@ -776,4 +783,24 @@ export class DevEvent {
|
|
|
776
783
|
this.postMessageFn();
|
|
777
784
|
});
|
|
778
785
|
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* 更新截屏列表
|
|
789
|
+
*
|
|
790
|
+
* @param {DevTool.CaptureScreenItem[]} list
|
|
791
|
+
* @memberof DevEvent
|
|
792
|
+
*/
|
|
793
|
+
updateCaptureScreenList(list: DevTool.CaptureScreenItem[]) {
|
|
794
|
+
this.store.updateCaptureScreenList(list);
|
|
795
|
+
this.postMessage();
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* 清空截屏列表
|
|
800
|
+
*
|
|
801
|
+
* @memberof DevEvent
|
|
802
|
+
*/
|
|
803
|
+
clearCaptureScreenList() {
|
|
804
|
+
this.store.clearCaptureScreenList();
|
|
805
|
+
}
|
|
779
806
|
}
|
|
@@ -724,4 +724,22 @@ export class DevIntercept {
|
|
|
724
724
|
this.interceptUniEventFactory('emit');
|
|
725
725
|
this.interceptUniEventFactory('off');
|
|
726
726
|
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* 监听截屏
|
|
730
|
+
*
|
|
731
|
+
* @memberof DevIntercept
|
|
732
|
+
*/
|
|
733
|
+
interceptCaptureScreen() {
|
|
734
|
+
uni.onUserCaptureScreen(() => {
|
|
735
|
+
if (!this.event.getDevToolDestroy()) {
|
|
736
|
+
this.event.updateCaptureScreenList([
|
|
737
|
+
{
|
|
738
|
+
position: getCurrentPagePath(),
|
|
739
|
+
timer: getCurrentDate(),
|
|
740
|
+
},
|
|
741
|
+
]);
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
}
|
|
727
745
|
}
|
package/dev/devStore/index.ts
CHANGED
|
@@ -26,6 +26,7 @@ export class DevStore {
|
|
|
26
26
|
deviceInfo: {},
|
|
27
27
|
windowInfo: {},
|
|
28
28
|
systemInfo: {},
|
|
29
|
+
appInfo: {},
|
|
29
30
|
wsList: [],
|
|
30
31
|
netWorkStatus: {},
|
|
31
32
|
uploadList: [],
|
|
@@ -36,6 +37,7 @@ export class DevStore {
|
|
|
36
37
|
emit: 0,
|
|
37
38
|
off: 0,
|
|
38
39
|
},
|
|
40
|
+
captureScreenList: [],
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
/** 调试配置 */
|
|
@@ -52,6 +54,8 @@ export class DevStore {
|
|
|
52
54
|
private eventListMaxSize = 1000;
|
|
53
55
|
/** js 最大运行条数 */
|
|
54
56
|
private runJsMaxSize = 1000;
|
|
57
|
+
/** 截屏最大值 */
|
|
58
|
+
private captureScreenMaxSize = 1000;
|
|
55
59
|
|
|
56
60
|
/** 缓存最大值 */
|
|
57
61
|
cacheMaxSize = 8 * 1024 * 1024 * 10;
|
|
@@ -185,6 +189,14 @@ export class DevStore {
|
|
|
185
189
|
const systemInfo = uni.getSystemInfoSync();
|
|
186
190
|
const deviceInfo = uni.getDeviceInfo();
|
|
187
191
|
const windowInfo = uni.getWindowInfo();
|
|
192
|
+
|
|
193
|
+
const appInfo = {
|
|
194
|
+
...(await uni.getAppBaseInfo()),
|
|
195
|
+
|
|
196
|
+
// #ifndef H5
|
|
197
|
+
...(await uni.getAppAuthorizeSetting()),
|
|
198
|
+
// #endif
|
|
199
|
+
};
|
|
188
200
|
const ip = getWifiIp() || getLanIp() || (await getMicroAppIp());
|
|
189
201
|
return {
|
|
190
202
|
...this.state,
|
|
@@ -192,6 +204,7 @@ export class DevStore {
|
|
|
192
204
|
deviceInfo,
|
|
193
205
|
windowInfo,
|
|
194
206
|
devToolVisible: this.getDevToolVisible(),
|
|
207
|
+
appInfo,
|
|
195
208
|
netWorkStatus: {
|
|
196
209
|
ip,
|
|
197
210
|
...networkType,
|
|
@@ -344,6 +357,8 @@ export class DevStore {
|
|
|
344
357
|
emit: 0,
|
|
345
358
|
off: 0,
|
|
346
359
|
};
|
|
360
|
+
|
|
361
|
+
this.state.captureScreenList = [];
|
|
347
362
|
}
|
|
348
363
|
|
|
349
364
|
addUploadTask(index: number | string, task: UniApp.UploadTask) {
|
|
@@ -682,4 +697,22 @@ export class DevStore {
|
|
|
682
697
|
};
|
|
683
698
|
this.state.eventList = [];
|
|
684
699
|
}
|
|
700
|
+
|
|
701
|
+
updateCaptureScreenList(captureScreenList: DevTool.CaptureScreenItem[]) {
|
|
702
|
+
const len = this.state.captureScreenList?.length ?? 0;
|
|
703
|
+
const max = this.captureScreenMaxSize;
|
|
704
|
+
if (len + captureScreenList.length > max) {
|
|
705
|
+
this.state.captureScreenList?.splice(
|
|
706
|
+
0,
|
|
707
|
+
len - max - captureScreenList.length,
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
this.state.captureScreenList?.push(...captureScreenList);
|
|
711
|
+
|
|
712
|
+
return this.state.captureScreenList;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
clearCaptureScreenList() {
|
|
716
|
+
this.state.captureScreenList = [];
|
|
717
|
+
}
|
|
685
718
|
}
|