oxy-uni-ui 2.1.0 → 2.1.2

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 (269) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +145 -100
  3. package/components/common/util.ts +25 -0
  4. package/components/composables/useDynamicVirtualScroll.ts +80 -0
  5. package/components/oxy-action-sheet/index.scss +6 -6
  6. package/components/oxy-backtop/index.scss +1 -1
  7. package/components/oxy-badge/index.scss +2 -2
  8. package/components/oxy-button/index.scss +3 -6
  9. package/components/oxy-calendar/index.scss +2 -2
  10. package/components/oxy-calendar/oxy-calendar.vue +3 -3
  11. package/components/oxy-calendar-view/monthPanel/month-panel.vue +72 -37
  12. package/components/oxy-calendar-view/monthPanel/types.ts +43 -1
  13. package/components/oxy-calendar-view/types.ts +1 -1
  14. package/components/oxy-calendar-view/utils.ts +12 -1
  15. package/components/oxy-calendar-view/yearPanel/types.ts +36 -2
  16. package/components/oxy-calendar-view/yearPanel/year-panel.vue +64 -45
  17. package/components/oxy-card/index.scss +4 -4
  18. package/components/oxy-cell/index.scss +1 -1
  19. package/components/oxy-cell-group/index.scss +2 -2
  20. package/components/oxy-checkbox/index.scss +87 -197
  21. package/components/oxy-collapse/index.scss +1 -1
  22. package/components/oxy-collapse-item/index.scss +2 -2
  23. package/components/oxy-corner/index.scss +3 -3
  24. package/components/oxy-count-to/oxy-count-to.vue +3 -3
  25. package/components/oxy-count-to/types.ts +1 -1
  26. package/components/oxy-date-strip-item/index.scss +4 -4
  27. package/components/oxy-datetime-picker/types.ts +1 -1
  28. package/components/oxy-datetime-picker-view/types.ts +2 -2
  29. package/components/oxy-fab/index.scss +1 -5
  30. package/components/oxy-file-list/index.scss +2 -2
  31. package/components/oxy-footer/index.scss +2 -2
  32. package/components/oxy-footer/oxy-footer.vue +2 -3
  33. package/components/oxy-form-item/index.scss +0 -5
  34. package/components/oxy-grid/oxy-grid.vue +1 -1
  35. package/components/oxy-grid-item/index.scss +1 -1
  36. package/components/oxy-guidance/index.scss +2 -2
  37. package/components/oxy-img/index.scss +2 -2
  38. package/components/oxy-img-cropper/index.scss +0 -2
  39. package/components/oxy-img-lazy/index.scss +0 -1
  40. package/components/oxy-index-anchor/index.scss +3 -3
  41. package/components/oxy-input/index.scss +2 -2
  42. package/components/oxy-input-number/index.scss +21 -3
  43. package/components/oxy-input-number/oxy-input-number.vue +9 -1
  44. package/components/oxy-keyboard/index.scss +1 -1
  45. package/components/oxy-link/index.scss +11 -10
  46. package/components/oxy-loading/index.scss +1 -1
  47. package/components/oxy-loadmore/index.scss +1 -1
  48. package/components/oxy-message-box/index.scss +7 -7
  49. package/components/oxy-navbar/index.scss +1 -1
  50. package/components/oxy-navbar/oxy-navbar.vue +2 -3
  51. package/components/oxy-password-input/index.scss +4 -4
  52. package/components/oxy-picker/types.ts +1 -1
  53. package/components/oxy-picker-view/oxy-picker-view.vue +8 -5
  54. package/components/oxy-picker-view/types.ts +2 -2
  55. package/components/oxy-progress/index.scss +2 -2
  56. package/components/oxy-radio/index.scss +8 -4
  57. package/components/oxy-radio-group/index.scss +0 -1
  58. package/components/oxy-rich-text/index.scss +2 -6
  59. package/components/oxy-rich-text/mp-html/mp-html.d.ts +2 -0
  60. package/components/oxy-rich-text/mp-html/mp-html.vue +2 -1
  61. package/components/oxy-rich-text/mp-html/node/node.vue +23 -0
  62. package/components/oxy-rich-text/mp-html/parser.js +6 -6
  63. package/components/oxy-rich-text/oxy-rich-text.vue +23 -0
  64. package/components/oxy-search/index.scss +1 -1
  65. package/components/oxy-segmented/index.scss +4 -8
  66. package/components/oxy-select/index.scss +6 -6
  67. package/components/oxy-sidebar-item/index.scss +20 -11
  68. package/components/oxy-slider/index.scss +4 -5
  69. package/components/oxy-sort-button/index.scss +6 -9
  70. package/components/oxy-splitter-panel/index.scss +8 -8
  71. package/components/oxy-step/index.scss +9 -9
  72. package/components/oxy-swiper-nav/index.scss +2 -2
  73. package/components/oxy-switch/index.scss +3 -3
  74. package/components/oxy-tab/index.scss +8 -2
  75. package/components/oxy-tabbar/index.scss +3 -3
  76. package/components/oxy-tabbar/oxy-tabbar.vue +3 -3
  77. package/components/oxy-table/index.scss +0 -1
  78. package/components/oxy-table-col/index.scss +1 -2
  79. package/components/oxy-tabs/index.scss +3 -3
  80. package/components/oxy-tag/index.scss +160 -20
  81. package/components/oxy-tag/oxy-tag.vue +14 -2
  82. package/components/oxy-tag/types.ts +9 -0
  83. package/components/oxy-text/index.scss +1 -1
  84. package/components/oxy-textarea/index.scss +2 -6
  85. package/components/oxy-toast/index.scss +1 -1
  86. package/components/oxy-tree/index.scss +31 -11
  87. package/components/oxy-tree/oxy-tree.vue +113 -2
  88. package/components/oxy-tree/types.ts +1 -0
  89. package/components/oxy-upload/index.scss +3 -3
  90. package/components/oxy-video-preview/index.scss +3 -3
  91. package/components/oxy-virtual-scroll/index.scss +1 -1
  92. package/components/oxy-voice-player/index.scss +36 -36
  93. package/components/oxy-watermark/index.scss +1 -1
  94. package/dev-tools.ts +2 -0
  95. package/devTools/components/DevToolsOverlay.vue +56 -0
  96. package/devTools/components/DevToolsUiHost.vue +589 -0
  97. package/devTools/config.js +55 -0
  98. package/devTools/core/components/mpDevBubble.vue +174 -0
  99. package/devTools/core/libs/createH5Bubble.js +156 -0
  100. package/devTools/core/libs/devCache.js +151 -0
  101. package/devTools/core/libs/devOptions.js +163 -0
  102. package/devTools/core/libs/devUi.js +219 -0
  103. package/devTools/core/libs/drawView.js +140 -0
  104. package/devTools/core/libs/errorReport.js +64 -0
  105. package/devTools/core/libs/jsonCompress.js +334 -0
  106. package/devTools/core/libs/logReport.js +59 -0
  107. package/devTools/core/libs/pageLinkList.js +125 -0
  108. package/devTools/core/libs/timeFormat.js +94 -0
  109. package/devTools/core/proxy/console.js +430 -0
  110. package/devTools/core/proxy/index.js +36 -0
  111. package/devTools/core/proxy/request.js +495 -0
  112. package/devTools/core/proxy/storage.js +113 -0
  113. package/devTools/core/proxy/uniBus.js +153 -0
  114. package/devTools/core/proxy/uniListen.js +192 -0
  115. package/devTools/core/proxy/vueMixin.js +120 -0
  116. package/devTools/index.js +168 -0
  117. package/devTools/page/components/bottomTools.vue +1046 -0
  118. package/devTools/page/components/dialog/addStorage.vue +204 -0
  119. package/devTools/page/components/dialog/createDir.vue +366 -0
  120. package/devTools/page/components/dialog/editDialog.vue +192 -0
  121. package/devTools/page/components/dialog/routeDialog.vue +184 -0
  122. package/devTools/page/components/dialog/sendRequest.vue +603 -0
  123. package/devTools/page/components/dialog/textFileEditDialog.vue +391 -0
  124. package/devTools/page/components/libs/appDelDir.js +86 -0
  125. package/devTools/page/components/libs/dirReader.js +248 -0
  126. package/devTools/page/components/libs/fileSize.js +15 -0
  127. package/devTools/page/components/libs/getRuntimeInfo.js +134 -0
  128. package/devTools/page/components/listItem/consoleItem.vue +314 -0
  129. package/devTools/page/components/listItem/errorItem.vue +292 -0
  130. package/devTools/page/components/listItem/fileSysItem.vue +533 -0
  131. package/devTools/page/components/listItem/infoList.vue +100 -0
  132. package/devTools/page/components/listItem/jsRunnerItem.vue +255 -0
  133. package/devTools/page/components/listItem/logItem.vue +193 -0
  134. package/devTools/page/components/listItem/networkItem.vue +398 -0
  135. package/devTools/page/components/listItem/objectAnalysis.vue +651 -0
  136. package/devTools/page/components/listItem/pages.vue +319 -0
  137. package/devTools/page/components/listItem/routeItem.vue +153 -0
  138. package/devTools/page/components/listItem/setting.vue +734 -0
  139. package/devTools/page/components/listItem/storageList.vue +681 -0
  140. package/devTools/page/components/listItem/tools.vue +315 -0
  141. package/devTools/page/components/listItem/vuexList.vue +599 -0
  142. package/devTools/page/components/main.vue +1867 -0
  143. package/devTools/page/components/mixins/animationControl.js +91 -0
  144. package/devTools/page/components/mixins/mp.js +83 -0
  145. package/devTools/page/components/ui/btnTabs.vue +90 -0
  146. package/devTools/page/components/ui/codeHisPicker.vue +172 -0
  147. package/devTools/page/components/ui/h5Cell.vue +13 -0
  148. package/devTools/page/components/ui/menuBtn.vue +94 -0
  149. package/devTools/page/components/ui/mobileSwiperScroll.vue +74 -0
  150. package/devTools/page/components/ui/requestSpeedLimit.vue +52 -0
  151. package/devTools/page/components/ui/requestTimeoutMock.vue +55 -0
  152. package/devTools/page/components/ui/subTitleBar.vue +101 -0
  153. package/devTools/page/static/copy.png +0 -0
  154. package/devTools/page/static/delete.png +0 -0
  155. package/devTools/page/static/fileSys/AI.png +0 -0
  156. package/devTools/page/static/fileSys/DWG.png +0 -0
  157. package/devTools/page/static/fileSys/EXE.png +0 -0
  158. package/devTools/page/static/fileSys/GIF.png +0 -0
  159. package/devTools/page/static/fileSys/HTML.png +0 -0
  160. package/devTools/page/static/fileSys/PSD.png +0 -0
  161. package/devTools/page/static/fileSys/RVT.png +0 -0
  162. package/devTools/page/static/fileSys/SKP.png +0 -0
  163. package/devTools/page/static/fileSys/SVG.png +0 -0
  164. package/devTools/page/static/fileSys/excel.png +0 -0
  165. package/devTools/page/static/fileSys/pdf.png +0 -0
  166. package/devTools/page/static/fileSys/pptl.png +0 -0
  167. package/devTools/page/static/fileSys/shipin.png +0 -0
  168. package/devTools/page/static/fileSys/tupian.png +0 -0
  169. package/devTools/page/static/fileSys/txt.png +0 -0
  170. package/devTools/page/static/fileSys/weizhiwenjian.png +0 -0
  171. package/devTools/page/static/fileSys/wenjianjia.png +0 -0
  172. package/devTools/page/static/fileSys/word.png +0 -0
  173. package/devTools/page/static/fileSys/yasuo.png +0 -0
  174. package/devTools/page/static/fileSys/yinpin.png +0 -0
  175. package/devTools/page/static/fold.png +0 -0
  176. package/devTools/page/static/menu.png +0 -0
  177. package/devTools/page/static/refresh.png +0 -0
  178. package/devTools/page/static/unfold.png +0 -0
  179. package/devTools/tools.vue +25 -0
  180. package/devTools/type/devTools.d.ts +406 -0
  181. package/oxy-dev-tools/components/DevToolsUiHost.vue +555 -0
  182. package/oxy-dev-tools/config.js +61 -0
  183. package/oxy-dev-tools/core/components/mpDevBubble.vue +176 -0
  184. package/oxy-dev-tools/core/libs/createH5Bubble.js +156 -0
  185. package/oxy-dev-tools/core/libs/devCache.js +149 -0
  186. package/oxy-dev-tools/core/libs/devOptions.js +160 -0
  187. package/oxy-dev-tools/core/libs/devUi.js +219 -0
  188. package/oxy-dev-tools/core/libs/drawView.js +144 -0
  189. package/oxy-dev-tools/core/libs/errorReport.js +60 -0
  190. package/oxy-dev-tools/core/libs/jsonCompress.js +328 -0
  191. package/oxy-dev-tools/core/libs/logReport.js +55 -0
  192. package/oxy-dev-tools/core/libs/pageLinkList.js +121 -0
  193. package/oxy-dev-tools/core/libs/timeFormat.js +93 -0
  194. package/oxy-dev-tools/core/proxy/console.js +398 -0
  195. package/oxy-dev-tools/core/proxy/index.js +33 -0
  196. package/oxy-dev-tools/core/proxy/request.js +473 -0
  197. package/oxy-dev-tools/core/proxy/storage.js +96 -0
  198. package/oxy-dev-tools/core/proxy/uniBus.js +148 -0
  199. package/oxy-dev-tools/core/proxy/uniListen.js +190 -0
  200. package/oxy-dev-tools/core/proxy/vueMixin.js +115 -0
  201. package/oxy-dev-tools/index.ts +183 -0
  202. package/oxy-dev-tools/oxy-dev-tools.vue +62 -0
  203. package/oxy-dev-tools/page/components/bottomTools.vue +933 -0
  204. package/oxy-dev-tools/page/components/dialog/addStorage.vue +184 -0
  205. package/oxy-dev-tools/page/components/dialog/createDir.vue +352 -0
  206. package/oxy-dev-tools/page/components/dialog/editDialog.vue +178 -0
  207. package/oxy-dev-tools/page/components/dialog/routeDialog.vue +170 -0
  208. package/oxy-dev-tools/page/components/dialog/sendRequest.vue +530 -0
  209. package/oxy-dev-tools/page/components/dialog/textFileEditDialog.vue +379 -0
  210. package/oxy-dev-tools/page/components/libs/appDelDir.js +77 -0
  211. package/oxy-dev-tools/page/components/libs/dirReader.js +239 -0
  212. package/oxy-dev-tools/page/components/libs/fileSize.js +15 -0
  213. package/oxy-dev-tools/page/components/libs/getRuntimeInfo.js +132 -0
  214. package/oxy-dev-tools/page/components/listItem/consoleItem.vue +292 -0
  215. package/oxy-dev-tools/page/components/listItem/errorItem.vue +268 -0
  216. package/oxy-dev-tools/page/components/listItem/fileSysItem.vue +511 -0
  217. package/oxy-dev-tools/page/components/listItem/infoList.vue +89 -0
  218. package/oxy-dev-tools/page/components/listItem/jsRunnerItem.vue +236 -0
  219. package/oxy-dev-tools/page/components/listItem/logItem.vue +185 -0
  220. package/oxy-dev-tools/page/components/listItem/networkItem.vue +362 -0
  221. package/oxy-dev-tools/page/components/listItem/objectAnalysis.vue +642 -0
  222. package/oxy-dev-tools/page/components/listItem/pages.vue +285 -0
  223. package/oxy-dev-tools/page/components/listItem/routeItem.vue +140 -0
  224. package/oxy-dev-tools/page/components/listItem/setting.vue +687 -0
  225. package/oxy-dev-tools/page/components/listItem/storageList.vue +623 -0
  226. package/oxy-dev-tools/page/components/listItem/tools.vue +273 -0
  227. package/oxy-dev-tools/page/components/listItem/vuexList.vue +559 -0
  228. package/oxy-dev-tools/page/components/main.vue +1824 -0
  229. package/oxy-dev-tools/page/components/mixins/animationControl.js +80 -0
  230. package/oxy-dev-tools/page/components/mixins/mp.js +76 -0
  231. package/oxy-dev-tools/page/components/ui/btnTabs.vue +77 -0
  232. package/oxy-dev-tools/page/components/ui/codeHisPicker.vue +161 -0
  233. package/oxy-dev-tools/page/components/ui/h5Cell.vue +13 -0
  234. package/oxy-dev-tools/page/components/ui/menuBtn.vue +87 -0
  235. package/oxy-dev-tools/page/components/ui/mobileSwiperScroll.vue +71 -0
  236. package/oxy-dev-tools/page/components/ui/requestSpeedLimit.vue +47 -0
  237. package/oxy-dev-tools/page/components/ui/requestTimeoutMock.vue +50 -0
  238. package/oxy-dev-tools/page/components/ui/subTitleBar.vue +87 -0
  239. package/oxy-dev-tools/page/static/copy.png +0 -0
  240. package/oxy-dev-tools/page/static/delete.png +0 -0
  241. package/oxy-dev-tools/page/static/fileSys/AI.png +0 -0
  242. package/oxy-dev-tools/page/static/fileSys/DWG.png +0 -0
  243. package/oxy-dev-tools/page/static/fileSys/EXE.png +0 -0
  244. package/oxy-dev-tools/page/static/fileSys/GIF.png +0 -0
  245. package/oxy-dev-tools/page/static/fileSys/HTML.png +0 -0
  246. package/oxy-dev-tools/page/static/fileSys/PSD.png +0 -0
  247. package/oxy-dev-tools/page/static/fileSys/RVT.png +0 -0
  248. package/oxy-dev-tools/page/static/fileSys/SKP.png +0 -0
  249. package/oxy-dev-tools/page/static/fileSys/SVG.png +0 -0
  250. package/oxy-dev-tools/page/static/fileSys/excel.png +0 -0
  251. package/oxy-dev-tools/page/static/fileSys/pdf.png +0 -0
  252. package/oxy-dev-tools/page/static/fileSys/pptl.png +0 -0
  253. package/oxy-dev-tools/page/static/fileSys/shipin.png +0 -0
  254. package/oxy-dev-tools/page/static/fileSys/tupian.png +0 -0
  255. package/oxy-dev-tools/page/static/fileSys/txt.png +0 -0
  256. package/oxy-dev-tools/page/static/fileSys/weizhiwenjian.png +0 -0
  257. package/oxy-dev-tools/page/static/fileSys/wenjianjia.png +0 -0
  258. package/oxy-dev-tools/page/static/fileSys/word.png +0 -0
  259. package/oxy-dev-tools/page/static/fileSys/yasuo.png +0 -0
  260. package/oxy-dev-tools/page/static/fileSys/yinpin.png +0 -0
  261. package/oxy-dev-tools/page/static/fold.png +0 -0
  262. package/oxy-dev-tools/page/static/menu.png +0 -0
  263. package/oxy-dev-tools/page/static/refresh.png +0 -0
  264. package/oxy-dev-tools/page/static/unfold.png +0 -0
  265. package/oxy-dev-tools/tools.vue +22 -0
  266. package/oxy-dev-tools/type/devTools.d.ts +406 -0
  267. package/package.json +1 -1
  268. package/tags.json +1 -1
  269. package/web-types.json +1 -1
