oxy-uni-ui 2.1.1 → 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 (183) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +13 -2
  3. package/components/oxy-checkbox/index.scss +37 -2
  4. package/components/oxy-sort-button/index.scss +3 -4
  5. package/components/oxy-tag/index.scss +157 -17
  6. package/components/oxy-tag/oxy-tag.vue +14 -2
  7. package/components/oxy-tag/types.ts +9 -0
  8. package/dev-tools.ts +2 -0
  9. package/devTools/components/DevToolsOverlay.vue +56 -0
  10. package/devTools/components/DevToolsUiHost.vue +589 -0
  11. package/devTools/config.js +55 -0
  12. package/devTools/core/components/mpDevBubble.vue +174 -0
  13. package/devTools/core/libs/createH5Bubble.js +156 -0
  14. package/devTools/core/libs/devCache.js +151 -0
  15. package/devTools/core/libs/devOptions.js +163 -0
  16. package/devTools/core/libs/devUi.js +219 -0
  17. package/devTools/core/libs/drawView.js +140 -0
  18. package/devTools/core/libs/errorReport.js +64 -0
  19. package/devTools/core/libs/jsonCompress.js +334 -0
  20. package/devTools/core/libs/logReport.js +59 -0
  21. package/devTools/core/libs/pageLinkList.js +125 -0
  22. package/devTools/core/libs/timeFormat.js +94 -0
  23. package/devTools/core/proxy/console.js +430 -0
  24. package/devTools/core/proxy/index.js +36 -0
  25. package/devTools/core/proxy/request.js +495 -0
  26. package/devTools/core/proxy/storage.js +113 -0
  27. package/devTools/core/proxy/uniBus.js +153 -0
  28. package/devTools/core/proxy/uniListen.js +192 -0
  29. package/devTools/core/proxy/vueMixin.js +120 -0
  30. package/devTools/index.js +168 -0
  31. package/devTools/page/components/bottomTools.vue +1046 -0
  32. package/devTools/page/components/dialog/addStorage.vue +204 -0
  33. package/devTools/page/components/dialog/createDir.vue +366 -0
  34. package/devTools/page/components/dialog/editDialog.vue +192 -0
  35. package/devTools/page/components/dialog/routeDialog.vue +184 -0
  36. package/devTools/page/components/dialog/sendRequest.vue +603 -0
  37. package/devTools/page/components/dialog/textFileEditDialog.vue +391 -0
  38. package/devTools/page/components/libs/appDelDir.js +86 -0
  39. package/devTools/page/components/libs/dirReader.js +248 -0
  40. package/devTools/page/components/libs/fileSize.js +15 -0
  41. package/devTools/page/components/libs/getRuntimeInfo.js +134 -0
  42. package/devTools/page/components/listItem/consoleItem.vue +314 -0
  43. package/devTools/page/components/listItem/errorItem.vue +292 -0
  44. package/devTools/page/components/listItem/fileSysItem.vue +533 -0
  45. package/devTools/page/components/listItem/infoList.vue +100 -0
  46. package/devTools/page/components/listItem/jsRunnerItem.vue +255 -0
  47. package/devTools/page/components/listItem/logItem.vue +193 -0
  48. package/devTools/page/components/listItem/networkItem.vue +398 -0
  49. package/devTools/page/components/listItem/objectAnalysis.vue +651 -0
  50. package/devTools/page/components/listItem/pages.vue +319 -0
  51. package/devTools/page/components/listItem/routeItem.vue +153 -0
  52. package/devTools/page/components/listItem/setting.vue +734 -0
  53. package/devTools/page/components/listItem/storageList.vue +681 -0
  54. package/devTools/page/components/listItem/tools.vue +315 -0
  55. package/devTools/page/components/listItem/vuexList.vue +599 -0
  56. package/devTools/page/components/main.vue +1867 -0
  57. package/devTools/page/components/mixins/animationControl.js +91 -0
  58. package/devTools/page/components/mixins/mp.js +83 -0
  59. package/devTools/page/components/ui/btnTabs.vue +90 -0
  60. package/devTools/page/components/ui/codeHisPicker.vue +172 -0
  61. package/devTools/page/components/ui/h5Cell.vue +13 -0
  62. package/devTools/page/components/ui/menuBtn.vue +94 -0
  63. package/devTools/page/components/ui/mobileSwiperScroll.vue +74 -0
  64. package/devTools/page/components/ui/requestSpeedLimit.vue +52 -0
  65. package/devTools/page/components/ui/requestTimeoutMock.vue +55 -0
  66. package/devTools/page/components/ui/subTitleBar.vue +101 -0
  67. package/devTools/page/static/copy.png +0 -0
  68. package/devTools/page/static/delete.png +0 -0
  69. package/devTools/page/static/fileSys/AI.png +0 -0
  70. package/devTools/page/static/fileSys/DWG.png +0 -0
  71. package/devTools/page/static/fileSys/EXE.png +0 -0
  72. package/devTools/page/static/fileSys/GIF.png +0 -0
  73. package/devTools/page/static/fileSys/HTML.png +0 -0
  74. package/devTools/page/static/fileSys/PSD.png +0 -0
  75. package/devTools/page/static/fileSys/RVT.png +0 -0
  76. package/devTools/page/static/fileSys/SKP.png +0 -0
  77. package/devTools/page/static/fileSys/SVG.png +0 -0
  78. package/devTools/page/static/fileSys/excel.png +0 -0
  79. package/devTools/page/static/fileSys/pdf.png +0 -0
  80. package/devTools/page/static/fileSys/pptl.png +0 -0
  81. package/devTools/page/static/fileSys/shipin.png +0 -0
  82. package/devTools/page/static/fileSys/tupian.png +0 -0
  83. package/devTools/page/static/fileSys/txt.png +0 -0
  84. package/devTools/page/static/fileSys/weizhiwenjian.png +0 -0
  85. package/devTools/page/static/fileSys/wenjianjia.png +0 -0
  86. package/devTools/page/static/fileSys/word.png +0 -0
  87. package/devTools/page/static/fileSys/yasuo.png +0 -0
  88. package/devTools/page/static/fileSys/yinpin.png +0 -0
  89. package/devTools/page/static/fold.png +0 -0
  90. package/devTools/page/static/menu.png +0 -0
  91. package/devTools/page/static/refresh.png +0 -0
  92. package/devTools/page/static/unfold.png +0 -0
  93. package/devTools/tools.vue +25 -0
  94. package/devTools/type/devTools.d.ts +406 -0
  95. package/oxy-dev-tools/components/DevToolsUiHost.vue +555 -0
  96. package/oxy-dev-tools/config.js +61 -0
  97. package/oxy-dev-tools/core/components/mpDevBubble.vue +176 -0
  98. package/oxy-dev-tools/core/libs/createH5Bubble.js +156 -0
  99. package/oxy-dev-tools/core/libs/devCache.js +149 -0
  100. package/oxy-dev-tools/core/libs/devOptions.js +160 -0
  101. package/oxy-dev-tools/core/libs/devUi.js +219 -0
  102. package/oxy-dev-tools/core/libs/drawView.js +144 -0
  103. package/oxy-dev-tools/core/libs/errorReport.js +60 -0
  104. package/oxy-dev-tools/core/libs/jsonCompress.js +328 -0
  105. package/oxy-dev-tools/core/libs/logReport.js +55 -0
  106. package/oxy-dev-tools/core/libs/pageLinkList.js +121 -0
  107. package/oxy-dev-tools/core/libs/timeFormat.js +93 -0
  108. package/oxy-dev-tools/core/proxy/console.js +398 -0
  109. package/oxy-dev-tools/core/proxy/index.js +33 -0
  110. package/oxy-dev-tools/core/proxy/request.js +473 -0
  111. package/oxy-dev-tools/core/proxy/storage.js +96 -0
  112. package/oxy-dev-tools/core/proxy/uniBus.js +148 -0
  113. package/oxy-dev-tools/core/proxy/uniListen.js +190 -0
  114. package/oxy-dev-tools/core/proxy/vueMixin.js +115 -0
  115. package/oxy-dev-tools/index.ts +183 -0
  116. package/oxy-dev-tools/oxy-dev-tools.vue +62 -0
  117. package/oxy-dev-tools/page/components/bottomTools.vue +933 -0
  118. package/oxy-dev-tools/page/components/dialog/addStorage.vue +184 -0
  119. package/oxy-dev-tools/page/components/dialog/createDir.vue +352 -0
  120. package/oxy-dev-tools/page/components/dialog/editDialog.vue +178 -0
  121. package/oxy-dev-tools/page/components/dialog/routeDialog.vue +170 -0
  122. package/oxy-dev-tools/page/components/dialog/sendRequest.vue +530 -0
  123. package/oxy-dev-tools/page/components/dialog/textFileEditDialog.vue +379 -0
  124. package/oxy-dev-tools/page/components/libs/appDelDir.js +77 -0
  125. package/oxy-dev-tools/page/components/libs/dirReader.js +239 -0
  126. package/oxy-dev-tools/page/components/libs/fileSize.js +15 -0
  127. package/oxy-dev-tools/page/components/libs/getRuntimeInfo.js +132 -0
  128. package/oxy-dev-tools/page/components/listItem/consoleItem.vue +292 -0
  129. package/oxy-dev-tools/page/components/listItem/errorItem.vue +268 -0
  130. package/oxy-dev-tools/page/components/listItem/fileSysItem.vue +511 -0
  131. package/oxy-dev-tools/page/components/listItem/infoList.vue +89 -0
  132. package/oxy-dev-tools/page/components/listItem/jsRunnerItem.vue +236 -0
  133. package/oxy-dev-tools/page/components/listItem/logItem.vue +185 -0
  134. package/oxy-dev-tools/page/components/listItem/networkItem.vue +362 -0
  135. package/oxy-dev-tools/page/components/listItem/objectAnalysis.vue +642 -0
  136. package/oxy-dev-tools/page/components/listItem/pages.vue +285 -0
  137. package/oxy-dev-tools/page/components/listItem/routeItem.vue +140 -0
  138. package/oxy-dev-tools/page/components/listItem/setting.vue +687 -0
  139. package/oxy-dev-tools/page/components/listItem/storageList.vue +623 -0
  140. package/oxy-dev-tools/page/components/listItem/tools.vue +273 -0
  141. package/oxy-dev-tools/page/components/listItem/vuexList.vue +559 -0
  142. package/oxy-dev-tools/page/components/main.vue +1824 -0
  143. package/oxy-dev-tools/page/components/mixins/animationControl.js +80 -0
  144. package/oxy-dev-tools/page/components/mixins/mp.js +76 -0
  145. package/oxy-dev-tools/page/components/ui/btnTabs.vue +77 -0
  146. package/oxy-dev-tools/page/components/ui/codeHisPicker.vue +161 -0
  147. package/oxy-dev-tools/page/components/ui/h5Cell.vue +13 -0
  148. package/oxy-dev-tools/page/components/ui/menuBtn.vue +87 -0
  149. package/oxy-dev-tools/page/components/ui/mobileSwiperScroll.vue +71 -0
  150. package/oxy-dev-tools/page/components/ui/requestSpeedLimit.vue +47 -0
  151. package/oxy-dev-tools/page/components/ui/requestTimeoutMock.vue +50 -0
  152. package/oxy-dev-tools/page/components/ui/subTitleBar.vue +87 -0
  153. package/oxy-dev-tools/page/static/copy.png +0 -0
  154. package/oxy-dev-tools/page/static/delete.png +0 -0
  155. package/oxy-dev-tools/page/static/fileSys/AI.png +0 -0
  156. package/oxy-dev-tools/page/static/fileSys/DWG.png +0 -0
  157. package/oxy-dev-tools/page/static/fileSys/EXE.png +0 -0
  158. package/oxy-dev-tools/page/static/fileSys/GIF.png +0 -0
  159. package/oxy-dev-tools/page/static/fileSys/HTML.png +0 -0
  160. package/oxy-dev-tools/page/static/fileSys/PSD.png +0 -0
  161. package/oxy-dev-tools/page/static/fileSys/RVT.png +0 -0
  162. package/oxy-dev-tools/page/static/fileSys/SKP.png +0 -0
  163. package/oxy-dev-tools/page/static/fileSys/SVG.png +0 -0
  164. package/oxy-dev-tools/page/static/fileSys/excel.png +0 -0
  165. package/oxy-dev-tools/page/static/fileSys/pdf.png +0 -0
  166. package/oxy-dev-tools/page/static/fileSys/pptl.png +0 -0
  167. package/oxy-dev-tools/page/static/fileSys/shipin.png +0 -0
  168. package/oxy-dev-tools/page/static/fileSys/tupian.png +0 -0
  169. package/oxy-dev-tools/page/static/fileSys/txt.png +0 -0
  170. package/oxy-dev-tools/page/static/fileSys/weizhiwenjian.png +0 -0
  171. package/oxy-dev-tools/page/static/fileSys/wenjianjia.png +0 -0
  172. package/oxy-dev-tools/page/static/fileSys/word.png +0 -0
  173. package/oxy-dev-tools/page/static/fileSys/yasuo.png +0 -0
  174. package/oxy-dev-tools/page/static/fileSys/yinpin.png +0 -0
  175. package/oxy-dev-tools/page/static/fold.png +0 -0
  176. package/oxy-dev-tools/page/static/menu.png +0 -0
  177. package/oxy-dev-tools/page/static/refresh.png +0 -0
  178. package/oxy-dev-tools/page/static/unfold.png +0 -0
  179. package/oxy-dev-tools/tools.vue +22 -0
  180. package/oxy-dev-tools/type/devTools.d.ts +406 -0
  181. package/package.json +1 -1
  182. package/tags.json +1 -1
  183. 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
+ }