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
|
@@ -16,99 +16,138 @@
|
|
|
16
16
|
<view style="margin-left: 6px">{{ sizeFormat }}</view>
|
|
17
17
|
</template> -->
|
|
18
18
|
</Tabs>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<
|
|
111
|
-
|
|
19
|
+
<swiper
|
|
20
|
+
class="dev-tool-window-container"
|
|
21
|
+
:current="activeTab"
|
|
22
|
+
@change="onChangeSwiper"
|
|
23
|
+
>
|
|
24
|
+
<swiper-item>
|
|
25
|
+
<ConsoleList
|
|
26
|
+
v-if="swiperShow(0)"
|
|
27
|
+
:currentConsoleType="currentConsoleType"
|
|
28
|
+
:consoleList="consoleList"
|
|
29
|
+
:sourceFileServers="sourceFileServers"
|
|
30
|
+
:mode="mode"
|
|
31
|
+
:useDevSource="useDevSource"
|
|
32
|
+
v-model="searchConsole"
|
|
33
|
+
@choose="onConsoleChoose"
|
|
34
|
+
@search="onSearchConsole"
|
|
35
|
+
@run="onRunJS"
|
|
36
|
+
/>
|
|
37
|
+
</swiper-item>
|
|
38
|
+
<swiper-item>
|
|
39
|
+
<Connection v-if="swiperShow(1)" :netWorkStatus="netWorkStatus" />
|
|
40
|
+
</swiper-item>
|
|
41
|
+
<swiper-item>
|
|
42
|
+
<NetworkList
|
|
43
|
+
v-if="swiperShow(2)"
|
|
44
|
+
:currentNetworkType="currentNetworkType"
|
|
45
|
+
:networkList="networkList"
|
|
46
|
+
v-model="searchNetwork"
|
|
47
|
+
@choose="onNetworkChoose"
|
|
48
|
+
@search="onSearchNetwork"
|
|
49
|
+
/>
|
|
50
|
+
</swiper-item>
|
|
51
|
+
<swiper-item>
|
|
52
|
+
<UploadList
|
|
53
|
+
v-if="swiperShow(3)"
|
|
54
|
+
:currentUploadType="currentUploadType"
|
|
55
|
+
:uploadList="uploadList"
|
|
56
|
+
v-model="searchUpload"
|
|
57
|
+
@choose="onUploadChoose"
|
|
58
|
+
@search="onSearchUpload"
|
|
59
|
+
/>
|
|
60
|
+
</swiper-item>
|
|
61
|
+
<swiper-item>
|
|
62
|
+
<WebSocket
|
|
63
|
+
v-if="swiperShow(4)"
|
|
64
|
+
:wsList="wsList"
|
|
65
|
+
:currentWebSocketType="currentWebSocketType"
|
|
66
|
+
v-model="searchWs"
|
|
67
|
+
@choose="onWebSocketChoose"
|
|
68
|
+
@search="onSearchWs"
|
|
69
|
+
/>
|
|
70
|
+
</swiper-item>
|
|
71
|
+
<swiper-item>
|
|
72
|
+
<RouteList
|
|
73
|
+
v-if="swiperShow(5)"
|
|
74
|
+
:routeList="routeList"
|
|
75
|
+
v-model="searchRoute"
|
|
76
|
+
@goTo="onGoTo"
|
|
77
|
+
@search="onSearchRoute"
|
|
78
|
+
@routeRefresh="onRouteRefresh"
|
|
79
|
+
/>
|
|
80
|
+
</swiper-item>
|
|
81
|
+
<swiper-item>
|
|
82
|
+
<UniEvent
|
|
83
|
+
v-if="swiperShow(6)"
|
|
84
|
+
:eventList="eventList"
|
|
85
|
+
:eventCount="eventCount"
|
|
86
|
+
:mode="mode"
|
|
87
|
+
:useDevSource="useDevSource"
|
|
88
|
+
:sourceFileServers="sourceFileServers"
|
|
89
|
+
@clear="onUniEventClear"
|
|
90
|
+
/>
|
|
91
|
+
</swiper-item>
|
|
92
|
+
<swiper-item>
|
|
93
|
+
<CaptureScreen
|
|
94
|
+
v-if="swiperShow(7)"
|
|
95
|
+
:captureScreenList="captureScreenList"
|
|
96
|
+
@clear="onCaptureScreenClear"
|
|
97
|
+
/>
|
|
98
|
+
</swiper-item>
|
|
99
|
+
<swiper-item>
|
|
100
|
+
<StorageList
|
|
101
|
+
v-if="swiperShow(8)"
|
|
102
|
+
v-model:storage-list="storageList"
|
|
103
|
+
v-model="searchStorage"
|
|
104
|
+
@choose="onStorageChoose"
|
|
105
|
+
@remove="onStorageRemove"
|
|
106
|
+
@diff-value="onChangeStorage"
|
|
107
|
+
@search="onSearchStorage"
|
|
108
|
+
/>
|
|
109
|
+
</swiper-item>
|
|
110
|
+
<swiper-item>
|
|
111
|
+
<VuexList
|
|
112
|
+
v-if="swiperShow(9)"
|
|
113
|
+
v-model:vuexList="vuexList"
|
|
114
|
+
@diff-value="onChangeVuex"
|
|
115
|
+
/>
|
|
116
|
+
</swiper-item>
|
|
117
|
+
<swiper-item>
|
|
118
|
+
<PiniaList
|
|
119
|
+
v-if="swiperShow(10)"
|
|
120
|
+
v-model:pinia-list="piniaList"
|
|
121
|
+
@diff-value="onChangePinia"
|
|
122
|
+
/>
|
|
123
|
+
</swiper-item>
|
|
124
|
+
<swiper-item>
|
|
125
|
+
<WindowInfo v-if="swiperShow(11)" :windowInfo="windowInfo" />
|
|
126
|
+
</swiper-item>
|
|
127
|
+
<swiper-item>
|
|
128
|
+
<DeviceInfo v-if="swiperShow(12)" :deviceInfo="deviceInfo" />
|
|
129
|
+
</swiper-item>
|
|
130
|
+
<swiper-item>
|
|
131
|
+
<SystemInfo v-if="swiperShow(13)" :systemInfo="systemInfo" />
|
|
132
|
+
</swiper-item>
|
|
133
|
+
<swiper-item>
|
|
134
|
+
<AppInfo v-if="swiperShow(14)" :appInfo="appInfo" />
|
|
135
|
+
</swiper-item>
|
|
136
|
+
<swiper-item>
|
|
137
|
+
<SettingList
|
|
138
|
+
v-if="swiperShow(15)"
|
|
139
|
+
:devToolVisible="devToolVisible"
|
|
140
|
+
:sizeFormat="sizeFormat"
|
|
141
|
+
@showDevButton="onShowDevButton"
|
|
142
|
+
@restartDevTool="onRestartDevTool"
|
|
143
|
+
@restartApp="onRestartApp"
|
|
144
|
+
@exportLog="onExportLog"
|
|
145
|
+
@screenshot="onScreenshot"
|
|
146
|
+
@clearCache="onClearCache"
|
|
147
|
+
@destroyDevTool="onDestroyDevTool"
|
|
148
|
+
/>
|
|
149
|
+
</swiper-item>
|
|
150
|
+
</swiper>
|
|
112
151
|
</view>
|
|
113
152
|
</template>
|
|
114
153
|
|
|
@@ -130,7 +169,8 @@ import WindowInfo from '../WindowInfo/index.vue';
|
|
|
130
169
|
import WebSocket from '../WebSocket/index.vue';
|
|
131
170
|
import UploadList from '../UploadList/index.vue';
|
|
132
171
|
import UniEvent from '../UniEvent/index.vue';
|
|
133
|
-
import
|
|
172
|
+
import AppInfo from '../AppInfo/index.vue';
|
|
173
|
+
import CaptureScreen from '../CaptureScreen/index.vue';
|
|
134
174
|
import {
|
|
135
175
|
DEV_BUTTON_SHOW_OR_HIDE,
|
|
136
176
|
DEV_CONSOLE_CLEAR,
|
|
@@ -154,8 +194,8 @@ import {
|
|
|
154
194
|
DEV_WINDOW_INFO,
|
|
155
195
|
DEV_APP_MESSAGE,
|
|
156
196
|
DEV_UNI_EVENT_CLEAR,
|
|
157
|
-
DEV_RUN_JS_CLEAR,
|
|
158
197
|
DEV_RUN_JS,
|
|
198
|
+
DEV_CAPTURE_SCREEN_CLEAR,
|
|
159
199
|
} from '../../const';
|
|
160
200
|
import { debounce, hightLight } from '../../utils/index';
|
|
161
201
|
import type { DevTool } from '../../type';
|
|
@@ -166,72 +206,98 @@ const items = [
|
|
|
166
206
|
key: 'Console',
|
|
167
207
|
label: 'Console',
|
|
168
208
|
value: 'Console',
|
|
209
|
+
index: 0,
|
|
169
210
|
},
|
|
170
211
|
{
|
|
171
212
|
key: 'Connection',
|
|
172
213
|
label: 'Connection',
|
|
173
214
|
value: 'Connection',
|
|
215
|
+
index: 1,
|
|
174
216
|
},
|
|
175
217
|
{
|
|
176
218
|
key: 'Network',
|
|
177
219
|
label: 'Network',
|
|
178
220
|
value: 'NetWork',
|
|
221
|
+
index: 2,
|
|
179
222
|
},
|
|
180
223
|
{
|
|
181
224
|
key: 'Upload',
|
|
182
225
|
label: 'Upload',
|
|
183
226
|
value: 'Upload',
|
|
227
|
+
index: 3,
|
|
184
228
|
},
|
|
185
229
|
{
|
|
186
230
|
key: 'WebSocket',
|
|
187
231
|
label: 'WebSocket',
|
|
188
232
|
value: 'WebSocket',
|
|
233
|
+
index: 4,
|
|
189
234
|
},
|
|
190
235
|
{
|
|
191
236
|
key: 'Route',
|
|
192
237
|
label: 'Route',
|
|
193
238
|
value: 'Route',
|
|
239
|
+
index: 5,
|
|
194
240
|
},
|
|
195
241
|
{
|
|
196
242
|
key: 'UniEvent',
|
|
197
243
|
label: 'UniEvent',
|
|
198
244
|
value: 'UniEvent',
|
|
245
|
+
index: 6,
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
key: 'CaptureScreen',
|
|
249
|
+
label: 'CaptureScreen',
|
|
250
|
+
value: 'CaptureScreen',
|
|
251
|
+
index: 7,
|
|
199
252
|
},
|
|
200
253
|
{
|
|
201
254
|
key: 'Storage',
|
|
202
255
|
label: 'Storage',
|
|
203
256
|
value: 'Storage',
|
|
257
|
+
index: 8,
|
|
204
258
|
},
|
|
205
259
|
|
|
206
260
|
{
|
|
207
261
|
key: 'Vuex',
|
|
208
262
|
label: 'Vuex',
|
|
209
263
|
value: 'Vuex',
|
|
264
|
+
index: 9,
|
|
210
265
|
},
|
|
211
266
|
{
|
|
212
267
|
key: 'Pinia',
|
|
213
268
|
label: 'Pinia',
|
|
214
269
|
value: 'Pinia',
|
|
270
|
+
index: 10,
|
|
215
271
|
},
|
|
216
272
|
{
|
|
217
273
|
key: 'Window',
|
|
218
274
|
label: 'Window',
|
|
219
275
|
value: 'Window',
|
|
276
|
+
index: 11,
|
|
220
277
|
},
|
|
221
278
|
{
|
|
222
279
|
key: 'Device',
|
|
223
280
|
label: 'Device',
|
|
224
281
|
value: 'Device',
|
|
282
|
+
index: 12,
|
|
225
283
|
},
|
|
226
284
|
{
|
|
227
285
|
key: 'System',
|
|
228
286
|
label: 'System',
|
|
229
287
|
value: 'System',
|
|
288
|
+
index: 13,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
key: 'AppInfo',
|
|
292
|
+
label: 'AppInfo',
|
|
293
|
+
value: 'AppInfo',
|
|
294
|
+
index: 14,
|
|
230
295
|
},
|
|
231
296
|
{
|
|
232
297
|
key: 'Setting',
|
|
233
298
|
label: 'Setting',
|
|
234
299
|
value: 'Setting',
|
|
300
|
+
index: 15,
|
|
235
301
|
},
|
|
236
302
|
];
|
|
237
303
|
|
|
@@ -267,6 +333,8 @@ const deviceInfo = ref<Record<string, any>>({});
|
|
|
267
333
|
const windowInfo = ref<Record<string, any>>({});
|
|
268
334
|
const eventList = ref<DevTool.EventItem[]>([]);
|
|
269
335
|
const eventCount = ref<DevTool.EventCount>();
|
|
336
|
+
const appInfo = ref<Record<string, any>>({});
|
|
337
|
+
const captureScreenList = ref<DevTool.CaptureScreenItem[]>([]);
|
|
270
338
|
|
|
271
339
|
const netWorkStatus = ref<{
|
|
272
340
|
isConnected?: boolean;
|
|
@@ -276,7 +344,7 @@ const sizeFormat = ref('');
|
|
|
276
344
|
|
|
277
345
|
const devToolVisible = ref(true);
|
|
278
346
|
|
|
279
|
-
const activeTab = ref(
|
|
347
|
+
const activeTab = ref(0);
|
|
280
348
|
const tabScrollLeft = ref(0);
|
|
281
349
|
const currentConsoleType = ref('all');
|
|
282
350
|
const currentNetworkType = ref('all');
|
|
@@ -303,6 +371,14 @@ const emits = defineEmits<{
|
|
|
303
371
|
(e: 'sendMessage', data: { type: string; data: Record<string, any> }): void;
|
|
304
372
|
}>();
|
|
305
373
|
|
|
374
|
+
function swiperShow(index: number) {
|
|
375
|
+
const show =
|
|
376
|
+
index == activeTab.value - 1 ||
|
|
377
|
+
index == activeTab.value ||
|
|
378
|
+
index == activeTab.value + 1;
|
|
379
|
+
return show;
|
|
380
|
+
}
|
|
381
|
+
|
|
306
382
|
const listenPostMessage = (data: DevTool.WindowData) => {
|
|
307
383
|
if (!props.open) return;
|
|
308
384
|
if (!isActive) return;
|
|
@@ -319,7 +395,11 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
319
395
|
})
|
|
320
396
|
.filter((item) => {
|
|
321
397
|
return (
|
|
322
|
-
item.args?.some(
|
|
398
|
+
item.args?.some(
|
|
399
|
+
(arg) =>
|
|
400
|
+
arg.type === 'string' &&
|
|
401
|
+
arg.value?.includes?.(searchConsole.value),
|
|
402
|
+
) ||
|
|
323
403
|
item.position.includes(searchConsole.value) ||
|
|
324
404
|
item?.stack?.includes(searchConsole.value)
|
|
325
405
|
);
|
|
@@ -329,7 +409,15 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
329
409
|
...item,
|
|
330
410
|
position: hightLight(item.position, searchConsole.value),
|
|
331
411
|
stack: hightLight(item.stack, searchConsole.value),
|
|
332
|
-
args: item.args.map((arg) =>
|
|
412
|
+
args: item.args.map((arg) => {
|
|
413
|
+
if (arg.type === 'string') {
|
|
414
|
+
return {
|
|
415
|
+
type: 'string',
|
|
416
|
+
value: hightLight(arg.value, searchConsole.value),
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return arg;
|
|
420
|
+
}),
|
|
333
421
|
};
|
|
334
422
|
});
|
|
335
423
|
|
|
@@ -455,13 +543,21 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
455
543
|
if (data.sizeFormat) {
|
|
456
544
|
sizeFormat.value = data.sizeFormat;
|
|
457
545
|
}
|
|
546
|
+
|
|
547
|
+
if (data.appInfo) {
|
|
548
|
+
appInfo.value = data.appInfo;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (data.captureScreenList) {
|
|
552
|
+
captureScreenList.value = data.captureScreenList;
|
|
553
|
+
}
|
|
458
554
|
};
|
|
459
555
|
|
|
460
556
|
let isActive = false;
|
|
461
557
|
onMounted(() => {
|
|
462
558
|
const windowInfo = uni.getStorageSync(DEV_WINDOW_INFO);
|
|
463
559
|
if (windowInfo) {
|
|
464
|
-
activeTab.value = windowInfo?.activeTab ||
|
|
560
|
+
activeTab.value = windowInfo?.activeTab || 0;
|
|
465
561
|
currentConsoleType.value = windowInfo?.currentConsoleType || 'all';
|
|
466
562
|
currentNetworkType.value = windowInfo?.currentNetworkType || 'all';
|
|
467
563
|
tabScrollLeft.value = windowInfo?.tabScrollLeft || 0;
|
|
@@ -515,6 +611,15 @@ function onChangeTabs() {
|
|
|
515
611
|
setWindowInfo();
|
|
516
612
|
}
|
|
517
613
|
|
|
614
|
+
function onChangeSwiper({
|
|
615
|
+
detail,
|
|
616
|
+
}: {
|
|
617
|
+
detail: { current: number; source: any };
|
|
618
|
+
}) {
|
|
619
|
+
activeTab.value = detail.current;
|
|
620
|
+
setWindowInfo();
|
|
621
|
+
}
|
|
622
|
+
|
|
518
623
|
function onScrollTabs(e: any) {
|
|
519
624
|
tabScrollLeft.value = e.detail.scrollLeft;
|
|
520
625
|
debounceSetWindowInfo();
|
|
@@ -556,7 +661,9 @@ function onSearchConsole(value: string) {
|
|
|
556
661
|
consoleList.value = backup.consoleList
|
|
557
662
|
.filter((item) => {
|
|
558
663
|
return (
|
|
559
|
-
item.args.some(
|
|
664
|
+
item.args.some(
|
|
665
|
+
(arg) => arg.type === 'string' && arg.value.includes(value),
|
|
666
|
+
) ||
|
|
560
667
|
item.position.includes(value) ||
|
|
561
668
|
item?.stack?.includes(value)
|
|
562
669
|
);
|
|
@@ -566,7 +673,15 @@ function onSearchConsole(value: string) {
|
|
|
566
673
|
...item,
|
|
567
674
|
position: hightLight(item.position, searchConsole.value),
|
|
568
675
|
stack: hightLight(item.stack, searchConsole.value),
|
|
569
|
-
args: item.args.map((arg) =>
|
|
676
|
+
args: item.args.map((arg) => {
|
|
677
|
+
if (arg.type === 'string') {
|
|
678
|
+
return {
|
|
679
|
+
type: 'string',
|
|
680
|
+
value: hightLight(arg.value, value),
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
return arg;
|
|
684
|
+
}),
|
|
570
685
|
};
|
|
571
686
|
});
|
|
572
687
|
}
|
|
@@ -761,6 +876,14 @@ function onUniEventClear() {
|
|
|
761
876
|
});
|
|
762
877
|
}
|
|
763
878
|
|
|
879
|
+
function onCaptureScreenClear() {
|
|
880
|
+
captureScreenList.value = [];
|
|
881
|
+
basicSendMessage({
|
|
882
|
+
type: DEV_CAPTURE_SCREEN_CLEAR,
|
|
883
|
+
data: {},
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
|
|
764
887
|
function onGoTo(page: DevTool.Page) {
|
|
765
888
|
basicSendMessage({
|
|
766
889
|
type: DEV_PAGE_JUMP,
|
|
@@ -907,6 +1030,7 @@ function onChangePinia(value: Record<string, any>) {
|
|
|
907
1030
|
height: 0;
|
|
908
1031
|
background-color: transparent;
|
|
909
1032
|
}
|
|
1033
|
+
|
|
910
1034
|
.dev-tool-window::after {
|
|
911
1035
|
content: '';
|
|
912
1036
|
}
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
|
-
v-if="isOpen
|
|
3
|
+
v-if="isOpen || isClose"
|
|
4
4
|
:class="`json-pretty-carets json-pretty-carets-${
|
|
5
5
|
isOpen ? 'open' : 'close'
|
|
6
6
|
}`"
|
|
7
7
|
@click="onClick"
|
|
8
8
|
>
|
|
9
|
-
<
|
|
10
|
-
viewBox="0 0 1024 1024"
|
|
11
|
-
focusable="false"
|
|
12
|
-
data-icon="caret-down"
|
|
13
|
-
width="1em"
|
|
14
|
-
height="1em"
|
|
15
|
-
fill="currentColor"
|
|
16
|
-
aria-hidden="true"
|
|
17
|
-
>
|
|
18
|
-
<path
|
|
19
|
-
d="M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"
|
|
20
|
-
></path>
|
|
21
|
-
</svg>
|
|
9
|
+
<view class="json-pretty-caret-down"></view>
|
|
22
10
|
</view>
|
|
23
11
|
</template>
|
|
24
12
|
<script lang="ts" setup>
|
|
@@ -60,4 +48,12 @@ function onClick(e: MouseEvent) {
|
|
|
60
48
|
.json-pretty-carets-close {
|
|
61
49
|
transform: rotate(-90deg);
|
|
62
50
|
}
|
|
51
|
+
|
|
52
|
+
.json-pretty-caret-down {
|
|
53
|
+
margin: 7px 4px;
|
|
54
|
+
border: 3px solid #000;
|
|
55
|
+
border-top-color: transparent;
|
|
56
|
+
border-left-color: transparent;
|
|
57
|
+
transform: rotate(45deg);
|
|
58
|
+
}
|
|
63
59
|
</style>
|
|
@@ -16,51 +16,55 @@
|
|
|
16
16
|
: style
|
|
17
17
|
"
|
|
18
18
|
>
|
|
19
|
-
<
|
|
19
|
+
<VirtualListPro
|
|
20
20
|
v-if="autoVirtual"
|
|
21
21
|
:height="state.height"
|
|
22
|
-
:
|
|
22
|
+
:pageSize="pageSize"
|
|
23
23
|
:data="flatData"
|
|
24
24
|
>
|
|
25
|
-
<template v-slot="{ list }">
|
|
26
|
-
<
|
|
27
|
-
v-for="item in list"
|
|
28
|
-
:
|
|
29
|
-
:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
25
|
+
<template v-slot="{ list, start }">
|
|
26
|
+
<AutoSize
|
|
27
|
+
v-for="(item, index) in list"
|
|
28
|
+
:index="start + index"
|
|
29
|
+
:key="start + index"
|
|
30
|
+
>
|
|
31
|
+
<TreeNode
|
|
32
|
+
:data="data"
|
|
33
|
+
:rootPath="rootPath"
|
|
34
|
+
:indent="indent"
|
|
35
|
+
:node="item"
|
|
36
|
+
:collapsed="!!state.hiddenPaths[item.path]"
|
|
37
|
+
:theme="theme"
|
|
38
|
+
:showDoubleQuotes="showDoubleQuotes"
|
|
39
|
+
:showLength="showLength"
|
|
40
|
+
:checked="selectedPaths.includes(item.path)"
|
|
41
|
+
:selectableType="selectableType"
|
|
42
|
+
:showLine="showLine"
|
|
43
|
+
:showLineNumber="showLineNumber"
|
|
44
|
+
:showSelectController="showSelectController"
|
|
45
|
+
:selectOnClickNode="selectOnClickNode"
|
|
46
|
+
:nodeSelectable="nodeSelectable"
|
|
47
|
+
:highlightSelectedNode="highlightSelectedNode"
|
|
48
|
+
:editable="editable"
|
|
49
|
+
:editableTrigger="editableTrigger"
|
|
50
|
+
:showIcon="showIcon"
|
|
51
|
+
:showKeyValueSpace="showKeyValueSpace"
|
|
52
|
+
:showNodeActions="showNodeActions"
|
|
53
|
+
@nodeClick="handleNodeClick"
|
|
54
|
+
@nodeMouseover="handleNodeMouseover"
|
|
55
|
+
@bracketsClick="handleBracketsClick"
|
|
56
|
+
@iconClick="handleIconClick"
|
|
57
|
+
@selectedChange="handleSelectedChange"
|
|
58
|
+
@valueChange="handleValueChange"
|
|
59
|
+
:style="
|
|
60
|
+
itemHeight && itemHeight !== 20
|
|
61
|
+
? { lineHeight: `${itemHeight}px` }
|
|
62
|
+
: {}
|
|
63
|
+
"
|
|
64
|
+
/>
|
|
65
|
+
</AutoSize>
|
|
62
66
|
</template>
|
|
63
|
-
</
|
|
67
|
+
</VirtualListPro>
|
|
64
68
|
<template v-else>
|
|
65
69
|
<TreeNode
|
|
66
70
|
v-for="item in state?.visibleData"
|
|
@@ -115,7 +119,8 @@ import {
|
|
|
115
119
|
} from 'vue';
|
|
116
120
|
import TreeNode from './components/TreeNode/index.vue';
|
|
117
121
|
|
|
118
|
-
import
|
|
122
|
+
import VirtualListPro from '../VirtualListPro/index.vue';
|
|
123
|
+
import AutoSize from '../VirtualListPro/AutoSize.vue';
|
|
119
124
|
|
|
120
125
|
import { emitError, jsonFlatten, cloneDeep, isFunction } from './utils';
|
|
121
126
|
|
|
@@ -162,6 +167,10 @@ const emits = defineEmits<Emits>();
|
|
|
162
167
|
|
|
163
168
|
const originFlatData = computed(() => jsonFlatten(props.data, props.rootPath));
|
|
164
169
|
|
|
170
|
+
const pageSize = computed(() => {
|
|
171
|
+
return Math.ceil(props.height / props.itemHeight) + 5;
|
|
172
|
+
});
|
|
173
|
+
|
|
165
174
|
// 初始化折叠路径
|
|
166
175
|
const initHiddenPaths = (
|
|
167
176
|
deep: number,
|