@@ -0,0 +1,170 @@
1
+ <template>
2
+ <view>
3
+ <view
4
+ class="routeDialogMask"
5
+ v-if="isShow"
6
+ :style="{
7
+ height: height + 'px'
8
+ }"
9
+ @click.stop
10
+ >
11
+ <view class="routeDialog" @click.stop>
12
+ <view>
13
+ <text class="title">跳转至指定页面</text>
14
+ </view>
15
+ <textarea v-model="path" type="text" placeholder="请输入..." class="textarea" />
16
+ <view class="btnGroup">
17
+ <view class="btnItem left" @click="hide">
18
+ <text class="btnText">取消</text>
19
+ </view>
20
+ <view class="btnItem right" @click="goPath">
21
+ <text class="btnText">跳转</text>
22
+ </view>
23
+ </view>
24
+ </view>
25
+ </view>
26
+ </view>
27
+ </template>
28
+ <script>
29
+ import devUi from '../../../core/libs/devUi.js'
30
+ export default {
31
+ data() {
32
+ return {
33
+ /**
34
+ * 是否展示
35
+ */
36
+ isShow: false,
37
+ /**
38
+ * 输入框的值
39
+ */
40
+ path: '',
41
+ /**
42
+ * 屏幕高度
43
+ */
44
+ height: uni.getSystemInfoSync().windowHeight
45
+ }
46
+ },
47
+ mounted() {
48
+ let that = this
49
+ /**
50
+ * 使用uni.$on打开弹窗
51
+ */
52
+ uni.$on('devTools_showRouteDialog', (path) => {
53
+ that.path = path ? path : ''
54
+ that.isShow = true
55
+ })
56
+ },
57
+ beforeUnmount() {
58
+ uni.$off('devTools_showRouteDialog')
59
+ },
60
+ methods: {
61
+ /**
62
+ * 关闭弹窗
63
+ */
64
+ hide() {
65
+ this.isShow = false
66
+ },
67
+ /**
68
+ * 执行跳转
69
+ */
70
+ goPath() {
71
+ let that = this
72
+ let path = String(that.path)
73
+ path = path.replace(/[\r\n\s]+/g, '')
74
+ if (path.substring(0, 1) !== '/') {
75
+ return devUi.showToast({
76
+ title: '页面路径需以“/”开头!',
77
+ icon: 'none'
78
+ })
79
+ }
80
+ if (path.length < 2) {
81
+ return devUi.showToast({
82
+ title: '请输入正确的路径!',
83
+ icon: 'none'
84
+ })
85
+ }
86
+ uni.navigateTo({
87
+ url: path
88
+ })
89
+ }
90
+ }
91
+ }
92
+ </script>
93
+ <style lang="scss" scoped>
94
+ .routeDialogMask {
95
+ display: flex;
96
+ flex-direction: column;
97
+ align-items: center;
98
+ justify-content: center;
99
+ background-color: rgba(0, 0, 0, 0.3);
100
+ width: 750rpx;
101
+ flex: 1;
102
+ /* #ifndef APP-PLUS */
103
+ height: 100vh;
104
+ backdrop-filter: blur(1px);
105
+ /* #endif */
106
+ position: fixed;
107
+ left: 0;
108
+ top: 0;
109
+ z-index: 999;
110
+ .routeDialog {
111
+ display: flex;
112
+ flex-direction: column;
113
+ align-items: center;
114
+ justify-content: center;
115
+ width: 690rpx;
116
+ background-color: #fff;
117
+ border-radius: 20rpx;
118
+ padding: 20rpx;
119
+ .title {
120
+ font-size: 28rpx;
121
+ line-height: 28rpx;
122
+ color: #333;
123
+ /* #ifndef APP-PLUS */
124
+ word-wrap: break-word;
125
+ max-width: 600rpx;
126
+ /* #endif */
127
+ /* #ifdef APP-PLUS */
128
+ width: 600rpx;
129
+ /* #endif */
130
+ }
131
+ .textarea {
132
+ margin-top: 20rpx;
133
+ margin-bottom: 20rpx;
134
+ width: 640rpx;
135
+ /* #ifndef APP-PLUS */
136
+ min-height: 200rpx;
137
+ max-height: 750rpx;
138
+ /* #endif */
139
+ background-color: rgba(0, 0, 0, 0.02);
140
+ padding: 10rpx;
141
+ }
142
+ .btnGroup {
143
+ display: flex;
144
+ flex-direction: row;
145
+ width: 640rpx;
146
+ justify-content: space-between;
147
+ .btnItem {
148
+ height: 64rpx;
149
+ border-radius: 10rpx;
150
+ display: flex;
151
+ flex-direction: row;
152
+ align-items: center;
153
+ justify-content: center;
154
+ .btnText {
155
+ font-size: 24rpx;
156
+ color: #fff;
157
+ }
158
+ &.left {
159
+ width: 160rpx;
160
+ background-color: #8799a3;
161
+ }
162
+ &.right {
163
+ width: 450rpx;
164
+ background-color: #3cbb45;
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+ </style>
@@ -0,0 +1,530 @@
1
+ <template>
2
+ <view>
3
+ <view
4
+ class="dialogMask"
5
+ v-if="isShow"
6
+ :style="{
7
+ height: height + 'px'
8
+ }"
9
+ @click.stop
10
+ >
11
+ <view class="dialogContent" @click.stop>
12
+ <view class="dialogHead">
13
+ <view>
14
+ <text class="title">请求构建工具</text>
15
+ </view>
16
+ <view class="closeBtn" @click.stop="hide">
17
+ <text class="closeText">关闭</text>
18
+ <text class="closeIcon">×</text>
19
+ </view>
20
+ </view>
21
+ <scroll-view
22
+ @click.stop
23
+ scroll-y
24
+ class="scrollList"
25
+ :style="{
26
+ height: dialogHeight + 'px'
27
+ }"
28
+ >
29
+ <subTitleBar title="请求地址(url):" :showArrow="false" />
30
+ <view class="inputRow">
31
+ <input type="text" placeholder="请输入url地址" class="input" v-model="request.url" maxlength="-1" />
32
+ <text class="del" @click="request.url = ''">x</text>
33
+ </view>
34
+
35
+ <subTitleBar title="请求方式[method]:" :showArrow="false" />
36
+ <view class="inputRow">
37
+ <picker
38
+ @change="request.method = requestMethods[$event.detail.value]"
39
+ :value="requestMethods.findIndex((x) => x == request.method)"
40
+ :range="requestMethods"
41
+ >
42
+ <view class="method">
43
+ <text class="methodName">{{ request.method }}</text>
44
+ <image class="unfold" src="../../static/unfold.png" />
45
+ </view>
46
+ </picker>
47
+ </view>
48
+
49
+ <subTitleBar title="请求参数[data]:(json对象)" :showArrow="false" />
50
+ <view class="inputRow">
51
+ <textarea placeholder="请输入JSON对象" class="textarea" v-model="request.data" maxlength="-1" />
52
+ <text class="del" @click="request.data = ''">x</text>
53
+ </view>
54
+
55
+ <subTitleBar title="请求头(header):" :showArrow="false" />
56
+ <view class="inputRow">
57
+ <textarea placeholder="请输入JSON对象" class="textarea" v-model="request.header" maxlength="-1" />
58
+ <text class="del" @click="request.header = ''">x</text>
59
+ </view>
60
+
61
+ <view :class="[send.status ? 'loading' : '']" class="sendBtn" @click="sendRequest">
62
+ <text v-if="send.status" class="sendBtnText">
63
+ 发送中[{{ send.t }}ms]
64
+ <text class="msg">(点击可取消)</text>
65
+ </text>
66
+ <text v-else class="sendBtnText">发送</text>
67
+ </view>
68
+
69
+ <template v-if="ajaxHasRes">
70
+ <subTitleBar title="响应结果:" :showArrow="false" />
71
+ <view class="inputRow">
72
+ <objectAnalysis :data="ajaxRes" :width="710" :isOpenFirst="true" />
73
+ </view>
74
+ </template>
75
+
76
+ <view style="height: 100rpx"></view>
77
+ </scroll-view>
78
+ </view>
79
+ </view>
80
+ </view>
81
+ </template>
82
+ <script>
83
+ import objectAnalysis from '../listItem/objectAnalysis.vue'
84
+ import subTitleBar from '../ui/subTitleBar.vue'
85
+ import devUi from '../../../core/libs/devUi.js'
86
+ let success, error
87
+
88
+ /**
89
+ * 转json字符串并格式化
90
+ */
91
+ function toJsonStr(obj) {
92
+ return JSON.stringify(obj, null, 2)
93
+ }
94
+
95
+ export default {
96
+ components: {
97
+ subTitleBar,
98
+ objectAnalysis
99
+ },
100
+ data() {
101
+ return {
102
+ /**
103
+ * 是否展示
104
+ */
105
+ isShow: false,
106
+ /**
107
+ * 屏幕高度
108
+ */
109
+ height: uni.getSystemInfoSync().windowHeight,
110
+ dialogHeight: Math.ceil(uni.getSystemInfoSync().windowHeight * 0.85),
111
+
112
+ requestMethods: ['get', 'post', 'down', 'upload', 'put', 'delete', 'head', 'options', 'patch', 'trace'],
113
+ /**
114
+ * 请求构建对象
115
+ */
116
+ request: {
117
+ url: '', //请求地址
118
+ header: '', //请求头
119
+ method: 'GET', //请求方式
120
+ data: '' //请求参数
121
+ },
122
+ /**
123
+ * 是否有响应结果
124
+ */
125
+ ajaxHasRes: false,
126
+ /**
127
+ * 响应结果对象
128
+ */
129
+ ajaxRes: {},
130
+
131
+ /**
132
+ * 是否状态
133
+ */
134
+ send: {
135
+ status: false, //是否处于发送中状态
136
+ t: 0, //等待时间 ms
137
+ time: 0 //发送时的时间
138
+ }
139
+ }
140
+ },
141
+ mounted() {
142
+ let that = this
143
+ setInterval(() => {
144
+ if (that.send.status) {
145
+ that.send.t = new Date().getTime() - that.send.time
146
+ }
147
+ }, 1000 / 24)
148
+ },
149
+ methods: {
150
+ /**
151
+ * 展示弹窗
152
+ */
153
+ show(item, needSend = false) {
154
+ let that = this
155
+
156
+ if (that.send.status) {
157
+ that.send.status = false
158
+ }
159
+ if (that.ajaxHasRes) {
160
+ that.ajaxHasRes = false
161
+ }
162
+
163
+ return new Promise((yes, err) => {
164
+ success = yes
165
+ error = err
166
+ if (item && item.url && item.method) {
167
+ that.request.url = item.url
168
+ if (typeof item.method == 'string') {
169
+ that.request.method = item.method.toLocaleLowerCase()
170
+ } else {
171
+ that.request.method = 'get'
172
+ }
173
+
174
+ try {
175
+ let data = toJsonStr(item.data)
176
+ if (Object.keys(data).length == 0) {
177
+ data = ''
178
+ } else {
179
+ that.request.data = data
180
+ }
181
+ } catch (error) {
182
+ that.request.data = ''
183
+ }
184
+ try {
185
+ that.request.header = toJsonStr(item.header)
186
+ } catch (error) {
187
+ that.request.header = toJsonStr({
188
+ 'content-type': 'application/x-www-form-urlencoded'
189
+ })
190
+ }
191
+ } else {
192
+ that.request.url = ''
193
+ that.request.data = ''
194
+ that.request.method = 'get'
195
+ that.ajaxHasRes = false
196
+ that.request.header = toJsonStr({
197
+ 'content-type': 'application/x-www-form-urlencoded'
198
+ })
199
+ }
200
+ that.send.status = false
201
+ that.isShow = true
202
+ if (needSend) {
203
+ that.sendRequest()
204
+ }
205
+ })
206
+ },
207
+ /**
208
+ * 关闭弹窗
209
+ */
210
+ hide() {
211
+ this.isShow = false
212
+ error()
213
+ },
214
+ /**
215
+ * 发送请求
216
+ */
217
+ sendRequest() {
218
+ let that = this
219
+
220
+ if (that.send.status) {
221
+ return devUi.showModal({
222
+ title: '提示',
223
+ content: '请求还在进行,是否确认取消请求?',
224
+ success(res) {
225
+ if (res.confirm) {
226
+ if (that.send.status) {
227
+ that.send.status = false
228
+ that.ajaxHasRes = false
229
+ }
230
+ }
231
+ }
232
+ })
233
+ }
234
+ let tw = (m) =>
235
+ devUi.showToast({
236
+ icon: 'none',
237
+ title: m
238
+ })
239
+ if (that.request.url == '' || typeof that.request.url != 'string') return tw('请输入url')
240
+ if (that.request.url.indexOf('http') != 0) return tw('请输入正确的url地址')
241
+ if (that.request.url.indexOf('://') == -1) return tw('请输入正确的url地址')
242
+ if (that.request.url.length < 10) return tw('请输入正确的url地址')
243
+
244
+ let data = {}
245
+ if (that.request.data != '') {
246
+ try {
247
+ data = JSON.parse(that.request.data)
248
+ } catch (error) {
249
+ return tw('请求参数json解析失败!')
250
+ }
251
+ }
252
+
253
+ let header = {}
254
+ if (that.request.header) {
255
+ try {
256
+ header = JSON.parse(that.request.header)
257
+ } catch (error) {
258
+ return tw('请求头json解析失败!')
259
+ }
260
+ }
261
+
262
+ header['Devtoolssend'] = 1
263
+
264
+ that.send.t = 0
265
+ that.send.time = new Date().getTime()
266
+ that.send.status = true
267
+ that.ajaxHasRes = false
268
+
269
+ // 处理上传文件请求
270
+ if (that.request.method === 'upload') {
271
+ // 检查是否有预设的文件路径(来自请求记录)
272
+ let filePath = data.filePath || (data.data && data.data.filePath)
273
+
274
+ // 直接使用记录中的文件路径
275
+ let uploadParams = {
276
+ url: that.request.url,
277
+ filePath: filePath,
278
+ name: data.name || 'file',
279
+ header: header,
280
+ success(uploadRes) {
281
+ if (!that.send.status || !that.isShow) return
282
+ that.send.status = false
283
+ uploadRes['请求用时'] = new Date().getTime() - that.send.time + 'ms'
284
+ uploadRes['文件路径'] = filePath
285
+ that.$set(that, 'ajaxRes', uploadRes)
286
+ that.ajaxHasRes = true
287
+ devUi.showToast({
288
+ title: '上传成功',
289
+ icon: 'success'
290
+ })
291
+ },
292
+ fail(msg) {
293
+ if (!that.send.status || !that.isShow) return
294
+ let uploadRes = {
295
+ fail: msg,
296
+ 请求用时: new Date().getTime() - that.send.time + 'ms',
297
+ 文件路径: filePath
298
+ }
299
+ that.send.status = false
300
+ that.$set(that, 'ajaxRes', uploadRes)
301
+ that.ajaxHasRes = true
302
+ devUi.showToast({
303
+ title: '上传失败',
304
+ icon: 'error'
305
+ })
306
+ }
307
+ }
308
+
309
+ // 添加表单数据
310
+ if (data.formData) {
311
+ uploadParams.formData = data.formData
312
+ }
313
+
314
+ uni.uploadFile(uploadParams)
315
+
316
+ return
317
+ }
318
+
319
+ // 处理下载文件请求
320
+ if (that.request.method === 'down') {
321
+ uni.downloadFile({
322
+ url: that.request.url,
323
+ header: header,
324
+ success(downloadRes) {
325
+ if (!that.send.status || !that.isShow) return
326
+ that.send.status = false
327
+ downloadRes['请求用时'] = new Date().getTime() - that.send.time + 'ms'
328
+ that.$set(that, 'ajaxRes', downloadRes)
329
+ that.ajaxHasRes = true
330
+ devUi.showToast({
331
+ title: '下载成功',
332
+ icon: 'success'
333
+ })
334
+ },
335
+ fail(msg) {
336
+ if (!that.send.status || !that.isShow) return
337
+ let downloadRes = {
338
+ fail: msg,
339
+ 请求用时: new Date().getTime() - that.send.time + 'ms'
340
+ }
341
+ that.send.status = false
342
+ that.$set(that, 'ajaxRes', downloadRes)
343
+ that.ajaxHasRes = true
344
+ devUi.showToast({
345
+ title: '下载失败',
346
+ icon: 'error'
347
+ })
348
+ }
349
+ })
350
+ return
351
+ }
352
+
353
+ // 处理普通请求
354
+ uni.request({
355
+ url: that.request.url,
356
+ method: that.request.method,
357
+ data,
358
+ header,
359
+ success(res) {
360
+ if (!that.send.status || !that.isShow) return
361
+ that.send.status = false
362
+ res['请求用时'] = new Date().getTime() - that.send.time + 'ms'
363
+ that.$set(that, 'ajaxRes', res)
364
+ that.ajaxHasRes = true
365
+ devUi.showToast({
366
+ title: '请求响应成功',
367
+ icon: 'success'
368
+ })
369
+ },
370
+ fail(msg, request) {
371
+ if (!that.send.status || !that.isShow) return
372
+ let res = {
373
+ fail: msg,
374
+ request,
375
+ 请求用时: new Date().getTime() - that.send.time + 'ms'
376
+ }
377
+ that.send.status = false
378
+ that.$set(that, 'ajaxRes', res)
379
+ that.ajaxHasRes = true
380
+ devUi.showToast({
381
+ title: '请求响应失败',
382
+ icon: 'error'
383
+ })
384
+ }
385
+ })
386
+ }
387
+ }
388
+ }
389
+ </script>
390
+ <style lang="scss" scoped>
391
+ .dialogMask {
392
+ display: flex;
393
+ flex-direction: column-reverse;
394
+ background-color: rgba(0, 0, 0, 0.3);
395
+ width: 750rpx;
396
+ flex: 1;
397
+ /* #ifndef APP-PLUS */
398
+ height: 100vh;
399
+ backdrop-filter: blur(1px);
400
+ /* #endif */
401
+ position: fixed;
402
+ left: 0;
403
+ top: 0;
404
+ z-index: 999;
405
+ .dialogContent {
406
+ display: flex;
407
+ flex-direction: column;
408
+ width: 750rpx;
409
+ background-color: #fff;
410
+ border-radius: 20rpx 20rpx 0 0;
411
+ .dialogHead {
412
+ display: flex;
413
+ flex-direction: row;
414
+ align-items: center;
415
+ justify-content: space-between;
416
+ height: 80rpx;
417
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
418
+ width: 750rpx;
419
+ .title {
420
+ margin-left: 20rpx;
421
+ font-size: 24rpx;
422
+ line-height: 28rpx;
423
+ height: 28rpx;
424
+ color: #333;
425
+ }
426
+ .closeBtn {
427
+ margin-right: 20rpx;
428
+ padding: 8rpx 14rpx;
429
+ border-radius: 999rpx;
430
+ border: 1px solid rgba(100, 116, 139, 0.28);
431
+ background-color: #f8fafc;
432
+ display: flex;
433
+ flex-direction: row;
434
+ align-items: center;
435
+ }
436
+ .closeText {
437
+ font-size: 22rpx;
438
+ color: #64748b;
439
+ line-height: 22rpx;
440
+ }
441
+ .closeIcon {
442
+ margin-left: 8rpx;
443
+ font-size: 24rpx;
444
+ line-height: 24rpx;
445
+ color: #334155;
446
+ }
447
+ }
448
+ .scrollList {
449
+ width: 750rpx;
450
+ .inputRow {
451
+ width: 750rpx;
452
+ padding: 0rpx 20rpx;
453
+ position: relative;
454
+ .input {
455
+ width: 710rpx;
456
+ border: 1px solid rgba(0, 0, 0, 0.05);
457
+ padding-left: 5rpx;
458
+ padding-top: 5rpx;
459
+ padding-bottom: 5rpx;
460
+ padding-right: 50rpx;
461
+ font-size: 24rpx;
462
+ border-radius: 6rpx;
463
+ height: 60rpx;
464
+ }
465
+ .textarea {
466
+ width: 710rpx;
467
+ border: 1px solid rgba(0, 0, 0, 0.05);
468
+ padding-left: 5rpx;
469
+ padding-top: 5rpx;
470
+ padding-bottom: 5rpx;
471
+ padding-right: 50rpx;
472
+ font-size: 24rpx;
473
+ border-radius: 6rpx;
474
+ height: 140rpx;
475
+ }
476
+ .del {
477
+ position: absolute;
478
+ right: 24rpx;
479
+ top: 10rpx;
480
+ height: 40rpx;
481
+ background-color: #fff;
482
+ padding: 0 10rpx;
483
+ font-size: 24rpx;
484
+ color: #999;
485
+ line-height: 40rpx;
486
+ }
487
+ .method {
488
+ display: flex;
489
+ flex-direction: row;
490
+ align-items: center;
491
+ .methodName {
492
+ font-size: 24rpx;
493
+ color: #333;
494
+ }
495
+ .unfold {
496
+ margin-left: 10rpx;
497
+ width: 24rpx;
498
+ height: 24rpx;
499
+ }
500
+ }
501
+ }
502
+ .sendBtn {
503
+ width: 710rpx;
504
+ margin-left: 20rpx;
505
+ margin-top: 30rpx;
506
+ margin-bottom: 30rpx;
507
+ height: 60rpx;
508
+ display: flex;
509
+ flex-direction: row;
510
+ align-items: center;
511
+ justify-content: center;
512
+ border-radius: 10rpx;
513
+ background-color: rgb(59, 130, 246);
514
+ &.loading {
515
+ background-color: rgba(59, 130, 246, 0.5);
516
+ }
517
+ .sendBtnText {
518
+ color: #fff;
519
+ font-size: 26rpx;
520
+ }
521
+ .msg {
522
+ color: #fff;
523
+ font-size: 20rpx;
524
+ margin-left: 20rpx;
525
+ }
526
+ }
527
+ }
528
+ }
529
+ }
530
+ </style>