vite-uni-dev-tool 0.0.22 → 0.0.24

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.
Files changed (50) hide show
  1. package/README.md +15 -3
  2. package/dist/const.d.ts +4 -0
  3. package/dist/const.d.ts.map +1 -1
  4. package/dist/const.js +30 -29
  5. package/dist/core.d.ts +3 -3
  6. package/dist/core.d.ts.map +1 -1
  7. package/dist/core.js +47 -50
  8. package/dist/devEvent/index.d.ts.map +1 -1
  9. package/dist/devEvent/index.js +26 -18
  10. package/dist/devIntercept/index.d.ts.map +1 -1
  11. package/dist/devIntercept/index.js +140 -127
  12. package/dist/devStore/index.d.ts +5 -1
  13. package/dist/devStore/index.d.ts.map +1 -1
  14. package/dist/devStore/index.js +16 -14
  15. package/dist/type.d.ts +8 -1
  16. package/dist/type.d.ts.map +1 -1
  17. package/dist/v2/AutoSizer/index.vue +1 -1
  18. package/dist/v2/ConsoleList/ConsoleItem.vue +1 -1
  19. package/dist/v2/DevToolButton/index.vue +2 -2
  20. package/dist/v3/AutoSizer/index.vue +1 -1
  21. package/dist/v3/CaptureScreen/index.vue +5 -1
  22. package/dist/v3/ConsoleList/ConsoleItem.vue +2 -2
  23. package/dist/v3/ConsoleList/RunJSInput.vue +1 -0
  24. package/dist/v3/DevToolButton/index.vue +3 -2
  25. package/dist/v3/DevToolWindow/index.vue +94 -3
  26. package/dist/v3/JsonPretty/components/Brackets/index.vue +3 -0
  27. package/dist/v3/JsonPretty/components/Carets/index.vue +2 -3
  28. package/dist/v3/NetworkList/InterceptConfig.vue +13 -34
  29. package/dist/v3/NetworkList/NetworkDetail.vue +13 -17
  30. package/dist/v3/NetworkList/NetworkItem.vue +0 -11
  31. package/dist/v3/NetworkList/NetworkSend.vue +20 -29
  32. package/dist/v3/RunJS/index.vue +1 -1
  33. package/dist/v3/SettingList/const.d.ts +2 -0
  34. package/dist/v3/SettingList/const.d.ts.map +1 -0
  35. package/dist/v3/SettingList/index.vue +8 -1
  36. package/dist/v3/SettingList/typing.d.ts +2 -0
  37. package/dist/v3/SourceCode/Line.vue +5 -4
  38. package/dist/v3/SourceCode/index.vue +1 -1
  39. package/dist/v3/Tabs/index.vue +4 -0
  40. package/dist/v3/Tag/index.vue +1 -1
  41. package/dist/v3/UniEvent/index.vue +7 -6
  42. package/dist/v3/UploadList/UploadDetail.vue +36 -18
  43. package/dist/v3/UploadList/UploadItem.vue +38 -34
  44. package/dist/v3/UploadList/index.vue +12 -1
  45. package/dist/v3/VirtualListPro/index.vue +15 -12
  46. package/dist/v3/WebSocket/WebSocketDetail.vue +252 -0
  47. package/dist/v3/WebSocket/WebSocketItem.vue +20 -37
  48. package/dist/v3/WebSocket/index.vue +6 -1
  49. package/package.json +1 -1
  50. package/dist/v3/WebSocket/WebSocketList.vue +0 -161
@@ -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
 
