vite-uni-dev-tool 0.0.12 → 0.0.14

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 (235) hide show
  1. package/dist/const.d.ts +133 -0
  2. package/dist/const.d.ts.map +1 -0
  3. package/dist/const.js +36 -0
  4. package/dist/core.d.ts +52 -0
  5. package/dist/core.d.ts.map +1 -0
  6. package/dist/core.js +80 -0
  7. package/dist/devConsole/index.d.ts +169 -0
  8. package/dist/devConsole/index.d.ts.map +1 -0
  9. package/dist/devConsole/index.js +270 -0
  10. package/dist/devEvent/index.d.ts +286 -0
  11. package/dist/devEvent/index.d.ts.map +1 -0
  12. package/dist/devEvent/index.js +435 -0
  13. package/dist/devEventBus/index.d.ts +42 -0
  14. package/dist/devEventBus/index.d.ts.map +1 -0
  15. package/dist/devEventBus/index.js +70 -0
  16. package/dist/devIntercept/index.d.ts +119 -0
  17. package/dist/devIntercept/index.d.ts.map +1 -0
  18. package/dist/devIntercept/index.js +582 -0
  19. package/dist/devRunJS/index.d.ts +67 -0
  20. package/dist/devRunJS/index.d.ts.map +1 -0
  21. package/dist/devStore/index.d.ts +178 -0
  22. package/dist/devStore/index.d.ts.map +1 -0
  23. package/dist/devStore/index.js +395 -0
  24. package/dist/devToolInfo/index.d.ts +17 -0
  25. package/dist/devToolInfo/index.d.ts.map +1 -0
  26. package/dist/devToolInfo/index.js +15 -0
  27. package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +7 -1
  28. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
  29. package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
  30. package/{dev → dist}/plugins/utils/index.d.ts +3 -0
  31. package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
  32. package/dist/plugins/utils/index.js +1 -0
  33. package/dist/type.d.ts +264 -0
  34. package/dist/type.d.ts.map +1 -0
  35. package/dist/utils/array.d.ts +2 -0
  36. package/dist/utils/array.d.ts.map +1 -0
  37. package/dist/utils/array.js +12 -0
  38. package/dist/utils/date.d.ts +19 -0
  39. package/dist/utils/date.d.ts.map +1 -0
  40. package/dist/utils/date.js +40 -0
  41. package/dist/utils/file.d.ts +11 -0
  42. package/dist/utils/file.d.ts.map +1 -0
  43. package/dist/utils/file.js +87 -0
  44. package/dist/utils/function.d.ts +28 -0
  45. package/dist/utils/function.d.ts.map +1 -0
  46. package/dist/utils/function.js +46 -0
  47. package/dist/utils/index.d.ts +11 -0
  48. package/dist/utils/index.d.ts.map +1 -0
  49. package/dist/utils/index.js +55 -0
  50. package/dist/utils/ip.d.ts +5 -0
  51. package/dist/utils/ip.d.ts.map +1 -0
  52. package/dist/utils/ip.js +21 -0
  53. package/dist/utils/language.d.ts +29 -0
  54. package/dist/utils/language.d.ts.map +1 -0
  55. package/dist/utils/language.js +50 -0
  56. package/dist/utils/object.d.ts +49 -0
  57. package/dist/utils/object.d.ts.map +1 -0
  58. package/dist/utils/object.js +118 -0
  59. package/dist/utils/page.d.ts +7 -0
  60. package/dist/utils/page.d.ts.map +1 -0
  61. package/dist/utils/page.js +7 -0
  62. package/dist/utils/platform.d.ts +4 -0
  63. package/dist/utils/platform.d.ts.map +1 -0
  64. package/dist/utils/platform.js +14 -0
  65. package/dist/utils/string.d.ts +45 -0
  66. package/dist/utils/string.d.ts.map +1 -0
  67. package/dist/utils/string.js +88 -0
  68. package/dist/utils/utils.d.ts +16 -0
  69. package/dist/utils/utils.d.ts.map +1 -0
  70. package/dist/v2/AppInfo/index.vue +41 -0
  71. package/dist/v2/AutoSizer/index.vue +189 -0
  72. package/dist/v2/AutoSizer/index1.vue +193 -0
  73. package/dist/v2/AutoSizer/utils.d.ts +5 -0
  74. package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
  75. package/dist/v2/CaptureScreen/index.vue +78 -0
  76. package/dist/v2/CloseButton/index.vue +32 -0
  77. package/dist/v2/Connection/index.vue +94 -0
  78. package/dist/v2/ConsoleList/ConsoleItem.vue +235 -0
  79. package/dist/v2/ConsoleList/RunJSInput.vue +243 -0
  80. package/dist/v2/ConsoleList/index.vue +164 -0
  81. package/dist/v2/ConsoleList/staticTips.js +1144 -0
  82. package/dist/v2/DevTool/index.vue +162 -0
  83. package/dist/v2/DevToolButton/index.vue +228 -0
  84. package/dist/v2/DevToolTitle/index.vue +28 -0
  85. package/dist/v2/DevToolWindow/index.vue +1051 -0
  86. package/dist/v2/DeviceInfo/index.vue +48 -0
  87. package/dist/v2/Empty/index.vue +40 -0
  88. package/dist/v2/FilterInput/index.vue +100 -0
  89. package/dist/v2/JsonPretty/components/Brackets/index.vue +30 -0
  90. package/dist/v2/JsonPretty/components/Carets/index.vue +65 -0
  91. package/dist/v2/JsonPretty/components/CheckController/index.vue +127 -0
  92. package/dist/v2/JsonPretty/components/TreeNode/index.vue +417 -0
  93. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
  94. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  95. package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
  96. package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
  97. package/dist/v2/JsonPretty/index.vue +531 -0
  98. package/dist/v2/JsonPretty/type.d.ts +93 -0
  99. package/dist/v2/JsonPretty/type.d.ts.map +1 -0
  100. package/dist/v2/JsonPretty/utils/index.js +211 -0
  101. package/dist/v2/NetworkList/NetworkDetail.vue +215 -0
  102. package/dist/v2/NetworkList/NetworkItem.vue +135 -0
  103. package/dist/v2/NetworkList/index.vue +148 -0
  104. package/dist/v2/PiniaList/index.vue +79 -0
  105. package/dist/v2/RouteList/index.vue +137 -0
  106. package/dist/v2/SettingList/index.vue +318 -0
  107. package/dist/v2/SourceCode/index.vue +237 -0
  108. package/dist/v2/StorageList/index.vue +165 -0
  109. package/dist/v2/SystemInfo/index.vue +49 -0
  110. package/dist/v2/Tabs/index.vue +127 -0
  111. package/dist/v2/Tag/index.vue +91 -0
  112. package/dist/v2/UniEvent/UniEventItem.vue +157 -0
  113. package/dist/v2/UniEvent/index.vue +127 -0
  114. package/dist/v2/UploadList/UploadDetail.vue +204 -0
  115. package/dist/v2/UploadList/UploadItem.vue +134 -0
  116. package/dist/v2/UploadList/index.vue +143 -0
  117. package/dist/v2/VirtualList/index.vue +140 -0
  118. package/dist/v2/VirtualListPro/AutoSize.vue +50 -0
  119. package/dist/v2/VirtualListPro/index.vue +255 -0
  120. package/dist/v2/VuexList/index.vue +80 -0
  121. package/dist/v2/WebSocket/WebSocketItem.vue +129 -0
  122. package/dist/v2/WebSocket/WebSocketList.vue +183 -0
  123. package/dist/v2/WebSocket/index.vue +155 -0
  124. package/dist/v2/WindowInfo/index.vue +49 -0
  125. package/{dev/components → dist/v3}/AppInfo/index.vue +0 -1
  126. package/dist/v3/AutoSizer/utils.d.ts +5 -0
  127. package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
  128. package/dist/v3/AutoSizer/utils.ts +49 -0
  129. package/{dev/components → dist/v3}/CloseButton/index.vue +5 -2
  130. package/{dev/components → dist/v3}/ConsoleList/ConsoleItem.vue +10 -9
  131. package/{dev/components → dist/v3}/ConsoleList/RunJSInput.vue +5 -2
  132. package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
  133. package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
  134. package/{dev/components → dist/v3}/DevTool/index.vue +33 -4
  135. package/{dev/components → dist/v3}/DevToolWindow/index.vue +67 -4
  136. package/dist/v3/Empty/empty.png +0 -0
  137. package/{dev/components → dist/v3}/FilterInput/index.vue +5 -4
  138. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
  139. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  140. package/dist/v3/JsonPretty/hooks/useClipboard.ts +21 -0
  141. package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
  142. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
  143. package/dist/v3/JsonPretty/hooks/useError.ts +21 -0
  144. package/{dev/components → dist/v3}/JsonPretty/index.vue +10 -10
  145. package/dist/v3/JsonPretty/type.d.ts +93 -0
  146. package/dist/v3/JsonPretty/type.d.ts.map +1 -0
  147. package/dist/v3/JsonPretty/type.ts +125 -0
  148. package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
  149. package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
  150. package/{dev/components → dist/v3}/NetworkList/NetworkDetail.vue +2 -2
  151. package/{dev/components → dist/v3}/NetworkList/NetworkItem.vue +2 -1
  152. package/dist/v3/RunJS/index.vue +128 -0
  153. package/{dev/components → dist/v3}/SettingList/index.vue +128 -37
  154. package/{dev/components → dist/v3}/SourceCode/index.vue +2 -2
  155. package/{dev/components → dist/v3}/Tag/index.vue +4 -4
  156. package/{dev/components → dist/v3}/UploadList/UploadDetail.vue +3 -15
  157. package/{dev/components → dist/v3}/UploadList/UploadItem.vue +1 -1
  158. package/dist/v3/VirtualListPro/readme.md +40 -0
  159. package/{dev/components → dist/v3}/WebSocket/WebSocketItem.vue +1 -1
  160. package/{dev/components → dist/v3}/WebSocket/WebSocketList.vue +3 -15
  161. package/package.json +5 -5
  162. package/dev/components/Button/index.vue +0 -34
  163. package/dev/components/Checkbox/index.vue +0 -40
  164. package/dev/components/Code/index.vue +0 -230
  165. package/dev/components/ConsoleList/Code.vue +0 -227
  166. package/dev/const.ts +0 -164
  167. package/dev/core.ts +0 -118
  168. package/dev/devConsole/index.ts +0 -350
  169. package/dev/devEvent/index.ts +0 -810
  170. package/dev/devEventBus/index.ts +0 -94
  171. package/dev/devIntercept/index.ts +0 -745
  172. package/dev/devRunJS/index.ts +0 -170
  173. package/dev/devStore/index.ts +0 -732
  174. package/dev/devToolInfo/index.ts +0 -26
  175. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  176. package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
  177. package/dev/plugins/utils/index.js +0 -1
  178. package/dev/shims-uni.d.ts +0 -43
  179. package/dev/type.ts +0 -291
  180. package/dev/utils/array.ts +0 -15
  181. package/dev/utils/date.ts +0 -75
  182. package/dev/utils/file.ts +0 -121
  183. package/dev/utils/function.ts +0 -192
  184. package/dev/utils/index.d.ts +0 -6
  185. package/dev/utils/index.ts +0 -51
  186. package/dev/utils/ip.ts +0 -79
  187. package/dev/utils/language.ts +0 -77
  188. package/dev/utils/object.ts +0 -306
  189. package/dev/utils/page.ts +0 -13
  190. package/dev/utils/platform.ts +0 -14
  191. package/dev/utils/string.ts +0 -133
  192. package/dev/utils/utils.ts +0 -198
  193. /package/{dev → dist}/index.d.ts +0 -0
  194. /package/{dev → dist}/index.d.ts.map +0 -0
  195. /package/{dev → dist}/index.js +0 -0
  196. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
  197. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
  198. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
  199. /package/{dev/components → dist/v2}/AutoSizer/utils.ts +0 -0
  200. /package/{dev/components → dist/v2}/Empty/empty.png +0 -0
  201. /package/{dev/components → dist/v2}/JsonPretty/hooks/useClipboard.ts +0 -0
  202. /package/{dev/components → dist/v2}/JsonPretty/hooks/useError.ts +0 -0
  203. /package/{dev/components → dist/v2}/JsonPretty/type.ts +0 -0
  204. /package/{dev/components → dist/v2}/RunJS/index.vue +0 -0
  205. /package/{dev/components → dist/v2}/VirtualListPro/readme.md +0 -0
  206. /package/{dev/components → dist/v3}/AutoSizer/index.vue +0 -0
  207. /package/{dev/components → dist/v3}/AutoSizer/index1.vue +0 -0
  208. /package/{dev/components → dist/v3}/CaptureScreen/index.vue +0 -0
  209. /package/{dev/components → dist/v3}/Connection/index.vue +0 -0
  210. /package/{dev/components → dist/v3}/ConsoleList/index.vue +0 -0
  211. /package/{dev/components → dist/v3}/ConsoleList/staticTips.ts +0 -0
  212. /package/{dev/components → dist/v3}/DevToolButton/index.vue +0 -0
  213. /package/{dev/components → dist/v3}/DevToolTitle/index.vue +0 -0
  214. /package/{dev/components → dist/v3}/DeviceInfo/index.vue +0 -0
  215. /package/{dev/components → dist/v3}/Empty/index.vue +0 -0
  216. /package/{dev/components → dist/v3}/JsonPretty/components/Brackets/index.vue +0 -0
  217. /package/{dev/components → dist/v3}/JsonPretty/components/Carets/index.vue +0 -0
  218. /package/{dev/components → dist/v3}/JsonPretty/components/CheckController/index.vue +0 -0
  219. /package/{dev/components → dist/v3}/JsonPretty/components/TreeNode/index.vue +0 -0
  220. /package/{dev/components → dist/v3}/JsonPretty/utils/index.ts +0 -0
  221. /package/{dev/components → dist/v3}/NetworkList/index.vue +0 -0
  222. /package/{dev/components → dist/v3}/PiniaList/index.vue +0 -0
  223. /package/{dev/components → dist/v3}/RouteList/index.vue +0 -0
  224. /package/{dev/components → dist/v3}/StorageList/index.vue +0 -0
  225. /package/{dev/components → dist/v3}/SystemInfo/index.vue +0 -0
  226. /package/{dev/components → dist/v3}/Tabs/index.vue +0 -0
  227. /package/{dev/components → dist/v3}/UniEvent/UniEventItem.vue +0 -0
  228. /package/{dev/components → dist/v3}/UniEvent/index.vue +0 -0
  229. /package/{dev/components → dist/v3}/UploadList/index.vue +0 -0
  230. /package/{dev/components → dist/v3}/VirtualList/index.vue +0 -0
  231. /package/{dev/components → dist/v3}/VirtualListPro/AutoSize.vue +0 -0
  232. /package/{dev/components → dist/v3}/VirtualListPro/index.vue +0 -0
  233. /package/{dev/components → dist/v3}/VuexList/index.vue +0 -0
  234. /package/{dev/components → dist/v3}/WebSocket/index.vue +0 -0
  235. /package/{dev/components → dist/v3}/WindowInfo/index.vue +0 -0
