vite-uni-dev-tool 0.0.48 → 1.0.0

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 (292) hide show
  1. package/README.md +20 -0
  2. package/dist/const.cjs +1 -0
  3. package/dist/const.d.ts +78 -161
  4. package/dist/const.d.ts.map +1 -1
  5. package/dist/const.js +1 -47
  6. package/dist/core-shared.d.ts +44 -0
  7. package/dist/core-shared.d.ts.map +1 -0
  8. package/dist/core-shared.js +1 -0
  9. package/dist/core.d.ts +2 -40
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +4 -159
  12. package/dist/i18n/index.cjs +1 -0
  13. package/dist/i18n/index.d.ts +9 -0
  14. package/dist/i18n/index.d.ts.map +1 -0
  15. package/dist/i18n/index.js +1 -0
  16. package/dist/i18n/instance.cjs +1 -0
  17. package/dist/i18n/instance.d.ts +15 -0
  18. package/dist/i18n/instance.d.ts.map +1 -0
  19. package/dist/i18n/instance.js +1 -0
  20. package/dist/i18n/locales/en.cjs +1 -0
  21. package/dist/i18n/locales/en.d.ts +470 -0
  22. package/dist/i18n/locales/en.d.ts.map +1 -0
  23. package/dist/i18n/locales/en.js +1 -0
  24. package/dist/i18n/locales/zh-Hans.cjs +1 -0
  25. package/dist/i18n/locales/zh-Hans.d.ts +476 -0
  26. package/dist/i18n/locales/zh-Hans.d.ts.map +1 -0
  27. package/dist/i18n/locales/zh-Hans.js +1 -0
  28. package/dist/index.cjs +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/modules/devConsole/index.cjs +4 -0
  32. package/dist/{devConsole → modules/devConsole}/index.d.ts +1 -1
  33. package/dist/modules/devConsole/index.d.ts.map +1 -0
  34. package/dist/modules/devConsole/index.js +4 -0
  35. package/dist/modules/devEvent/index.cjs +5 -0
  36. package/dist/modules/devEvent/index.d.ts +115 -0
  37. package/dist/modules/devEvent/index.d.ts.map +1 -0
  38. package/dist/modules/devEvent/index.js +5 -0
  39. package/dist/modules/devIntercept/index.cjs +13 -0
  40. package/dist/modules/devIntercept/index.d.ts +71 -0
  41. package/dist/modules/devIntercept/index.d.ts.map +1 -0
  42. package/dist/modules/devIntercept/index.js +13 -0
  43. package/dist/modules/devStore/index.cjs +1 -0
  44. package/dist/modules/devStore/index.d.ts +159 -0
  45. package/dist/modules/devStore/index.d.ts.map +1 -0
  46. package/dist/modules/devStore/index.js +1 -0
  47. package/dist/modules/devToolInfo/index.cjs +1 -0
  48. package/dist/modules/devToolInfo/index.d.ts +27 -0
  49. package/dist/modules/devToolInfo/index.d.ts.map +1 -0
  50. package/dist/modules/devToolInfo/index.js +1 -0
  51. package/dist/plugins/uniDevTool/transform/transformApp.cjs +44 -0
  52. package/dist/plugins/uniDevTool/transform/transformApp.d.ts.map +1 -1
  53. package/dist/plugins/uniDevTool/transform/transformApp.js +17 -17
  54. package/dist/plugins/uniDevTool/transform/transformMain.cjs +3 -0
  55. package/dist/plugins/uniDevTool/transform/transformMain.d.ts.map +1 -1
  56. package/dist/plugins/uniDevTool/transform/transformMain.js +3 -3
  57. package/dist/plugins/uniDevTool/transform/transformVue.cjs +41 -0
  58. package/dist/plugins/uniDevTool/transform/transformVue.d.ts +1 -2
  59. package/dist/plugins/uniDevTool/transform/transformVue.d.ts.map +1 -1
  60. package/dist/plugins/uniDevTool/transform/transformVue.js +32 -19
  61. package/dist/plugins/uniDevTool/uniDevTool.cjs +5 -0
  62. package/dist/plugins/uniDevTool/uniDevTool.d.ts +3 -11
  63. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -1
  64. package/dist/plugins/uniDevTool/uniDevTool.js +3 -3
  65. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.cjs +19 -0
  66. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +1 -1
  67. package/dist/plugins/uniGlobalComponents/uniGlobalComponents.js +11 -19
  68. package/dist/plugins/uniParseStock/index.d.ts +10 -0
  69. package/dist/plugins/uniParseStock/index.d.ts.map +1 -0
  70. package/dist/plugins/utils/index.cjs +2 -0
  71. package/dist/plugins/utils/index.d.ts +1 -3
  72. package/dist/plugins/utils/index.d.ts.map +1 -1
  73. package/dist/plugins/utils/index.js +2 -2
  74. package/dist/shims-uni.d.ts +140 -0
  75. package/dist/type.d.ts +174 -16
  76. package/dist/type.d.ts.map +1 -1
  77. package/dist/utils/array.cjs +1 -0
  78. package/dist/utils/array.d.ts.map +1 -1
  79. package/dist/utils/array.js +1 -12
  80. package/dist/utils/date.cjs +1 -0
  81. package/dist/utils/date.d.ts.map +1 -1
  82. package/dist/utils/date.js +1 -59
  83. package/dist/utils/file.cjs +1 -0
  84. package/dist/utils/file.d.ts.map +1 -1
  85. package/dist/utils/file.js +1 -85
  86. package/dist/utils/function.cjs +1 -0
  87. package/dist/utils/function.d.ts +13 -0
  88. package/dist/utils/function.d.ts.map +1 -1
  89. package/dist/utils/function.js +1 -68
  90. package/dist/utils/index.cjs +1 -0
  91. package/dist/utils/index.d.ts.map +1 -1
  92. package/dist/utils/index.js +1 -63
  93. package/dist/utils/ip.cjs +1 -0
  94. package/dist/utils/ip.d.ts +1 -1
  95. package/dist/utils/ip.d.ts.map +1 -1
  96. package/dist/utils/ip.js +1 -45
  97. package/dist/utils/language.cjs +1 -0
  98. package/dist/utils/language.d.ts +2 -1
  99. package/dist/utils/language.d.ts.map +1 -1
  100. package/dist/utils/language.js +1 -63
  101. package/dist/utils/object.cjs +1 -0
  102. package/dist/utils/object.d.ts +4 -5
  103. package/dist/utils/object.d.ts.map +1 -1
  104. package/dist/utils/object.js +1 -136
  105. package/dist/utils/openLink.cjs +1 -0
  106. package/dist/utils/openLink.d.ts.map +1 -1
  107. package/dist/utils/openLink.js +1 -28
  108. package/dist/utils/page.cjs +1 -0
  109. package/dist/utils/page.d.ts.map +1 -1
  110. package/dist/utils/page.js +1 -7
  111. package/dist/utils/platform.cjs +1 -0
  112. package/dist/utils/platform.d.ts.map +1 -1
  113. package/dist/utils/platform.js +1 -17
  114. package/dist/utils/string.cjs +1 -0
  115. package/dist/utils/string.d.ts.map +1 -1
  116. package/dist/utils/string.js +1 -114
  117. package/dist/utils/utils.cjs +1 -0
  118. package/dist/utils/utils.d.ts +1 -1
  119. package/dist/utils/utils.d.ts.map +1 -1
  120. package/dist/utils/utils.js +1 -126
  121. package/dist/v3/AppTransition/index.vue +170 -0
  122. package/dist/v3/AutoSizer/index.vue +4 -5
  123. package/dist/v3/AutoSizer/index1.vue +4 -6
  124. package/dist/v3/AutoSizer/utils.ts +1 -1
  125. package/dist/v3/CaptureScreen/index.vue +19 -8
  126. package/dist/v3/CircularButton/index.vue +64 -13
  127. package/dist/v3/ConsoleList/ConsoleItem.vue +56 -5
  128. package/dist/v3/ConsoleList/RunJSInput.vue +10 -6
  129. package/dist/v3/ConsoleList/index.vue +51 -35
  130. package/dist/v3/CustomSwiper/CustomSwiperItem.vue +49 -0
  131. package/dist/v3/CustomSwiper/index.vue +104 -0
  132. package/dist/v3/DevTool/fps-collector.render.ts +148 -0
  133. package/dist/v3/DevTool/index.vue +209 -102
  134. package/dist/v3/DevToolButton/index.vue +40 -59
  135. package/dist/v3/DevToolTitle/index.vue +4 -1
  136. package/dist/v3/DevToolWindow/DevToolOverlay.vue +182 -0
  137. package/dist/v3/DevToolWindow/const.ts +47 -69
  138. package/dist/v3/DevToolWindow/hooks/dataUtils.ts +48 -0
  139. package/dist/v3/DevToolWindow/hooks/useDevToolData.ts +338 -0
  140. package/dist/v3/DevToolWindow/hooks/useDevToolHandlers.ts +549 -0
  141. package/dist/v3/DevToolWindow/hooks/useDevToolOverlay.ts +184 -0
  142. package/dist/v3/DevToolWindow/index.css +89 -0
  143. package/dist/v3/DevToolWindow/index.vue +800 -1450
  144. package/dist/v3/DraggableContainer/index.vue +456 -0
  145. package/dist/v3/ElEvent/ElEventItem.vue +4 -3
  146. package/dist/v3/ElEvent/index.vue +26 -9
  147. package/dist/v3/Empty/index.vue +1 -0
  148. package/dist/v3/FilterInput/index.vue +8 -22
  149. package/dist/v3/FilterSelect/index.vue +37 -24
  150. package/dist/v3/Instance/components/InstanceTreeNode.vue +265 -0
  151. package/dist/v3/Instance/flatten.ts +226 -0
  152. package/dist/v3/Instance/index.vue +94 -0
  153. package/dist/v3/Instance/registry.ts +49 -0
  154. package/dist/v3/Instance/transformTree.ts +375 -0
  155. package/dist/v3/Instance/transformTreeCtx.ts +268 -0
  156. package/dist/v3/{InstanceTree → Instance}/typing.d.ts +15 -2
  157. package/dist/v3/InstanceDetail/index.vue +433 -44
  158. package/dist/v3/JsonDetail/index.vue +12 -8
  159. package/dist/v3/JsonPretty/components/Brackets/index.vue +1 -0
  160. package/dist/v3/JsonPretty/components/Carets/index.vue +2 -1
  161. package/dist/v3/JsonPretty/components/CheckController/index.vue +26 -15
  162. package/dist/v3/JsonPretty/components/TreeNode/index.vue +42 -20
  163. package/dist/v3/JsonPretty/index.vue +60 -37
  164. package/dist/v3/JsonPretty/utils/index.ts +41 -44
  165. package/dist/v3/MovableContainer/index.vue +89 -0
  166. package/dist/v3/NFCList/NFCItem.vue +14 -14
  167. package/dist/v3/NFCList/NFCTool.vue +99 -81
  168. package/dist/v3/NFCList/index.vue +14 -10
  169. package/dist/v3/NetworkList/InterceptConfig.vue +154 -364
  170. package/dist/v3/NetworkList/InterceptItem.vue +14 -6
  171. package/dist/v3/NetworkList/NetworkDetail.vue +34 -29
  172. package/dist/v3/NetworkList/NetworkIntercept.vue +11 -8
  173. package/dist/v3/NetworkList/NetworkItem.vue +27 -11
  174. package/dist/v3/NetworkList/NetworkSend.vue +132 -290
  175. package/dist/v3/NetworkList/hooks/useNetworkForm.ts +86 -0
  176. package/dist/v3/NetworkList/index.vue +32 -24
  177. package/dist/v3/NetworkList/utils.ts +101 -0
  178. package/dist/v3/Performance/index.vue +495 -0
  179. package/dist/v3/Performance/modules/PerformanceMetrics.vue +153 -0
  180. package/dist/v3/Performance/modules/PerformanceWidget.vue +249 -0
  181. package/dist/v3/Performance/modules/usePerformanceChart.ts +460 -0
  182. package/dist/v3/Performance/modules/usePerformanceData.ts +258 -0
  183. package/dist/v3/Pick/index.vue +322 -0
  184. package/dist/v3/PiniaList/index.vue +38 -17
  185. package/dist/v3/RouteList/index.vue +32 -15
  186. package/dist/v3/RunJS/index.vue +30 -10
  187. package/dist/v3/ScanCodeList/ScanCodeItem.vue +2 -9
  188. package/dist/v3/ScanCodeList/index.vue +12 -9
  189. package/dist/v3/SettingButton/index.vue +45 -0
  190. package/dist/v3/SettingList/index.css +120 -0
  191. package/dist/v3/SettingList/index.vue +96 -537
  192. package/dist/v3/SettingList/modules/SettingDevTool.vue +208 -0
  193. package/dist/v3/SettingList/modules/SettingInfo.vue +119 -0
  194. package/dist/v3/SettingList/modules/SettingLanguage.vue +74 -0
  195. package/dist/v3/SettingList/modules/SettingLog.vue +230 -0
  196. package/dist/v3/SettingList/modules/SettingNetwork.vue +120 -0
  197. package/dist/v3/SettingList/modules/SettingTheme.vue +312 -0
  198. package/dist/v3/SourceCode/Line.vue +15 -2
  199. package/dist/v3/SourceCode/index.vue +25 -24
  200. package/dist/v3/SourceCode/parseCode.ts +114 -56
  201. package/dist/v3/StorageList/index.vue +33 -33
  202. package/dist/v3/Tabs/index.vue +31 -28
  203. package/dist/v3/Tag/index.vue +39 -20
  204. package/dist/v3/TransferList/TransferDetail.vue +268 -0
  205. package/dist/v3/TransferList/TransferItem.vue +125 -0
  206. package/dist/v3/TransferList/index.vue +181 -0
  207. package/dist/v3/UniEvent/UniEventItem.vue +1 -0
  208. package/dist/v3/UniEvent/index.vue +28 -29
  209. package/dist/v3/{VirtualListPro → VirtualList}/AutoSize.vue +1 -1
  210. package/dist/v3/VirtualList/index.vue +382 -82
  211. package/dist/v3/VuexList/index.vue +38 -17
  212. package/dist/v3/WebSocket/WebSocketDetail.vue +142 -80
  213. package/dist/v3/WebSocket/WebSocketItem.vue +10 -4
  214. package/dist/v3/WebSocket/index.vue +44 -30
  215. package/dist/v3/hooks/useNFC/index.ts +6 -6
  216. package/dist/v3/hooks/useNFC/typing.d.ts +2 -2
  217. package/dist/v3/hooks/useNFC/useNFCAndroid.ts +215 -626
  218. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.ts +54 -85
  219. package/dist/v3/hooks/useNFC/utils.ts +3 -3
  220. package/dist/v3/hooks/useRequest/index.ts +2 -2
  221. package/dist/v3/hooks/useScanCode/index.ts +10 -8
  222. package/dist/v3/styles/theme.css +290 -0
  223. package/dist/v3/styles/theme.ts +12 -0
  224. package/package.json +25 -5
  225. package/dist/devConsole/index.d.ts.map +0 -1
  226. package/dist/devConsole/index.js +0 -273
  227. package/dist/devEvent/index.d.ts +0 -328
  228. package/dist/devEvent/index.d.ts.map +0 -1
  229. package/dist/devEvent/index.js +0 -697
  230. package/dist/devEventBus/index.d.ts +0 -42
  231. package/dist/devEventBus/index.d.ts.map +0 -1
  232. package/dist/devEventBus/index.js +0 -70
  233. package/dist/devIntercept/index.d.ts +0 -281
  234. package/dist/devIntercept/index.d.ts.map +0 -1
  235. package/dist/devIntercept/index.js +0 -949
  236. package/dist/devRunJS/index.d.ts +0 -67
  237. package/dist/devRunJS/index.d.ts.map +0 -1
  238. package/dist/devStore/index.d.ts +0 -199
  239. package/dist/devStore/index.d.ts.map +0 -1
  240. package/dist/devStore/index.js +0 -562
  241. package/dist/devToolInfo/index.d.ts +0 -17
  242. package/dist/devToolInfo/index.d.ts.map +0 -1
  243. package/dist/devToolInfo/index.js +0 -15
  244. package/dist/v3/AutoSizer/utils.d.ts +0 -5
  245. package/dist/v3/AutoSizer/utils.d.ts.map +0 -1
  246. package/dist/v3/ConsoleList/staticTips.d.ts +0 -13
  247. package/dist/v3/ConsoleList/staticTips.d.ts.map +0 -1
  248. package/dist/v3/DevToolWindow/const.d.ts +0 -46
  249. package/dist/v3/DevToolWindow/const.d.ts.map +0 -1
  250. package/dist/v3/InstanceTree/components/InstanceTreeNode.vue +0 -81
  251. package/dist/v3/InstanceTree/flatten.d.ts +0 -10
  252. package/dist/v3/InstanceTree/flatten.d.ts.map +0 -1
  253. package/dist/v3/InstanceTree/flatten.ts +0 -75
  254. package/dist/v3/InstanceTree/index.vue +0 -51
  255. package/dist/v3/InstanceTree/transformTree.d.ts +0 -17
  256. package/dist/v3/InstanceTree/transformTree.d.ts.map +0 -1
  257. package/dist/v3/InstanceTree/transformTree.ts +0 -237
  258. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +0 -4
  259. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +0 -1
  260. package/dist/v3/JsonPretty/hooks/useError.d.ts +0 -8
  261. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +0 -1
  262. package/dist/v3/JsonPretty/type.d.ts +0 -94
  263. package/dist/v3/JsonPretty/type.d.ts.map +0 -1
  264. package/dist/v3/JsonPretty/utils/index.d.ts +0 -10
  265. package/dist/v3/JsonPretty/utils/index.d.ts.map +0 -1
  266. package/dist/v3/NFCList/const.d.ts +0 -13
  267. package/dist/v3/NFCList/const.d.ts.map +0 -1
  268. package/dist/v3/NetworkList/const.d.ts +0 -5
  269. package/dist/v3/NetworkList/const.d.ts.map +0 -1
  270. package/dist/v3/SourceCode/parseCode.d.ts +0 -27
  271. package/dist/v3/SourceCode/parseCode.d.ts.map +0 -1
  272. package/dist/v3/UploadList/UploadDetail.vue +0 -255
  273. package/dist/v3/UploadList/UploadItem.vue +0 -122
  274. package/dist/v3/UploadList/index.vue +0 -125
  275. package/dist/v3/VirtualListPro/index.vue +0 -229
  276. package/dist/v3/hooks/useContainerStyle.d.ts +0 -15
  277. package/dist/v3/hooks/useContainerStyle.d.ts.map +0 -1
  278. package/dist/v3/hooks/useNFC/index.d.ts +0 -5
  279. package/dist/v3/hooks/useNFC/index.d.ts.map +0 -1
  280. package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts +0 -2
  281. package/dist/v3/hooks/useNFC/useNFCAndroid.d.ts.map +0 -1
  282. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts +0 -2
  283. package/dist/v3/hooks/useNFC/useNFCMpWeiXin.d.ts.map +0 -1
  284. package/dist/v3/hooks/useNFC/utils.d.ts +0 -95
  285. package/dist/v3/hooks/useNFC/utils.d.ts.map +0 -1
  286. package/dist/v3/hooks/useRequest/index.d.ts +0 -126
  287. package/dist/v3/hooks/useRequest/index.d.ts.map +0 -1
  288. package/dist/v3/hooks/useRequest/utils.d.ts +0 -35
  289. package/dist/v3/hooks/useRequest/utils.d.ts.map +0 -1
  290. package/dist/v3/hooks/useScanCode/index.d.ts +0 -36
  291. package/dist/v3/hooks/useScanCode/index.d.ts.map +0 -1
  292. /package/dist/v3/{VirtualListPro → VirtualList}/readme.md +0 -0
