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,148 @@
1
+ import devCache from '../libs/devCache'
2
+ import devOptions from '../libs/devOptions'
3
+ import jsonCompress from '../libs/jsonCompress'
4
+
5
+ export default {
6
+ logList: [],
7
+ busCount: [],
8
+
9
+ options: null,
10
+ /**
11
+ * 挂载打印拦截器
12
+ */
13
+ install() {
14
+ try {
15
+ let that = this
16
+
17
+ this.options = devOptions.getOptions()
18
+ if (!this.options.uniBus.status) return
19
+
20
+ this.logList = devCache.get('uniBus')
21
+ if (!this.logList) this.logList = []
22
+
23
+ this.busCount = devCache.get('busCount')
24
+ if (!this.busCount) this.busCount = []
25
+
26
+ this.syncReqData() //同步缓存
27
+
28
+ let now = () => new Date().getTime()
29
+
30
+ const _on = uni.$on
31
+ uni.$on = function () {
32
+ try {
33
+ let n = arguments[0]
34
+ if (n && typeof n == 'string' && n.length < 200 && n.indexOf('devTools_') == -1) {
35
+ that.logList.unshift({
36
+ t: now(),
37
+ e: jsonCompress.compressObject(`on>${n}`, that.options.uniBus.cache.rowMax)
38
+ })
39
+ addCount(n, 'on')
40
+ }
41
+ } catch (error) {
42
+ console.error('uni.$on出错', error)
43
+ }
44
+ _on(...arguments)
45
+ }
46
+
47
+ const _once = uni.$once
48
+ uni.$once = function () {
49
+ try {
50
+ let n = arguments[0]
51
+ if (n && typeof n == 'string' && n.length < 200 && n.indexOf('devTools_') == -1) {
52
+ that.logList.unshift({
53
+ t: now(),
54
+ e: jsonCompress.compressObject(`once>${n}`, that.options.uniBus.cache.rowMax)
55
+ })
56
+ addCount(n, 'once')
57
+ }
58
+ } catch (error) {
59
+ console.error('uni.$once出错', error)
60
+ }
61
+ _once(...arguments)
62
+ }
63
+
64
+ const _emit = uni.$emit
65
+ uni.$emit = function () {
66
+ try {
67
+ let n = arguments[0]
68
+ let p = arguments[1]
69
+ if (n && typeof n == 'string' && n.length < 200 && n.indexOf('devTools_') == -1) {
70
+ that.logList.unshift({
71
+ t: now(),
72
+ e: jsonCompress.compressObject(`emit>${n}` + (p ? '>' + JSON.stringify(p) : ''), that.options.uniBus.cache.rowMax)
73
+ })
74
+ addCount(n, 'emit')
75
+ }
76
+ } catch (error) {
77
+ console.error('uni.$emit出错', error)
78
+ }
79
+ _emit(...arguments)
80
+ }
81
+
82
+ const _off = uni.$off
83
+ uni.$off = function () {
84
+ try {
85
+ let n = arguments[0]
86
+ if (n && typeof n == 'string' && n.length < 200 && n.indexOf('devTools_') == -1) {
87
+ that.logList.unshift({
88
+ t: now(),
89
+ e: jsonCompress.compressObject(`off>${n}` + arguments[0], that.options.uniBus.cache.rowMax)
90
+ })
91
+ addCount(n, 'off')
92
+ }
93
+ } catch (error) {
94
+ console.error('uni.$off出错', error)
95
+ }
96
+ _off(...arguments)
97
+ }
98
+
99
+ /**
100
+ * 统计总次数
101
+ */
102
+ function addCount(name, type = 'on') {
103
+ let i = that.busCount.findIndex((x) => x.e == name)
104
+ if (i == -1) {
105
+ let item = {
106
+ e: name,
107
+ on: 0,
108
+ off: 0,
109
+ emit: 0,
110
+ once: 0
111
+ }
112
+ item[type] = item[type] + 1
113
+ that.busCount.push(item)
114
+ } else {
115
+ that.busCount[i][type] = that.busCount[i][type] + 1
116
+ }
117
+ }
118
+
119
+ // ! 清空全部记录
120
+ uni.$on('devTools_delUniBusAll', () => {
121
+ that.logList = []
122
+ that.busCount = []
123
+ devCache.clearItem('uniBus')
124
+ devCache.clearItem('busCount')
125
+ })
126
+ } catch (error) {
127
+ console.log('devTools uniBus.install error', error)
128
+ }
129
+ },
130
+ /**
131
+ * 同步请求信息到缓存数据中
132
+ */
133
+ syncReqData() {
134
+ let that = this
135
+ setTimeout(() => {
136
+ try {
137
+ that.logList = jsonCompress.compressArray(that.logList, 'end', that.options.uniBus.cache.rowMax)
138
+ devCache.set('uniBus', that.logList)
139
+
140
+ that.busCount = jsonCompress.compressArray(that.busCount, 'end', that.options.uniBus.cache.countMaxSize)
141
+ devCache.set('busCount', that.busCount)
142
+ } catch (error) {
143
+ console.log('devTools uniBus.syncReqData error', error)
144
+ }
145
+ that.syncReqData()
146
+ }, 5000)
147
+ }
148
+ }
@@ -0,0 +1,190 @@
1
+ import logReport from '../libs/logReport'
2
+
3
+ export default {
4
+ /**
5
+ * 挂载uni大部分api监听器
6
+ */
7
+ install() {
8
+ try {
9
+ this.addDefUniApiListen()
10
+ this.onNetworkStatusChange()
11
+ this.scanCodeListen()
12
+ this.onLocaleChange()
13
+ } catch (error) {
14
+ console.log('uniListen error', error)
15
+ }
16
+ },
17
+ /**
18
+ * 批量挂载api调用日志
19
+ */
20
+ addDefUniApiListen() {
21
+ /**
22
+ * 需要挂载监听的api列表
23
+ */
24
+ let diyListenApi = {
25
+ downloadFile(args) {
26
+ logReport('downloadFile>' + (args && args.url ? args.url : ''))
27
+ },
28
+ connectSocket(args) {
29
+ logReport('connectSocket>' + args.url)
30
+ },
31
+ makePhoneCall(args) {
32
+ logReport('makePhoneCall>' + args.phoneNumber)
33
+ },
34
+ addPhoneContact(args) {
35
+ logReport('addPhoneContact>' + args.name)
36
+ },
37
+ showToast(args) {
38
+ logReport('showToast>' + args.title)
39
+ },
40
+ showModal(args) {
41
+ logReport('showModal>' + args.title + '>' + args.content)
42
+ },
43
+ setLocale(args) {
44
+ logReport('setLocale>' + args)
45
+ },
46
+ saveFile(args) {
47
+ logReport('saveFile>' + args.tempFilePath)
48
+ },
49
+ login(args) {
50
+ logReport('login>' + JSON.stringify(args))
51
+ },
52
+ share(args) {
53
+ logReport('share>' + JSON.stringify(args))
54
+ },
55
+ shareWithSystem(args) {
56
+ logReport('shareWithSystem>' + JSON.stringify(args))
57
+ },
58
+ requestPayment(args) {
59
+ logReport('requestPayment>' + JSON.stringify(args))
60
+ },
61
+ authorize(args) {
62
+ logReport('requestPayment>' + args.scope)
63
+ },
64
+ navigateToMiniProgram(args) {
65
+ logReport('navigateToMiniProgram>' + args.appId + '>' + args.path)
66
+ },
67
+ openDocument(args) {
68
+ logReport('openDocument>' + args.filePath)
69
+ }
70
+ }
71
+ /**
72
+ * 需要监听打印日志的api名称列表
73
+ */
74
+ let waitListenApiNames = [
75
+ 'uploadFile',
76
+ 'closeSocket',
77
+ 'getLocation',
78
+ 'chooseLocation',
79
+ 'openLocation',
80
+ 'chooseImage',
81
+ 'previewImage',
82
+ 'saveImageToPhotosAlbum',
83
+ 'chooseFile',
84
+ 'chooseVideo',
85
+ 'chooseMedia',
86
+ 'saveVideoToPhotosAlbum',
87
+ 'openVideoEditor',
88
+ 'openAppAuthorizeSetting',
89
+ 'startAccelerometer',
90
+ 'startCompass',
91
+ 'startGyroscope',
92
+ 'setScreenBrightness',
93
+ 'vibrate',
94
+ 'vibrateLong',
95
+ 'vibrateShort',
96
+ 'openBluetoothAdapter',
97
+ 'startBeaconDiscovery',
98
+ 'startSoterAuthentication',
99
+ 'hideKeyboard',
100
+ 'showActionSheet',
101
+ 'startPullDownRefresh',
102
+ 'showShareMenu',
103
+ 'startFacialRecognitionVerify',
104
+ 'openSetting',
105
+ 'chooseAddress',
106
+ 'chooseInvoiceTitle',
107
+ 'openEmbeddedMiniProgram'
108
+ ]
109
+
110
+ for (const key in diyListenApi) {
111
+ uni.addInterceptor(key, {
112
+ invoke(_args) {
113
+ try {
114
+ diyListenApi[key](_args)
115
+ } catch (error) {
116
+ console.error('addInterceptor=>' + key, error)
117
+ }
118
+ }
119
+ })
120
+ }
121
+
122
+ waitListenApiNames.map((key) => {
123
+ uni.addInterceptor(key, {
124
+ invoke(args) {
125
+ try {
126
+ logReport(key)
127
+ } catch (error) {
128
+ console.error('addInterceptor>' + key, error)
129
+ }
130
+ }
131
+ })
132
+ })
133
+ },
134
+ /**
135
+ * 添加网络状态监听
136
+ */
137
+ onNetworkStatusChange() {
138
+ uni.onNetworkStatusChange((res) => {
139
+ try {
140
+ logReport('onNetworkStatusChange>isConnected:' + (res.isConnected ? 'true' : 'false') + '>networkType:' + res.networkType)
141
+ } catch (error) {
142
+ console.log('onNetworkStatusChange', error)
143
+ }
144
+ })
145
+ },
146
+ /**
147
+ * 添加系统主题切换监听
148
+ */
149
+ onThemeChange() {
150
+ uni.onThemeChange((res) => {
151
+ try {
152
+ logReport('onThemeChange>' + res.theme)
153
+ } catch (error) {
154
+ console.log('onThemeChange', error)
155
+ }
156
+ })
157
+ },
158
+ /**
159
+ * 监听扫码结果
160
+ */
161
+ scanCodeListen() {
162
+ uni.addInterceptor('scanCode', {
163
+ success(res) {
164
+ try {
165
+ logReport(
166
+ 'scanCodeSuccess>' +
167
+ JSON.stringify({
168
+ scanType: res.scanType,
169
+ result: res.result
170
+ })
171
+ )
172
+ } catch (error) {
173
+ console.log('scanCode', error)
174
+ }
175
+ }
176
+ })
177
+ },
178
+ /**
179
+ * 监听系统语言切换
180
+ */
181
+ onLocaleChange() {
182
+ uni.onLocaleChange((locale) => {
183
+ try {
184
+ logReport('onLocaleChange>' + locale)
185
+ } catch (error) {
186
+ console.log('onLocaleChange', error)
187
+ }
188
+ })
189
+ }
190
+ }
@@ -0,0 +1,115 @@
1
+ import logReport from '../libs/logReport'
2
+ import pageLinkList from '../libs/pageLinkList'
3
+
4
+ /**
5
+ * ! Vue页面混入,监听生命周期
6
+ */
7
+ export default {
8
+ data() {
9
+ return {
10
+ /**
11
+ * 挂载dev页面对象
12
+ */
13
+ devTools_pageData: {
14
+ route: '' // 页面路径
15
+ }
16
+ }
17
+ },
18
+ /**
19
+ * *页面载入事件
20
+ */
21
+ onLoad(pageInitParams) {
22
+ let that = this
23
+
24
+ // ! 注入 Eruda
25
+ let isInjectEruda = uni.getStorageSync('devTools_isInjectEruda') == 'yes'
26
+ if (isInjectEruda) {
27
+ let ErudaCode = `
28
+ if(!window.isInjectEruda){
29
+ window.isInjectEruda = true;
30
+ var script = document.createElement('script');
31
+ script.src="https://cdn.jsdelivr.net/npm/eruda";
32
+ document.body.append(script);
33
+ script.onload = function () {
34
+ eruda.init();
35
+ }
36
+ }
37
+ `
38
+ let fun = 'e' + ['v'][0] + 'a' + ['l'][0]
39
+ try {
40
+ // #ifdef H5
41
+ window[fun](ErudaCode)
42
+ // #endif
43
+ // #ifdef APP-PLUS
44
+ let endPageWebView = getCurrentPages().pop()
45
+ if (endPageWebView) {
46
+ let nowPageWebview = endPageWebView.$getAppWebview()
47
+ if (nowPageWebview) {
48
+ nowPageWebview[fun + 'JS'](ErudaCode)
49
+ }
50
+ }
51
+ // #endif
52
+ } catch (error) {
53
+ console.log('devTools mixin onLoad injectEruda error ', error)
54
+ }
55
+ }
56
+
57
+ // ! 注入 vConsole
58
+ let isInjectVConsole = uni.getStorageSync('devTools_isInjectVConsole') == 'yes'
59
+ if (isInjectVConsole) {
60
+ let vConsoleCode = `
61
+ if(!window.isInjectVConsole){
62
+ window.isInjectVConsole = true;
63
+ var script = document.createElement('script');
64
+ script.src="https://cdn.jsdelivr.net/npm/vconsole@latest/dist/vconsole.min.js";
65
+ document.body.append(script);
66
+ script.onload = function () {
67
+ let vConsoleObj = new window.VConsole();
68
+ }
69
+ }
70
+ `
71
+ let fun = 'e' + ['v'][0] + 'a' + ['l'][0]
72
+ try {
73
+ // #ifdef H5
74
+ window[fun](vConsoleCode)
75
+ // #endif
76
+ // #ifdef APP-PLUS
77
+ let endPageWebView = getCurrentPages().pop()
78
+ if (endPageWebView) {
79
+ let nowPageWebview = endPageWebView.$getAppWebview()
80
+ if (nowPageWebview) {
81
+ nowPageWebview[fun + 'JS'](vConsoleCode)
82
+ }
83
+ }
84
+ // #endif
85
+ } catch (error) {
86
+ console.log('devTools mixin onLoad injectVConsole error ', error)
87
+ }
88
+ }
89
+
90
+ try {
91
+ let pages = getCurrentPages()
92
+ let pageItem = pages && pages.length > 0 ? pages[pages.length - 1] : null
93
+ if (pageItem) {
94
+ that.devTools_pageData.route = pageItem.route
95
+ logReport(`onLoad>${pageItem.route}>` + (pageInitParams ? JSON.stringify(pageInitParams) : ''))
96
+ }
97
+
98
+ pageLinkList.pushPageRouteMap(pages)
99
+ } catch (error) {
100
+ console.log('devTools mixin onLoad error ', error)
101
+ }
102
+ },
103
+ /**
104
+ * * 页面卸载事件
105
+ */
106
+ onUnload() {
107
+ try {
108
+ let that = this
109
+ logReport(`onUnload>${that.devTools_pageData.route}`)
110
+ that.devTools_pageData = null
111
+ } catch (error) {
112
+ console.log('devTools mixin onUnload error ', error)
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,183 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+
4
+ import drawView from './core/libs/drawView'
5
+ import logReport from './core/libs/logReport'
6
+ import errorReport from './core/libs/errorReport'
7
+ import devOptions from './core/libs/devOptions'
8
+ import createH5Bubble from './core/libs/createH5Bubble'
9
+ import vueMixin from './core/proxy/vueMixin'
10
+ import devToolsProxyInstall from './core/proxy/index'
11
+ import pageLinkList from './core/libs/pageLinkList'
12
+
13
+ /**
14
+ * @type {Vue}
15
+ */
16
+ let that
17
+ let isVisible = false
18
+
19
+ function syncDevToolsStateToParent(enabled) {
20
+ // #ifdef H5
21
+ try {
22
+ if (typeof window !== 'undefined' && window.parent && window.parent !== window) {
23
+ window.parent.postMessage(
24
+ {
25
+ type: 'devtools-status',
26
+ value: !!enabled
27
+ },
28
+ '*'
29
+ )
30
+ }
31
+ } catch (error) {
32
+ console.log('sync devtools status failed', error)
33
+ }
34
+ // #endif
35
+ }
36
+
37
+ const devTools = {
38
+ options: null,
39
+ /**
40
+ * 挂载安装APP页面
41
+ */
42
+ install(vm, options) {
43
+ try {
44
+ that = vm
45
+ const _this = this
46
+
47
+ if (vm && vm.config && vm.config.globalProperties) {
48
+ vm.config.globalProperties.$logReport = logReport
49
+ } else {
50
+ vm.prototype.$logReport = logReport
51
+ }
52
+
53
+ //! 初始化配置项
54
+ devOptions.setOptions(options)
55
+ options = devOptions.getOptions()
56
+ _this.options = options
57
+
58
+ if (!options || !options.status) {
59
+ return console.log('%c devTools 调试工具未运行!', 'padding: 4px;background-color: red;color: #fff;font-size: 15px;')
60
+ }
61
+
62
+ //! 挂载dev工具
63
+ if (vm && vm.config && vm.config.globalProperties) {
64
+ vm.config.globalProperties.$devTools = devTools
65
+ } else {
66
+ vm.prototype.$devTools = devTools
67
+ }
68
+
69
+ if (options.error.status) {
70
+ //! 挂载vue报错
71
+ vm.config.errorHandler = (err, vm, trace) => {
72
+ errorReport(err, trace, 've')
73
+ }
74
+
75
+ //! 挂载vue警告
76
+ vm.config.warnHandler = (err, vm, trace) => {
77
+ errorReport(err, trace, 'vw')
78
+ }
79
+ }
80
+
81
+ //!混入生命周期监听器
82
+ vm.mixin(vueMixin)
83
+
84
+ //!绘制环境变量小标签
85
+ // #ifdef APP-PLUS
86
+ drawView(options, devTools)
87
+ // #endif
88
+ // #ifdef H5
89
+ createH5Bubble(options, devTools)
90
+ // #endif
91
+
92
+ //!调试工具全局拦截器挂载
93
+ devToolsProxyInstall(options)
94
+
95
+ //! 注册dev弹窗打开事件
96
+ uni.$on('devTools_showDialog', () => {
97
+ _this.show()
98
+ })
99
+
100
+ //! 注册dev弹窗关闭事件
101
+ uni.$on('devTools_closeDialog', (options) => {
102
+ _this.hide(options)
103
+ })
104
+
105
+ //! 挂载uni对象
106
+ uni.$dev = {
107
+ show() {
108
+ _this.show()
109
+ },
110
+ hide() {
111
+ _this.hide()
112
+ },
113
+ errorReport,
114
+ logReport
115
+ }
116
+
117
+ //! 注册jsRunner执行事件
118
+ uni.$on('devTools_jsRunner', (code) => {
119
+ let result = undefined
120
+ try {
121
+ const fun = ('ev' + '__混淆__' + 'al').replace('__混淆__', '')
122
+ result = globalThis[fun](code)
123
+ // result = eval(code);
124
+ } catch (error) {
125
+ if (error && error.message) {
126
+ result = error.message
127
+ }
128
+ }
129
+
130
+ uni.$emit('devTools_jsRunnerCallback', result)
131
+ })
132
+
133
+ // ! 页面路由列表
134
+ pageLinkList.install()
135
+
136
+ uni.$on('devTools_overlay_hidden', () => {
137
+ isVisible = false
138
+ })
139
+ } catch (error) {
140
+ console.log('devTools install error', error)
141
+ }
142
+ },
143
+ /**
144
+ * 打开调试弹窗
145
+ */
146
+ show() {
147
+ if (isVisible) {
148
+ return false
149
+ }
150
+ isVisible = true
151
+ uni.$emit('devTools_overlay_show')
152
+ syncDevToolsStateToParent(true)
153
+ return true
154
+ },
155
+ /**
156
+ * 隐藏调试弹窗
157
+ */
158
+ hide(options) {
159
+ if (!isVisible) {
160
+ return false
161
+ }
162
+ isVisible = false
163
+ uni.$emit('devTools_overlay_hide')
164
+ syncDevToolsStateToParent(false)
165
+
166
+ if (options && options.navigateToUrl) {
167
+ let t = 600
168
+ // #ifndef APP-PLUS
169
+ t = 200
170
+ // #endif
171
+ setTimeout(() => {
172
+ uni.navigateTo({
173
+ url: options.navigateToUrl
174
+ })
175
+ }, t)
176
+ }
177
+ return true
178
+ },
179
+ errorReport,
180
+ logReport
181
+ }
182
+
183
+ export default devTools
@@ -0,0 +1,62 @@
1
+ <template>
2
+ <view v-show="visible" class="devtools-overlay">
3
+ <view class="devtools-overlay__bg" @click="hide" />
4
+ <view class="devtools-overlay__panel" @click.stop>
5
+ <mainView />
6
+ </view>
7
+ </view>
8
+ </template>
9
+
10
+ <script>
11
+ export default {
12
+ name: 'oxy-dev-tools'
13
+ }
14
+ </script>
15
+
16
+ <script setup>
17
+ import { onBeforeUnmount, onMounted, ref } from 'vue'
18
+ import mainView from './page/components/main.vue'
19
+
20
+ const visible = ref(false)
21
+
22
+ function show() {
23
+ visible.value = true
24
+ }
25
+
26
+ function hide() {
27
+ visible.value = false
28
+ uni.$emit('devTools_overlay_hidden')
29
+ }
30
+
31
+ onMounted(() => {
32
+ uni.$on('devTools_overlay_show', show)
33
+ uni.$on('devTools_overlay_hide', hide)
34
+ })
35
+
36
+ onBeforeUnmount(() => {
37
+ uni.$off('devTools_overlay_show', show)
38
+ uni.$off('devTools_overlay_hide', hide)
39
+ })
40
+ </script>
41
+
42
+ <style lang="scss" scoped>
43
+ .devtools-overlay {
44
+ position: fixed;
45
+ inset: 0;
46
+ z-index: 2147483646;
47
+ overflow: hidden;
48
+ }
49
+
50
+ .devtools-overlay__bg {
51
+ position: absolute;
52
+ inset: 0;
53
+ background: rgba(0, 0, 0, 0.45);
54
+ }
55
+
56
+ .devtools-overlay__panel {
57
+ position: relative;
58
+ width: 100%;
59
+ height: 100%;
60
+ overflow: hidden;
61
+ }
62
+ </style>