vite-uni-dev-tool 0.0.11 → 0.0.13

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 (180) hide show
  1. package/README.md +55 -1
  2. package/dist/const.d.ts +133 -0
  3. package/dist/const.d.ts.map +1 -0
  4. package/dist/const.js +36 -0
  5. package/dist/core.d.ts +52 -0
  6. package/dist/core.d.ts.map +1 -0
  7. package/dist/core.js +80 -0
  8. package/dist/devConsole/index.d.ts +169 -0
  9. package/dist/devConsole/index.d.ts.map +1 -0
  10. package/dist/devConsole/index.js +270 -0
  11. package/dist/devEvent/index.d.ts +286 -0
  12. package/dist/devEvent/index.d.ts.map +1 -0
  13. package/dist/devEvent/index.js +435 -0
  14. package/dist/devEventBus/index.d.ts +42 -0
  15. package/dist/devEventBus/index.d.ts.map +1 -0
  16. package/dist/devEventBus/index.js +70 -0
  17. package/dist/devIntercept/index.d.ts +119 -0
  18. package/dist/devIntercept/index.d.ts.map +1 -0
  19. package/dist/devIntercept/index.js +582 -0
  20. package/dist/devRunJS/index.d.ts +67 -0
  21. package/dist/devRunJS/index.d.ts.map +1 -0
  22. package/dist/devStore/index.d.ts +178 -0
  23. package/dist/devStore/index.d.ts.map +1 -0
  24. package/dist/devStore/index.js +395 -0
  25. package/dist/devToolInfo/index.d.ts +17 -0
  26. package/dist/devToolInfo/index.d.ts.map +1 -0
  27. package/dist/devToolInfo/index.js +15 -0
  28. package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
  29. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
  30. package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
  31. package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
  32. package/{dev → dist}/plugins/utils/index.d.ts +3 -0
  33. package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
  34. package/dist/plugins/utils/index.js +1 -0
  35. package/dist/type.d.ts +264 -0
  36. package/dist/type.d.ts.map +1 -0
  37. package/dist/utils/array.d.ts +2 -0
  38. package/dist/utils/array.d.ts.map +1 -0
  39. package/dist/utils/array.js +12 -0
  40. package/dist/utils/date.d.ts +19 -0
  41. package/dist/utils/date.d.ts.map +1 -0
  42. package/dist/utils/date.js +40 -0
  43. package/dist/utils/file.d.ts +11 -0
  44. package/dist/utils/file.d.ts.map +1 -0
  45. package/dist/utils/file.js +87 -0
  46. package/dist/utils/function.d.ts +28 -0
  47. package/dist/utils/function.d.ts.map +1 -0
  48. package/dist/utils/function.js +46 -0
  49. package/dist/utils/index.d.ts +11 -0
  50. package/dist/utils/index.d.ts.map +1 -0
  51. package/dist/utils/index.js +55 -0
  52. package/dist/utils/ip.d.ts +5 -0
  53. package/dist/utils/ip.d.ts.map +1 -0
  54. package/dist/utils/ip.js +21 -0
  55. package/dist/utils/language.d.ts +29 -0
  56. package/dist/utils/language.d.ts.map +1 -0
  57. package/dist/utils/language.js +50 -0
  58. package/dist/utils/object.d.ts +49 -0
  59. package/dist/utils/object.d.ts.map +1 -0
  60. package/dist/utils/object.js +118 -0
  61. package/dist/utils/page.d.ts +7 -0
  62. package/dist/utils/page.d.ts.map +1 -0
  63. package/dist/utils/page.js +7 -0
  64. package/dist/utils/platform.d.ts +4 -0
  65. package/dist/utils/platform.d.ts.map +1 -0
  66. package/dist/utils/platform.js +14 -0
  67. package/dist/utils/string.d.ts +45 -0
  68. package/dist/utils/string.d.ts.map +1 -0
  69. package/dist/utils/string.js +88 -0
  70. package/dist/utils/utils.d.ts +16 -0
  71. package/dist/utils/utils.d.ts.map +1 -0
  72. package/dist/v2/AutoSizer/utils.d.ts +5 -0
  73. package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
  74. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
  75. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  76. package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
  77. package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
  78. package/dist/v2/JsonPretty/type.d.ts +93 -0
  79. package/dist/v2/JsonPretty/type.d.ts.map +1 -0
  80. package/dist/v3/AutoSizer/utils.d.ts +5 -0
  81. package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
  82. package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
  83. package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
  84. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
  85. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  86. package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
  87. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
  88. package/dist/v3/JsonPretty/type.d.ts +93 -0
  89. package/dist/v3/JsonPretty/type.d.ts.map +1 -0
  90. package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
  91. package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
  92. package/package.json +5 -5
  93. package/dev/components/AppInfo/index.vue +0 -36
  94. package/dev/components/AutoSizer/index.vue +0 -193
  95. package/dev/components/AutoSizer/index1.vue +0 -186
  96. package/dev/components/AutoSizer/utils.ts +0 -49
  97. package/dev/components/Button/index.vue +0 -34
  98. package/dev/components/CaptureScreen/index.vue +0 -62
  99. package/dev/components/Checkbox/index.vue +0 -40
  100. package/dev/components/CloseButton/index.vue +0 -26
  101. package/dev/components/Code/index.vue +0 -230
  102. package/dev/components/Connection/index.vue +0 -88
  103. package/dev/components/ConsoleList/Code.vue +0 -227
  104. package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
  105. package/dev/components/ConsoleList/RunJSInput.vue +0 -235
  106. package/dev/components/ConsoleList/index.vue +0 -130
  107. package/dev/components/ConsoleList/staticTips.ts +0 -1145
  108. package/dev/components/DevTool/index.vue +0 -182
  109. package/dev/components/DevToolButton/index.vue +0 -213
  110. package/dev/components/DevToolTitle/index.vue +0 -21
  111. package/dev/components/DevToolWindow/index.vue +0 -1037
  112. package/dev/components/DeviceInfo/index.vue +0 -32
  113. package/dev/components/Empty/empty.png +0 -0
  114. package/dev/components/Empty/index.vue +0 -28
  115. package/dev/components/FilterInput/index.vue +0 -86
  116. package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
  117. package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
  118. package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
  119. package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
  120. package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
  121. package/dev/components/JsonPretty/hooks/useError.ts +0 -21
  122. package/dev/components/JsonPretty/index.vue +0 -474
  123. package/dev/components/JsonPretty/type.ts +0 -125
  124. package/dev/components/JsonPretty/utils/index.ts +0 -172
  125. package/dev/components/NetworkList/NetworkDetail.vue +0 -197
  126. package/dev/components/NetworkList/NetworkItem.vue +0 -106
  127. package/dev/components/NetworkList/index.vue +0 -115
  128. package/dev/components/PiniaList/index.vue +0 -64
  129. package/dev/components/RouteList/index.vue +0 -110
  130. package/dev/components/RunJS/index.vue +0 -128
  131. package/dev/components/SettingList/index.vue +0 -225
  132. package/dev/components/StorageList/index.vue +0 -170
  133. package/dev/components/SystemInfo/index.vue +0 -34
  134. package/dev/components/Tabs/index.vue +0 -123
  135. package/dev/components/Tag/index.vue +0 -89
  136. package/dev/components/UniEvent/UniEventItem.vue +0 -124
  137. package/dev/components/UniEvent/index.vue +0 -94
  138. package/dev/components/UploadList/UploadDetail.vue +0 -208
  139. package/dev/components/UploadList/UploadItem.vue +0 -111
  140. package/dev/components/UploadList/index.vue +0 -104
  141. package/dev/components/VirtualList/index.vue +0 -112
  142. package/dev/components/VirtualListPro/AutoSize.vue +0 -43
  143. package/dev/components/VirtualListPro/index.vue +0 -175
  144. package/dev/components/VirtualListPro/readme.md +0 -40
  145. package/dev/components/VuexList/index.vue +0 -54
  146. package/dev/components/WebSocket/WebSocketItem.vue +0 -98
  147. package/dev/components/WebSocket/WebSocketList.vue +0 -176
  148. package/dev/components/WebSocket/index.vue +0 -111
  149. package/dev/components/WindowInfo/index.vue +0 -33
  150. package/dev/const.ts +0 -166
  151. package/dev/core.ts +0 -118
  152. package/dev/devConsole/index.ts +0 -350
  153. package/dev/devEvent/index.ts +0 -806
  154. package/dev/devEventBus/index.ts +0 -94
  155. package/dev/devIntercept/index.ts +0 -745
  156. package/dev/devRunJS/index.ts +0 -170
  157. package/dev/devStore/index.ts +0 -718
  158. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  159. package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
  160. package/dev/plugins/utils/index.js +0 -1
  161. package/dev/shims-uni.d.ts +0 -43
  162. package/dev/type.ts +0 -264
  163. package/dev/utils/array.ts +0 -15
  164. package/dev/utils/date.ts +0 -75
  165. package/dev/utils/file.ts +0 -121
  166. package/dev/utils/function.ts +0 -192
  167. package/dev/utils/index.d.ts +0 -6
  168. package/dev/utils/index.ts +0 -46
  169. package/dev/utils/ip.ts +0 -79
  170. package/dev/utils/language.ts +0 -72
  171. package/dev/utils/object.ts +0 -298
  172. package/dev/utils/page.ts +0 -13
  173. package/dev/utils/platform.ts +0 -14
  174. package/dev/utils/string.ts +0 -133
  175. package/dev/utils/utils.ts +0 -198
  176. /package/{dev → dist}/index.d.ts +0 -0
  177. /package/{dev → dist}/index.d.ts.map +0 -0
  178. /package/{dev → dist}/index.js +0 -0
  179. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
  180. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