@@ -0,0 +1,252 @@
1
+ <template>
2
+ <view class="web-socket-list-container" :style="{ zIndex: zIndex }">
3
+ <view class="web-socket-detail-control">
4
+ <DevToolTitle style="margin-right: 16px"> 套接字详情 </DevToolTitle>
5
+ <Tag
6
+ mode="info"
7
+ v-for="item in selectItems"
8
+ :active="item.value === currentSelect"
9
+ :key="item.value"
10
+ style="margin-right: 16px"
11
+ @click="onSelect(item)"
12
+ >
13
+ {{ item.label }}
14
+ </Tag>
15
+ <CircularButton style="margin-left: auto" text="×" @click="onClose" />
16
+ </view>
17
+
18
+ <view class="web-socket-data" v-if="currentSelect === 'base'">
19
+ <DevToolTitle> 常规 </DevToolTitle>
20
+ <view class="web-socket-detail-item">
21
+ <view>请求地址:</view>
22
+ <view>{{ ws?.url }}</view>
23
+ </view>
24
+
25
+ <view class="web-socket-detail-item">
26
+ <view>请求方法:</view>
27
+ <Tag mode="info">{{ ws?.method }}</Tag>
28
+ </view>
29
+
30
+ <DevToolTitle>请求头</DevToolTitle>
31
+ <template v-if="ws?.headers && ws.headers?.length > 0">
32
+ <view
33
+ class="web-socket-detail-item"
34
+ v-for="item in ws.headers"
35
+ :key="item.key"
36
+ >
37
+ <view class="web-socket-detail-item-key">{{ item.key }}: </view>
38
+ {{ item.value }}
39
+ </view>
40
+ </template>
41
+ <Empty v-else />
42
+ </view>
43
+ <template v-if="currentSelect === 'message'">
44
+ <view class="web-socket-detail-control">
45
+ <DevToolTitle>消息列表</DevToolTitle>
46
+ <Tag mode="clear" style="margin-left: auto" @click="emit('clear', ws!)">
47
+ 清除
48
+ </Tag>
49
+ </view>
50
+
51
+ <view class="web-socket-data-list">
52
+ <template v-if="ws?.message && ws.message.length > 0">
53
+ <view
54
+ v-for="item in ws.message"
55
+ :key="item.time"
56
+ :class="`web-socket-data-item web-socket-data-item-${item.status}`"
57
+ @click="onClick(item)"
58
+ >
59
+ <view class="web-socket-data-time">
60
+ {{ item.type === 'send' ? '↑' : '↓' }}
61
+ {{ formatDate(item.time, 'HH:mm:ss') }}
62
+ </view>
63
+ <view class="web-socket-data-content">
64
+ {{ item.data }}
65
+ </view>
66
+ </view>
67
+ </template>
68
+ <Empty v-else text="暂无消息" />
69
+ </view>
70
+
71
+ <!-- <textarea
72
+ :value="sendText"
73
+ class="web-socket-textarea"
74
+ placeholder="请输入消息"
75
+ placeholderStyle="font-size: 12px"
76
+ @change="onChangeText"
77
+ />
78
+ <button class="web-socket-send-button" size="mini">发送</button> -->
79
+ </template>
80
+ </view>
81
+ </template>
82
+ <script setup lang="ts">
83
+ import { ref } from 'vue';
84
+ import Tag from '../Tag/index.vue';
85
+ import CircularButton from '../CircularButton/index.vue';
86
+ import DevToolTitle from '../DevToolTitle/index.vue';
87
+ import Empty from '../Empty/index.vue';
88
+ import { formatDate } from '../../utils/index';
89
+ import type { DevTool } from '../../type';
90
+
91
+ defineProps<{ ws?: DevTool.WS; zIndex?: number }>();
92
+ const emit = defineEmits<{
93
+ (e: 'close'): void;
94
+ (e: 'clear', value: DevTool.WS): void;
95
+ }>();
96
+
97
+ const selectItems = [
98
+ {
99
+ label: 'base',
100
+ value: 'base',
101
+ },
102
+ {
103
+ label: 'message',
104
+ value: 'message',
105
+ },
106
+ ];
107
+ const currentSelect = ref('base');
108
+
109
+ const sendText = ref('');
110
+
111
+ function onSelect(item: { label: string; value: string }) {
112
+ currentSelect.value = item.value;
113
+ }
114
+ function onClose() {
115
+ emit('close');
116
+ }
117
+
118
+ function onClick(item: {
119
+ status: 'success' | 'error';
120
+ data: string;
121
+ time: number;
122
+ }) {
123
+ uni.setClipboardData({
124
+ data: JSON.stringify(item),
125
+ success() {
126
+ uni.showToast({
127
+ title: '复制成功',
128
+ icon: 'none',
129
+ });
130
+ },
131
+ fail() {
132
+ uni.showToast({
133
+ title: '复制失败',
134
+ icon: 'none',
135
+ });
136
+ },
137
+ });
138
+ }
139
+
140
+ function onChangeText(e: any) {
141
+ sendText.value = e.detail.value;
142
+ console.log(' sendText.value: ', sendText.value);
143
+ }
144
+ </script>
145
+ <style>
146
+ .web-socket-list-container {
147
+ position: fixed;
148
+ width: 100vw;
149
+ height: 100vh;
150
+ z-index: 1001;
151
+ top: 0;
152
+ left: 0;
153
+ padding: 0 16px;
154
+ /* #ifdef H5 */
155
+ padding: 50px 16px;
156
+ /* #endif */
157
+
158
+ background-color: var(--dev-tool-bg3-color);
159
+
160
+ box-sizing: border-box;
161
+ }
162
+
163
+ .web-socket-detail-control {
164
+ display: flex;
165
+ align-items: center;
166
+ /* margin-bottom: 4px; */
167
+ height: 32px;
168
+ border-bottom: 1px solid transparent;
169
+ box-sizing: border-box;
170
+ }
171
+
172
+ .web-socket-list-title {
173
+ min-height: 32px;
174
+ display: flex;
175
+ align-items: center;
176
+ }
177
+
178
+ .web-socket-data {
179
+ height: calc(100% - 32px);
180
+ overflow: auto;
181
+ }
182
+
183
+ .web-socket-detail-item {
184
+ display: flex;
185
+ align-items: center;
186
+ min-height: 28px;
187
+ word-break: break-all;
188
+ font-size: 12px;
189
+ }
190
+
191
+ .web-socket-detail-item-key {
192
+ white-space: nowrap;
193
+ margin-right: 8px;
194
+ color: var(--dev-tool-info-color);
195
+ }
196
+
197
+ .web-socket-url {
198
+ display: flex;
199
+ align-items: center;
200
+ min-height: 28px;
201
+
202
+ white-space: wrap;
203
+ word-break: break-all;
204
+ }
205
+
206
+ .web-socket-data-item {
207
+ display: flex;
208
+ align-items: center;
209
+ min-height: 28px;
210
+ font-size: 12px;
211
+ }
212
+ .web-socket-data-item-error {
213
+ background-color: var(--dev-tool-error-bg-color);
214
+ }
215
+ .web-socket-data-item-success {
216
+ background-color: var(--dev-tool-success-bg-color);
217
+ }
218
+ .web-socket-data-time {
219
+ /* margin-right: 16px; */
220
+ padding: 0 6px;
221
+ flex-shrink: 0;
222
+ color: var(--dev-tool-info-color);
223
+ }
224
+ .web-socket-data-content {
225
+ padding: 6px;
226
+ flex: 1;
227
+ overflow: hidden;
228
+ text-overflow: ellipsis;
229
+ word-break: break-all;
230
+ }
231
+
232
+ .web-socket-data-list {
233
+ /* height: calc(100% - 32px - 32px - 130px); */
234
+ height: calc(100% - 32px - 32px);
235
+ overflow: auto;
236
+ }
237
+
238
+ .web-socket-textarea {
239
+ padding: 6px;
240
+ height: 80px;
241
+ width: 100%;
242
+ font-size: 12px;
243
+ border: 1px solid var(--dev-tool-border-color);
244
+ box-sizing: border-box;
245
+ }
246
+ .web-socket-send-button {
247
+ margin-top: 12px;
248
+ width: 100%;
249
+ color: #fff;
250
+ background-color: var(--dev-tool-main-color);
251
+ }
252
+ </style>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <view class="websocket-item">
3
- <view class="websocket-url-row">
4
- <Tag mode="info" v-if="ws.readyState === 'connection'">con</Tag>
3
+ <view class="websocket-url-row" @click="emit('openDetail', ws)">
4
+ <Tag mode="info" v-if="ws.readyState === 'connection'">connection</Tag>
5
5
  <Tag mode="success" v-if="ws.readyState === 'open'">open</Tag>
