vite-uni-dev-tool 0.0.22 → 0.0.23

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.
@@ -70,9 +70,13 @@
70
70
  :currentUploadType="currentUploadType"
71
71
  :uploadList="uploadList"
72
72
  :zIndex="zIndex + 1"
73
+ :mode="mode"
74
+ :useDevSource="useDevSource"
73
75
  v-model="searchUpload"
74
76
  @choose="onUploadChoose"
75
77
  @search="onSearchUpload"
78
+ @openDetail="onOpenUploadDetail"
79
+ @openCode="onOpenCode"
76
80
  />
77
81
  </swiper-item>
78
82
  <swiper-item>
@@ -84,6 +88,8 @@
84
88
  v-model="searchWs"
85
89
  @choose="onWebSocketChoose"
86
90
  @search="onSearchWs"
91
+ @openDetail="onOpenWebSocketDetail"
92
+ @openCode="onOpenCode"
87
93
  />
88
94
  </swiper-item>
89
95
  <swiper-item>
@@ -235,12 +241,28 @@
235
241
  :network="network"
236
242
  @close="onCloseNetworkDetail"
237
243
  />
244
+
245
+ <!-- 上传详情 -->
246
+ <UploadDetail
247
+ v-if="showUploadDetail"
248
+ :upload="upload"
249
+ :zIndex="zIndex"
250
+ @close="onCloseUploadDetail"
251
+ />
252
+
253
+ <WebSocketDetail
254
+ v-if="showWebSocketDetail"
255
+ :ws="currentWebSocket"
256
+ :zIndex="zIndex"
257
+ @close="onCloseWebSocketDetail"
258
+ @clear="onClearWebSocketMessage"
259
+ />
238
260
  </view>
239
261
  </template>
240
262
 
241
263
  <script setup lang="ts">
242
264
  import { onLoad, onUnload, onShow, onHide } from '@dcloudio/uni-app';
243
- import { ref, onMounted, reactive } from 'vue';
265
+ import { ref, onMounted, reactive, computed, nextTick } from 'vue';
244
266
  import Tabs from '../Tabs/index.vue';
245
267
  import ConsoleList from '../ConsoleList/index.vue';
246
268
  import NetworkList from '../NetworkList/index.vue';
@@ -265,6 +287,9 @@ import NetworkDetail from '../NetworkList/NetworkDetail.vue';
265
287
  import NetworkIntercept from '../NetworkList/NetworkIntercept.vue';
266
288
  import InterceptConfig from '../NetworkList/InterceptConfig.vue';
267
289
 