@@ -1,154 +1,134 @@
1
1
  <template>
2
2
  <view class="network-send" :style="customStyle">
3
3
  <view class="network-send-control">
4
- <DevToolTitle>发起请求</DevToolTitle>
4
+ <DevToolTitle>{{ t('network.sendRequest') }}</DevToolTitle>
5
5
  <CircularButton style="margin-left: auto" text="×" @click="onClose" />
6
6
  </view>
7
7
  <scroll-view scroll-y class="network-send-form">
8
8
  <view class="network-send-control">
9
- <DevToolTitle>超时时间(ms)</DevToolTitle>
9
+ <DevToolTitle>{{ t('network.timeout') }}</DevToolTitle>
10
10
  </view>
11
11
  <input
12
12
  class="network-input"
13
13
  :value="state.timeout"
14
- @input="onChangeState($event, 'timeout')"
15
- />
14
+ @input="onChangeState($event, 'timeout')" />
16
15
  <view class="network-send-control">
17
- <DevToolTitle>请求方式</DevToolTitle>
16
+ <DevToolTitle>{{ t('network.requestMethod') }}</DevToolTitle>
18
17
  </view>
19
18
  <radio-group class="radio-group" @change="onChangeRequestMethod">
20
19
  <label
21
20
  class="radio-group-item"