6
6
  <Tag
7
7
  mode="warn"
@@ -13,65 +13,48 @@
13
13
  <Tag mode="error" v-if="ws.readyState === 'error'">error</Tag>
14
14
 
15
15
  <view class="websocket-url" v-html="ws.url" />
16
-
17
- <Tag
18
- mode="main"
19
- class="websocket-detail-icon"
20
- @click="showDetail = !showDetail"
21
- >
22
- 详情
23
- </Tag>
24
16
  </view>
25
17
  <view class="websocket-info">
26
18
  <view class="websocket-info-last">
27
- {{ ws?.message?.[ws.message.length - 1]?.data }}
19
+ {{ ws?.message?.[ws.message.length - 1]?.data ?? '暂无消息' }}
28
20
  </view>
29
21
 
30
- <view>{{
31
- ws?.message?.[ws.message.length - 1].time
32
- ? formatDate(ws?.message?.[ws.message.length - 1].time, 'HH:mm:ss')
33
- : '-'
34
- }}</view>
22
+ <view>
23
+ {{
24
+ ws?.message?.[ws.message.length - 1]?.time
25
+ ? formatDate(
26
+ ws?.message?.[ws.message.length - 1]?.time,
27
+ 'HH:mm:ss:SS',
28
+ )
29
+ : '--:--:--:---'
30
+ }}
31
+ </view>
35
32
  </view>
