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,176 @@
1
+ <template>
2
+ <view
3
+ v-if="isMp && options && options.status && options.bubble.status"
4
+ class="mpDevBubble"
5
+ :style="{
6
+ left: `${tagConfig.x}px`,
7
+ top: `${tagConfig.y}px`,
8
+ 'background-color': options.bubble.bgColor,
9
+ 'box-shadow': `0px 0px 6px ${options.bubble.bgColor}`
10
+ }"
11
+ @touchstart.stop="touchstart"
12
+ @touchmove.stop="touchmove"
13
+ @touchend.stop="touchend"
14
+ @mousedown.stop="touchstart"
15
+ >
16
+ <text
17
+ class="mpDevBubbleText"
18
+ :style="{
19
+ color: options.bubble.color,
20
+ 'font-size': '20rpx'
21
+ }"
22
+ >
23
+ {{ options.bubble.text }}
24
+ </text>
25
+ </view>
26
+ </template>
27
+ <script>
28
+ import devOptions from '../libs/devOptions'
29
+ import { reactive } from 'vue'
30
+
31
+ let options = devOptions.getOptions()
32
+ let sysInfo = uni.getSystemInfoSync()
33
+ let tagConfig = uni.getStorageSync('devTools_tagConfig')
34
+ if (!tagConfig) {
35
+ tagConfig = {}
36
+ }
37
+
38
+ // #ifndef VUE3
39
+ tagConfig = Object.assign(
40
+ {
41
+ x: sysInfo.screenWidth - 150,
42
+ y: sysInfo.screenHeight - 240
43
+ },
44
+ tagConfig
45
+ )
46
+ // #endif
47
+
48
+ // #ifdef VUE3
49
+ tagConfig = reactive(
50
+ Object.assign(
51
+ {
52
+ x: sysInfo.screenWidth - 150,
53
+ y: sysInfo.screenHeight - 240
54
+ },
55
+ tagConfig
56
+ )
57
+ )
58
+ // #endif
59
+
60
+ // 拖动范围限制
61
+ let dragLimit = {
62
+ min: { x: 0, y: 0 },
63
+ max: {
64
+ x: sysInfo.screenWidth - 70,
65
+ y: sysInfo.screenHeight - 24
66
+ }
67
+ }
68
+
69
+ tagConfig.x = Math.min(Math.max(tagConfig.x, dragLimit.min.x), dragLimit.max.x)
70
+ tagConfig.y = Math.min(Math.max(tagConfig.y, dragLimit.min.y), dragLimit.max.y)
71
+
72
+ let isTouch = false
73
+ let touchStartPoint = {
74
+ clientX: 0,
75
+ clientY: 0,
76
+ tagX: tagConfig.x,
77
+ tagY: tagConfig.y,
78
+ hasMove: false
79
+ }
80
+
81
+ let isMp = false
82
+ // #ifdef MP
83
+ isMp = true
84
+ // #endif
85
+
86
+ export default {
87
+ data() {
88
+ return {
89
+ isMp,
90
+ /**
91
+ * 标签参数
92
+ */
93
+ options,
94
+ /**
95
+ * 标签坐标信息配置
96
+ */
97
+ tagConfig
98
+ }
99
+ },
100
+ mounted() {
101
+ // #ifdef H5
102
+ document.addEventListener('mousemove', this.touchmove)
103
+ document.addEventListener('mouseup', this.touchend)
104
+ // #endif
105
+ },
106
+ beforeUnmount() {
107
+ // #ifdef H5
108
+ document.removeEventListener('mousemove', this.touchmove)
109
+ document.addEventListener('mouseup', this.touchend)
110
+ // #endif
111
+ },
112
+ methods: {
113
+ touchstart(e) {
114
+ if (isTouch) return
115
+ if (e.preventDefault) {
116
+ e.preventDefault()
117
+ }
118
+ let clientX = e.clientX ? e.clientX : e.touches[0].clientX
119
+ let clientY = e.clientY ? e.clientY : e.touches[0].clientY
120
+ touchStartPoint.clientX = clientX
121
+ touchStartPoint.clientY = clientY
122
+ touchStartPoint.tagX = tagConfig.x
123
+ touchStartPoint.tagY = tagConfig.y
124
+ touchStartPoint.hasMove = false
125
+ isTouch = true
126
+ },
127
+ touchmove(e) {
128
+ if (!isTouch) return
129
+ if (e.preventDefault) {
130
+ e.preventDefault()
131
+ }
132
+ let clientX = e.clientX ? e.clientX : e.touches[0].clientX
133
+ let clientY = e.clientY ? e.clientY : e.touches[0].clientY
134
+ touchStartPoint.hasMove = true
135
+ let offsetX = touchStartPoint.clientX - clientX
136
+ let offsetY = touchStartPoint.clientY - clientY
137
+ let tx = touchStartPoint.tagX - offsetX
138
+ let ty = touchStartPoint.tagY - offsetY
139
+ tx = Math.min(Math.max(tx, dragLimit.min.x), dragLimit.max.x)
140
+ ty = Math.min(Math.max(ty, dragLimit.min.y), dragLimit.max.y)
141
+ tagConfig.x = tx
142
+ tagConfig.y = ty
143
+ this.tagConfig.x = tx
144
+ this.tagConfig.y = ty
145
+ },
146
+ touchend(e) {
147
+ if (!isTouch) return
148
+ if (e.preventDefault) {
149
+ e.preventDefault()
150
+ }
151
+ isTouch = false
152
+ uni.setStorageSync('devTools_tagConfig', tagConfig)
153
+ if (!touchStartPoint.hasMove) {
154
+ this.$devTools.show()
155
+ }
156
+ }
157
+ }
158
+ }
159
+ </script>
160
+ <style lang="scss" scoped>
161
+ .mpDevBubble {
162
+ box-sizing: border-box;
163
+ position: fixed;
164
+ z-index: 9999999;
165
+ width: 70px;
166
+ height: 24px;
167
+ display: flex;
168
+ flex-direction: column;
169
+ align-items: center;
170
+ justify-content: center;
171
+ padding: 4px;
172
+ border-radius: 6px;
173
+ font-size: 10px;
174
+ cursor: grab;
175
+ }
176
+ </style>
@@ -0,0 +1,156 @@
1
+ /**
2
+ *! 创建h5页面上拖动的气泡标签
3
+ */
4
+ function createH5Bubble(options, devTools) {
5
+ let tagConfig = localStorage.getItem('devTools_tagConfig')
6
+ if (!tagConfig) {
7
+ tagConfig = {}
8
+ } else {
9
+ tagConfig = JSON.parse(tagConfig)
10
+ }
11
+
12
+ tagConfig = Object.assign(
13
+ {
14
+ show: options.bubble.status,
15
+ x: window.innerWidth - 90,
16
+ y: window.innerHeight - 90
17
+ },
18
+ tagConfig
19
+ )
20
+
21
+ tagConfig.show = options.bubble.status
22
+
23
+ // 拖动范围限制
24
+ let dragLimit = {
25
+ min: { x: 0, y: 0 },
26
+ max: {
27
+ x: window.innerWidth - 70,
28
+ y: window.innerHeight - 24
29
+ }
30
+ }
31
+
32
+ tagConfig.x = Math.min(Math.max(tagConfig.x, dragLimit.min.x), dragLimit.max.x)
33
+ tagConfig.y = Math.min(Math.max(tagConfig.y, dragLimit.min.y), dragLimit.max.y)
34
+
35
+ let tag = document.createElement('div')
36
+ tag.style = `
37
+ box-sizing: border-box;
38
+ position: fixed;
39
+ z-index: 9999999;
40
+ left: ${tagConfig.x}px;
41
+ top: ${tagConfig.y}px;
42
+ width: 70px;
43
+ height: 24px;
44
+ display: flex;
45
+ flex-direction: column;
46
+ align-items: center;
47
+ justify-content: center;
48
+ padding: 4px;
49
+ border-radius: 6px;
50
+ background-color: ${options.bubble.bgColor};
51
+ color: ${options.bubble.color};
52
+ font-size: 10px;
53
+ cursor: grab;
54
+ box-shadow: 0px 0px 6px ${options.bubble.bgColor};
55
+ backdrop-filter: blur(1px);
56
+ `
57
+ tag.innerHTML = options.bubble.text
58
+ tag.setAttribute('id', 'debugTag')
59
+ const canShowBubble = tagConfig.show === true
60
+
61
+ if (canShowBubble) {
62
+ document.body.appendChild(tag)
63
+ }
64
+
65
+ function hideBubble() {
66
+ if (!canShowBubble) return
67
+ tag.style.display = 'none'
68
+ }
69
+
70
+ function showBubble() {
71
+ if (!canShowBubble) return
72
+ if (!document.body.contains(tag)) {
73
+ document.body.appendChild(tag)
74
+ }
75
+ tag.style.display = 'flex'
76
+ }
77
+
78
+ uni.$on('devTools_overlay_show', hideBubble)
79
+ uni.$on('devTools_overlay_hide', showBubble)
80
+
81
+ /**
82
+ * 标签单击事件
83
+ */
84
+ function tagClick() {
85
+ devTools.show()
86
+ }
87
+
88
+ let isTouch = false
89
+ let touchStartPoint = {
90
+ clientX: 0,
91
+ clientY: 0,
92
+ tagX: tagConfig.x,
93
+ tagY: tagConfig.y,
94
+ hasMove: false
95
+ }
96
+
97
+ function touchStart(e) {
98
+ if (isTouch) return
99
+ if (e.preventDefault) {
100
+ e.preventDefault()
101
+ }
102
+ let clientX = e.clientX ? e.clientX : e.targetTouches[0].clientX
103
+ let clientY = e.clientX ? e.clientY : e.targetTouches[0].clientY
104
+ touchStartPoint.clientX = clientX
105
+ touchStartPoint.clientY = clientY
106
+ touchStartPoint.tagX = tagConfig.x
107
+ touchStartPoint.tagY = tagConfig.y
108
+ touchStartPoint.hasMove = false
109
+ isTouch = true
110
+ }
111
+ function touchMove(e) {
112
+ if (!isTouch) return
113
+ if (e.preventDefault) {
114
+ e.preventDefault()
115
+ }
116
+ let clientX = e.clientX ? e.clientX : e.targetTouches[0].clientX
117
+ let clientY = e.clientX ? e.clientY : e.targetTouches[0].clientY
118
+ let offsetX = touchStartPoint.clientX - clientX
119
+ let offsetY = touchStartPoint.clientY - clientY
120
+ const moveDistance = Math.sqrt(offsetX * offsetX + offsetY * offsetY)
121
+ if (!touchStartPoint.hasMove && moveDistance < 6) {
122
+ return
123
+ }
124
+ touchStartPoint.hasMove = true
125
+ let tx = touchStartPoint.tagX - offsetX
126
+ let ty = touchStartPoint.tagY - offsetY
127
+ tx = Math.min(Math.max(tx, dragLimit.min.x), dragLimit.max.x)
128
+ ty = Math.min(Math.max(ty, dragLimit.min.y), dragLimit.max.y)
129
+ tag.style.left = `${tx}px`
130
+ tag.style.top = `${ty}px`
131
+ tagConfig.x = tx
132
+ tagConfig.y = ty
133
+ }
134
+ function touchEnd(e) {
135
+ if (!isTouch) return
136
+ if (e.preventDefault) {
137
+ e.preventDefault()
138
+ }
139
+ isTouch = false
140
+ localStorage.setItem('devTools_tagConfig', JSON.stringify(tagConfig))
141
+ if (!touchStartPoint.hasMove) {
142
+ tagClick()
143
+ }
144
+ }
145
+ tag.addEventListener('touchstart', touchStart)
146
+ tag.addEventListener('touchmove', touchMove)
147
+ tag.addEventListener('touchend', touchEnd)
148
+
149
+ tag.addEventListener('mousedown', touchStart)
150
+ document.addEventListener('mousemove', touchMove)
151
+ document.addEventListener('mouseup', touchEnd)
152
+
153
+ localStorage.setItem('devTools_tagConfig', JSON.stringify(tagConfig))
154
+ }
155
+
156
+ export default createH5Bubble
@@ -0,0 +1,149 @@
1
+ import devOptions from './devOptions'
2
+ /**
3
+ * dev工具缓存管理
4
+ */
5
+ export default {
6
+ /**
7
+ * 存储的键开始名称
8
+ */
9
+ cacheKey: 'devTools_v3_',
10
+ options: null,
11
+ /**
12
+ * 临时缓存对象
13
+ */
14
+ tempCache: {
15
+ errorReport: [],
16
+ logReport: [],
17
+ console: [],
18
+ request: [],
19
+ uniBus: []
20
+ },
21
+ /**
22
+ * 临时数据存放
23
+ */
24
+ tempData: {},
25
+ /**
26
+ * 长列表配置缺省值
27
+ */
28
+ defaultLongListSetting: {
29
+ status: false,
30
+ cache: {
31
+ status: false
32
+ }
33
+ },
34
+ /**
35
+ * 向缓存内写入数据
36
+ */
37
+ set(key, value) {
38
+ try {
39
+ if (['errorReport', 'logReport', 'console', 'request', 'uniBus'].indexOf(key) != -1) {
40
+ const setting = this.getLongListSetting(key)
41
+ if (setting.status !== true) return
42
+ if (!setting.cache || setting.cache.status !== true) {
43
+ // !不使用缓存
44
+ this.tempCache[key] = value
45
+ return
46
+ }
47
+ }
48
+ key = `${this.cacheKey}${key}`
49
+
50
+ this.tempData[key] = value
51
+ } catch (error) {
52
+ console.log('devCache.set error', error)
53
+ }
54
+ },
55
+ /**
56
+ * 同步读取缓存数据
57
+ */
58
+ get(key) {
59
+ try {
60
+ if (['errorReport', 'logReport', 'console', 'request', 'uniBus'].indexOf(key) != -1) {
61
+ const setting = this.getLongListSetting(key)
62
+ if (setting.status !== true) return []
63
+ if (!setting.cache || setting.cache.status !== true) {
64
+ // !不使用缓存
65
+ return this.tempCache[key]
66
+ }
67
+ }
68
+ key = `${this.cacheKey}${key}`
69
+
70
+ if (this.tempData.hasOwnProperty(key)) {
71
+ return this.tempData[key]
72
+ } else {
73
+ let value = uni.getStorageSync(key)
74
+ this.tempData[key] = value
75
+ return value
76
+ }
77
+ } catch (error) {
78
+ console.log('devCache.get error', error)
79
+ return ''
80
+ }
81
+ },
82
+ /**
83
+ * 向缓存内写入数据
84
+ */
85
+ clearItem(key) {
86
+ try {
87
+ if (['errorReport', 'logReport', 'console', 'request', 'uniBus'].indexOf(key) != -1) {
88
+ const setting = this.getLongListSetting(key)
89
+ if (setting.status !== true) return []
90
+ if (!setting.cache || setting.cache.status !== true) {
91
+ // !不使用缓存
92
+ delete this.tempData[key]
93
+ uni.removeStorageSync(key)
94
+ }
95
+ }
96
+ key = `${this.cacheKey}${key}`
97
+ delete this.tempData[key]
98
+ uni.removeStorageSync(key)
99
+ } catch (error) {
100
+ console.log('devCache.clearItem error', JSON.stringify(error))
101
+ }
102
+ },
103
+ getLongListSetting(key) {
104
+ const optionsKey = {
105
+ errorReport: 'error',
106
+ logReport: 'logs',
107
+ console: 'console',
108
+ request: 'network',
109
+ uniBus: 'uniBus'
110
+ }
111
+ const optionName = optionsKey[key]
112
+ if (!optionName) {
113
+ return this.defaultLongListSetting
114
+ }
115
+ this.options = devOptions.getOptions() || {}
116
+ const setting = this.options ? this.options[optionName] : null
117
+ if (!setting || typeof setting !== 'object') {
118
+ return this.defaultLongListSetting
119
+ }
120
+ return setting
121
+ },
122
+ /**
123
+ * 同步本地缓存
124
+ */
125
+ syncLocalCache() {
126
+ let that = this
127
+ setTimeout(() => {
128
+ try {
129
+ let waitSetKeys = Object.keys(that.tempData)
130
+ for (let i = 0; i < waitSetKeys.length; i++) {
131
+ const key = waitSetKeys[i]
132
+ uni.setStorage({
133
+ key,
134
+ data: that.tempData[key],
135
+ success() {
136
+ // console.log("set " + key + " success,length=" + that.tempData[key].length);
137
+ delete that.tempData[key]
138
+ }
139
+ })
140
+ }
141
+ } catch (error) {
142
+ console.log('devCache error: ', error)
143
+ }
144
+ setTimeout(() => {
145
+ that.syncLocalCache()
146
+ }, 500)
147
+ }, Math.round(Math.random() * 3 * 1000) + 2000)
148
+ }
149
+ }
@@ -0,0 +1,160 @@
1
+ import devCache from './devCache'
2
+
3
+ /**
4
+ * 设置各端大小 kb
5
+ */
6
+ const defSize = (h5, app, mp) => {
7
+ let r = 0
8
+ // #ifdef H5
9
+ r = h5
10
+ // #endif
11
+ // #ifdef MP
12
+ r = mp
13
+ // #endif
14
+ // #ifdef APP-PLUS
15
+ r = app
16
+ // #endif
17
+ return Math.ceil(r * 1024)
18
+ }
19
+
20
+ /**
21
+ * 获取配置
22
+ */
23
+ export default {
24
+ /**
25
+ * 配置缓存key
26
+ */
27
+ cacheKey: 'options_v8',
28
+ /**
29
+ * 默认配置项
30
+ */
31
+ defaultOptions: {
32
+ version: 3.81,
33
+ status: false, //调试工具总开关
34
+ bubble: {
35
+ //调试弹窗气泡设置
36
+ status: false, // 气泡标签是否显示,生产环境建议关闭
37
+ text: '调试工具', // 气泡上展示的文字
38
+ color: '#ffffff', // 气泡文字颜色
39
+ bgColor: 'rgba(250, 53, 52,0.7)' // 气泡背景颜色
40
+ },
41
+ console: {
42
+ status: true, // 开关
43
+ isOutput: true, //打印的日志是否对外输出到浏览器调试界面,建议在生产环境时开启
44
+ cache: {
45
+ status: true, //是否启用console缓存
46
+ size: defSize(512, 1024 * 2, 512),
47
+ rowSize: defSize(5.12, 20, 10)
48
+ }
49
+ },
50
+ error: {
51
+ status: true,
52
+ cache: {
53
+ status: true,
54
+ size: defSize(512, 1024 * 2, 512),
55
+ rowSize: defSize(5.12, 20, 10)
56
+ }
57
+ },
58
+ network: {
59
+ status: true,
60
+ cache: {
61
+ status: true,
62
+ size: defSize(512, 1024 * 2, 512),
63
+ rowSize: defSize(5.12, 20, 10)
64
+ }
65
+ },
66
+ logs: {
67
+ status: true,
68
+ cache: {
69
+ status: true,
70
+ size: defSize(512, 1024 * 2, 512),
71
+ rowSize: defSize(0.4, 0.4, 0.4)
72
+ }
73
+ },
74
+ // uni event bus 监听设置
75
+ uniBus: {
76
+ status: true,
77
+ cache: {
78
+ status: true,
79
+ size: defSize(512, 1024 * 2, 512),
80
+ rowSize: defSize(5.12, 20, 10),
81
+ countMaxSize: defSize(512, 1024 * 2, 512) // bus统计上限 kb
82
+ }
83
+ }
84
+ },
85
+ /**
86
+ * 获取配置信息
87
+ */
88
+ getOptions() {
89
+ try {
90
+ let options = devCache.get(this.cacheKey)
91
+ if (!options) {
92
+ return {
93
+ status: false //默认关闭调试工具
94
+ }
95
+ }
96
+ return options
97
+ } catch (error) {
98
+ console.log('devOptions.getOptions error: ', error)
99
+ return {
100
+ status: false //默认关闭调试工具
101
+ }
102
+ }
103
+ },
104
+ /**
105
+ * 保存配置项
106
+ */
107
+ setOptions(options) {
108
+ try {
109
+ if (!options) {
110
+ options = this.defaultOptions
111
+ }
112
+
113
+ let data = deepMerge(this.defaultOptions, options)
114
+
115
+ devCache.set(this.cacheKey, data)
116
+ } catch (error) {
117
+ console.log('devOptions.setOptions error: ', error)
118
+ }
119
+ },
120
+ /**
121
+ * 弹出错误信息
122
+ */
123
+ outputError(msg) {
124
+ console.log(
125
+ '%c' + msg,
126
+ `
127
+ padding: 4px;
128
+ background-color: red;
129
+ color: #fff;
130
+ font-size: 15px;
131
+ `
132
+ )
133
+ }
134
+ }
135
+
136
+ /**
137
+ * 深度合并对象
138
+ */
139
+ function deepMerge(target, ...sources) {
140
+ try {
141
+ if (!sources.length) return target // 如果没有源对象则直接返回目标对象
142
+
143
+ const source = sources[0]
144
+
145
+ for (let key in source) {
146
+ if (source.hasOwnProperty(key)) {
147
+ if (typeof source[key] === 'object' && typeof target[key] !== undefined) {
148
+ target[key] = deepMerge({}, target[key], source[key]) // 若属性值为对象类型且目标对象已存在该属性,则递归调用deepMerge函数进行合并
149
+ } else {
150
+ target[key] = source[key] // 否则将源对象的属性赋值到目标对象上
151
+ }
152
+ }
153
+ }
154
+
155
+ return deepMerge(target, ...sources.slice(1)) // 处理完第一个源对象后再次调用deepMerge函数处理其他源对象
156
+ } catch (error) {
157
+ console.log('deepMerge error', error)
158
+ return {}
159
+ }
160
+ }