22
21
  v-for="item in requestMethods"
23
- :key="item.value"
24
- >
22
+ :key="item.value">
25
23
  <radio
26
24
  size
27
25
  style="transform: scale(0.8)"
28
- color="#9254de"
26
+ :color="themeColor"
29
27
  :value="item.value"
30
- :checked="item.value === state.method"
31
- />
28
+ :checked="item.value === state.method" />
32
29
 
33
30
  <view>{{ item.name }}</view>
34
31
  </label>
35
32
  </radio-group>
36
33
  <view class="network-send-control">
37
- <DevToolTitle>请求头</DevToolTitle>
34
+ <DevToolTitle>{{ t('network.requestHeaders') }}</DevToolTitle>
38
35
  <CircularButton
39
36
  style="margin-left: auto"
40
37
  text="+"
41
- @click="onAddHeader"
42
- />
38
+ @click="onAddHeader" />
43
39
  </view>
44
40
 
45
41
  <view class="network-header-list">
46
42
  <checkbox-group
47
43
  v-if="headerList.length > 0"
48
- @change="onChangeHeaderChecked"
49
- >
44
+ @change="onChangeHeaderChecked">
50
45
  <view
51
46
  class="network-header-item"
52
47
  v-for="(item, index) in headerList"
53
- :key="item.id"
54
- >
48
+ :key="item.id">
55
49
  <checkbox color="#9254de" :checked="item.checked" />
