vite-uni-dev-tool 0.0.15 → 0.0.17

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 (38) hide show
  1. package/README.md +47 -20
  2. package/dist/devIntercept/index.d.ts.map +1 -1
  3. package/dist/devIntercept/index.js +139 -137
  4. package/dist/devStore/index.js +1 -1
  5. package/dist/type.d.ts +5 -1
  6. package/dist/type.d.ts.map +1 -1
  7. package/dist/v2/{CloseButton → CircularButton}/index.vue +5 -2
  8. package/dist/v2/ConsoleList/ConsoleItem.vue +3 -2
  9. package/dist/v2/NetworkList/NetworkDetail.vue +3 -3
  10. package/dist/v2/NetworkList/NetworkItem.vue +5 -3
  11. package/dist/v2/SettingList/index.vue +1 -1
  12. package/dist/v2/SourceCode/index.vue +3 -3
  13. package/dist/v2/StorageList/index.vue +7 -3
  14. package/dist/v2/Tabs/index.vue +3 -3
  15. package/dist/v2/UploadList/UploadDetail.vue +3 -3
  16. package/dist/v2/WebSocket/WebSocketList.vue +3 -3
  17. package/dist/v3/{CloseButton → CircularButton}/index.vue +4 -2
  18. package/dist/v3/ConsoleList/ConsoleItem.vue +47 -99
  19. package/dist/v3/ConsoleList/index.vue +2 -0
  20. package/dist/v3/DevTool/index.vue +4 -4
  21. package/dist/v3/DevToolWindow/index.vue +162 -14
  22. package/dist/v3/FilterSelect/index.vue +165 -0
  23. package/dist/v3/NetworkList/NetworkDetail.vue +11 -8
  24. package/dist/v3/NetworkList/NetworkItem.vue +56 -26
  25. package/dist/v3/NetworkList/NetworkSend.vue +819 -0
  26. package/dist/v3/NetworkList/const.d.ts +5 -0
  27. package/dist/v3/NetworkList/const.d.ts.map +1 -0
  28. package/dist/v3/NetworkList/const.ts +4 -0
  29. package/dist/v3/NetworkList/index.vue +104 -21
  30. package/dist/v3/SettingList/index.vue +1 -1
  31. package/dist/v3/SourceCode/index.vue +22 -8
  32. package/dist/v3/StorageList/index.vue +7 -6
  33. package/dist/v3/Tabs/index.vue +2 -2
  34. package/dist/v3/UniEvent/UniEventItem.vue +6 -54
  35. package/dist/v3/UniEvent/index.vue +2 -0
  36. package/dist/v3/UploadList/UploadDetail.vue +2 -2
  37. package/dist/v3/WebSocket/WebSocketList.vue +2 -2
  38. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ export declare const sortMap: {
2
+ '-1': string;
3
+ '1': string;
4
+ };
5
+ //# sourceMappingURL=const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../dev/v3/NetworkList/const.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;CAGnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export const sortMap = {
2
+ '-1': ' ↑ ',
3
+ '1': ' ↓ ',
4
+ };
@@ -7,15 +7,20 @@
7
7
  @search="emit('search', $event)"
8
8
  @update:modelValue="emit('update:modelValue', $event)"
9
9
  />
10
- <Tag
11
- v-for="item in networkFilterItems"
12
- :mode="item.mode"
13
- :key="item.value"
14
- :active="item.value === currentNetworkType"
15
- @click="onChoose(item.value)"
16
- >
17
- {{ item.label }}
10
+
11
+ <FilterSelect
12
+ readonly
13
+ :modelValue="currentNetworkType"
14
+ :options="networkFilterItems"
15
+ @change="onChoose($event.value)"
16
+ />
17
+
18
+ <Tag mode="clear" @click="onSort">
19
+ &nbsp;{{ sortMap?.[currentNetworkSort] ?? '一' }}&nbsp;
18
20
  </Tag>
21
+
22
+ <Tag mode="clear" @click="onOpenSend"> 发起 </Tag>
23
+ <Tag mode="clear" @click="onChoose('clear')"> 清除 </Tag>
19
24
  </view>
20
25
 
21
26
  <VirtualListPro
@@ -30,11 +35,30 @@
30
35
  :index="start + index"
31
36
  :key="start + index"
32
37
  >