290
+ import UploadDetail from '../UploadList/UploadDetail.vue';
291
+ import WebSocketDetail from '../WebSocket/WebSocketDetail.vue';
292
+
268
293
  import {
269
294
  DEV_BUTTON_SHOW_OR_HIDE,
270
295
  DEV_CONSOLE_CLEAR,
@@ -292,6 +317,7 @@ import {
292
317
  DEV_INTERCEPT_NETWORK_UPDATE,
293
318
  DEV_INTERCEPT_NETWORK_REMOVE,
294
319
  DEV_CHANGE_CACHE_INTERCEPT_CONFIG,
320
+ DEV_WEBSOCKET_CLEAR_MESSAGE,
295
321
  } from '../../const';
296
322
  import { debounce, hightLight, isAndroid, isMockWX } from '../../utils/index';
297
323
  import type { DevTool } from '../../type';
@@ -367,9 +393,25 @@ const showNetworkSend = ref(false);
367
393
  const showNetworkDetail = ref(false);
368
394
  const showNetworkIntercept = ref(false);
369
395
  const showInterceptConfig = ref(false);
370
-
371
396
  const cacheInterceptConfig = ref(true);
372
397
 
398
+ const upload = reactive<DevTool.UploadItem>({
399
+ index: 0,
400
+ status: '',
401
+ });
402
+ const showUploadDetail = ref(false);
403
+
404
+ const webSocket = reactive<DevTool.WS>({
405
+ url: '',
406
+ message: [],
407
+ });
408
+
409
+ const currentWebSocket = computed(() => {
410
+ return wsList.value.find((item) => item.url === webSocket.url);
411
+ });
412
+
413
+ const showWebSocketDetail = ref(false);
414
+
373
415
  const props = withDefaults(
374
416
  defineProps<{
375
417
  open?: boolean;
@@ -1230,6 +1272,40 @@ function onConfirmInterceptConfig(ni: DevTool.NetworkItem) {
1230
1272
  data: [ni],
1231
1273
  });
1232
1274
  }
1275
+
1276
+ function onOpenUploadDetail(up?: DevTool.UploadItem) {
1277
+ Object.assign(upload, up);
1278
+ showUploadDetail.value = true;
1279
+ }
1280
+
1281
+ function onCloseUploadDetail() {
1282
+ showUploadDetail.value = false;
1283
+ }
1284
+
1285
+ function onOpenWebSocketDetail(ws?: DevTool.WS) {
1286
+ Object.assign(webSocket, ws);
1287
+
1288
+ nextTick(() => {
1289
+ if (currentWebSocket.value) {
1290
+ showWebSocketDetail.value = true;
1291
+ } else {
1292
+ //
1293
+ }
1294
+ });
1295
+ }
1296
+
1297
+ function onCloseWebSocketDetail() {
1298
+ showWebSocketDetail.value = false;
1299
+ }
1300
+
1301
+ function onClearWebSocketMessage(ws: DevTool.WS) {
1302
+ console.log('ws: ', ws);
1303
+
1304
+ basicSendMessage({
1305
+ type: DEV_WEBSOCKET_CLEAR_MESSAGE,
1306
+ data: ws,
1307
+ });
1308
+ }
1233
1309
  </script>
1234
1310
 
1235
1311
  <style scoped>
@@ -1283,7 +1359,6 @@ function onConfirmInterceptConfig(ni: DevTool.NetworkItem) {
1283
1359
  --dev-tool-info-color: #9c9c9c;
1284
1360
  --dev-tool-log-color: #f9f9f9;
1285
1361
  --dev-tool-nil-color: #020201;
1286
- --dev-tool-string-color: #888888;
1287
1362
  --dev-tool-number-color: #1d8ce0;
1288
1363
  --dev-tool-boolean-color: #1d8ce0;
1289
1364
  --dev-tool-symbol-color: bisque;
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <view class="network-detail" :style="{ zIndex: zIndex }">
3
3
  <view class="network-detail-control">
4
+ <DevToolTitle style="margin-right: 16px"> 请求详情 </DevToolTitle>
4
5
  <Tag
5
6
  mode="info"
6
7
  v-for="item in selectItems"
@@ -220,7 +221,6 @@ onMounted(() => {
220
221
  display: flex;
221
222
  align-items: center;
222
223
  /* margin-bottom: 4px; */
223
- gap: 12px;
224
224
  height: 32px;
225
225
  border-bottom: 1px solid transparent;
226
226
  box-sizing: border-box;
@@ -237,6 +237,7 @@ onMounted(() => {
237
237
  align-items: center;
238
238
  min-height: 28px;
239
239
  word-break: break-all;
240
+ font-size: 12px;
240
241
  }
241
242
  .network-detail-header {
242
243
  overflow: auto;
@@ -120,17 +120,6 @@ const tagMode = computed(() => {
120
120
  color: var(--dev-tool-text-color);
121
121
  transition: color 0.3s;
122
122
  }
123
- .slide-fade-enter-active {
124
- transition: all 0.8s ease-out;
125
- }
126
- .slide-fade-leave-active {
127
- transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
128
- }
129
- .slide-fade-enter-from,
130
- .slide-fade-leave-to {
131
- transform: translateY(20px);
132
- opacity: 0;
133
- }
134
123
 
135
124
  .network-time-line {
136
125
  position: relative;
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <view class="setting-content">
3
3
  <view class="setting-item">
4
- <DevToolTitle>DevTool(v0.0.22-vue3)</DevToolTitle>
4
+ <DevToolTitle>DevTool({{ version }}-vue3)</DevToolTitle>
5
5
  <view class="setting-item-content">
6
6
  <view class="setting-row">
7
7
  <view>显示调试按钮:</view>
@@ -183,6 +183,9 @@
183
183
  <script lang="ts" setup>
184
184
  import { reactive } from 'vue';
185
185
  import DevToolTitle from '../DevToolTitle/index.vue';
186
+
187
+ const version = __VERSION__ ?? '1.0.0';
188
+
186
189
  const props = defineProps<{
187
190
  devToolVisible?: boolean;
188
191
  sizeFormat?: string;
@@ -0,0 +1,2 @@
1
+ // 插件版本号
2
+ declare const __VERSION__: string;
@@ -35,7 +35,7 @@ const props = withDefaults(
35
35
  .source-code-line {
36
36
  display: flex;
37
37
  align-items: center;
38
- height: 24px;
38
+ height: 20px;
39
39
  }
40
40
 
41
41
  .source-code-line-active {
@@ -49,14 +49,14 @@ const props = withDefaults(
49
49
  padding: 0 6px;
50
50
  margin-right: 6px;
51
51
  text-align: right;
52
- height: 24px;
52
+ height: 20px;
53
53
  border-right: 1px solid var(--dev-tool-border-color);
54
54
  }
55
55
 
56
56
  .source-code-line-content {
57
57
  display: flex;
58
58
  white-space: nowrap;
59
- height: 24px;
59
+ height: 20px;
60
60
  }
61
61
 
62
62
  .source-code-line-word {
@@ -217,7 +217,7 @@ onMounted(() => {
217
217
 
218
218
  width: 100vw;
219
219
  height: 100vh;
220
- font-size: 14px;
220
+ font-size: 12px;
221
221
  color: var(--dev-tool-text-color);
222
222
  box-sizing: border-box;
223
223
  transition: color 0.3s;
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <view class="upload-detail" :style="{ zIndex: zIndex }">
3
3
  <view class="upload-detail-control">
4
+ <DevToolTitle style="margin-right: 16px">上传详情</DevToolTitle>
5
+
4
6
  <Tag
5
7
  v-for="item in selectItems"
6
8
  :active="currentSelect === item.value"
@@ -15,31 +17,42 @@
15
17
  </view>
16
18
 
17
19
  <view class="upload-detail-header" v-if="currentSelect === 'header'">
18
- <view class="upload-detail-title">常规</view>
19
- <view class="net-detail-item">
20
+ <DevToolTitle>常规</DevToolTitle>
21
+ <view class="upload-detail-item">
20
22
  <view>请求url:</view>
21
23
  <view>{{ upload.url }}</view>
22
24
  </view>
23
- <view class="net-detail-item">
25
+ <view class="upload-detail-item">
24
26
  <view>请求方法:</view>
25
27
  <Tag mode="info">{{ upload.method ?? 'POST' }}</Tag>
26
28
  </view>
27
- <view class="net-detail-item">
29
+ <view class="upload-detail-item">
28
30
  <view>状态代码:</view>
29
31
  <Tag mode="info">{{ upload.status }}</Tag>
30
32
  </view>
31
- <view class="upload-detail-title">请求头</view>
32
- <view
33
- class="net-detail-item"
34
- v-for="item in upload?.headers?.requestHeader"
35
- :key="item.key"
33
+
34
+ <DevToolTitle>请求头</DevToolTitle>
35
+ <template
36
+ v-if="
37
+ upload?.headers &&
38
+ upload?.headers?.requestHeader &&
39
+ upload?.headers?.requestHeader?.length > 0
40
+ "
36
41
  >
37
- <view>{{ item.key }}:</view>
38
- {{ item.value }}
39
- </view>
42
+ <view
43
+ class="upload-detail-item"
44
+ v-for="item in upload?.headers?.requestHeader"
45
+ :key="item.key"
46
+ >
47
+ <view>{{ item.key }}:</view>
48
+ {{ item.value }}
49
+ </view>
50
+ </template>
51
+ <Empty v-else />
52
+
40
53
  <!-- <view class="upload-detail-title">响应头</view>
41
54
  <view
42
- class="net-detail-item"
55
+ class="upload-detail-item"
43
56
  v-for="item in upload?.headers?.responseHeader"
44
57
  :key="item.key"
45
58
  >
@@ -81,6 +94,7 @@ import JsonPretty from '../JsonPretty/index.vue';
81
94
  import Tag from '../Tag/index.vue';
82
95
  import Empty from '../Empty/index.vue';
83
96
  import CircularButton from '../CircularButton/index.vue';
97
+ import DevToolTitle from '../DevToolTitle/index.vue';
84
98
  import type { DevTool } from '../../type';
85
99
  const props = defineProps<{ upload: DevTool.UploadItem; zIndex?: number }>();
86
100
  const emit = defineEmits<{ (e: 'close'): void }>();
@@ -160,11 +174,14 @@ function onClose() {
160
174
  top: 0;
161
175
  left: 0;
162
176
  padding: 0 16px;
163
- background-color: var(--dev-tool-bg2-color);
177
+ /* #ifdef H5 */
178
+ padding: 50px 16px;
179
+ /* #endif */
180
+ background-color: var(--dev-tool-bg3-color);
164
181
  box-sizing: border-box;
165
182
  transform: background-color 0.3s;
166
183
  }
167
- .upload-detail .upload-detail-control {
184
+ .upload-detail-control {
168
185
  display: flex;
169
186
  align-items: center;
170
187
  margin-bottom: 4px;
@@ -174,18 +191,19 @@ function onClose() {
174
191
  box-sizing: border-box;
175
192
  }
176
193
 
177
- .upload-detail .upload-detail-header .net-detail-item {
194
+ .upload-detail-item {
178
195
  display: flex;
179
196
  align-items: center;
180
197
  min-height: 28px;
181
198
  word-break: break-all;
199
+ font-size: 12px;
182
200
  }
183
- .upload-detail .upload-detail-header .net-detail-item > view:first-child {
201
+ .upload-detail-item > view:first-child {
184
202
  white-space: nowrap;
185
203
  margin-right: 8px;
186
204
  color: var(--dev-tool-info-color);
187
205
  }
188
- .upload-detail .upload-detail-payload {
206
+ .upload-detail-payload {
189
207
  word-break: break-all;
190
208
  max-width: 100%;
191
209
  }
@@ -1,14 +1,8 @@
1
1
  <template>
2
- <view class="upload-item">
2
+ <view class="upload-item" @click="emit('openDetail', upload)">
3
3
  <view class="upload-url-row">
4
4
  <Tag mode="info">POST</Tag>
5
5
  <view class="upload-url" v-html="upload.url" />
6
- <Tag
7
- mode="main"
8
- class="upload-detail-icon"
9
- @click="showDetail = !showDetail"
10
- >详情</Tag
11
- >
12
6
  </view>
13
7
  <view class="upload-info">
14
8
  <view>
@@ -28,39 +22,53 @@
28
22
  <view>进度: {{ upload.progress }}%</view>
29
23
  <view>
30
24
  开始:
31
- {{ upload.startTime ? formatDate(upload.startTime, ' HH:mm:ss') : '-' }}
25
+ {{
26
+ upload.startTime
27
+ ? formatDate(upload.startTime, ' HH:mm:ss:SS')
28
+ : '--:--:--:---'
29
+ }}
32
30
  </view>
33
31
  <view>
34
32
  结束:
35
- {{ upload.endTime ? formatDate(upload.endTime, ' HH:mm:ss') : '-' }}
33
+ {{
34
+ upload.endTime
35
+ ? formatDate(upload.endTime, ' HH:mm:ss:SS')
36
+ : '--:--:--:---'
37
+ }}
36
38
  </view>
37
39
  </view>
40
+ <view
41
+ :class="['upload-stock ', isUseDevSource ? 'upload-stock-link' : '']"
42
+ @click.stop="emit('openCode', upload.stack)"
43
+ >
44
+ {{ upload?.stack }}
45
+ </view>
38
46
  </view>
39
- <!-- <Transition name="slide-fade"> -->
40
- <UploadDetail
41
- v-if="showDetail"
42
- :upload="upload"
43
- :zIndex="zIndex"
44
- @close="onClose"
45
- />
46
- <!-- </Transition> -->
47
47
  </template>
48
48
 
49
49
  <script lang="ts" setup>
50
- import { ref } from 'vue';
50
+ import { computed } from 'vue';
51
51
  import Tag from '../Tag/index.vue';
52
- import UploadDetail from './UploadDetail.vue';
53
- import { formatDate } from '../../utils';
52
+ import { formatDate, isMockWX } from '../../utils';
54
53
  import type { DevTool } from '../../type';
55
- defineProps<{
54
+ const props = defineProps<{
56
55
  upload: DevTool.UploadItem;
57
56
  zIndex?: number;
57
+ mode?: string;
58
+ useDevSource?: boolean;
59
+ }>();
60
+ const emit = defineEmits<{
61
+ (e: 'openDetail', value: DevTool.UploadItem): void;
62
+ (e: 'openCode', value?: string): void;
58
63
  }>();
59
- const showDetail = ref(false);
60
64
 
61
- function onClose() {
62
- showDetail.value = false;
63
- }
65
+ const isUseDevSource = computed(() => {
66
+ return (
67
+ !isMockWX(props?.upload?.stack ?? '') &&
68
+ props.mode === 'development' &&
69
+ props.useDevSource
70
+ );
71
+ });
64
72
  </script>
65
73
  <style scoped>
66
74
  .upload-item {
@@ -103,15 +111,11 @@ function onClose() {
103
111
  color: var(--dev-tool-text-color);
104
112
  }
105
113
 
106
- .slide-fade-enter-active {
107
- transition: all 0.8s ease-out;
108
- }
109
- .slide-fade-leave-active {
110
- transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
114
+ .upload-stock {
115
+ text-align: right;
116
+ word-wrap: break-word;
111
117
  }
112
- .slide-fade-enter-from,
113
- .slide-fade-leave-to {
114
- transform: translateY(20px);
115
- opacity: 0;
118
+ .upload-stock-link {
119
+ text-decoration: underline;
116
120
  }
117
121
  </style>
@@ -29,7 +29,14 @@
29
29
  :index="start + index"
30
30
  :key="start + index"
31
31
  >
32
- <UploadItem :upload="item" :zIndex="zIndex" />
32
+ <UploadItem
33
+ :upload="item"
34
+ :zIndex="zIndex"
35
+ :mode="mode"
36
+ :useDevSource="useDevSource"
37
+ @openDetail="emit('openDetail', $event)"
38
+ @openCode="emit('openCode', $event)"
39
+ />
33
40
  </AutoSize>
34
41
  <Empty v-if="!uploadList || uploadList.length === 0" />
35
42
  </template>
@@ -50,13 +57,17 @@ defineProps<{
50
57
  currentUploadType: string;
51
58
  uploadList: DevTool.UploadItem[];
52
59
  modelValue: string;
60
+ mode: string;
53
61
  zIndex: number;
62
+ useDevSource: boolean;
54
63
  }>();
55
64
 
56
65
  const emit = defineEmits<{
57
66
  (e: 'choose', type: string): void;
58
67
  (e: 'update:modelValue', value: string): void;
59
68
  (e: 'search', value: string): void;
69
+ (e: 'openDetail', value: DevTool.UploadItem): void;
70
+ (e: 'openCode', value: string): void;
60
71
  }>();
61
72
  const uploadFilterItems = [
62
73
  {
@@ -111,14 +111,16 @@ const innerScrollIntoView = computed(() => {
111
111
 
112
112
  onBeforeMount(() => {
113
113
  // 初始渲染数据
114
- state.visitableData = props.data.slice(
115
- (props.defaultCurrent - 1) * props.pageSize,
116
- props.pageSize * 2,
117
- );
118
-
119
- state.currentHeight = itemsHeight
120
- .slice(0, (props.defaultCurrent - 1) * props.pageSize)
121
- ?.reduce((acc, cur) => acc + cur, 0);
114
+ state.visitableData =
115
+ props.data?.slice(
116
+ (props.defaultCurrent - 1) * props.pageSize,
117
+ props.pageSize * 2,
118
+ ) ?? [];
119
+
120
+ state.currentHeight =
121
+ itemsHeight
122
+ ?.slice(0, (props.defaultCurrent - 1) * props.pageSize)
123
+ ?.reduce((acc, cur) => acc + cur, 0) ?? 0;
122
124
  });
123
125
 
124
126
  // 数据更新时重置
@@ -147,11 +149,12 @@ watch(
147
149
  const endIndex = Math.min(currentAdd1 * pageSize, data.length);
148
150
 
149
151
  // 更新可见数据
150
- state.visitableData = data.slice(startIndex, endIndex);
152
+ state.visitableData = data?.slice(startIndex, endIndex) ?? [];
151
153
 
152
- state.currentHeight = itemsHeight
153
- .slice(0, currentSub1 * pageSize)
154
- ?.reduce((acc, cur) => acc + cur, 0);
154
+ state.currentHeight =
155
+ itemsHeight
156
+ ?.slice(0, currentSub1 * pageSize)
157
+ ?.reduce((acc, cur) => acc + cur, 0) ?? 0;
155
158
  },
156
159
  );
157
160