56
50
  <input
57
51
  class="network-input"
58
- placeholder="请输入请求头名称"
59
- placeholderStyle="font-size: 12px"
52
+ :placeholder="t('network.placeholderHeaderName')"
60
53
  :value="item.key"
61
- @input="onChangeHeader($event, 'key', index)"
62
- />
54
+ @input="onChangeHeader($event, 'key', index)" />
63
55
  <input
64
56
  class="network-input"
65
- placeholder="请输入请求头值"
66
- placeholderStyle="font-size: 12px"
57
+ :placeholder="t('network.placeholderHeaderValue')"
67
58
  :value="item.value"
68
- @input="onChangeHeader($event, 'value', index)"
69
- />
59
+ @input="onChangeHeader($event, 'value', index)" />
70
60
  <CircularButton
71
61
  style="margin-left: 6px"
72
62
  text="一"
73
- @click="onDeleteHeader(item)"
74
- />
63
+ @click="onDeleteHeader(item)" />
75
64
  </view>
76
65
  </checkbox-group>
77
66
 
78
- <view class="network-empty" v-else> 暂无请求头 </view>
67
+ <view class="network-empty" v-else>
68
+ {{ t('network.noRequestHeaders') }}
69
+ </view>
79
70
  </view>
80
- <DevToolTitle>请求地址</DevToolTitle>
71
+ <DevToolTitle>{{ t('network.requestUrl') }}</DevToolTitle>
81
72
  <textarea
