vite-uni-dev-tool 0.0.16 → 0.0.18
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 +12 -0
- package/dist/devIntercept/index.d.ts.map +1 -1
- package/dist/devIntercept/index.js +139 -137
- package/dist/devStore/index.js +1 -1
- package/dist/type.d.ts +5 -1
- package/dist/type.d.ts.map +1 -1
- package/dist/v2/{CloseButton → CircularButton}/index.vue +5 -2
- package/dist/v2/NetworkList/NetworkDetail.vue +3 -3
- package/dist/v2/NetworkList/NetworkItem.vue +5 -3
- package/dist/v2/SettingList/index.vue +1 -1
- package/dist/v2/SourceCode/index.vue +3 -3
- package/dist/v2/StorageList/index.vue +7 -3
- package/dist/v2/Tabs/index.vue +3 -3
- package/dist/v2/UploadList/UploadDetail.vue +3 -3
- package/dist/v2/WebSocket/WebSocketList.vue +3 -3
- package/dist/v3/AppInfo/index.vue +2 -1
- package/dist/v3/{CloseButton → CircularButton}/index.vue +4 -2
- package/dist/v3/ConsoleList/ConsoleItem.vue +44 -96
- package/dist/v3/ConsoleList/index.vue +2 -0
- package/dist/v3/DevTool/index.vue +4 -4
- package/dist/v3/DevToolWindow/index.vue +182 -19
- package/dist/v3/DeviceInfo/index.vue +2 -1
- package/dist/v3/FilterSelect/index.vue +166 -0
- package/dist/v3/JsonPretty/index.vue +2 -0
- package/dist/v3/NetworkList/NetworkDetail.vue +12 -8
- package/dist/v3/NetworkList/NetworkItem.vue +56 -26
- package/dist/v3/NetworkList/NetworkSend.vue +701 -0
- package/dist/v3/NetworkList/const.d.ts +5 -0
- package/dist/v3/NetworkList/const.d.ts.map +1 -0
- package/dist/v3/NetworkList/const.ts +4 -0
- package/dist/v3/NetworkList/index.vue +104 -21
- package/dist/v3/PiniaList/index.vue +5 -4
- package/dist/v3/SettingList/index.vue +3 -3
- package/dist/v3/SourceCode/index.vue +22 -8
- package/dist/v3/StorageList/index.vue +9 -6
- package/dist/v3/SystemInfo/index.vue +2 -1
- package/dist/v3/Tabs/index.vue +2 -2
- package/dist/v3/UniEvent/UniEventItem.vue +6 -54
- package/dist/v3/UniEvent/index.vue +2 -0
- package/dist/v3/UploadList/UploadDetail.vue +2 -2
- package/dist/v3/VuexList/index.vue +4 -2
- package/dist/v3/WebSocket/WebSocketList.vue +2 -2
- package/dist/v3/WindowInfo/index.vue +2 -1
- package/package.json +1 -1
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
@choose="onConsoleChoose"
|
|
40
40
|
@search="onSearchConsole"
|
|
41
41
|
@run="onRunJS"
|
|
42
|
+
@openCode="onOpenCode"
|
|
42
43
|
/>
|
|
43
44
|
</swiper-item>
|
|
44
45
|
<swiper-item>
|
|
@@ -47,12 +48,17 @@
|
|
|
47
48
|
<swiper-item>
|
|
48
49
|
<NetworkList
|
|
49
50
|
v-if="swiperShow(2)"
|
|
50
|
-
:currentNetworkType="currentNetworkType"
|
|
51
|
-
:networkList="networkList"
|
|
52
|
-
:zIndex="zIndex + 1"
|
|
53
51
|
v-model="searchNetwork"
|
|
52
|
+
:mode="mode"
|
|
53
|
+
:zIndex="zIndex + 1"
|
|
54
|
+
:networkList="networkList"
|
|
55
|
+
:useDevSource="useDevSource"
|
|
56
|
+
:currentNetworkType="currentNetworkType"
|
|
57
|
+
:currentNetworkSort="currentNetworkSort"
|
|
54
58
|
@choose="onNetworkChoose"
|
|
55
59
|
@search="onSearchNetwork"
|
|
60
|
+
@sort="onSortNetwork"
|
|
61
|
+
@openCode="onOpenCode"
|
|
56
62
|
/>
|
|
57
63
|
</swiper-item>
|
|
58
64
|
<swiper-item>
|
|
@@ -90,13 +96,14 @@
|
|
|
90
96
|
<swiper-item>
|
|
91
97
|
<UniEvent
|
|
92
98
|
v-if="swiperShow(6)"
|
|
99
|
+
:mode="mode"
|
|
93
100
|
:eventList="eventList"
|
|
94
101
|
:eventCount="eventCount"
|
|
95
|
-
:
|
|
102
|
+
:zIndex="zIndex + 1"
|
|
96
103
|
:useDevSource="useDevSource"
|
|
97
104
|
:sourceFileServers="sourceFileServers"
|
|
98
|
-
:zIndex="zIndex + 1"
|
|
99
105
|
@clear="onUniEventClear"
|
|
106
|
+
@openCode="onOpenCode"
|
|
100
107
|
/>
|
|
101
108
|
</swiper-item>
|
|
102
109
|
<swiper-item>
|
|
@@ -111,6 +118,7 @@
|
|
|
111
118
|
v-if="swiperShow(8)"
|
|
112
119
|
v-model:storage-list="storageList"
|
|
113
120
|
v-model="searchStorage"
|
|
121
|
+
:theme="theme"
|
|
114
122
|
@choose="onStorageChoose"
|
|
115
123
|
@remove="onStorageRemove"
|
|
116
124
|
@diff-value="onChangeStorage"
|
|
@@ -121,6 +129,7 @@
|
|
|
121
129
|
<VuexList
|
|
122
130
|
v-if="swiperShow(9)"
|
|
123
131
|
v-model:vuexList="vuexList"
|
|
132
|
+
:theme="theme"
|
|
124
133
|
@diff-value="onChangeVuex"
|
|
125
134
|
/>
|
|
126
135
|
</swiper-item>
|
|
@@ -128,20 +137,33 @@
|
|
|
128
137
|
<PiniaList
|
|
129
138
|
v-if="swiperShow(10)"
|
|
130
139
|
v-model:pinia-list="piniaList"
|
|
140
|
+
:theme="theme"
|
|
131
141
|
@diff-value="onChangePinia"
|
|
132
142
|
/>
|
|
133
143
|
</swiper-item>
|
|
134
144
|
<swiper-item>
|
|
135
|
-
<WindowInfo
|
|
145
|
+
<WindowInfo
|
|
146
|
+
v-if="swiperShow(11)"
|
|
147
|
+
:windowInfo="windowInfo"
|
|
148
|
+
:theme="theme"
|
|
149
|
+
/>
|
|
136
150
|
</swiper-item>
|
|
137
151
|
<swiper-item>
|
|
138
|
-
<DeviceInfo
|
|
152
|
+
<DeviceInfo
|
|
153
|
+
v-if="swiperShow(12)"
|
|
154
|
+
:deviceInfo="deviceInfo"
|
|
155
|
+
:theme="theme"
|
|
156
|
+
/>
|
|
139
157
|
</swiper-item>
|
|
140
158
|
<swiper-item>
|
|
141
|
-
<SystemInfo
|
|
159
|
+
<SystemInfo
|
|
160
|
+
v-if="swiperShow(13)"
|
|
161
|
+
:systemInfo="systemInfo"
|
|
162
|
+
:theme="theme"
|
|
163
|
+
/>
|
|
142
164
|
</swiper-item>
|
|
143
165
|
<swiper-item>
|
|
144
|
-
<AppInfo v-if="swiperShow(14)" :appInfo="appInfo" />
|
|
166
|
+
<AppInfo v-if="swiperShow(14)" :appInfo="appInfo" :theme="theme" />
|
|
145
167
|
</swiper-item>
|
|
146
168
|
<swiper-item>
|
|
147
169
|
<SettingList
|
|
@@ -160,6 +182,16 @@
|
|
|
160
182
|
/>
|
|
161
183
|
</swiper-item>
|
|
162
184
|
</swiper>
|
|
185
|
+
|
|
186
|
+
<!-- 源码查看 -->
|
|
187
|
+
<SourceCode
|
|
188
|
+
v-if="openCode"
|
|
189
|
+
:url="stack"
|
|
190
|
+
:sourceFileServers="sourceFileServers"
|
|
191
|
+
:mode="mode"
|
|
192
|
+
:zIndex="zIndex"
|
|
193
|
+
@close="onCloseCode"
|
|
194
|
+
/>
|
|
163
195
|
</view>
|
|
164
196
|
</template>
|
|
165
197
|
|
|
@@ -183,6 +215,8 @@ import UploadList from '../UploadList/index.vue';
|
|
|
183
215
|
import UniEvent from '../UniEvent/index.vue';
|
|
184
216
|
import AppInfo from '../AppInfo/index.vue';
|
|
185
217
|
import CaptureScreen from '../CaptureScreen/index.vue';
|
|
218
|
+
import SourceCode from '../SourceCode/index.vue';
|
|
219
|
+
|
|
186
220
|
import {
|
|
187
221
|
DEV_BUTTON_SHOW_OR_HIDE,
|
|
188
222
|
DEV_CONSOLE_CLEAR,
|
|
@@ -208,7 +242,7 @@ import {
|
|
|
208
242
|
DEV_RUN_JS,
|
|
209
243
|
DEV_CAPTURE_SCREEN_CLEAR,
|
|
210
244
|
} from '../../const';
|
|
211
|
-
import { debounce, hightLight } from '../../utils/index';
|
|
245
|
+
import { debounce, hightLight, isAndroid, isMockWX } from '../../utils/index';
|
|
212
246
|
import type { DevTool } from '../../type';
|
|
213
247
|
import { eventBus } from '../../core';
|
|
214
248
|
import { getDevToolInfo, setDevToolInfo } from '../../devToolInfo';
|
|
@@ -360,6 +394,7 @@ const activeTab = ref(0);
|
|
|
360
394
|
const tabScrollLeft = ref(0);
|
|
361
395
|
const currentConsoleType = ref('all');
|
|
362
396
|
const currentNetworkType = ref('all');
|
|
397
|
+
const currentNetworkSort = ref<-1 | 1>(1);
|
|
363
398
|
const currentUploadType = ref('all');
|
|
364
399
|
const currentWebSocketType = ref('all');
|
|
365
400
|
|
|
@@ -370,6 +405,8 @@ const searchWs = ref('');
|
|
|
370
405
|
const searchRoute = ref('');
|
|
371
406
|
const searchStorage = ref('');
|
|
372
407
|
const theme = ref('light');
|
|
408
|
+
const openCode = ref(false);
|
|
409
|
+
const stack = ref('');
|
|
373
410
|
|
|
374
411
|
const props = withDefaults(
|
|
375
412
|
defineProps<{
|
|
@@ -398,6 +435,51 @@ function swiperShow(index: number) {
|
|
|
398
435
|
return show;
|
|
399
436
|
}
|
|
400
437
|
|
|
438
|
+
const calcLineStartAndEnd = (
|
|
439
|
+
list: DevTool.NetworkItem[],
|
|
440
|
+
): {
|
|
441
|
+
startTime: number;
|
|
442
|
+
endTime: number;
|
|
443
|
+
} => {
|
|
444
|
+
const startTime = Math.min(...list.map((item) => item.startTime));
|
|
445
|
+
const endTime = Math.max(...list.map((item) => item?.endTime ?? Date.now()));
|
|
446
|
+
|
|
447
|
+
return { startTime, endTime };
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* 计算 时间轴
|
|
452
|
+
* @param list
|
|
453
|
+
* @param startTime
|
|
454
|
+
* @param endTime
|
|
455
|
+
*/
|
|
456
|
+
const calcNetworkTimeline = (
|
|
457
|
+
list: DevTool.NetworkItem[],
|
|
458
|
+
startTime: number,
|
|
459
|
+
endTime: number,
|
|
460
|
+
): DevTool.NetworkItem[] => {
|
|
461
|
+
const total = endTime - startTime;
|
|
462
|
+
|
|
463
|
+
return (
|
|
464
|
+
list?.map((item) => {
|
|
465
|
+
const width =
|
|
466
|
+
(
|
|
467
|
+
(((item.endTime ?? Date.now()) - item.startTime) / total) *
|
|
468
|
+
100
|
|
469
|
+
).toFixed(2) + '%';
|
|
470
|
+
|
|
471
|
+
const left =
|
|
472
|
+
(((item.startTime - startTime) / total) * 100).toFixed(2) + '%';
|
|
473
|
+
|
|
474
|
+
return {
|
|
475
|
+
...item,
|
|
476
|
+
width,
|
|
477
|
+
left,
|
|
478
|
+
};
|
|
479
|
+
}) ?? []
|
|
480
|
+
);
|
|
481
|
+
};
|
|
482
|
+
|
|
401
483
|
const listenPostMessage = (data: DevTool.WindowData) => {
|
|
402
484
|
if (!props.open) return;
|
|
403
485
|
if (!isActive) return;
|
|
@@ -444,7 +526,11 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
444
526
|
}
|
|
445
527
|
|
|
446
528
|
if (data.networkList) {
|
|
447
|
-
|
|
529
|
+
const { startTime, endTime } = calcLineStartAndEnd(data.networkList);
|
|
530
|
+
|
|
531
|
+
const list = calcNetworkTimeline(data.networkList, startTime, endTime);
|
|
532
|
+
|
|
533
|
+
networkList.value = list
|
|
448
534
|
.filter((item) => {
|
|
449
535
|
if (currentNetworkType.value === 'all') return item;
|
|
450
536
|
if (currentNetworkType.value !== 'clear') {
|
|
@@ -458,6 +544,13 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
458
544
|
...item,
|
|
459
545
|
url: hightLight(item.url, searchNetwork.value),
|
|
460
546
|
};
|
|
547
|
+
})
|
|
548
|
+
?.sort((a, b) => {
|
|
549
|
+
if (currentNetworkSort.value === 1) {
|
|
550
|
+
return b.startTime - a.startTime;
|
|
551
|
+
} else {
|
|
552
|
+
return a.startTime - b.startTime;
|
|
553
|
+
}
|
|
461
554
|
});
|
|
462
555
|
|
|
463
556
|
backup.networkList = [...data.networkList];
|
|
@@ -528,6 +621,7 @@ const listenPostMessage = (data: DevTool.WindowData) => {
|
|
|
528
621
|
});
|
|
529
622
|
backup.routeList = [...data.routeList];
|
|
530
623
|
}
|
|
624
|
+
|
|
531
625
|
if (data.eventList) {
|
|
532
626
|
eventList.value = [...data.eventList];
|
|
533
627
|
}
|
|
@@ -604,13 +698,14 @@ onUnload(() => {
|
|
|
604
698
|
onShow(() => {
|
|
605
699
|
isActive = true;
|
|
606
700
|
});
|
|
607
|
-
onHide(() => {
|
|
608
|
-
isActive = false;
|
|
609
701
|
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
702
|
+
// onHide(() => {
|
|
703
|
+
// isActive = false;
|
|
704
|
+
|
|
705
|
+
// setDevToolInfo({
|
|
706
|
+
// devToolWindowVisible: false,
|
|
707
|
+
// });
|
|
708
|
+
// });
|
|
614
709
|
|
|
615
710
|
/** 发送消息给 uniapp */
|
|
616
711
|
function basicSendMessage(message: {
|
|
@@ -760,6 +855,23 @@ function onSearchNetwork(value: string) {
|
|
|
760
855
|
});
|
|
761
856
|
}
|
|
762
857
|
|
|
858
|
+
/**
|
|
859
|
+
* 排序
|
|
860
|
+
* @param sort -1 降序 1 升序
|
|
861
|
+
*/
|
|
862
|
+
function onSortNetwork(sort: -1 | 1) {
|
|
863
|
+
currentNetworkSort.value = sort;
|
|
864
|
+
|
|
865
|
+
const list = networkList.value.sort((a, b) => {
|
|
866
|
+
if (sort === 1) {
|
|
867
|
+
return b.startTime - a.startTime;
|
|
868
|
+
} else {
|
|
869
|
+
return a.startTime - b.startTime;
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
networkList.value = [...list];
|
|
873
|
+
}
|
|
874
|
+
|
|
763
875
|
function onUploadChoose(type: string) {
|
|
764
876
|
if (type === 'clear') {
|
|
765
877
|
uploadList.value = [];
|
|
@@ -1020,12 +1132,51 @@ function onChangePinia(value: Record<string, any>) {
|
|
|
1020
1132
|
data: value,
|
|
1021
1133
|
});
|
|
1022
1134
|
}
|
|
1135
|
+
|
|
1136
|
+
function onCloseCode() {
|
|
1137
|
+
openCode.value = false;
|
|
1138
|
+
stack.value = '';
|
|
1139
|
+
}
|
|
1140
|
+
function onOpenCode(value?: string) {
|
|
1141
|
+
if (!value) return;
|
|
1142
|
+
|
|
1143
|
+
stack.value = value;
|
|
1144
|
+
|
|
1145
|
+
const isWXLink = isMockWX(value ?? '') || props.mode !== 'development';
|
|
1146
|
+
const isUseDevSource = !isWXLink && props.useDevSource;
|
|
1147
|
+
|
|
1148
|
+
if (isWXLink) {
|
|
1149
|
+
uni.showToast({
|
|
1150
|
+
icon: 'none',
|
|
1151
|
+
title: '[DevTool] 请在小程序真机调试模式下查看源码',
|
|
1152
|
+
});
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if (!isUseDevSource) {
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if (isAndroid()) {
|
|
1161
|
+
if (props.sourceFileServers && props.sourceFileServers?.length > 0) {
|
|
1162
|
+
openCode.value = true;
|
|
1163
|
+
} else {
|
|
1164
|
+
uni.showToast({
|
|
1165
|
+
icon: 'none',
|
|
1166
|
+
title: '[DevTool] sourceFileServers 配置异常',
|
|
1167
|
+
});
|
|
1168
|
+
uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
|
|
1169
|
+
}
|
|
1170
|
+
} else {
|
|
1171
|
+
openCode.value = true;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1023
1174
|
</script>
|
|
1024
1175
|
|
|
1025
1176
|
<style scoped>
|
|
1026
1177
|
.dev-tool-window {
|
|
1027
1178
|
--dev-tool-main-color: #9254de;
|
|
1028
|
-
|
|
1179
|
+
|
|
1029
1180
|
--dev-tool-warn-color: #ffa940;
|
|
1030
1181
|
--dev-tool-warn-bg-color: #fff7e6;
|
|
1031
1182
|
--dev-tool-error-color: #ff4d4f;
|
|
@@ -1036,6 +1187,10 @@ function onChangePinia(value: Record<string, any>) {
|
|
|
1036
1187
|
--dev-tool-base-font-size: 12px;
|
|
1037
1188
|
--dev-tool-tag-font-size: 10px;
|
|
1038
1189
|
--dev-tool-tips-font-size: 10px;
|
|
1190
|
+
|
|
1191
|
+
--dev-tool-text-color-placeholder: #909090;
|
|
1192
|
+
|
|
1193
|
+
--dev-tool-active-bg-color: rgba(0, 0, 0, 0.05);
|
|
1039
1194
|
-webkit-tap-highlight-color: transparent;
|
|
1040
1195
|
|
|
1041
1196
|
position: fixed;
|
|
@@ -1061,8 +1216,10 @@ function onChangePinia(value: Record<string, any>) {
|
|
|
1061
1216
|
.dev-tool-window-light {
|
|
1062
1217
|
--dev-tool-bg-color: rgba(255, 255, 255, 0.8);
|
|
1063
1218
|
--dev-tool-bg2-color: rgba(255, 255, 255, 0.95);
|
|
1219
|
+
--dev-tool-bg3-color: rgba(255, 255, 255, 0.999);
|
|
1064
1220
|
|
|
1065
1221
|
--dev-tool-text-color: #000;
|
|
1222
|
+
|
|
1066
1223
|
--dev-tool-border-color: #f0f0f0;
|
|
1067
1224
|
--dev-tool-info-color: #9c9c9c;
|
|
1068
1225
|
--dev-tool-log-color: #f9f9f9;
|
|
@@ -1071,15 +1228,21 @@ function onChangePinia(value: Record<string, any>) {
|
|
|
1071
1228
|
--dev-tool-number-color: #1d8ce0;
|
|
1072
1229
|
--dev-tool-boolean-color: #1d8ce0;
|
|
1073
1230
|
--dev-tool-symbol-color: bisque;
|
|
1231
|
+
--dev-tool-active-bg-color: #f0f0f0;
|
|
1232
|
+
--dev-tool-time-line-color: #9254de;
|
|
1074
1233
|
}
|
|
1075
|
-
.dev-tool-window-
|
|
1234
|
+
.dev-tool-window-dark {
|
|
1076
1235
|
--dev-tool-bg-color: rgba(0, 0, 0, 0.8);
|
|
1077
1236
|
--dev-tool-bg2-color: rgba(43, 43, 43, 0.8);
|
|
1237
|
+
--dev-tool-bg3-color: rgba(43, 43, 43, 0.999);
|
|
1078
1238
|
|
|
1079
1239
|
--dev-tool-text-color: #fff;
|
|
1080
1240
|
--dev-tool-border-color: #3d3d3d;
|
|
1081
1241
|
|
|
1082
1242
|
--dev-tool-log-color: #f9f9f9;
|
|
1243
|
+
--dev-tool-active-bg-color: #3d3d3d;
|
|
1244
|
+
|
|
1245
|
+
--dev-tool-time-line-color: #f9f9f9;
|
|
1083
1246
|
}
|
|
1084
1247
|
|
|
1085
1248
|
.dev-tool-window-bg {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="device-info-content">
|
|
3
|
-
<JsonPretty :data="deviceInfo" v-if="showJson" />
|
|
3
|
+
<JsonPretty :data="deviceInfo" v-if="showJson" :theme="theme" />
|
|
4
4
|
<Empty v-else />
|
|
5
5
|
</view>
|
|
6
6
|
</template>
|
|
@@ -10,6 +10,7 @@ import Empty from '../Empty/index.vue';
|
|
|
10
10
|
import JsonPretty from '../JsonPretty/index.vue';
|
|
11
11
|
const props = defineProps<{
|
|
12
12
|
deviceInfo: Record<string, any>;
|
|
13
|
+
theme?: string;
|
|
13
14
|
}>();
|
|
14
15
|
|
|
15
16
|
const showJson = computed(() => {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="filter-select-wrapper">
|
|
3
|
+
<view
|
|
4
|
+
v-if="readonly"
|
|
5
|
+
:class="`filter-select ${!modelValue ? 'filter-select-placeholder' : ''}`"
|
|
6
|
+
@click="onOpenList"
|
|
7
|
+
>
|
|
8
|
+
{{ label ?? (placeholder || '请选择') }}
|
|
9
|
+
</view>
|
|
10
|
+
<input
|
|
11
|
+
v-else
|
|
12
|
+
:class="`filter-select`"
|
|
13
|
+
:value="label"
|
|
14
|
+
:placeholder="placeholder || '请选择'"
|
|
15
|
+
@confirm="debounceInput"
|
|
16
|
+
@focus="onOpenList"
|
|
17
|
+
/>
|
|
18
|
+
<view class="filter-select-clear" v-if="allowClear" @click="onClear">
|
|
19
|
+
×
|
|
20
|
+
</view>
|
|
21
|
+
|
|
22
|
+
<view class="filter-select-list" v-if="isActive">
|
|
23
|
+
<view
|
|
24
|
+
v-for="item in options"
|
|
25
|
+
:key="item.value"
|
|
26
|
+
:class="`filter-select-item ${
|
|
27
|
+
item.value === modelValue ? 'filter-select-item-active' : ''
|
|
28
|
+
}`"
|
|
29
|
+
@click="onSelect(item)"
|
|
30
|
+
>
|
|
31
|
+
{{ item.label }}
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
|
|
35
|
+
<view
|
|
36
|
+
class="filter-select-mask"
|
|
37
|
+
v-if="isActive"
|
|
38
|
+
@click="isActive = false"
|
|
39
|
+
></view>
|
|
40
|
+
</view>
|
|
41
|
+
</template>
|
|
42
|
+
<script lang="ts" setup>
|
|
43
|
+
import { debounce } from '../../utils';
|
|
44
|
+
import { ref, computed } from 'vue';
|
|
45
|
+
const props = defineProps<{
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
modelValue?: string;
|
|
48
|
+
readonly?: boolean;
|
|
49
|
+
allowClear?: boolean;
|
|
50
|
+
options?: { label: string; value: any }[];
|
|
51
|
+
}>();
|
|
52
|
+
const emit = defineEmits<{
|
|
53
|
+
(e: 'update:modelValue', value: string): void;
|
|
54
|
+
(e: 'search', value: string): void;
|
|
55
|
+
(e: 'openSearch', value: boolean): void;
|
|
56
|
+
(e: 'change', value: { label: string; value: any }): void;
|
|
57
|
+
}>();
|
|
58
|
+
|
|
59
|
+
const isActive = ref(false);
|
|
60
|
+
|
|
61
|
+
const label = computed(() => {
|
|
62
|
+
return (
|
|
63
|
+
props.options?.find((item) => item.value === props.modelValue)?.label ??
|
|
64
|
+
props.modelValue
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
function onInput(e: any) {
|
|
69
|
+
const value = e.detail.value;
|
|
70
|
+
emit('update:modelValue', value);
|
|
71
|
+
emit('search', value);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function onClear() {
|
|
75
|
+
emit('update:modelValue', '');
|
|
76
|
+
emit('search', '');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const debounceInput = debounce(onInput, 500);
|
|
80
|
+
|
|
81
|
+
function onOpenList() {
|
|
82
|
+
isActive.value = true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function onSelect(item: { label: string; value: any }) {
|
|
86
|
+
emit('change', item);
|
|
87
|
+
isActive.value = false;
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
<style scoped>
|
|
91
|
+
.filter-select-wrapper {
|
|
92
|
+
position: relative;
|
|
93
|
+
flex: 1;
|
|
94
|
+
display: flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
padding: 0 8px;
|
|
97
|
+
width: 100%;
|
|
98
|
+
min-width: 100px;
|
|
99
|
+
height: 24px;
|
|
100
|
+
|
|
101
|
+
border-radius: 4px;
|
|
102
|
+
border: 1px solid var(--dev-tool-border-color);
|
|
103
|
+
|
|
104
|
+
background-color: var(--dev-tool-bg-color);
|
|
105
|
+
transition: background-color 0.3s;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.filter-select {
|
|
110
|
+
flex: 1;
|
|
111
|
+
box-shadow: none;
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
border-radius: 5;
|
|
114
|
+
font-family: inherit;
|
|
115
|
+
color: var(--dev-tool-text-color);
|
|
116
|
+
font-weight: 400;
|
|
117
|
+
font: unset;
|
|
118
|
+
height: 24px;
|
|
119
|
+
line-height: 24px;
|
|
120
|
+
transition: color 0.3s;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.filter-select-placeholder {
|
|
124
|
+
color: var(--dev-tool-text-color-placeholder);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.filter-select-clear {
|
|
128
|
+
padding-left: 8px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.filter-select-icon {
|
|
132
|
+
width: 24px;
|
|
133
|
+
height: 24px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.filter-select-list {
|
|
137
|
+
z-index: 9999;
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: 24px;
|
|
140
|
+
left: 0;
|
|
141
|
+
max-height: 300px;
|
|
142
|
+
width: 100%;
|
|
143
|
+
overflow: auto;
|
|
144
|
+
background-color: var(--dev-tool-bg2-color);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.filter-select-item {
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: 24px;
|
|
150
|
+
line-height: 24px;
|
|
151
|
+
padding: 0 8px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.filter-select-item-active {
|
|
155
|
+
background-color: var(--dev-tool-active-bg-color);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.filter-select-mask {
|
|
159
|
+
position: fixed;
|
|
160
|
+
z-index: 9005;
|
|
161
|
+
top: 0;
|
|
162
|
+
left: 0;
|
|
163
|
+
width: 100vw;
|
|
164
|
+
height: 100vh;
|
|
165
|
+
}
|
|
166
|
+
</style>
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
>
|
|
11
11
|
{{ item.label }}
|
|
12
12
|
</Tag>
|
|
13
|
-
<
|
|
13
|
+
<CircularButton style="margin-left: auto" text="×" @click="onClose" />
|
|
14
14
|
</view>
|
|
15
15
|
|
|
16
16
|
<view class="network-detail-header" v-if="currentSelect === 'header'">
|
|
17
|
-
<
|
|
17
|
+
<DevToolTitle>常规</DevToolTitle>
|
|
18
18
|
<view class="net-detail-item">
|
|
19
19
|
<view>请求url:</view>
|
|
20
20
|
<view>{{ network.url }}</view>
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
<view>状态代码:</view>
|
|
28
28
|
{{ network.status }}
|
|
29
29
|
</view>
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
<DevToolTitle>请求头</DevToolTitle>
|
|
31
32
|
<view
|
|
32
33
|
class="net-detail-item"
|
|
33
34
|
v-for="item in network.headers.requestHeader"
|
|
@@ -36,7 +37,8 @@
|
|
|
36
37
|
<view>{{ item.key }}:</view>
|
|
37
38
|
{{ item.value }}
|
|
38
39
|
</view>
|
|
39
|
-
|
|
40
|
+
|
|
41
|
+
<DevToolTitle>响应头</DevToolTitle>
|
|
40
42
|
<view
|
|
41
43
|
class="net-detail-item"
|
|
42
44
|
v-for="item in network.headers.responseHeader"
|
|
@@ -79,7 +81,8 @@ import { ref, computed } from 'vue';
|
|
|
79
81
|
import JsonPretty from '../JsonPretty/index.vue';
|
|
80
82
|
import Tag from '../Tag/index.vue';
|
|
81
83
|
import Empty from '../Empty/index.vue';
|
|
82
|
-
import
|
|
84
|
+
import CircularButton from '../CircularButton/index.vue';
|
|
85
|
+
import DevToolTitle from '../DevToolTitle/index.vue';
|
|
83
86
|
import type { DevTool } from '../../type';
|
|
84
87
|
const props = defineProps<{ network: DevTool.NetworkItem; zIndex?: number }>();
|
|
85
88
|
const emit = defineEmits<{ (e: 'close'): void }>();
|
|
@@ -150,13 +153,14 @@ function onClose() {
|
|
|
150
153
|
.network-detail {
|
|
151
154
|
position: fixed;
|
|
152
155
|
width: 100vw;
|
|
153
|
-
height:
|
|
154
|
-
z-index:
|
|
156
|
+
height: 100%;
|
|
157
|
+
z-index: 5;
|
|
158
|
+
/* z-index: 1001; */
|
|
155
159
|
top: 0;
|
|
156
160
|
left: 0;
|
|
157
161
|
padding: 0 16px;
|
|
158
162
|
|
|
159
|
-
background-color: var(--dev-tool-
|
|
163
|
+
background-color: var(--dev-tool-bg3-color);
|
|
160
164
|
box-sizing: border-box;
|
|
161
165
|
}
|
|
162
166
|
.network-detail .network-detail-control {
|