33
- <NetworkItem :network="item" :zIndex="zIndex" />
38
+ <NetworkItem
39
+ :network="item"
40
+ :zIndex="zIndex"
41
+ :currentNetworkSort="currentNetworkSort"
42
+ :mode="mode"
43
+ :useDevSource="useDevSource"
44
+ @openDetail="onOpenDetail(item)"
45
+ @resend="onResend(item)"
46
+ @openCode="emit('openCode', $event)"
47
+ />
34
48
  </AutoSize>
35
49
  <Empty v-if="!networkList || networkList.length === 0" />
36
50
  </template>
37
51
  </VirtualListPro>
52
+
53
+ <!-- 请求详情 -->
54
+ <NetworkDetail
55
+ v-if="showDetail"
56
+ :network="network"
57
+ @close="onCloseDetail"
58
+ />
59
+
60
+ <!-- 发起请求 -->
61
+ <NetworkSend v-if="showSend" :network="network" @close="onCloseSend" />
38
62
  </view>
39
63
  </template>
40
64
  <script lang="ts" setup>
@@ -42,22 +66,31 @@ import Tag from '../Tag/index.vue';
42
66
  import NetworkItem from './NetworkItem.vue';
43
67
  import Empty from '../Empty/index.vue';
44
68
  import FilterInput from '../FilterInput/index.vue';
69
+ import FilterSelect from '../FilterSelect/index.vue';
45
70
  import type { DevTool } from '../../type';
46
71
  import VirtualListPro from '../VirtualListPro/index.vue';
47
72
  import AutoSize from '../VirtualListPro/AutoSize.vue';
48
- import { onMounted, ref } from 'vue';
73
+ import NetworkSend from './NetworkSend.vue';
74
+ import NetworkDetail from './NetworkDetail.vue';
75
+ import { sortMap } from './const';
76
+ import { onMounted, ref, reactive } from 'vue';
49
77
 