82
- placeholder="请输入请求地址"
83
- placeholderStyle="font-size: 12px"
73
+ :placeholder="t('network.placeholderUrl')"
84
74
  class="network-textarea"
85
75
  :value="state.url"
86
- @input="onChangeUrl"
87
- />
76
+ @input="onChangeUrl" />
88
77
  <view class="form-error-message">
89
- {{ hasUrl ? '' : '请输入请求地址' }}
78
+ {{ hasUrl ? '' : t('network.toastEnterUrl') }}
90
79
  </view>
91
80
 
92
81
  <view class="network-send-control">
93
- <DevToolTitle>请求参数(query)</DevToolTitle>
82
+ <DevToolTitle>{{ t('network.requestParams') }}</DevToolTitle>
94
83
  <CircularButton
95
84
  style="margin-left: auto"
96
85
  text="+"
97
- @click="onAddQuery"
98
- />
86
+ @click="onAddQuery" />
99
87
  </view>
100
88
  <view class="network-param-list">
101
89
  <checkbox-group
102
90
  v-if="queryList.length > 0"
103
- @change="onChangeQueryChecked"
104
- >
91
+ @change="handleQueryCheckedChange">
105
92
  <view
106
93
  class="network-param-item"
107
94
  v-for="(item, index) in queryList"
108
- :key="item.id"
109
- >
95
+ :key="item.id">
110
96
  <checkbox
111
- color="#9254de"
97
+ :color="themeColor"
112
98
  :checked="item.checked"
113
- :value="item.id"
114
- />
99
+ :value="item.id" />
115
100
  <input
116
101
  class="network-input"
117
- placeholder="请输入参数名称"
118
- placeholderStyle="font-size: 12px"
102
+ :placeholder="t('network.placeholderParamName')"
119
103
  :value="item.key"
120
- @input="onChangeQuery($event, 'key', index)"
121
- />
104
+ @input="onChangeQuery($event, 'key', index)" />
122
105
  <input
123
106
  class="network-input"
124
- placeholder="请输入参数值"
125
- placeholderStyle="font-size: 12px"
107
+ :placeholder="t('network.placeholderParamValue')"
126
108
  :value="item.value"
127
- @input="onChangeQuery($event, 'value', index)"
128
- />
109
+ @input="onChangeQuery($event, 'value', index)" />
129
110
  <CircularButton
130
111
  text="一"
131
112
  style="margin-left: 6px"
132
- @click="onDeleteQuery(item)"
133
- />
113
+ @click="onDeleteQuery(item)" />
134
114
  </view>
135
115
  </checkbox-group>
136
116
 
137
- <view class="network-empty" v-else> 暂无请求参数 </view>
117
+ <view class="network-empty" v-else>
118
+ {{ t('network.emptyParams') }}
119
+ </view>
138
120
  </view>
139
121
 
140
122
  <template v-if="!noBodyRequestMethods.includes(state.method)">
141
123
  <view class="network-send-control">
142
- <DevToolTitle>请求体(body)</DevToolTitle>
124
+ <DevToolTitle>{{ t('network.requestBody') }}</DevToolTitle>
143
125
  </view>
144
126
 
145
127
  <textarea
146
- placeholder="请输入请求体"
128
+ :placeholder="t('network.placeholderBody')"
147
129
  class="network-textarea"
148
- placeholderStyle="font-size: 12px"
149
130
  :value="state.bodyText"
150
- @input="onChangeState($event, 'bodyText')"
151
- />
131
+ @input="onChangeState($event, 'bodyText')" />
152
132
  </template>
153
133
  </scroll-view>
154
134
  <view class="network-send-buttons">
@@ -156,26 +136,30 @@
156
136
  size="mini"
157
137
  :disabled="!isFinished"
158
138
  class="network-send-button"
159
- @click="emit('openDetail', network)"
160
- >
161
- 详情
139
+ @click="emit('openDetail', currentNetwork)">
140
+ {{ t('network.detail') }}
162
141
  </button>
163
142
  <button size="mini" class="network-send-button" @click="onReset">
164
- 重置
143
+ {{ t('network.reset') }}
165
144
  </button>
166
145
  <button size="mini" class="network-send-button-last" @click="onSend">
167
- 发送
146
+ {{ t('network.send') }}
168
147
  </button>
169
148
  </view>
170
149
  </view>
171
150
  </template>
172
151
  <script lang="ts" setup>
173
- import { ref, reactive, onMounted } from 'vue';
152
+ import { computed, ref, reactive, onMounted } from 'vue';
174
153
  import CircularButton from '../CircularButton/index.vue';
175
154
  import DevToolTitle from '../DevToolTitle/index.vue';
176
155
  import type { DevTool } from '../../type';
156
+ import { useI18n } from '../../i18n';
157
+ import { getThemeMainColor } from '../styles/theme';
158
+ const { t } = useI18n();
159
+ const themeColor = computed(() => getThemeMainColor(props.theme));
177
160
 