36
-
37
- <WebSocketList
38
- v-if="showDetail"
39
- :ws="ws"
40
- :zIndex="zIndex"
41
- @close="onClose"
42
- />
43
33
  </view>
44
34
  </template>
45
35
  <script lang="ts" setup>
46
- import { ref } from 'vue';
47
-
48
36
  import Tag from '../Tag/index.vue';
49
- import WebSocketList from './WebSocketList.vue';
50
37
  import { formatDate } from '../../utils';
51
38
  import type { DevTool } from '../../type';
52
39
 
53
40
  defineProps<{ ws: DevTool.WS; zIndex?: number }>();
54
- const showDetail = ref(false);
55
41
 
56
- function onClose() {
57
- showDetail.value = false;
58
- }
42
+ const emit = defineEmits<{ (e: 'openDetail', value: DevTool.WS): void }>();
59
43
  </script>
60
44
  <style scoped>
61
45
  .websocket-item {
62
46
  padding: 16px;
63
-
64
47
  box-sizing: border-box;
65
48
  border-bottom: 1px solid var(--dev-tool-border-color);
66
49
  font-size: var(--dev-tool-base-font-size);
67
50
  }
68
- .websocket-item .websocket-url-row {
51
+ .websocket-url-row {
69
52
  display: flex;
70
53
  align-items: center;
71
54
  word-break: break-all;
72
55
  }
73
56
 
74
- .websocket-item .websocket-url-row .websocket-url {
57
+ .websocket-url {
75
58
  margin-left: 4px;
76
59
  flex: 1;
77
60
  white-space: nowrap;
@@ -79,14 +62,14 @@ function onClose() {
79
62
  text-overflow: ellipsis;
80
63
  }
81
64
 
82
- .websocket-item .websocket-url-row .websocket-detail-icon {
65
+ .websocket-detail-icon {
83
66
  flex-shrink: 0;
84
67
  margin-left: auto;
85
68
  }
86
- .websocket-item .websocket-url-row .websocket-detail-active {
69
+ .websocket-detail-active {
87
70
  transform: rotate(135deg);
88
71
  }
89
- .websocket-item .websocket-info {
72
+ .websocket-info {
90
73
  display: flex;
91
74
  align-items: center;
92
75
  justify-content: space-between;
@@ -94,7 +77,7 @@ function onClose() {
94
77
  color: var(--dev-tool-info-color);
95
78
  }
96
79
 
97
- .websocket-item .websocket-info .websocket-info-last {
80
+ .websocket-info-last {
98
81
  white-space: nowrap;
99
82
  flex: 1;
100
83
  overflow: hidden;
@@ -30,7 +30,11 @@
30
30
  :index="start + index"
31
31
  :key="start + index"
32
32
  >
33
- <WebSocketItem :ws="item" :zIndex="zIndex" />
33
+ <WebSocketItem
34
+ :ws="item"
35
+ :zIndex="zIndex"
36
+ @openDetail="emit('openDetail', $event)"
37
+ />
34
38
  </AutoSize>
35
39
  <Empty v-if="!wsList || wsList.length === 0" />
36
40
  </template>
@@ -57,6 +61,7 @@ const emit = defineEmits<{
57
61
  (e: 'choose', type: string): void;
58
62
  (e: 'update:modelValue', value: string): void;
59
63
  (e: 'search', value: string): void;
64
+ (e: 'openDetail', value: DevTool.WS): void;
60
65
  }>();
61
66
  const webSocketFilter = [
62
67
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-uni-dev-tool",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
5
5
  "keywords": [
6
6
  "vite",
@@ -1,161 +0,0 @@
1
- <template>
2
- <view class="web-socket-list-container" :style="{ zIndex: zIndex }">
3
- <view class="web-socket-top">
4
- 请求url:
5
-
6
- <CircularButton style="margin-left: auto" text="×" @click="onClose" />
7
- </view>
8
- <view class="web-socket-url">
9
- {{ ws.url }}
10
- </view>
11
-
12
- <view class="web-socket-data">
13
- <view class="web-socket-title"
14
- >请求方式:<Tag mode="info"> {{ ws.method }} </Tag></view
15
- >
16
- <view class="web-socket-title">请求头:</view>
17
- <view
18
- class="header-detail-item"
19
- v-for="item in ws.headers"
20
- :key="item.key"
21
- >
22
- <view>{{ item.key }}: </view>
23
- {{ item.value }}
24
- </view>
25
-
26
- <view class="web-socket-title">消息列表:</view>
27
- <view class="web-socket-data-list">
28
- <view
29
- v-for="item in ws.message"
30
- :key="item.time"
31
- :class="`web-socket-data-item web-socket-data-item-${item.type}`"
32
- @click="onClick(item)"
33
- >
34
- <view class="web-socket-data-time"
35
- >{{ formatDate(item.time, 'HH:mm:ss') }}
36
- </view>
37
- <view class="web-socket-data-content">
38
- {{ item.data }}
39
- </view>
40
- </view>
41
- </view>
42
- </view>
43
- </view>
44
- </template>
45
- <script setup lang="ts">
46
- import Tag from '../Tag/index.vue';
47
- import CircularButton from '../CircularButton/index.vue';
48
- import { formatDate } from '../../utils/index';
49
- import type { DevTool } from '../../type';
50
-
51
- defineProps<{ ws: DevTool.WS; zIndex?: number }>();
52
- const emit = defineEmits<{ (e: 'close'): void }>();
53
-
54
- function onClose() {
55
- emit('close');
56
- }
57
-
58
- function onClick(item: {
59
- type: 'success' | 'error';
60
- data: string;
61
- time: number;
62
- }) {
63
- uni.setClipboardData({
64
- data: JSON.stringify(item),
65
- success() {
66
- uni.showToast({
67
- title: '复制成功',
68
- icon: 'none',
69
- });
70
- },
71
- fail() {
72
- uni.showToast({
73
- title: '复制失败',
74
- icon: 'none',
75
- });
76
- },
77
- });
78
- }
79
- </script>
80
- <style>
81
- .web-socket-list-container {
82
- position: fixed;
83
- width: 100vw;
84
- height: 100vh;
85
- z-index: 1001;
86
- top: 0;
87
- left: 0;
88
- padding: 0 16px;
89
-
90
- background-color: var(--dev-tool-bg2-color);
91
- box-sizing: border-box;
92
- }
93
- .web-socket-list-title {
94
- min-height: 32px;
95
- display: flex;
96
- align-items: center;
97
- }
98
-
99
- .web-socket-data {
100
- height: calc(100% - 32px);
101
- overflow: auto;
102
- }
103
-
104
- .web-socket-url {
105
- display: flex;
106
- align-items: center;
107
- min-height: 28px;
108
-
109
- white-space: wrap;
110
- word-break: break-all;
111
- }
112
-
113
- .web-socket-top {
114
- display: flex;
115
- align-items: center;
116
- height: 32px;
117
-
118
- border-bottom: 1px solid transparent;
119
- box-sizing: border-box;
120
- }
121
- .web-socket-title {
122
- display: flex;
123
- align-items: center;
124
- }
125
- .header-detail-item {
126
- display: flex;
127
- align-items: center;
128
- min-height: 28px;
129
- word-break: break-all;
130
- }
131
- .header-detail-item > view:first-child {
132
- white-space: nowrap;
133
- margin-right: 8px;
134
- color: var(--dev-tool-info-color);
135
- }
136
-
137
- .web-socket-data-item {
138
- display: flex;
139
- align-items: center;
140
- min-height: 28px;
141
- }
142
- .web-socket-data-item-error {
143
- background-color: var(--dev-tool-error-bg-color);
144
- }
145
- .web-socket-data-item-success {
146
- background-color: var(--dev-tool-success-bg-color);
147
- }
148
- .web-socket-data-time {
149
- /* margin-right: 16px; */
150
- padding: 0 6px;
151
- flex-shrink: 0;
152
- color: var(--dev-tool-info-color);
153
- }
154
- .web-socket-data-content {
155
- padding: 6px;
156
- flex: 1;
157
- overflow: hidden;
158
- text-overflow: ellipsis;
159
- word-break: break-all;
160
- }
161
- </style>