@@ -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,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>
package/dev/const.ts DELETED
@@ -1,164 +0,0 @@
1
- /**
2
- * 调试按钮事件
3
- */
4
- export const DEV_BUTTON_VISIBLE = 'dev-button-visible';
5
-
6
- /**
7
- * 调试弹窗事件
8
- */
9
- export const DEV_WINDOW_VISIBLE = 'dev-window-visible';
10
-
11
- /**
12
- * app 发出的信息
13
- */
14
- export const DEV_APP_MESSAGE = 'dev-app-message';
15
-
16
- /**
17
- * 调试弹窗发出的消息
18
- */
19
- export const DEV_WINDOW_MESSAGE = 'dev-window-message';
20
-
21
- /**
22
- * 调试器销毁
23
- */
24
- export const DEV_IS_DESTROY = 'dev-is-destroy';
25
-
26
- /**
27
- * 清空console
28
- */
29
- export const DEV_CONSOLE_CLEAR = 'dev-console-clear';
30
-
31
- /**
32
- * 清空network
33
- */
34
- export const DEV_NETWORK_CLEAR = 'dev-network-clear';
35
-
36
- /**
37
- * 清空websocket
38
- */
39
- export const DEV_WEBSOCKET_CLEAR = 'dev-websocket-clear';
40
-
41
- /**
42
- * 清空upload
43
- */
44
- export const DEV_UPLOAD_CLEAR = 'dev-upload-clear';
45
-
46
- /**
47
- * 清空storage
48
- */
49
- export const DEV_STORAGE_CLEAR = 'dev-storage-clear';
50
-
51
- /**
52
- * 刷新storage
53
- */
54
- export const DEV_STORAGE_REFRESH = 'dev-storage-refresh';
55
-
56
- /**
57
- * 移除storage
58
- */
59
- export const DEV_STORAGE_REMOVE = 'dev-storage-remove';
60
-
61
- /**
62
- * 新增storage
63
- */
64
- export const DEV_STORAGE_ADD = 'dev-storage-add';
65
-
66
- /**
67
- * 更新storage
68
- */
69
- export const DEV_STORAGE_UPDATE = 'dev-storage-update';
70
-
71
- /**
72
- * 页面跳转
73
- */
74
- export const DEV_PAGE_JUMP = 'dev-page-jump';
75
-
76
- /**
77
- * 隐藏调试按钮
78
- */
79
- export const DEV_BUTTON_SHOW_OR_HIDE = 'dev-button-show-or-hide';
80
-
81
- /**
82
- * 重启调试器
83
- */
84
- export const DEV_RESTART_DEBUGGER = 'dev-restart-debugger';
85
-
86
- /**
87
- * 重启app
88
- */
89
- export const DEV_RESTART_APP = 'dev-restart-app';
90
-
91
- /**
92
- * 导出日志
93
- */
94
- export const DEV_EXPORT_LOG = 'dev-export-log';
95
-
96
- /**
97
- * 改变vuex数据
98
- */
99
- export const DEV_VUEX_CHANGE = 'dev-vuex-change';
100
-
101
- /**
102
- * 改变pinia
103
- */
104
- export const DEV_PINIA_CHANGE = 'dev-pinia-change';
105
-
106
- /**
107
- * 清除日志缓存
108
- */
109
- export const DEV_LOG_CACHE_CLEAR = 'dev-log-cache-clear';
110
-
111
- /**
112
- * 销毁调试工具
113
- */
114
- export const DEV_DESTROY = 'dev-destroy';
115
-
116
- /**
117
- * 显示调试弹窗
118
- */
119
- export const DEV_WINDOW_OPEN = 'dev-window-open';
120
-
121
- /**
122
- * 显示调试弹窗
123
- */
124
- export const DEV_WINDOW_CLOSE = 'dev-window-close';
125
-
126
- /**
127
- * 刷新路由列表
128
- */
129
- export const DEV_ROUTE_REFRESH = 'dev-route-refresh';
130
-
131
- /**
132
- * 获取 dev option
133
- */
134
- export const DEV_OPTION = 'dev-option';
135
-
136
- /**
137
- * 获取options
138
- */
139
- export const DEV_OPTION_GET = 'dev-option-get';
140
-
141
- /**
142
- * 发送 options
143
- */
144
- export const DEV_OPTION_SEND = 'dev-option-send';
145
-
146
- /**
147
- * 清空事件
148
- */
149
- export const DEV_UNI_EVENT_CLEAR = 'dev-uni-event-clear';
150
-
151
- /**
152
- * 运行js
153
- */
154
- export const DEV_RUN_JS = 'dev-uni-run-js';
155
-
156
- /**
157
- * 清空截屏列表
158
- */
159
- export const DEV_CAPTURE_SCREEN_CLEAR = 'dev-capture-screen-clear';
160
-
161
- /**
162
- * 存储的dev-tool 信息
163
- */
164
- export const DEV_TOOL_INFO = 'dev-tool-info';