178
161
  const props = defineProps<{
162
+ theme?: string;
179
163
  network: DevTool.NetworkItem;
180
164
  zIndex?: number;
181
165
  interceptNetworkList?: DevTool.NetworkItem[];
@@ -187,67 +171,43 @@ const emit = defineEmits<{
187
171
  (e: 'openDetail', v: DevTool.NetworkItem): void;
188
172
  }>();
189
173
 
190
- const requestMethods = [
191
- { name: 'GET', value: 'GET' },
192
- { name: 'POST', value: 'POST' },
193
- { name: 'PUT', value: 'PUT' },
194
- { name: 'DELETE', value: 'DELETE' },
195
- { name: 'PATCH', value: 'PATCH' },
196
- { name: 'OPTIONS', value: 'OPTIONS' },
197
- { name: 'HEAD', value: 'HEAD' },
198
- ];
199
-
200
- const hasUrl = ref(true);
201
-
202
- const state = reactive<{
203
- method: any;
204
- url: string;
205
- bodyText: string;
206
- timeout: number;
207
- }>({
208
- method: 'GET',
209
- url: 'http://192.168.0.1:8080/a?a=123',
210
- bodyText: '',
211
- timeout: 3 * 1000,
212
- });
213
-
214
- const defaultHeader = [
215
- {
216
- id: '1',
217
- key: 'Accept',
218
- value: '*/*',
219
- checked: false,
220
- },
221
- {
222
- id: '2',
223
- key: 'Accept-Language',
224
- value: 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
225
- checked: false,
226
- },
227
- {
228
- id: '3',
229
- key: 'Cache-Control',
230
- value: 'no-cache',
231
- checked: false,
232
- },
233
- {
234
- id: '4',
235
- key: 'Content-Type',
236
- value: 'application/json; charset=utf-8',
237
- checked: true,
238
- },
239
- ];
240
-
241
- type PB = {
242
- id: string;
243
- key: string;
244
- value: string;
245
- checked: boolean;
246
- };
247
-
248
- const headerList = reactive([...defaultHeader]);
174
+ import {
175
+ requestMethods,
176
+ noBodyRequestMethods,
177
+ defaultHeader,
178
+ arrayToObject,
179
+ objectToArray,
180
+ arrayToUrlParams,
181
+ urlParamsToObject,
182
+ unionArrayByKey,
183
+ } from './utils';
184
+ import { useKeyValueList, useNetworkState } from './hooks/useNetworkForm';
185
+
186
+ const { state, hasUrl, onChangeState, parseUrlToList, parseListToUrl } =
187
+ useNetworkState({
188
+ method: 'GET',
189
+ url: 'http://192.168.0.1:8080/a?a=123',
190
+ bodyText: '',
191
+ timeout: 3 * 1000,
192
+ });
249
193
 
250
- const queryList = reactive<PB[]>([
194
+ const {
195
+ list: headerList,
196
+ onAdd: onAddHeader,
197
+ onDelete: onDeleteHeader,
198
+ onChangeChecked: onChangeHeaderChecked,
199
+ onChangeValue: onChangeHeaderItem,
200
+ setList: setHeaderList,
201
+ } = useKeyValueList(defaultHeader);
202
+
203
+ const {
204
+ list: queryList,
205
+ onAdd: onAddQuery,
206
+ onDelete: onDeleteQuery,
207
+ onChangeChecked: onChangeQueryChecked,
208
+ onChangeValue: onChangeQueryItem,
209
+ setList: setQueryList,
210
+ } = useKeyValueList([
251
211
  {
252
212
  id: '1',
253
213
  key: 'a',
@@ -258,7 +218,7 @@ const queryList = reactive<PB[]>([
258
218
 
259
219
  const isFinished = ref(false);
260
220
 
261
- const network = reactive<DevTool.NetworkItem>({
221
+ const currentNetwork = reactive<DevTool.NetworkItem>({
262
222
  index: 0,
263
223
  url: '',
264
224
  name: '',
@@ -284,39 +244,15 @@ const network = reactive<DevTool.NetworkItem>({
284
244
  sponsor: 'dev_tool',
285
245
  });
286
246
 
287
- const noBodyRequestMethods = ['GET', 'HEAD', 'PATCH', 'OPTIONS'];
288
-
289
- function onChangeState(e: any, key: keyof typeof state) {
290
- state[key] = e.detail.value as never;
291
- }
292
-
293
- function parseUrlToList(url: string) {
294
- if (url.includes('?')) {
295
- const query = url.split('?')[1];
296
- const queryObject = urlParamsToObject(query);
297
- const list = objectToArray(queryObject);
298
-
299
- return list;
300
- }
301
- return [];
302
- }
303
-
304
- function parseListToUrl(list: PB[]) {
305
- const baseUrl = state.url.split('?')[0] || '';
306
- if (list.length === 0) {
307
- return baseUrl;
308
- } else {
309
- return (
310
- baseUrl + '?' + arrayToUrlParams(queryList?.filter((q) => q.checked))
311
- );
312
- }
247
+ function onChangeHeader(e: any, key: 'key' | 'value', index: number) {
248
+ onChangeHeaderItem(index, key, e.detail.value);
313
249
  }
314
250
 
315
251
  function onChangeUrl(e: any) {
316
252
  const url = e.detail.value;
317
253
  state.url = url;
318
254
  const list = parseUrlToList(url);
319
- queryList.splice(0, queryList.length, ...list);
255
+ setQueryList(list);
320
256
  }
321
257
 
322
258
  function onReset() {
@@ -325,8 +261,8 @@ function onReset() {
325
261
  state.method = 'GET';
326
262
  state.url = '';
327
263
  state.bodyText = '';
328
- headerList.splice(0, headerList.length, ...defaultHeader);
329
- queryList.splice(0, queryList.length);
264
+ setHeaderList(defaultHeader);
265
+ setQueryList([]);
330
266
  }
331
267
 
332
268
  function onClose() {
@@ -338,7 +274,7 @@ function onSend() {
338
274
  if (!state.url) {
339
275
  hasUrl.value = false;
340
276
  uni.showToast({
341
- title: '请输入请求地址',
277
+ title: t('network.toastEnterUrl'),
342
278
  icon: 'none',
343
279
  });
344
280
  return;
@@ -346,7 +282,7 @@ function onSend() {
346
282
  hasUrl.value = true;
347
283
 
348
284
  const header = arrayToObject(headerList);
349
- const query = arrayToUrlParams(queryList);
285
+ const query = arrayToUrlParams(queryList.filter((q) => q.checked));
350
286
 
351
287
  const requestOptions: UniNamespace.RequestOptions = {
352
288
  url: state.url,
@@ -362,7 +298,7 @@ function onSend() {
362
298
  if (noBodyRequestMethods.includes(state.method)) {
363
299
  // 不支持携带 body 参数
364
300
  requestOptions.data = {};
365
- state.url = parseListToUrl(queryList);
301
+ state.url = parseListToUrl(state.url, queryList);
366
302
  } else {
367
303
  // 支持 url 中携带参数
368
304
 
@@ -377,9 +313,9 @@ function onSend() {
377
313
  try {
378
314
  const bodyJson = JSON.parse(state.bodyText);
379
315
  requestOptions.data = bodyJson;
380
- } catch (error) {
316
+ } catch (_error) {
381
317
  uni.showToast({
382
- title: '请求体请输入正确的JSON格式',
318
+ title: t('network.toastBodyJson'),
383
319
  icon: 'none',
384
320
  });
385
321
  return;
@@ -390,7 +326,7 @@ function onSend() {
390
326
  isFinished.value = false;
391
327
 
392
328
  uni.showLoading({
393
- title: '发送中...',
329
+ title: t('network.sending'),
394
330
  mask: true,
395
331
  });
396
332
 
@@ -398,35 +334,36 @@ function onSend() {
398
334
  const lastSlashIndex = baseUrl.lastIndexOf('/');
399
335
  const name = lastSlashIndex !== -1 ? baseUrl.slice(lastSlashIndex + 1) : '';
400
336
 
401
- network.startTime = Date.now();
337
+ currentNetwork.startTime = Date.now();
402
338
 
403
339
  uni.request({
404
340
  ...requestOptions,
405
341
  complete: (res: any) => {
406
342
  // 赋值结果
407
- network.url = requestOptions.url;
408
- network.name = name;
409
- network.method = requestOptions.method as string;
410
- network.payload = requestOptions.data
343
+ currentNetwork.url = requestOptions.url;
344
+ currentNetwork.name = name;
345
+ currentNetwork.method = requestOptions.method as string;
346
+ currentNetwork.payload = requestOptions.data
411
347
  ? JSON.stringify(requestOptions.data)
412
348
  : '';
413
- network.endTime = Date.now();
414
- network.status = res.statusCode ?? 'error';
415
- const diff = network.endTime - network.startTime;
416
- network.time = diff < 1000 ? diff + 'ms' : diff / 1000 + 's';
349
+ currentNetwork.endTime = Date.now();
350
+ currentNetwork.status = res.statusCode ?? 'error';
351
+ const diff = currentNetwork.endTime - currentNetwork.startTime;
352
+ currentNetwork.time = diff < 1000 ? diff + 'ms' : diff / 1000 + 's';
417
353
  const len =
418
354
  res?.header?.['Content-Length'] || res?.header?.['content-length'] || 0;
419
- network.size = len > 1024 ? (len / 1024).toFixed(2) + 'k' : len + 'b';
420
- network.response = res;
421
- network.headers.requestHeader = objectToArray(
355
+ currentNetwork.size =
356
+ len > 1024 ? (len / 1024).toFixed(2) + 'k' : len + 'b';
357
+ currentNetwork.response = res;
358
+ currentNetwork.headers.requestHeader = objectToArray(
422
359
  requestOptions?.header ?? {},
423
360
  );
424
- network.headers.responseHeader = objectToArray(res.header ?? {});
361
+ currentNetwork.headers.responseHeader = objectToArray(res.header ?? {});
425
362
 
426
- network.intercepted =
363
+ currentNetwork.intercepted =
427
364
  props.interceptNetworkList?.some((item) => {
428
365
  const key = `${item.method?.toUpperCase()}|${item.url?.split('?')[0]}`;
429
- const curKey = `${network.method?.toUpperCase()}|${network.url?.split('?')[0]}`;
366
+ const curKey = `${currentNetwork.method?.toUpperCase()}|${currentNetwork.url?.split('?')[0]}`;
430
367
  return key === curKey;
431
368
  }) ?? false;
432
369
 
@@ -434,7 +371,7 @@ function onSend() {
434
371
  uni.hideLoading();
435
372
  isFinished.value = true;
436
373
  uni.showToast({
437
- title: '请求完成,点击左下角详情进行查看结果',
374
+ title: t('network.toastRequestSuccess'),
438
375
  icon: 'none',
439
376
  });
440
377
  },
@@ -446,114 +383,14 @@ function onChangeRequestMethod(e: any) {
446
383
  state.method = method;
447
384
  }
448
385
 
449
- function onDeleteHeader(item: any) {
450
- const index = headerList.findIndex((i) => i.id === item.id);
451
- headerList.splice(index, 1);
452
- }
453
-
454
- function onAddHeader() {
455
- const id = Date.now().toString();
456
- headerList.push({
457
- id,
458
- key: '',
459
- value: '',
460
- checked: false,
461
- });
462
- }
463
-
464
- function onChangeHeaderChecked(e: any) {
465
- const list = e.detail?.value ?? [];
466
- headerList.forEach((q) => {
467
- q.checked = list?.includes(q.id);
468
- });
469
- }
470
-
471
- function onChangeHeader(e: any, key: 'key' | 'value', index: number) {
472
- headerList[index][key] = e.detail.value;
473
- }
474
-
475
- function onDeleteQuery(item: any) {
476
- const index = queryList.findIndex((i) => i.id === item.id);
477
- queryList.splice(index, 1);
478
- }
479
- function onAddQuery() {
480
- const id = Date.now().toString();
481
- queryList.push({
482
- id,
483
- key: '',
484
- value: '',
485
- checked: false,
486
- });
487
- }
488
- function onChangeQueryChecked(e: any) {
489
- const list = e.detail?.value ?? [];
490
- queryList.forEach((q) => {
491
- q.checked = list?.includes(q.id);
492
- });
493
-
494
- state.url = parseListToUrl(queryList);
495
- }
496
-
497
386
  function onChangeQuery(e: any, key: 'key' | 'value', index: number) {
498
- queryList[index][key] = e.detail.value;
499
-
500
- state.url = parseListToUrl(queryList);
387
+ onChangeQueryItem(index, key, e.detail.value);
388
+ state.url = parseListToUrl(state.url, queryList);
501
389
  }
502
390
 
503
- function arrayToObject(arr: any[]) {
504
- return arr.reduce((acc, cur) => {
505
- if (cur.checked) {
506
- acc[cur.key] = cur.value;
507
- }
508
- return acc;
509
- }, {});
510
- }
511
-
512
- function objectToArray<T extends Record<string, any>>(obj: T) {
513
- return Object.entries(obj).map(([key, value]) => ({
514
- id: Date.now().toString(),
515
- key,
516
- value,
517
- checked: true,
518
- }));
519
- }
520
-
521
- function objectToUrlParams(obj: any) {
522
- return Object.keys(obj)
523
- .map((key) => `${key}=${encodeURIComponent(obj[key])}`)
524
- .join('&');
525
- }
526
-
527
- function arrayToUrlParams(arr: any[]) {
528
- return arr
529
- .map((item) => `${item.key}=${encodeURIComponent(item.value)}`)
530
- ?.join('&');
531
- }
532
-
533
- function unionArrayByKey<T>(arr1: T[], arr2: T[], key: keyof T): T[] {
534
- const map = new Map();
535
- arr1.forEach((item) => {
536
- map.set(item?.[key], item);
537
- });
538
- arr2.forEach((item) => {
539
- if (map.has(item?.[key])) {
540
- map.set(item?.[key], { ...map.get(item?.[key]), ...item });
541
- } else {
542
- map.set(item?.[key], item);
543
- }
544
- });
545
- return Array.from(map.values());
546
- }
547
-
548
- function urlParamsToObject(urlParams: string) {
549
- return urlParams.split('&').reduce(
550
- (acc, cur) => {
551
- const [key, value] = cur.split('=');
552
- acc[key] = value;
553
- return acc;
554
- },
555
- {} as Record<string, any>,
556
- );
391
+ function handleQueryCheckedChange(e: any) {
392
+ onChangeQueryChecked(e);
393
+ state.url = parseListToUrl(state.url, queryList);
557
394
  }
558
395
 
559
396
  /**
@@ -577,9 +414,9 @@ function handleResendNetwork() {
577
414
  };
578
415
  }) ?? [];
579
416
 
580
- headerList.splice(0, headerList.length, ...requestHeaders);
417
+ setHeaderList(requestHeaders);
581
418
 
582
- queryList.splice(0, queryList.length);
419
+ setQueryList([]);
583
420
 
584
421
  // 解析参数
585
422
  if (noBodyRequestMethods.includes(state.method)) {
@@ -592,7 +429,7 @@ function handleResendNetwork() {
592
429
 
593
430
  const list = unionArrayByKey(urlParams, payloadParams, 'key');
594
431
 
595
- queryList.splice(0, queryList.length, ...list);
432
+ setQueryList(list);
596
433
  }
597
434
  } else {
598
435
  // 参数在 query 中
@@ -600,7 +437,7 @@ function handleResendNetwork() {
600
437
  const urlParams = objectToArray(
601
438
  urlParamsToObject(props.network.url.split('?')?.[1] ?? ''),
602
439
  );
603
- queryList.splice(0, queryList.length, ...urlParams);
440
+ setQueryList(urlParams);
604
441
  }
605
442
  state.bodyText = JSON.stringify(props.network.payload);
606
443
  }
@@ -620,14 +457,16 @@ onMounted(() => {
620
457
  top: 0;
621
458
  left: 0;
622
459
  padding: 0 16px;
460
+
623
461
  /* #ifdef H5 || APP-PLUS */
624
462
  padding: 50px 16px;
463
+
625
464
  /* #endif */
626
465
  overflow: auto;
627
-
628
466
  background-color: var(--dev-tool-bg3-color);
629
467
  box-sizing: border-box;
630
468
  }
469
+
631
470
  .network-send-form {
632
471
  height: calc(100% - 32px - 42px);
633
472
  overflow: auto;
@@ -652,15 +491,14 @@ onMounted(() => {
652
491
  align-items: center;
653
492
  width: 25%;
654
493
  margin-bottom: 6px;
655
- font-size: 12px;
656
494
  }
657
495
 
658
496
  .network-input {
659
497
  padding: 0 6px;
660
498
  height: 24px;
661
- font-size: 12px;
662
499
  border: 1px solid var(--dev-tool-border-color);
663
500
  }
501
+
664
502
  .network-textarea {
665
503
  padding: 6px;
666
504
  width: 100%;
@@ -668,6 +506,7 @@ onMounted(() => {
668
506
  font-size: 12px;
669
507
  border: 1px solid var(--dev-tool-border-color);
670
508
  }
509
+
671
510
  .form-error-message {
672
511
  padding: 0 6px;
673
512
  height: 24px;
@@ -699,15 +538,18 @@ onMounted(() => {
699
538
  position: sticky;
700
539
  display: flex;
701
540
  justify-content: space-between;
541
+
702
542
  /* gap: 6px; */
703
543
  width: 100%;
704
544
  margin-top: 12px;
705
545
  background-color: var(--dev-tool-bg3-color);
706
546
  }
547
+
707
548
  .network-send-button {
708
549
  width: 100%;
709
550
  margin-right: 6px;
710
551
  }
552
+
711
553
  .network-send-button-last {
712
554
  width: 100%;
713
555
  }