@@ -1,34 +0,0 @@
1
- <template>
2
- <view class="button" :style="style" @click="onClick">
3
- <slot></slot>
4
- </view>
5
- </template>
6
- <script lang="ts" setup>
7
- defineProps<{ style?: any }>();
8
- const emit = defineEmits<{ (e: 'click', event?: MouseEvent): void }>();
9
- const onClick = (e: MouseEvent) => {
10
- emit('click', e);
11
- };
12
- </script>
13
- <style scoped>
14
- .button {
15
- display: flex;
16
- align-items: center;
17
- justify-content: center;
18
- width: 100%;
19
- height: 32px;
20
- border-radius: 4px;
21
- color: #fff;
22
- outline: none;
23
- border: 1px solid transparent;
24
- background-color: var(--dev-tool-main-color);
25
- transform: all 0.3s;
26
- font-size: var(--dev-tool-base-font-size);
27
- padding: 0;
28
- cursor: pointer;
29
- }
30
-
31
- .button:active {
32
- background-color: darken(#9254de, 10%);
33
- }
34
- </style>
@@ -1,62 +0,0 @@
1
- <template>
2
- <view class="capture-screen-content">
3
- <view class="capture-screen-control">
4
- <Tag style="margin-left: auto" mode="clear" @click="emit('clear')">
5
- 清空
6
- </Tag>
7
- </view>
8
-
9
- <view class="capture-screen-list">
10
- <view class="capture-screen-item" v-for="item in captureScreenList">
11
- <view class="info-row">时间:{{ item.timer }} </view>
12
- <view class="info-row">页面:{{ item.position }}</view>
13
- </view>
14
-
15
- <Empty v-if="!captureScreenList || captureScreenList.length === 0" />
16
- </view>
17
- </view>
18
- </template>
19
- <script lang="ts" setup>
20
- import type { DevTool } from '../../type';
21
- import Empty from '../Empty/index.vue';
22
- import Tag from '../Tag/index.vue';
23
-
24
- defineProps<{
25
- captureScreenList: DevTool.CaptureScreenItem[];
26
- }>();
27
-
28
- const emit = defineEmits<{
29
- (e: 'clear'): void;
30
- }>();
31
- </script>
32
- <style scoped>
33
- .capture-screen-content {
34
- height: 100%;
35
- font-size: var(--dev-tool-base-font-size);
36
- }
37
-
38
- .capture-screen-list {
39
- height: calc(100% - 32px);
40
- overflow: auto;
41
- }
42
-
43
- .capture-screen-control {
44
- display: flex;
45
- align-items: center;
46
- justify-content: space-between;
47
- gap: 8px;
48
- padding: 0 16px;
49
- height: 32px;
50
- border-bottom: 1px solid var(--dev-tool-border-color);
51
- box-sizing: border-box;
52
- }
53
-
54
- .capture-screen-item {
55
- padding: 16px;
56
- border-bottom: 1px solid var(--dev-tool-border-color);
57
- }
58
- .info-row {
59
- height: 28px;
60
- line-height: 28px;
61
- }
62
- </style>
@@ -1,40 +0,0 @@
1
- <template>
2
- <view
3
- :class="`checkbox ${modelValue ? 'checkbox-active' : ''}`"
4
- @click="onClickCheckbox"
5
- >
6
- {{ modelValue ? '√' : '' }}
7
- </view>
8
- </template>
9
- <script lang="ts" setup>
10
- const props = defineProps<{
11
- modelValue?: boolean;
12
- }>();
13
- const emit = defineEmits<{
14
- (e: 'update:modelValue', value: boolean): void;
15
- (e: 'change', value: boolean): void;
16
- }>();
17
-
18
- function onClickCheckbox() {
19
- const value = !props.modelValue;
20
- emit('update:modelValue', value);
21
- emit('change', value);
22
- }
23
- </script>
24
- <style scoped>
25
- .checkbox {
26
- display: flex;
27
- align-items: center;
28
- justify-content: center;
29
- width: 18px;
30
- height: 18px;
31
- border-radius: 4px;
32
- border: 1px solid var(--dev-tool-main-color);
33
- transition: all 0.3s;
34
- color: #fff;
35
- box-sizing: border-box;
36
- }
37
- .checkbox-active {
38
- background-color: var(--dev-tool-main-color);
39
- }
40
- </style>
@@ -1,26 +0,0 @@
1
- <template>
2
- <view class="close-button" @click="onClick"> × </view>
3
- </template>
4
- <script lang="ts" setup>
5
- const emit = defineEmits<{ (e: 'click'): void }>();
6
-
7
- function onClick() {
8
- emit('click');
9
- }
10
- </script>
11
-
12
- <style scoped>
13
- .close-button {
14
- flex-shrink: 0;
15
- display: flex;
16
- align-items: center;
17
- justify-content: center;
18
- width: 24px;
19
- height: 24px;
20
- margin-left: auto;
21
- border-radius: 50%;
22
- border: 1px solid #000;
23
- box-sizing: border-box;
24
- color: #000;
25
- }
26
- </style>
@@ -1,230 +0,0 @@
1
- <template>
2
- <view class="dev-tool-code">
3
- <view class="dev-tool-code-control">
4
- <FilterInput
5
- v-model="modelValue"
6
- style="width: 100%"
7
- @search="onSearch"
8
- />
9
- <CloseButton style="margin-left: auto" @click="onClose" />
10
- </view>
11
- <view class="dev-tool-code-title">{{ fileName }}</view>
12
- <scroll-view
13
- scroll-y="true"
14
- scroll-x="true"
15
- class="dev-tool-code-list"
16
- scroll-with-animation="true"
17
- :scroll-top="scrollTop"
18
- :scroll-into-view="scrollIntoView"
19
- >
20
- <view
21
- v-for="(code, index) in codes"
22
- :id="`dev-tool-code-item-${index}`"
23
- :key="index"
24
- :class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
25
- >
26
- <view class="dev-tool-code-item-index">
27
- {{ start + index + 1 }}
28
- </view>
29
-
30
- <view class="dev-tool-code-item-content" v-html="code"></view>
31
- </view>
32
- <Empty v-if="!codes || codes.length === 0" />
33
- </scroll-view>
34
- </view>
35
- </template>
36
- <script lang="ts" setup>
37
- import { computed, ref, nextTick, onMounted } from 'vue';
38
- import FilterInput from '../FilterInput/index.vue';
39
- import CloseButton from '../CloseButton/index.vue';
40
- import Empty from '../Empty/index.vue';
41
- import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
42
-
43
- const props = defineProps<{
44
- url: string;
45
- sourceFileServers?: string[];
46
- mode?: string;
47
- }>();
48
-
49
- const emit = defineEmits<{ (e: 'close'): void }>();
50
-
51
- const modelValue = ref('');
52
- const scrollTop = ref(0);
53
- const fileName = computed(() => {
54
- const name =
55
- props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
56
- return name;
57
- });
58
-
59
- const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
60
-
61
- let backupCodes: string[] = [];
62
-
63
- const codes = ref<string[]>([]);
64
-
65
- const scrollIntoView = ref('');
66
-
67
- const start = computed(() => {
68
- return activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
69
- });
70
-
71
- function onClose() {
72
- emit('close');
73
- }
74
-
75
- function onSearch(value: string) {
76
- codes.value = backupCodes.map((code) => {
77
- return hightLight(code, value);
78
- });
79
- }
80
-
81
- let index = 0;
82
- function getCode(url: string, i: number = 0) {
83
- let allUrl = url;
84
- // 平台判断
85
- if (isAndroid()) {
86
- if (!props.sourceFileServers?.[i]) {
87
- index = 0;
88
- return;
89
- }
90
-
91
- allUrl = props.sourceFileServers?.[i] + '/src/' + url;
92
- }
93
-
94
- uni.showLoading({ mask: true });
95
- uni.request({
96
- url: allUrl,
97
- success: (res) => {
98
- if (typeof res.data === 'string') {
99
- // 为什么要注释掉?
100
- // 在 Android 识别到标签后会进行重启,导致代码无法显示
101
- // TODO: 还有其它原因导致重启
102
- const str = res.data
103
- ?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
104
- ?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
105
- ?.replace(/<style/, '// [DevTool] 注释 <style')
106
- ?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
107
- backupCodes = escapeHTML(str ?? '')
108
- .toString()
109
- .split('\n');
110
-
111
- const start =
112
- activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
113
-
114
- const end =
115
- activeRowCol.value.row + 20 > backupCodes.length
116
- ? backupCodes.length
117
- : activeRowCol.value.row + 20;
118
-
119
- // backupCodes.slice(start, end);
120
-
121
- codes.value = backupCodes.slice(start, end);
122
-
123
- activeRowCol.value.activeRow = activeRowCol.value.row - start;
124
-
125
- nextTick(() => {
126
- scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
127
- });
128
- }
129
- },
130
- fail: (err) => {
131
- index++;
132
- getCode(url, index);
133
- uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
134
- },
135
- complete: () => {
136
- uni.hideLoading();
137
- },
138
- });
139
- }
140
-
141
- /** 开发环境获取源代码 */
142
- function getSourceCodeDev(url: string) {
143
- if (!url) {
144
- uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
145
- uni?.__dev__console?.log('[DevTool] url 处理异常');
146
- return;
147
- }
148
-
149
- getCode(url, index);
150
- }
151
-
152
- onMounted(() => {
153
- let url = props?.url;
154
-
155
- const { path, col, row } = parseStock(props?.url ?? '');
156
-
157
- if (path) {
158
- url = path;
159
- }
160
-
161
- activeRowCol.value.col = col;
162
- activeRowCol.value.row = row;
163
-
164
- if (props.mode === 'development') {
165
- // 开发环境查看源码
166
- getSourceCodeDev(url);
167
- } else if (props.mode === 'production') {
168
- // TODO 生产环境查看源码
169
- }
170
- });
171
- </script>
172
- <style scoped>
173
- .dev-tool-code {
174
- position: fixed;
175
- width: 100vw;
176
- height: 100vh;
177
- z-index: 1000;
178
- top: 0;
179
- left: 0;
180
- padding: 0 16px;
181
-
182
- background-color: rgba(255, 255, 255, 0.95);
183
- box-sizing: border-box;
184
- color: #000;
185
- }
186
-
187
- .dev-tool-code-control {
188
- display: flex;
189
- align-items: center;
190
- gap: 12px;
191
- height: 32px;
192
- border-bottom: 1px solid var(--dev-tool-border-color);
193
- box-sizing: border-box;
194
- }
195
-
196
- .dev-tool-code-title {
197
- height: 32px;
198
- line-height: 32px;
199
- margin-bottom: 4px;
200
- border-bottom: 1px solid var(--dev-tool-border-color);
201
- box-sizing: border-box;
202
- white-space: nowrap;
203
- overflow: auto;
204
- }
205
-
206
- .dev-tool-code-list {
207
- height: calc(100% - 68px);
208
- }
209
-
210
- .dev-tool-code-item {
211
- display: flex;
212
- align-items: center;
213
- height: 28px;
214
- }
215
- .dev-tool-code-item-active {
216
- color: #fff;
217
- background-color: var(--dev-tool-main-color);
218
- }
219
-
220
- .dev-tool-code-item-index {
221
- flex-shrink: 0;
222
- width: 20px;
223
- margin-right: 8px;
224
- text-align: right;
225
- }
226
-
227
- .dev-tool-code-item-content {
228
- white-space: pre;
229
- }
230
- </style>
@@ -1,88 +0,0 @@
1
- <template>
2
- <view class="connection-content">
3
- <view class="connection-item">
4
- <DevToolTitle>网络连接</DevToolTitle>
5
- <view class="connection-item-content">
6
- <view class="connection-row">
7
- <view>IP地址:</view>
8
- <Tag
9
- :mode="
10
- netWorkStatus?.isConnected === undefined || netWorkStatus?.ip
11
- ? 'info'
12
- : netWorkStatus?.isConnected && netWorkStatus?.ip
13
- ? 'success'
14
- : 'error'
15
- "
16
- >
17
- {{
18
- netWorkStatus?.isConnected === undefined
19
- ? '未获取'
20
- : netWorkStatus?.ip || '未获取'
21
- }}
22
- </Tag>
23
- </view>
24
- <view class="connection-row">
25
- <view>连接状态:</view>
26
- <Tag
27
- :mode="
28
- netWorkStatus?.isConnected === undefined
29
- ? 'info'
30
- : netWorkStatus?.isConnected
31
- ? 'success'
32
- : 'error'
33
- "
34
- >
35
- {{
36
- netWorkStatus?.isConnected === undefined
37
- ? '未获取'
38
- : netWorkStatus?.isConnected
39
- ? '已连接'
40
- : '已断开'
41
- }}
42
- </Tag>
43
- </view>
44
- <view class="connection-row">
45
- <view>网络类型:</view>
46
- <Tag mode="info">{{ netWorkStatus?.networkType ?? '未获取' }}</Tag>
47
- </view>
48
- <!-- <view class="connection-row">
49
- <view>上传速度:</view>
50
- <view>0 B/s</view>
51
- </view>
52
- <view class="connection-row">
53
- <view>下载速度:</view>
54
- <view>0 B/s</view>
55
- </view> -->
56
- </view>
57
- </view>
58
- </view>
59
- </template>
60
- <script lang="ts" setup>
61
- import Tag from '../Tag/index.vue';
62
- import DevToolTitle from '../DevToolTitle/index.vue';
63
- defineProps<{
64
- netWorkStatus: {
65
- isConnected?: boolean;
66
- networkType?: string;
67
- ip?: string;
68
- };
69
- }>();
70
- </script>
71
- <style scoped>
72
- .connection-content {
73
- height: 100%;
74
- overflow: auto;
75
- font-size: var(--dev-tool-base-font-size);
76
- }
77
- .connection-item {
78
- padding: 16px 16px 0 16px;
79
- box-sizing: border-box;
80
- }
81
-
82
- .connection-row {
83
- display: flex;
84
- align-items: center;
85
- justify-content: space-between;
86
- margin: 8px 0;
87
- }
88
- </style>
@@ -1,227 +0,0 @@
1
- <template>
2
- <view class="dev-tool-code">
3
- <view class="dev-tool-code-control">
4
- <FilterInput
5
- v-model="modelValue"
6
- style="width: 100%"
7
- @search="onSearch"
8
- />
9
- <CloseButton style="margin-left: auto" @click="onClose" />
10
- </view>
11
- <view class="dev-tool-code-title">{{ fileName }}</view>
12
- <scroll-view
13
- scroll-y="true"
14
- scroll-x="true"
15
- class="dev-tool-code-list"
16
- scroll-with-animation="true"
17
- :scroll-top="scrollTop"
18
- :scroll-into-view="scrollIntoView"
19
- >
20
- <view
21
- v-for="(code, index) in codes"
22
- :id="`dev-tool-code-item-${index}`"
23
- :key="index"
24
- :class="`dev-tool-code-item ${index === activeRowCol.activeRow ? 'dev-tool-code-item-active' : ''}`"
25
- >
26
- <view class="dev-tool-code-item-index"> {{ index + 1 }}</view>
27
-
28
- <view class="dev-tool-code-item-content" v-html="code"></view>
29
- </view>
30
- <Empty v-if="!codes || codes.length === 0" />
31
- </scroll-view>
32
- </view>
33
- </template>
34
- <script lang="ts" setup>
35
- import { computed, ref, nextTick, onMounted } from 'vue';
36
- import FilterInput from '../FilterInput/index.vue';
37
- import CloseButton from '../CloseButton/index.vue';
38
- import Empty from '../Empty/index.vue';
39
- import { escapeHTML, hightLight, isAndroid, parseStock } from '../../utils';
40
-
41
- const props = defineProps<{
42
- url: string;
43
- sourceFileServers?: string[];
44
- mode?: string;
45
- }>();
46
-
47
- const emit = defineEmits<{ (e: 'close'): void }>();
48
-
49
- const modelValue = ref('');
50
- const scrollTop = ref(0);
51
- const fileName = computed(() => {
52
- const name =
53
- props?.url?.split('/')?.pop()?.replace(/\)|\(/, '') ?? '文件名称未知';
54
- return name;
55
- });
56
-
57
- const activeRowCol = ref({ row: -1, col: -1, activeRow: -1 });
58
-
59
- let backupCodes: string[] = [];
60
-
61
- const codes = ref<string[]>([]);
62
-
63
- const scrollIntoView = ref('');
64
-
65
- function onClose() {
66
- emit('close');
67
- }
68
-
69
- function onSearch(value: string) {
70
- codes.value = backupCodes.map((code) => {
71
- return hightLight(code, value);
72
- });
73
- }
74
-
75
- let index = 0;
76
- function getCode(url: string, i: number = 0) {
77
- let allUrl = url;
78
- // 平台判断
79
- if (isAndroid()) {
80
- if (!props.sourceFileServers?.[i]) {
81
- index = 0;
82
- return;
83
- }
84
-
85
- allUrl = props.sourceFileServers?.[i] + '/src/' + url;
86
- }
87
-
88
- uni.showLoading({ mask: true });
89
- uni.request({
90
- url: allUrl,
91
- success: (res) => {
92
- if (typeof res.data === 'string') {
93
- // 为什么要注释掉?
94
- // 在 Android 识别到标签后会进行重启,导致代码无法显示
95
- // TODO: 还有其它原因导致重启
96
- const str = res.data
97
- ?.replace(/<jscript/, '// [DevTool] 注释 <javascript')
98
- ?.replace(/<\/script>/, '// [DevTool] 注释 </javascript>')
99
- ?.replace(/<style/, '// [DevTool] 注释 <style')
100
- ?.replace(/<\/style>/, '// [DevTool] 注释 </style>');
101
- backupCodes = escapeHTML(str ?? '')
102
- .toString()
103
- .split('\n');
104
-
105
- const start =
106
- activeRowCol.value.row - 20 > 0 ? activeRowCol.value.row - 20 : 0;
107
-
108
- const end =
109
- activeRowCol.value.row + 20 > backupCodes.length
110
- ? backupCodes.length
111
- : activeRowCol.value.row + 20;
112
-
113
- // backupCodes.slice(start, end);
114
-
115
- codes.value = backupCodes.slice(start, end);
116
-
117
- activeRowCol.value.activeRow = activeRowCol.value.row - start;
118
-
119
- nextTick(() => {
120
- scrollIntoView.value = `dev-tool-code-item-${activeRowCol.value.activeRow}`;
121
- });
122
- }
123
- },
124
- fail: (err) => {
125
- index++;
126
- getCode(url, index);
127
- uni.showToast({ icon: 'none', title: '正在重新尝试中...' });
128
- },
129
- complete: () => {
130
- uni.hideLoading();
131
- },
132
- });
133
- }
134
-
135
- /** 开发环境获取源代码 */
136
- function getSourceCodeDev(url: string) {
137
- if (!url) {
138
- uni.showToast({ icon: 'none', title: '[DevTool] url 处理异常' });
139
- uni?.__dev__console?.log('[DevTool] url 处理异常');
140
- return;
141
- }
142
-
143
- getCode(url, index);
144
- }
145
-
146
- onMounted(() => {
147
- let url = props?.url;
148
-
149
- const { path, col, row } = parseStock(props?.url ?? '');
150
-
151
- if (path) {
152
- url = path;
153
- }
154
-
155
- activeRowCol.value.col = col;
156
- activeRowCol.value.row = row;
157
-
158
- if (props.mode === 'development') {
159
- // 开发环境查看源码
160
- getSourceCodeDev(url);
161
- } else if (props.mode === 'production') {
162
- // TODO 生产环境查看源码
163
- }
164
- });
165
- </script>
166
- <style scoped>
167
- .dev-tool-code {
168
- position: fixed;
169
- width: 100vw;
170
- height: 100vh;
171
- z-index: 1000;
172
- top: 0;
173
- left: 0;
174
- padding: 0 16px;
175
- /* #ifdef H5 */
176
- padding: 50px 16px;
177
- /* #endif */
178
-
179
- background-color: rgba(255, 255, 255, 0.95);
180
- box-sizing: border-box;
181
- color: #000;
182
- }
183
-
184
- .dev-tool-code-control {
185
- display: flex;
186
- align-items: center;
187
- gap: 12px;
188
- height: 32px;
189
- border-bottom: 1px solid var(--dev-tool-border-color);
190
- box-sizing: border-box;
191
- }
192
-
193
- .dev-tool-code-title {
194
- height: 32px;
195
- line-height: 32px;
196
- margin-bottom: 4px;
197
- border-bottom: 1px solid var(--dev-tool-border-color);
198
- box-sizing: border-box;
199
- white-space: nowrap;
200
- overflow: auto;
201
- }
202
-
203
- .dev-tool-code-list {
204
- height: calc(100% - 68px);
205
- }
206
-
207
- .dev-tool-code-item {
208
- display: flex;
209
- align-items: center;
210
- height: 28px;
211
- }
212
- .dev-tool-code-item-active {
213
- color: #fff;
214
- background-color: var(--dev-tool-main-color);
215
- }
216
-
217
- .dev-tool-code-item-index {
218
- flex-shrink: 0;
219
- width: 20px;
220
- margin-right: 8px;
221
- text-align: right;
222
- }
223
-
224
- .dev-tool-code-item-content {
225
- white-space: pre;
226
- }
227
- </style>