50
- defineProps<{
78
+ const props = defineProps<{
51
79
  currentNetworkType: string;
80
+ currentNetworkSort: -1 | 1;
52
81
  networkList: DevTool.NetworkItem[];
53
82
  modelValue: string;
54
83
  zIndex?: number;
84
+ mode?: string;
85
+ useDevSource?: boolean;
55
86
  }>();
56
87
 
57
88
  const emit = defineEmits<{
58
89
  (e: 'choose', type: string): void;
59
90
  (e: 'update:modelValue', value: string): void;
60
91
  (e: 'search', value: string): void;
92
+ (e: 'sort', sort: -1 | 0 | 1): void;
93
+ (e: 'openCode', value?: string): void;
61
94
  }>();
62
95
  const networkFilterItems = [
63
96
  {
@@ -66,37 +99,55 @@ const networkFilterItems = [
66
99
  mode: 'all',
67
100
  },
68
101
  {
69
- label: 'get',
102
+ label: 'GET',
70
103
  value: 'GET',
71
104
  mode: 'info',
72
105
  },
73
106
  {
74
- label: 'post',
107
+ label: 'POST',
75
108
  value: 'POST',
76
109
  mode: 'info',
77
110
  },
78
111
  {
79
- label: 'put',
112
+ label: 'PUT',
80
113
  value: 'PUT',
81
114
  mode: 'info',
82
115
  },
83
116
  {
84
- label: 'del',
117
+ label: 'DELETE',
85
118
  value: 'DELETE',
86
119
  mode: 'info',
87
120
  },
88
121
  {
89
- label: 'error',
122
+ label: 'Error',
90
123
  value: 'error',
91
124
  mode: 'error',
92
125
  },
93
- {
94
- label: '清除',
95
- value: 'clear',
96
- mode: 'clear',
97
- },
98
126
  ];
99
127
 
128
+ const showSend = ref(false);
129
+
130
+ const showDetail = ref(false);
131
+
132
+ const emptyNetwork = {
133
+ index: 0,
134
+ url: '',
135
+ name: '',
136
+ method: '',
137
+ status: '',
138
+ time: '',
139
+ startTime: 0,
140
+ endTime: 0,
141
+ size: '',
142
+ headers: {
143
+ requestHeader: [],
144
+ responseHeader: [],
145
+ },
146
+ response: '',
147
+ payload: undefined,
148
+ };
149
+ const network = reactive<DevTool.NetworkItem>({ ...emptyNetwork });
150
+
100
151
  function onChoose(type: string) {
101
152
  emit('choose', type);
102
153
  }
@@ -106,6 +157,38 @@ onMounted(() => {
106
157
  const { windowHeight } = uni.getWindowInfo();
107
158
  height.value = windowHeight - 32 - 32;
108
159
  });
160
+
161
+ function onOpenSend() {
162
+ showSend.value = true;
163
+ }
164
+
165
+ function onCloseSend() {
166
+ showSend.value = false;
167
+
168
+ Object.assign(network, emptyNetwork);
169
+ }
170
+
171
+ function onOpenDetail(ni: DevTool.NetworkItem) {
172
+ showDetail.value = true;
173
+
174
+ Object.assign(network, emptyNetwork);
175
+ Object.assign(network, ni);
176
+ }
177
+ function onCloseDetail() {
178
+ showDetail.value = false;
179
+ }
180
+
181
+ function onResend(ni: DevTool.NetworkItem) {
182
+ showSend.value = true;
183
+
184
+ Object.assign(network, emptyNetwork);
185
+ Object.assign(network, ni);
186
+ }
187
+
188
+ function onSort() {
189
+ const sort = props.currentNetworkSort === 1 ? -1 : 1;
190
+ emit('sort', sort);
191
+ }
109
192
  </script>
110
193
  <style scoped>
111
194
  .network-content {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <view class="setting-content">
3
3
  <view class="setting-item">
4
- <DevToolTitle>DevTool(v0.0.12-vue3)</DevToolTitle>
4
+ <DevToolTitle>DevTool(v0.0.16-vue3)</DevToolTitle>
5
5
  <view class="setting-item-content">
6
6
  <view class="setting-row">
7
7
  <view>显示调试按钮:</view>
@@ -6,7 +6,7 @@
6
6
  style="width: 100%"
7
7
  @search="onSearch"
8
8
  />
9
- <CloseButton style="margin-left: auto" @click="onClose" />
9
+ <CircularButton style="margin-left: auto" text="×" @click="onClose" />
10
10
  </view>
11
11
  <view class="dev-tool-code-title">{{ fileName }}</view>
12
12
  <scroll-view
@@ -36,7 +36,7 @@
36
36
  <script lang="ts" setup>
37
37
  import { computed, ref, nextTick, onMounted } from 'vue';
38
38
  import FilterInput from '../FilterInput/index.vue';
39
- import CloseButton from '../CloseButton/index.vue';
39
+ import CircularButton from '../CircularButton/index.vue';
40
40
  import Empty from '../Empty/index.vue';
41
41
  import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
42
42
 
@@ -91,6 +91,9 @@ function getCode(url: string, i: number = 0) {
91
91
 
92
92
  allUrl = props.sourceFileServers?.[i] + '/src/' + url;
93
93
  }
94
+ if (props.sourceFileServers && props.sourceFileServers?.length < index) {
95
+ return;
96
+ }
94
97
 
95
98
  uni.showLoading({ mask: true });
96
99
  uni.request({
@@ -146,6 +149,7 @@ function getSourceCodeDev(url: string) {
146
149
  uni?.__dev__console?.log('[DevTool] url 处理异常');
147
150
  return;
148
151
  }
152
+ index = 0;
149
153
 
150
154
  getCode(url, index);
151
155
  }
@@ -173,16 +177,25 @@ onMounted(() => {
173
177
  <style scoped>
174
178
  .dev-tool-code {
175
179
  position: fixed;
176
- width: 100vw;
177
- height: 100vh;
178
- z-index: 1001;
179
180
  top: 0;
180
181
  left: 0;
182
+ z-index: 1001;
181
183
  padding: 0 16px;
184
+ /* #ifdef H5 */
185
+ padding: 50px 16px;
186
+ /* #endif */
182
187
 
183
- background-color: var(--dev-tool-bg2-color);
184
- box-sizing: border-box;
188
+ /* #ifdef MP-WEIXIN */
189
+ /* padding-bottom:30px; */
190
+ /* #endif */
191
+
192
+ width: 100vw;
193
+ height: 100vh;
194
+ font-size: 14px;
185
195
  color: var(--dev-tool-text-color);
196
+ box-sizing: border-box;
197
+ transition: color 0.3s;
198
+ background-color: var(--dev-tool-bg3-color);
186
199
  }
187
200
 
188
201
  .dev-tool-code-control {
@@ -190,13 +203,14 @@ onMounted(() => {
190
203
  align-items: center;
191
204
  gap: 12px;
192
205
  height: 32px;
206
+ box-sizing: border-box;
193
207
  border-bottom: 1px solid var(--dev-tool-border-color);
194
208
  box-sizing: border-box;
195
209
  }
196
210
 
197
211
  .dev-tool-code-title {
198
212
  height: 32px;
199
- line-height: 32px;
213
+ line-height: 30px;
200
214
  margin-bottom: 4px;
201
215
  border-bottom: 1px solid var(--dev-tool-border-color);
202
216
  box-sizing: border-box;
@@ -24,7 +24,11 @@
24
24
  <view>key: </view>
25
25
  <view v-html="item._oldKey" />
26
26
  </view>
27
- <CloseButton style="margin-left: auto" @click="onRemove(item.key)" />
27
+ <CircularButton
28
+ style="margin-left: auto"
29
+ text="×"
30
+ @click="onRemove(item.key)"
31
+ />
28
32
  </view>
29
33
 
30
34
  <JsonPretty
@@ -45,7 +49,7 @@
45
49
  import Tag from '../Tag/index.vue';
46
50
  import JsonPretty from '../JsonPretty/index.vue';
47
51
  import Empty from '../Empty/index.vue';
48
- import CloseButton from '../CloseButton/index.vue';
52
+ import CircularButton from '../CircularButton/index.vue';
49
53
  import FilterInput from '../FilterInput/index.vue';
50
54
  import type { DevTool } from '../../type';
51
55
  const props = defineProps<{
@@ -62,10 +66,7 @@ const emit = defineEmits<{
62
66
  (e: 'search', value: string): void;
63
67
  }>();
64
68
 
65
- function onUpdateData(
66
- data: DevTool.StorageItem,
67
- item: DevTool.StorageItem,
68
- ) {
69
+ function onUpdateData(data: DevTool.StorageItem, item: DevTool.StorageItem) {
69
70
  const tempList = JSON.parse(JSON.stringify(props.storageList));
70
71
  const index = props.storageList.findIndex(
71
72
  (store) => store.key === item._oldKey,
@@ -24,14 +24,14 @@
24
24
  </scroll-view>
25
25
  <view class="tabs-extra">
26
26
  <slot name="extra"></slot>
27
- <CloseButton style="margin: 0 16px" @click="onClose" />
27
+ <CircularButton style="margin: 0 16px" text="×" @click="onClose" />
28
28
  </view>
29
29
  </view>
30
30
  </template>
31
31
 
32
32
  <script setup lang="ts">
33
33
  import { computed, ref } from 'vue';
34
- import CloseButton from '../CloseButton/index.vue';
34
+ import CircularButton from '../CircularButton/index.vue';
35
35
  // const activeKey = ref("Console");
36
36
  const props = defineProps<{
37
37
  modelValue: number;
@@ -19,27 +19,17 @@
19
19
 
20
20
  <view
21
21
  :class="`uni-event-item-right ${isUseDevSource ? 'link' : ''}`"
22
- @click="onStackClick"
22
+ @click="emit('openCode', eventItem.stack)"
23
23
  >
24
24
  {{ eventItem.stack }}
25
25
  </view>
26
-
27
- <SourceCode
28
- v-if="openCode && eventItem.stack"
29
- :url="eventItem.stack"
30
- :sourceFileServers="sourceFileServers"
31
- :mode="mode"
32
- :zIndex="zIndex"
33
- @close="onCloseCode"
34
- />
35
26
  </view>
36
27
  </template>
37
28
  <script lang="ts" setup>
38
29
  import Tag from '../Tag/index.vue';
39
- import SourceCode from '../SourceCode/index.vue';
40
30
  import type { DevTool } from '../../type';
41
- import { computed, ref } from 'vue';
42
- import { isAndroid, isMockWX } from '../../utils';
31
+ import { computed } from 'vue';
32
+ import { isMockWX } from '../../utils';
43
33
 
44
34
  const props = defineProps<{
45
35
  eventItem: DevTool.EventItem;
@@ -49,7 +39,9 @@ const props = defineProps<{
49
39
  zIndex?: number;
50
40
  }>();
51
41
 
52
- const openCode = ref(false);
42
+ const emit = defineEmits<{
43
+ (e: 'openCode', value?: string): void;
44
+ }>();
53
45
 
54
46
  const isUseDevSource = computed(() => {
55
47
  return (
@@ -58,46 +50,6 @@ const isUseDevSource = computed(() => {
58
50
  props.useDevSource
59
51
  );
60
52
  });
61
-
62
- const isWXLink = computed(() => {
63
- console.log('props?.eventItem: ', props?.eventItem);
64
- console.log('props.mode: ', props.mode);
65
- return (
66
- isMockWX(props?.eventItem?.stack ?? '') || props.mode !== 'development'
67
- );
68
- });
69
-
70
- function onStackClick() {
71
- if (isWXLink.value) {
72
- uni.showToast({
73
- icon: 'none',
74
- title: '[DevTool] 请在小程序真机调试模式下查看源码',
75
- });
76
- return;
77
- }
78
-
79
- if (!isUseDevSource.value) {
80
- return;
81
- }
82
-
83
- if (isAndroid()) {
84
- if (props.sourceFileServers && props.sourceFileServers.length > 0) {
85
- openCode.value = true;
86
- } else {
87
- uni.showToast({
88
- icon: 'none',
89
- title: '[DevTool] sourceFileServers 配置异常',
90
- });
91
- uni?.__dev__console?.log('[DevTool] sourceFileServers 配置异常');
92
- }
93
- } else {
94
- openCode.value = true;
95
- }
96
- }
97
-
98
- function onCloseCode() {
99
- openCode.value = false;
100
- }
101
53
  </script>
102
54
 
103
55
  <style scoped>
@@ -42,6 +42,7 @@
42
42
  :useDevSource="useDevSource"
43
43
  :sourceFileServers="sourceFileServers"
44
44
  :zIndex="zIndex"
45
+ @openCode="emit('openCode', $event)"
45
46
  />
46
47
  <Empty v-if="!eventList || eventList.length === 0"> </Empty>
47
48
  </view>
@@ -65,6 +66,7 @@ defineProps<{
65
66
 
66
67
  const emit = defineEmits<{
67
68
  (e: 'clear'): void;
69
+ (e: 'openCode', value?: string): void;
68
70
  }>();
69
71
  </script>
70
72
  <style scoped>
@@ -11,7 +11,7 @@
11
11
  {{ item.label }}
12
12
  </Tag>
13
13
 
14
- <CloseButton style="margin-left: auto" @click="onClose" />
14
+ <CircularButton style="margin-left: auto" text="×" @click="onClose" />
15
15
  </view>
16
16
 
17
17
  <view class="upload-detail-header" v-if="currentSelect === 'header'">
@@ -80,7 +80,7 @@ import { ref, computed } from 'vue';
80
80
  import JsonPretty from '../JsonPretty/index.vue';
81
81
  import Tag from '../Tag/index.vue';
82
82
  import Empty from '../Empty/index.vue';
83
- import CloseButton from '../CloseButton/index.vue';
83
+ import CircularButton from '../CircularButton/index.vue';
84
84
  import type { DevTool } from '../../type';
85
85
  const props = defineProps<{ upload: DevTool.UploadItem; zIndex?: number }>();
86
86
  const emit = defineEmits<{ (e: 'close'): void }>();
@@ -3,7 +3,7 @@
3
3
  <view class="web-socket-top">
4
4
  请求url:
5
5
 
6
- <CloseButton style="margin-left: auto" @click="onClose" />
6
+ <CircularButton style="margin-left: auto" text="×" @click="onClose" />
7
7
  </view>
8
8
  <view class="web-socket-url">
9
9
  {{ ws.url }}
@@ -44,7 +44,7 @@
44
44
  </template>
45
45
  <script setup lang="ts">
46
46
  import Tag from '../Tag/index.vue';
47
- import CloseButton from '../CloseButton/index.vue';
47
+ import CircularButton from '../CircularButton/index.vue';
48
48
  import { formatDate } from '../../utils/index';
49
49
  import type { DevTool } from '../../type';
50
50
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-uni-dev-tool",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "vite-uni-dev-tool, debug, uni-app, 一处编写,到处调试",
5
5
  "keywords": [
6
6
  "vite",