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,1824 @@
1
+ <template>
2
+ <view class="devTools">
3
+ <view @click.stop ref="panel" class="panel" :style="[panelStyle]">
4
+ <view class="head">
5
+ <scroll-view
6
+ :scroll-x="true"
7
+ :scroll-y="false"
8
+ scroll-with-animation
9
+ :scroll-left="tabScrollLeft"
10
+ class="tabList showScrollbars"
11
+ :class="tabList[tabIndex].canRefreshing ? 'tab-with-actions' : ''"
12
+ :show-scrollbar="false"
13
+ @scroll="onTabListScroll"
14
+ @mousedown="onTabMouseDown"
15
+ @mousemove="onTabMouseMove"
16
+ @mouseup="onTabMouseUp"
17
+ @mouseleave="onTabMouseUp"
18
+ @touchstart="onTabTouchStart"
19
+ @touchmove="onTabTouchMove"
20
+ @touchend="onTabTouchEnd"
21
+ @touchcancel="onTabTouchEnd"
22
+ >
23
+ <view class="tabListInner">
24
+ <view v-for="(item, index) in tabList" :key="index" class="tabItem" @click="onTabClick(index)">
25
+ <view class="tabTextWrap">
26
+ <text class="tabText" :class="index == tabIndex ? 'active' : ''">
27
+ {{ item.title }}
28
+ </text>
29
+ <text class="tabDesc" :class="index == tabIndex ? 'active' : ''">
30
+ {{ item.desc }}
31
+ </text>
32
+ </view>
33
+ </view>
34
+ </view>
35
+ </scroll-view>
36
+ <view class="headActions">
37
+ <view v-if="tabList[tabIndex].canRefreshing" class="headRefresh" @click="getPage(true)">
38
+ <view class="line"></view>
39
+ <text class="headRefreshIcon" :class="tabList[tabIndex].isRefreshing ? 'refreshing' : ''">&#8635;</text>
40
+ </view>
41
+ <view class="close" @click="$devTools.hide()">
42
+ <view class="line"></view>
43
+ <text class="icon">×</text>
44
+ </view>
45
+ </view>
46
+ </view>
47
+
48
+ <mobileSwiperScroll
49
+ :scrollHeight="listHeight"
50
+ :tabIndex="tabIndex"
51
+ :tabList="tabList"
52
+ @tabIndexChange="tabIndex = $event"
53
+ ref="mobileSwiperScroll"
54
+ >
55
+ <template #default="{ item, index }">
56
+ <template v-if="item.title == 'Tools'">
57
+ <cell>
58
+ <tools ref="tools" @goOpenRequest="$refs.sendRequest.show()" />
59
+ </cell>
60
+ </template>
61
+ <template v-if="item.title == 'Error'">
62
+ <cell v-for="(_item, _index) in item.data" :key="_index">
63
+ <errorItem :item="_item" :key="_index" />
64
+ </cell>
65
+ </template>
66
+ <template v-if="item.title == 'Console'">
67
+ <cell v-for="(_item, _index) in item.data" :key="_index">
68
+ <consoleItem :item="_item" :key="_index" />
69
+ </cell>
70
+ </template>
71
+ <template v-if="item.title == 'Network'">
72
+ <cell v-for="(_item, _index) in item.data" :key="_index">
73
+ <networkItem
74
+ :item="_item"
75
+ :key="_index"
76
+ @goSendRequest="$refs.sendRequest.show($event, true)"
77
+ @goOpenRequest="$refs.sendRequest.show($event)"
78
+ />
79
+ </cell>
80
+ </template>
81
+ <template v-if="item.title == 'Storage'">
82
+ <cell>
83
+ <storageList ref="storageList" />
84
+ </cell>
85
+ </template>
86
+ <template v-if="item.title == 'Pages'">
87
+ <cell>
88
+ <subTitleBar :isOpen="item.isShowPages" title="当前页面栈" @click="pagesShowChange('isShowPages')" />
89
+ </cell>
90
+ <cell>
91
+ <pages ref="pages" :isShow="item.isShowPages" />
92
+ </cell>
93
+ <cell>
94
+ <view class="cellDivisionLine"></view>
95
+ </cell>
96
+ <cell>
97
+ <subTitleBar :isOpen="item.isShowRouteList" title="全部路由" @click="pagesShowChange('isShowRouteList')" />
98
+ </cell>
99
+ <template v-if="item.isShowRouteList">
100
+ <cell v-for="_item in item.routeList" :key="_item.path">
101
+ <routeItem :item="_item" />
102
+ </cell>
103
+ </template>
104
+ <cell>
105
+ <view class="cellDivisionLine"></view>
106
+ </cell>
107
+ </template>
108
+ <template v-if="item.title == 'Vuex'">
109
+ <cell>
110
+ <vuexList ref="vuexList" :stateType="tabList[tabList.findIndex((x) => x.title == 'Vuex')].stateType" />
111
+ </cell>
112
+ </template>
113
+ <template v-if="item.title == 'Logs'">
114
+ <cell v-for="(_item, _index) in item.data" :key="_index">
115
+ <logItem :item="_item" :key="_index" />
116
+ </cell>
117
+ </template>
118
+ <template v-if="item.title == 'Info'">
119
+ <cell>
120
+ <infoList ref="infoList" />
121
+ </cell>
122
+ </template>
123
+ <template v-if="item.title == 'UniBus'">
124
+ <cell>
125
+ <subTitleBar :isOpen="item.isShowCount" title="事件统计" @click="pagesShowChange('isShowCount')" />
126
+ </cell>
127
+ <template v-if="item.isShowCount">
128
+ <cell v-for="_item in item.countList" :key="_item.e">
129
+ <view class="eventItem">
130
+ <view class="eventHead">
131
+ <text class="eventName">name: {{ _item.e }}</text>
132
+ <view class="eventActionBtn" @click.stop="busCountMenu(_item)">
133
+ <text class="eventActionText">更多</text>
134
+ </view>
135
+ </view>
136
+ <view class="eventCount">
137
+ <text v-if="item.filterType == '' || item.filterType == 'on'" class="eventCountItem">on: {{ _item.on }}</text>
138
+ <text v-if="item.filterType == '' || item.filterType == 'emit'" class="eventCountItem">emit: {{ _item.emit }}</text>
139
+ <text v-if="item.filterType == '' || item.filterType == 'once'" class="eventCountItem">once: {{ _item.once }}</text>
140
+ <text v-if="item.filterType == '' || item.filterType == 'off'" class="eventCountItem">off: {{ _item.off }}</text>
141
+ </view>
142
+ </view>
143
+ </cell>
144
+ </template>
145
+ <cell>
146
+ <view class="cellDivisionLine"></view>
147
+ </cell>
148
+ <cell>
149
+ <subTitleBar :isOpen="item.isShowLog" title="执行记录" @click="pagesShowChange('isShowLog')" />
150
+ </cell>
151
+ <template v-if="item.isShowLog">
152
+ <cell v-for="(_item, _index) in item.logList" :key="_index">
153
+ <view class="eventLogItem">
154
+ <text class="logText">{{ _item.e }}</text>
155
+ <view class="eventLogFoot">
156
+ <text class="logTime">{{ _item.date }}</text>
157
+ <view class="eventActionBtn" @click.stop="busLogMenu(_item)">
158
+ <text class="eventActionText">更多</text>
159
+ </view>
160
+ </view>
161
+ </view>
162
+ </cell>
163
+ </template>
164
+ <cell>
165
+ <view class="cellDivisionLine"></view>
166
+ </cell>
167
+ </template>
168
+ <template v-if="item.title == 'FileSys'">
169
+ <!-- #ifdef APP-PLUS || MP-WEIXIN -->
170
+ <cell v-for="(_item, _index) in item.data" :key="_index">
171
+ <fileSysItem
172
+ :item="_item"
173
+ :key="_index"
174
+ :dirType="item.dirType"
175
+ :dirList="item.dirList"
176
+ @goChildDir="goChildDir"
177
+ @getPage="getPage"
178
+ @editDirName="editDirName"
179
+ @openEditFileDialog="($event) => $refs.textFileEditDialog.show($event)"
180
+ />
181
+ </cell>
182
+ <cell v-if="item.data.length == 0 || (item.data.length == 1 && item.data[0].type == 'back')">
183
+ <view class="devEmpty">
184
+ <text class="devEmptyText">空空如也</text>
185
+ </view>
186
+ </cell>
187
+ <!-- #endif -->
188
+ <!-- #ifndef APP-PLUS || MP-WEIXIN -->
189
+ <cell>
190
+ <view class="listCenterView">
191
+ <text class="listCenterText">该平台无FileSys文件管理</text>
192
+ </view>
193
+ </cell>
194
+ <!-- #endif -->
195
+ </template>
196
+ <template v-if="item.title == 'Setting'">
197
+ <cell>
198
+ <settingView ref="settingView" />
199
+ </cell>
200
+ </template>
201
+
202
+ <template v-if="item.title == 'JsRunner'">
203
+ <!-- #ifdef APP-PLUS || H5 -->
204
+ <cell v-for="(_item, _index) in item.data" :key="_index">
205
+ <jsRunnerItem :item="_item" :key="_index" />
206
+ </cell>
207
+ <cell v-if="item.data.length == 0">
208
+ <view class="devEmpty">
209
+ <text class="devEmptyText">动态执行JS代码</text>
210
+ </view>
211
+ </cell>
212
+ <!-- #endif -->
213
+ <!-- #ifndef APP-PLUS || H5 -->
214
+ <cell>
215
+ <view class="listCenterView">
216
+ <text class="listCenterText">该平台不支持该功能</text>
217
+ </view>
218
+ </cell>
219
+ <!-- #endif -->
220
+ </template>
221
+
222
+ <template v-if="item.isLongList">
223
+ <cell v-if="!item.isLoadAll && item.data.length == 30">
224
+ <view class="loadAll" @click="showListAll">
225
+ <image class="loadAllFold" src="../static/unfold.png" />
226
+ <text class="loadAllText">展示全部数据</text>
227
+ <image class="loadAllFold" src="../static/unfold.png" />
228
+ </view>
229
+ </cell>
230
+
231
+ <cell v-if="item.type == 'success' && item.data.length == 0">
232
+ <view class="devEmpty">
233
+ <text class="devEmptyText">空空如也</text>
234
+ </view>
235
+ </cell>
236
+
237
+ <cell v-if="(item.type == 'loading' || item.type == 'loading') && item.data.length == 0">
238
+ <view class="devEmpty">
239
+ <text class="devEmptyText">加载中</text>
240
+ </view>
241
+ </cell>
242
+ </template>
243
+
244
+ <cell>
245
+ <view
246
+ :style="{
247
+ height: bottomToolsExtraBottomPx
248
+ }"
249
+ ></view>
250
+ </cell>
251
+ </template>
252
+ </mobileSwiperScroll>
253
+ </view>
254
+
255
+ <bottomTools
256
+ :tabIndex="tabIndex"
257
+ :tabTitle="tabTitle"
258
+ :options="bottomToolsOptions"
259
+ :isShow="isShowBottomTools && !isValueViewerOpen"
260
+ @update:panelExtraBottomPx="bottomToolsExtraBottomPx = $event"
261
+ :stateType="tabList[tabList.findIndex((x) => x.title == 'Vuex')].stateType"
262
+ @filterTypeChange="onFilterTypeChange"
263
+ @goChildDir="goChildDir"
264
+ @changeFileDirType="changeFileDirType"
265
+ @changeStorageType="changeStorageType"
266
+ @editDirName="editDirName"
267
+ @getPage="getPage"
268
+ @runJs="runJs"
269
+ @emptyCodeHis="emptyCodeHis"
270
+ @changeStateType="changeStateType"
271
+ />
272
+
273
+ <editDialog ref="editDialog" />
274
+
275
+ <sendRequest ref="sendRequest" />
276
+
277
+ <textFileEditDialog ref="textFileEditDialog" @getPage="getPage" />
278
+
279
+ <createDir ref="createDir" :dirList="fileSysTab.dirList" :dirType="fileSysTab.dirType" @getPage="getPage" />
280
+
281
+ <addStorage :storageType="storageTab.storageType" @getPage="getPage" />
282
+
283
+ <routeDialog />
284
+ <DevToolsUiHost />
285
+ </view>
286
+ </template>
287
+ <script>
288
+ import init from '../../index'
289
+ import consoleItem from './listItem/consoleItem.vue'
290
+ import infoList from './listItem/infoList.vue'
291
+ import storageList from './listItem/storageList.vue'
292
+ import tools from './listItem/tools.vue'
293
+ import vuexList from './listItem/vuexList.vue'
294
+ import animationControl from './mixins/animationControl'
295
+ import { timeFormat, timeFromNow } from '../../core/libs/timeFormat'
296
+ import devCache from '../../core/libs/devCache'
297
+ import networkItem from './listItem/networkItem.vue'
298
+ import pages from './listItem/pages.vue'
299
+ import logItem from './listItem/logItem.vue'
300
+ import errorItem from './listItem/errorItem.vue'
301
+ import mobileSwiperScroll from './ui/mobileSwiperScroll.vue'
302
+ import subTitleBar from './ui/subTitleBar.vue'
303
+ import sendRequest from './dialog/sendRequest.vue'
304
+ import bottomTools from './bottomTools.vue'
305
+ import dirReader from './libs/dirReader'
306
+ import fileSysItem from './listItem/fileSysItem.vue'
307
+ import fileSize from './libs/fileSize'
308
+ import textFileEditDialog from './dialog/textFileEditDialog.vue'
309
+ import createDir from './dialog/createDir.vue'
310
+ import editDialog from './dialog/editDialog.vue'
311
+ import addStorage from './dialog/addStorage.vue'
312
+ import settingView from './listItem/setting.vue'
313
+ import mp from './mixins/mp'
314
+ import jsRunnerItem from './listItem/jsRunnerItem.vue'
315
+ import routeItem from './listItem/routeItem.vue'
316
+ import routeDialog from './dialog/routeDialog.vue'
317
+ import pageLinkList from '../../core/libs/pageLinkList.js'
318
+ import devUi from '../../core/libs/devUi.js'
319
+ import DevToolsUiHost from '../../components/DevToolsUiHost.vue'
320
+ import h5Cell from './ui/h5Cell.vue'
321
+
322
+ export default {
323
+ mixins: [animationControl, mp],
324
+ components: {
325
+ mobileSwiperScroll,
326
+ consoleItem,
327
+ storageList,
328
+ vuexList,
329
+ tools,
330
+ infoList,
331
+ networkItem,
332
+ pages,
333
+ logItem,
334
+ errorItem,
335
+ subTitleBar,
336
+ sendRequest,
337
+ bottomTools,
338
+ fileSysItem,
339
+ textFileEditDialog,
340
+ createDir,
341
+ editDialog,
342
+ addStorage,
343
+ settingView,
344
+ jsRunnerItem,
345
+ routeItem,
346
+ routeDialog,
347
+ DevToolsUiHost,
348
+ cell: h5Cell
349
+ },
350
+ data() {
351
+ return {
352
+ tabLoading: true,
353
+ isValueViewerOpen: false,
354
+ bottomToolsExtraBottomPx: '80px',
355
+ tabIndex: 0,
356
+ tabScrollLeft: 0,
357
+ tabTouchStartX: 0,
358
+ tabTouchStartLeft: 0,
359
+ tabTouchDragging: false,
360
+ tabTouchMoved: false,
361
+ tabList: [
362
+ {
363
+ title: 'Pages', //标题
364
+ desc: '页面路由',
365
+ canRefreshing: true, //是否允许下拉刷新
366
+ isRefreshing: false, //下拉刷新状态
367
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
368
+ hasLoad: false,
369
+ isShowPages: true, //是否展示页面堆栈列表
370
+ isShowBottomTools: true, //显示底部工具栏
371
+ isShowRouteList: false, // 是否显示路由列表
372
+ routeList: [] //全部路由列表
373
+ },
374
+ {
375
+ title: 'Error', //标题
376
+ desc: '异常告警',
377
+ canRefreshing: true, //是否允许下拉刷新
378
+ isRefreshing: false, //下拉刷新状态
379
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
380
+ type: 'init', //列表状态
381
+ data: [], //数据条数
382
+ hasLoad: false,
383
+ isLongList: true, // 是否长列表
384
+ isLoadAll: false, //是否加载全部
385
+ filterType: '', //过滤类型
386
+ isShowBottomTools: true //显示底部工具栏
387
+ },
388
+ {
389
+ title: 'Console', //标题
390
+ desc: '日志输出',
391
+ canRefreshing: true, //是否允许下拉刷新
392
+ isRefreshing: false, //下拉刷新状态
393
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
394
+ type: 'init', //列表状态
395
+ data: [], //数据条数
396
+ hasLoad: false,
397
+ isLongList: true, // 是否长列表
398
+ isLoadAll: false, //是否加载全部
399
+ filterType: '', //过滤类型
400
+ isShowBottomTools: true //显示底部工具栏
401
+ },
402
+ {
403
+ title: 'Network', //标题
404
+ desc: '请求抓包',
405
+ canRefreshing: true, //是否允许下拉刷新
406
+ isRefreshing: false, //下拉刷新状态
407
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
408
+ type: 'init', //列表状态
409
+ data: [], //数据条数
410
+ hasLoad: false,
411
+ isLongList: true, // 是否长列表
412
+ isLoadAll: false, //是否加载全部
413
+ filterType: '', //过滤类型
414
+ isShowBottomTools: true //显示底部工具栏
415
+ },
416
+ {
417
+ title: 'Storage', //标题
418
+ desc: '本地缓存',
419
+ canRefreshing: true, //是否允许下拉刷新
420
+ isRefreshing: false, //下拉刷新状态
421
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
422
+ hasLoad: false,
423
+ storageType: 'localStorage', //缓存类型默认为localStorage
424
+ isShowBottomTools: true //显示底部工具栏
425
+ },
426
+ {
427
+ title: 'Vuex', //标题
428
+ desc: '状态管理',
429
+ canRefreshing: true, //是否允许下拉刷新
430
+ isRefreshing: false, //下拉刷新状态
431
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
432
+ hasLoad: false,
433
+ stateType: 'vuex', //全局变量类型 vuex pinia globalData
434
+ isShowBottomTools: true //显示底部工具栏
435
+ },
436
+ {
437
+ title: 'Logs', //标题
438
+ desc: '运行日志',
439
+ canRefreshing: true, //是否允许下拉刷新
440
+ isRefreshing: false, //下拉刷新状态
441
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
442
+ type: 'init', //列表状态
443
+ data: [], //数据条数
444
+ page: 0, //当前页码
445
+ hasLoad: false,
446
+ isLoadAll: false, //是否加载全部
447
+ isLongList: true, // 是否长列表
448
+ isShowBottomTools: true //显示底部工具栏
449
+ },
450
+ {
451
+ title: 'Info', //标题
452
+ desc: '设备信息',
453
+ canRefreshing: true, //是否允许下拉刷新
454
+ isRefreshing: false, //下拉刷新状态
455
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
456
+ hasLoad: false
457
+ },
458
+ {
459
+ title: 'UniBus', //标题
460
+ desc: '事件总线',
461
+ canRefreshing: true, //是否允许下拉刷新
462
+ isRefreshing: false, //下拉刷新状态
463
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
464
+ type: 'init', //列表状态
465
+ isShowCount: true,
466
+ countList: [],
467
+ isShowLog: false,
468
+ logList: [],
469
+ filterType: '', //过滤类型
470
+ hasLoad: false,
471
+ isShowBottomTools: true //显示底部工具栏
472
+ },
473
+ {
474
+ title: 'FileSys', //标题
475
+ desc: '文件系统',
476
+ canRefreshing: true, //是否允许下拉刷新
477
+ isRefreshing: false, //下拉刷新状态
478
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
479
+ type: 'init', //列表状态
480
+ // #ifdef APP-PLUS
481
+ dirType: 'PRIVATE_DOC', //文件类型 wx, PRIVATE_WWW, PRIVATE_DOC PUBLIC_DOCUMENTS PUBLIC_DOWNLOADS
482
+ // #endif
483
+ // #ifdef MP
484
+ dirType: 'wx', //文件类型 wx, PRIVATE_WWW, PRIVATE_DOC
485
+ // #endif
486
+ data: [], //文件列表
487
+ dirList: [], //目录列表
488
+ hasLoad: false,
489
+ isShowBottomTools: true //显示底部工具栏
490
+ },
491
+ {
492
+ title: 'JsRunner', //标题
493
+ desc: '执行脚本',
494
+ canRefreshing: false, //是否允许下拉刷新
495
+ isRefreshing: false, //下拉刷新状态
496
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
497
+ type: 'init', //列表状态
498
+ data: [], //数据条数
499
+ hasLoad: false,
500
+ // #ifdef APP-PLUS || H5
501
+ isShowBottomTools: true //显示底部工具栏
502
+ // #endif
503
+ },
504
+ {
505
+ title: 'Tools', //标题
506
+ desc: '常用工具',
507
+ hasLoad: false
508
+ },
509
+ {
510
+ title: 'Setting', //标题
511
+ desc: '面板配置',
512
+ canRefreshing: true, //是否允许下拉刷新
513
+ isRefreshing: false, //下拉刷新状态
514
+ refreshType: 'waitPullUp', //刷新状态 'waitPullUp','waitRelease','refreshing'
515
+ type: 'init', //列表状态
516
+ data: [], //数据条数
517
+ page: 0, //当前页码
518
+ hasLoad: false
519
+ }
520
+ ]
521
+ }
522
+ },
523
+ watch: {
524
+ /**
525
+ * 监听tab改变事件
526
+ */
527
+ tabIndex(index) {
528
+ this.isValueViewerOpen = false
529
+ const currentTab = this.tabList[index]
530
+ if (!currentTab) return
531
+ // 这些 tab 在部分平台会随切换被销毁,回到该 tab 时需要强制刷新。
532
+ if (currentTab.title == 'Storage' || currentTab.title == 'Vuex' || currentTab.title == 'Info' || currentTab.title == 'Setting') {
533
+ this.getPage()
534
+ return
535
+ }
536
+ if (!currentTab.hasLoad) {
537
+ this.getPage()
538
+ }
539
+ }
540
+ },
541
+ computed: {
542
+ /**
543
+ * 挂载dev对象
544
+ */
545
+ $devTools() {
546
+ return init
547
+ },
548
+ fileSysTab() {
549
+ let tab = this.tabList.find((x) => x.title == 'FileSys')
550
+ if (!tab) {
551
+ tab = { dirList: [], dirType: '' }
552
+ }
553
+ return tab
554
+ },
555
+ storageTab() {
556
+ let tab = this.tabList.find((x) => x.title == 'Storage')
557
+ if (!tab) {
558
+ tab = { storageType: 'localStorage' }
559
+ }
560
+ return tab
561
+ },
562
+ /**
563
+ * 面板高度
564
+ */
565
+ panelHeight() {
566
+ return Math.ceil(this.windowInfo.system.windowHeight * 0.6)
567
+ },
568
+ /**
569
+ * 滚动列表的高度
570
+ */
571
+ listHeight() {
572
+ return this.panelHeight - uni.upx2px(80) - 1
573
+ },
574
+ /**
575
+ * 当前tab栏的标题
576
+ */
577
+ tabTitle() {
578
+ return this.tabList[this.tabIndex].title
579
+ },
580
+ /**
581
+ * 获取底部栏需要的参数
582
+ */
583
+ bottomToolsOptions() {
584
+ let that = this
585
+ const getTabItemByTitle = (title) => {
586
+ let i = that.tabList.findIndex((x) => x.title == title)
587
+ return that.tabList[i]
588
+ }
589
+ return {
590
+ errorFilterType: getTabItemByTitle('Error').filterType,
591
+ consoleFilterType: getTabItemByTitle('Console').filterType,
592
+ networkFilterType: getTabItemByTitle('Network').filterType,
593
+ busFilterType: getTabItemByTitle('UniBus').filterType,
594
+ fileSysDirList: getTabItemByTitle('FileSys').dirList,
595
+ fileSysDirType: getTabItemByTitle('FileSys').dirType,
596
+ storageType: getTabItemByTitle('Storage').storageType,
597
+ codeHisLength: getTabItemByTitle('JsRunner').data.length
598
+ }
599
+ },
600
+ /**
601
+ * 是否显示底部工具栏
602
+ */
603
+ isShowBottomTools() {
604
+ // [1, 2, 3, 4, 5, 7, 9, 10].indexOf(tabIndex) != -1
605
+ let item = this.tabList[this.tabIndex]
606
+ return item.isShowBottomTools === true
607
+ },
608
+ /**
609
+ * 面板样式
610
+ */
611
+ panelStyle() {
612
+ return {
613
+ height: this.panelHeight + 'px',
614
+ '--devtools-panel-top': `calc(100vh - ${this.panelHeight}px)`,
615
+ '--devtools-panel-height': `${this.panelHeight}px`,
616
+ borderRadius: '24rpx 24rpx 0 0'
617
+ // #ifdef APP-PLUS
618
+ // APP-PLUS 的原动画逻辑不再用于弹窗模式
619
+ // #endif
620
+ }
621
+ }
622
+ },
623
+ mounted() {
624
+ let that = this
625
+ this.getPage()
626
+
627
+ uni.$on('devTools_valueViewer_show', that.onValueViewerShow)
628
+ uni.$on('devTools_valueViewer_hide', that.onValueViewerHide)
629
+
630
+ // ! 刷新当前列表
631
+ uni.$on('devTools_listGetPage', () => {
632
+ that.getPage()
633
+ })
634
+
635
+ // ! 删除指定请求记录
636
+ uni.$on('devTools_delNetworkItemById', (id) => {
637
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Network')
638
+ let i = that.tabList[tabIndex].data.findIndex((x) => x.id == id)
639
+ if (i != -1) {
640
+ that.tabList[tabIndex].data.splice(i, 1)
641
+ }
642
+ })
643
+
644
+ // ! 删除日志
645
+ uni.$on('devTools_delLog', (item) => {
646
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Logs')
647
+ let i = that.tabList[tabIndex].data.findIndex((x) => x.date == item.date && x.t == item.t)
648
+ if (i != -1) {
649
+ that.tabList[tabIndex].data.splice(i, 1)
650
+ }
651
+ })
652
+
653
+ // ! 删除错误记录
654
+ uni.$on('devTools_delError', (item) => {
655
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Error')
656
+ let i = that.tabList[tabIndex].data.findIndex((x) => x.type == item.type && x.t == item.t && x.m == item.m && x.tr == item.tr && x.p == item.p)
657
+ if (i != -1) {
658
+ that.tabList[tabIndex].data.splice(i, 1)
659
+ }
660
+ })
661
+
662
+ // ! 删除打印日志
663
+ uni.$on('devTools_delConsoleItem', (item) => {
664
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Console')
665
+ let i = that.tabList[tabIndex].data.findIndex((x) => {
666
+ let t = JSON.stringify(x.list)
667
+ return t == JSON.stringify(item.list) && x.time == item.time && x.page == item.page && x.type == item.type
668
+ })
669
+ if (i != -1) {
670
+ that.tabList[tabIndex].data.splice(i, 1)
671
+ }
672
+ })
673
+
674
+ // !初始化Vuex,自动推断全局变量类型
675
+ let vIndex = that.tabList.findIndex((x) => x.title == 'Vuex')
676
+ let vType = 'globalData'
677
+ if (that.$store) {
678
+ vType = 'vuex'
679
+ } else if (uni.Pinia || that.$pinia) {
680
+ vType = 'pinia'
681
+ }
682
+ // console.log("vType", vType);
683
+ that.tabList[vIndex].stateType = vType
684
+ },
685
+ beforeUnmount() {
686
+ uni.$off('devTools_valueViewer_show', this.onValueViewerShow)
687
+ uni.$off('devTools_valueViewer_hide', this.onValueViewerHide)
688
+ },
689
+ methods: {
690
+ onValueViewerShow() {
691
+ this.isValueViewerOpen = true
692
+ },
693
+ onValueViewerHide() {
694
+ this.isValueViewerOpen = false
695
+ },
696
+ onTabClick(index) {
697
+ if (this.tabTouchMoved) {
698
+ this.tabTouchMoved = false
699
+ return
700
+ }
701
+ this.tabIndex = index
702
+ },
703
+ onTabListScroll(e) {
704
+ const detail = e && e.detail ? e.detail : null
705
+ if (!detail || typeof detail.scrollLeft !== 'number') return
706
+ this.tabScrollLeft = detail.scrollLeft
707
+ },
708
+ onTabTouchStart(e) {
709
+ const point = this.getTabTouchPoint(e)
710
+ if (!point) return
711
+ this.tabTouchDragging = true
712
+ this.tabTouchMoved = false
713
+ this.tabTouchStartX = point.x
714
+ this.tabTouchStartLeft = this.tabScrollLeft
715
+ },
716
+ onTabTouchMove(e) {
717
+ if (!this.tabTouchDragging) return
718
+ const point = this.getTabTouchPoint(e)
719
+ if (!point) return
720
+ const deltaX = point.x - this.tabTouchStartX
721
+ if (Math.abs(deltaX) > 4) {
722
+ this.tabTouchMoved = true
723
+ }
724
+ const nextLeft = this.tabTouchStartLeft - deltaX
725
+ this.tabScrollLeft = nextLeft > 0 ? nextLeft : 0
726
+ if (this.tabTouchMoved && e && typeof e.preventDefault == 'function') {
727
+ e.preventDefault()
728
+ }
729
+ },
730
+ onTabTouchEnd() {
731
+ this.tabTouchDragging = false
732
+ if (!this.tabTouchMoved) return
733
+ setTimeout(() => {
734
+ this.tabTouchMoved = false
735
+ }, 0)
736
+ },
737
+ onTabMouseDown(e) {
738
+ if (!e || typeof e.clientX !== 'number') return
739
+ this.tabTouchDragging = true
740
+ this.tabTouchMoved = false
741
+ this.tabTouchStartX = e.clientX
742
+ this.tabTouchStartLeft = this.tabScrollLeft
743
+ },
744
+ onTabMouseMove(e) {
745
+ if (!this.tabTouchDragging || !e || typeof e.clientX !== 'number') return
746
+ const deltaX = e.clientX - this.tabTouchStartX
747
+ if (Math.abs(deltaX) > 2) {
748
+ this.tabTouchMoved = true
749
+ }
750
+ const nextLeft = this.tabTouchStartLeft - deltaX
751
+ this.tabScrollLeft = nextLeft > 0 ? nextLeft : 0
752
+ if (this.tabTouchMoved && typeof e.preventDefault == 'function') {
753
+ e.preventDefault()
754
+ }
755
+ },
756
+ onTabMouseUp() {
757
+ this.onTabTouchEnd()
758
+ },
759
+ getTabTouchPoint(e) {
760
+ if (!e) return null
761
+ if (e.touches && e.touches[0]) {
762
+ return {
763
+ x: e.touches[0].clientX || e.touches[0].pageX || 0
764
+ }
765
+ }
766
+ if (e.changedTouches && e.changedTouches[0]) {
767
+ return {
768
+ x: e.changedTouches[0].clientX || e.changedTouches[0].pageX || 0
769
+ }
770
+ }
771
+ if (e.detail && typeof e.detail.x === 'number') {
772
+ return {
773
+ x: e.detail.x
774
+ }
775
+ }
776
+ return null
777
+ },
778
+ /**
779
+ * 加载列表
780
+ */
781
+ async getPage(notifySuccess = false) {
782
+ let that = this
783
+ const index = Number(that.tabIndex)
784
+ let item = that.tabList[index]
785
+ if (item.isRefreshing) return
786
+
787
+ await that.awaitNextTick()
788
+ // 等待渲染期间若已切换到其他 tab,放弃本次刷新,避免状态错乱。
789
+ if (index !== Number(that.tabIndex)) {
790
+ return
791
+ }
792
+
793
+ if (item.title == 'Storage') {
794
+ await that.refreshStorage({
795
+ notifySuccess
796
+ })
797
+ } else if (item.title == 'Vuex') {
798
+ await that.refreshVuex({
799
+ notifySuccess
800
+ })
801
+ } else if (item.title == 'Info') {
802
+ await that.refreshInfo({
803
+ notifySuccess
804
+ })
805
+ } else if (item.title == 'Pages') {
806
+ await that.getPages({
807
+ notifySuccess
808
+ })
809
+ } else if (item.title == 'Console') {
810
+ await that.getConsole({
811
+ notifySuccess
812
+ })
813
+ } else if (item.title == 'Network') {
814
+ await that.getNetwork({
815
+ notifySuccess
816
+ })
817
+ } else if (item.title == 'Logs') {
818
+ await that.getLogs({
819
+ notifySuccess
820
+ })
821
+ } else if (item.title == 'Error') {
822
+ await that.getError({
823
+ notifySuccess
824
+ })
825
+ } else if (item.title == 'UniBus') {
826
+ await that.getUniBus({
827
+ notifySuccess
828
+ })
829
+ } else if (item.title == 'FileSys') {
830
+ await that.getDirList({
831
+ notifySuccess
832
+ })
833
+ } else if (item.title == 'Setting') {
834
+ await that.refreshSetting({
835
+ notifySuccess
836
+ })
837
+ }
838
+ that.tabList[index].hasLoad = true
839
+ },
840
+ /**
841
+ * 等待渲染完成
842
+ */
843
+ awaitNextTick() {
844
+ let that = this
845
+ return new Promise((yes) => {
846
+ // #ifdef APP-PLUS
847
+ setTimeout(() => {
848
+ yes()
849
+ }, 16)
850
+ // #endif
851
+ // #ifndef APP-PLUS
852
+ that.$nextTick(() => {
853
+ yes()
854
+ })
855
+ // #endif
856
+ })
857
+ },
858
+ /**
859
+ * 统一刷新收尾
860
+ */
861
+ finishRefresh(tabIndex, options = {}) {
862
+ const tab = this.tabList[tabIndex]
863
+ if (!tab) return
864
+ const success = options.success !== false
865
+ const notifySuccess = options.notifySuccess === true
866
+ tab.isRefreshing = false
867
+ tab.refreshType = success ? 'success' : 'error'
868
+ if (options.updateType) {
869
+ tab.type = success ? 'success' : 'error'
870
+ }
871
+ if (success && notifySuccess) {
872
+ devUi.showToast({
873
+ icon: 'success',
874
+ title: '刷新成功'
875
+ })
876
+ }
877
+ setTimeout(() => {
878
+ if (tab.refreshType != 'refreshing') {
879
+ tab.refreshType = 'waitRelease'
880
+ }
881
+ }, 120)
882
+ },
883
+ /**
884
+ * 刷新setting数据
885
+ */
886
+ async refreshSetting(options = {}) {
887
+ let that = this
888
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Setting')
889
+ that.tabList[tabIndex].isRefreshing = true
890
+ that.tabList[tabIndex].refreshType = 'refreshing'
891
+ that.tabList[tabIndex].type = 'loading'
892
+ const notifySuccess = options.notifySuccess === true
893
+ try {
894
+ const settingRef = that.$refs.settingView
895
+ if (settingRef && typeof settingRef.getPage == 'function') {
896
+ await settingRef.getPage()
897
+ }
898
+ that.finishRefresh(tabIndex, {
899
+ updateType: true,
900
+ notifySuccess
901
+ })
902
+ } catch (error) {
903
+ console.log('refreshSetting error', error)
904
+ that.finishRefresh(tabIndex, {
905
+ success: false,
906
+ updateType: true
907
+ })
908
+ }
909
+ },
910
+ /**
911
+ * 隐藏弹窗
912
+ */
913
+ hide() {
914
+ init.hide()
915
+ },
916
+ /**
917
+ * 刷新缓存数据
918
+ */
919
+ async refreshStorage(options = {}) {
920
+ let that = this
921
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Storage')
922
+ that.tabList[tabIndex].isRefreshing = true
923
+ that.tabList[tabIndex].refreshType = 'refreshing'
924
+ const notifySuccess = options.notifySuccess === true
925
+ try {
926
+ const storageRef = that.$refs.storageList
927
+ if (!storageRef || typeof storageRef.getData != 'function') {
928
+ that.finishRefresh(tabIndex, {
929
+ success: false
930
+ })
931
+ return
932
+ }
933
+ await storageRef.getData(that.tabList[tabIndex].storageType)
934
+ that.finishRefresh(tabIndex, {
935
+ notifySuccess
936
+ })
937
+ } catch (error) {
938
+ console.log('refreshStorage error', error)
939
+ that.finishRefresh(tabIndex, {
940
+ success: false
941
+ })
942
+ }
943
+ },
944
+ /**
945
+ * 刷新vuex数据
946
+ */
947
+ async refreshVuex(options = {}) {
948
+ let that = this
949
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Vuex')
950
+ that.tabList[tabIndex].isRefreshing = true
951
+ that.tabList[tabIndex].refreshType = 'refreshing'
952
+ const notifySuccess = options.notifySuccess === true
953
+ try {
954
+ await that.awaitNextTick()
955
+ const vuexRef = that.$refs.vuexList
956
+ if (!vuexRef || typeof vuexRef.getData != 'function') {
957
+ that.finishRefresh(tabIndex, {
958
+ success: false
959
+ })
960
+ return
961
+ }
962
+ await vuexRef.getData()
963
+ that.finishRefresh(tabIndex, {
964
+ notifySuccess
965
+ })
966
+ } catch (error) {
967
+ console.log('refreshVuex error', error)
968
+ that.finishRefresh(tabIndex, {
969
+ success: false
970
+ })
971
+ }
972
+ },
973
+ /**
974
+ * 刷新pages
975
+ */
976
+ async getPages(options = {}) {
977
+ let that = this
978
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Pages')
979
+ that.tabList[tabIndex].isRefreshing = true
980
+ that.tabList[tabIndex].refreshType = 'refreshing'
981
+ const notifySuccess = options.notifySuccess === true
982
+ try {
983
+ const pagesRef = that.$refs.pages
984
+ if (pagesRef && typeof pagesRef.getData == 'function') {
985
+ await pagesRef.getData()
986
+ }
987
+ that.tabList[tabIndex].routeList = pageLinkList.getAllRoutes()
988
+ that.finishRefresh(tabIndex, {
989
+ notifySuccess
990
+ })
991
+ } catch (error) {
992
+ console.log('getPages error', error)
993
+ that.finishRefresh(tabIndex, {
994
+ success: false
995
+ })
996
+ }
997
+ },
998
+ /**
999
+ * 改变pages列表展示状态
1000
+ */
1001
+ pagesShowChange(key) {
1002
+ this.tabList[this.tabIndex][key] = !this.tabList[this.tabIndex][key]
1003
+ },
1004
+ /**
1005
+ * 刷新info
1006
+ */
1007
+ async refreshInfo(options = {}) {
1008
+ let that = this
1009
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Info')
1010
+ that.tabList[tabIndex].isRefreshing = true
1011
+ that.tabList[tabIndex].refreshType = 'refreshing'
1012
+ const notifySuccess = options.notifySuccess === true
1013
+ try {
1014
+ const infoRef = that.$refs.infoList
1015
+ if (infoRef && typeof infoRef.getData == 'function') {
1016
+ await infoRef.getData()
1017
+ }
1018
+ that.finishRefresh(tabIndex, {
1019
+ notifySuccess
1020
+ })
1021
+ } catch (error) {
1022
+ console.log('refreshInfo error', error)
1023
+ that.finishRefresh(tabIndex, {
1024
+ success: false
1025
+ })
1026
+ }
1027
+ },
1028
+ /**
1029
+ * 加载数据
1030
+ */
1031
+ async getConsole(options = {}) {
1032
+ let that = this
1033
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Console')
1034
+ that.tabList[tabIndex].isRefreshing = true
1035
+ that.tabList[tabIndex].refreshType = 'refreshing'
1036
+ that.tabList[tabIndex].type = 'loading'
1037
+ const notifySuccess = options.notifySuccess === true
1038
+ let data = devCache.get('console')
1039
+ if (!data) data = []
1040
+ data = data.map((item) => {
1041
+ // item.date = timeFormat(item.time);
1042
+ item.date = timeFromNow(item.time)
1043
+ return item
1044
+ })
1045
+ let filterType = that.tabList[tabIndex].filterType
1046
+ if (filterType != '') {
1047
+ data = data.filter((x) => x.type == filterType)
1048
+ }
1049
+ if (data.length > 30 && that.tabList[tabIndex].isLongList && !that.tabList[tabIndex].isLoadAll) {
1050
+ data.splice(30, data.length - 1)
1051
+ }
1052
+ that.tabList[tabIndex].data = data
1053
+ that.finishRefresh(tabIndex, {
1054
+ updateType: true,
1055
+ notifySuccess
1056
+ })
1057
+ },
1058
+ /**
1059
+ * 加载请求数据
1060
+ */
1061
+ async getNetwork(options = {}) {
1062
+ let that = this
1063
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Network')
1064
+ that.tabList[tabIndex].isRefreshing = true
1065
+ that.tabList[tabIndex].refreshType = 'refreshing'
1066
+ that.tabList[tabIndex].type = 'loading'
1067
+ const notifySuccess = options.notifySuccess === true
1068
+
1069
+ let data = devCache.get('request')
1070
+ if (!data) data = []
1071
+ data = data.map((item) => {
1072
+ item.date = timeFromNow(item.sendTime)
1073
+ return item
1074
+ })
1075
+ let filterType = that.tabList[tabIndex].filterType
1076
+ if (filterType != '') {
1077
+ if (filterType == '请求失败') {
1078
+ data = data.filter((x) => x.type == 2 || (x.type == 1 && x.responseStatus != 200))
1079
+ } else if (filterType == '其他') {
1080
+ data = data.filter((x) => x.method != 'get' && x.method != 'post')
1081
+ } else if (filterType == '1s+') {
1082
+ data = data.filter((x) => x.type != 0 && x.useTime > 1)
1083
+ } else if (filterType == '5s+') {
1084
+ data = data.filter((x) => x.type != 0 && x.useTime > 5)
1085
+ } else if (filterType == '10s+') {
1086
+ data = data.filter((x) => x.type != 0 && x.useTime > 10)
1087
+ } else if (filterType == 'get') {
1088
+ data = data.filter((x) => x.method.toLocaleLowerCase() == 'get')
1089
+ } else if (filterType == 'post') {
1090
+ data = data.filter((x) => x.method.toLocaleLowerCase() == 'post')
1091
+ } else if (filterType == '500KB+') {
1092
+ data = data.filter((x) => x.type == 1 && x.responseBodySize > 1024 * 500)
1093
+ } else if (filterType == '1MB+') {
1094
+ data = data.filter((x) => x.type == 1 && x.responseBodySize > 1024 * 1024)
1095
+ } else {
1096
+ data = data.filter((x) => x.method == filterType)
1097
+ }
1098
+ }
1099
+ console.log('data', data)
1100
+ if (data.length > 30 && that.tabList[tabIndex].isLongList && !that.tabList[tabIndex].isLoadAll) {
1101
+ data.splice(30, data.length - 1)
1102
+ }
1103
+ that.tabList[tabIndex].data = data
1104
+ that.finishRefresh(tabIndex, {
1105
+ updateType: true,
1106
+ notifySuccess
1107
+ })
1108
+ },
1109
+ /**
1110
+ * 获取日志
1111
+ */
1112
+ async getLogs(options = {}) {
1113
+ let that = this
1114
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Logs')
1115
+ that.tabList[tabIndex].isRefreshing = true
1116
+ that.tabList[tabIndex].refreshType = 'refreshing'
1117
+ that.tabList[tabIndex].type = 'loading'
1118
+ const notifySuccess = options.notifySuccess === true
1119
+ let data = devCache.get('logReport')
1120
+ if (!data) data = []
1121
+ data = data.map((x) => {
1122
+ x.date = timeFromNow(x.t)
1123
+ return x
1124
+ })
1125
+ if (data.length > 30 && that.tabList[tabIndex].isLongList && !that.tabList[tabIndex].isLoadAll) {
1126
+ data.splice(30, data.length - 1)
1127
+ }
1128
+ that.tabList[tabIndex].data = data
1129
+ that.finishRefresh(tabIndex, {
1130
+ updateType: true,
1131
+ notifySuccess
1132
+ })
1133
+ },
1134
+ /**
1135
+ * 获取错误列表
1136
+ */
1137
+ async getError(options = {}) {
1138
+ let that = this
1139
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Error')
1140
+ that.tabList[tabIndex].isRefreshing = true
1141
+ that.tabList[tabIndex].refreshType = 'refreshing'
1142
+ that.tabList[tabIndex].type = 'loading'
1143
+ const notifySuccess = options.notifySuccess === true
1144
+ let data = devCache.get('errorReport')
1145
+ if (!data) data = []
1146
+ data = data.map((x) => {
1147
+ x.date = timeFromNow(x.t)
1148
+ return x
1149
+ })
1150
+ let filterType = that.tabList[tabIndex].filterType
1151
+ if (filterType != '') {
1152
+ data = data.filter((x) => x.type == filterType)
1153
+ }
1154
+ if (data.length > 30 && that.tabList[tabIndex].isLongList && !that.tabList[tabIndex].isLoadAll) {
1155
+ data.splice(30, data.length - 1)
1156
+ }
1157
+ that.tabList[tabIndex].data = data
1158
+ that.finishRefresh(tabIndex, {
1159
+ updateType: true,
1160
+ notifySuccess
1161
+ })
1162
+ },
1163
+ /**
1164
+ * 加载全部列表
1165
+ */
1166
+ showListAll() {
1167
+ let that = this
1168
+ that.tabList[that.tabIndex].isLoadAll = true
1169
+ that.tabList[that.tabIndex].data = []
1170
+ that.tabList[that.tabIndex].type = 'loading'
1171
+ that.getPage()
1172
+ },
1173
+ /**
1174
+ * 加载eventBus日志列表
1175
+ */
1176
+ async getUniBus(options = {}) {
1177
+ let that = this
1178
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'UniBus')
1179
+ that.tabList[tabIndex].isRefreshing = true
1180
+ that.tabList[tabIndex].refreshType = 'refreshing'
1181
+ const notifySuccess = options.notifySuccess === true
1182
+
1183
+ let logList = devCache.get('uniBus')
1184
+ if (!logList) logList = []
1185
+
1186
+ let busCount = devCache.get('busCount')
1187
+ if (!busCount) busCount = []
1188
+
1189
+ logList = logList.map((x) => {
1190
+ x.date = timeFormat(x.t)
1191
+ return x
1192
+ })
1193
+
1194
+ let filterType = that.tabList[tabIndex].filterType
1195
+ if (filterType != '') {
1196
+ logList = logList.filter((x) => x.e.indexOf(`${filterType}>`) == 0)
1197
+ }
1198
+ that.tabList[tabIndex].logList = logList
1199
+ that.tabList[tabIndex].countList = busCount
1200
+ that.finishRefresh(tabIndex, {
1201
+ notifySuccess
1202
+ })
1203
+ },
1204
+ /**
1205
+ * 长按BUS事件
1206
+ */
1207
+ busCountMenu(item) {
1208
+ let that = this
1209
+
1210
+ let menu = [
1211
+ {
1212
+ text: '复制名称',
1213
+ click() {
1214
+ that.copyToClipboard(item.e)
1215
+ }
1216
+ },
1217
+ {
1218
+ text: '复制完整日志',
1219
+ click() {
1220
+ that.copyToClipboard(JSON.stringify(item))
1221
+ }
1222
+ }
1223
+ ]
1224
+
1225
+ devUi.showActionSheet({
1226
+ itemList: menu.map((x) => x.text),
1227
+ success({ tapIndex }) {
1228
+ menu[tapIndex].click()
1229
+ }
1230
+ })
1231
+ },
1232
+ /**
1233
+ * 长按BUS log事件
1234
+ */
1235
+ busLogMenu(item) {
1236
+ let that = this
1237
+ let menu = [
1238
+ {
1239
+ text: '复制名称',
1240
+ click() {
1241
+ that.copyToClipboard(item.e)
1242
+ }
1243
+ },
1244
+ {
1245
+ text: '复制完整日志',
1246
+ click() {
1247
+ that.copyToClipboard(JSON.stringify(item))
1248
+ }
1249
+ }
1250
+ ]
1251
+ devUi.showActionSheet({
1252
+ itemList: menu.map((x) => x.text),
1253
+ success({ tapIndex }) {
1254
+ menu[tapIndex].click()
1255
+ }
1256
+ })
1257
+ },
1258
+ copyToClipboard(data) {
1259
+ uni.setClipboardData({
1260
+ data,
1261
+ success: () => {
1262
+ devUi.showToast({
1263
+ title: '复制成功',
1264
+ icon: 'success'
1265
+ })
1266
+ }
1267
+ })
1268
+ },
1269
+ /**
1270
+ * 列表过滤类型改变事件
1271
+ */
1272
+ onFilterTypeChange(type) {
1273
+ this.tabList[this.tabIndex].filterType = type
1274
+ this.getPage()
1275
+ },
1276
+ /**
1277
+ * 加载文件列表
1278
+ */
1279
+ async getDirList(options = {}) {
1280
+ let that = this
1281
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'FileSys')
1282
+ // #ifndef APP-PLUS || MP-WEIXIN
1283
+ if (1) return
1284
+ // #endif
1285
+
1286
+ that.tabList[tabIndex].isRefreshing = true
1287
+ that.tabList[tabIndex].refreshType = 'refreshing'
1288
+ that.tabList[tabIndex].type = 'loading'
1289
+ const notifySuccess = options.notifySuccess === true
1290
+ try {
1291
+ let path = ''
1292
+ let data = []
1293
+ // #ifdef APP-PLUS
1294
+ if (that.tabList[tabIndex].dirType == 'PRIVATE_DOC') {
1295
+ path = '_doc'
1296
+ } else if (that.tabList[tabIndex].dirType == 'PRIVATE_WWW') {
1297
+ path = '_www'
1298
+ } else if (that.tabList[tabIndex].dirType == 'PUBLIC_DOCUMENTS') {
1299
+ path = '_documents'
1300
+ } else if (that.tabList[tabIndex].dirType == 'PUBLIC_DOWNLOADS') {
1301
+ path = '_downloads'
1302
+ }
1303
+
1304
+ if (that.tabList[tabIndex].dirList) {
1305
+ that.tabList[tabIndex].dirList.forEach((item) => {
1306
+ path = path + '/' + item
1307
+ })
1308
+ }
1309
+
1310
+ data = await dirReader.getDirFileList(path)
1311
+
1312
+ // #endif
1313
+
1314
+ // #ifdef MP-WEIXIN
1315
+ let fs = wx.getFileSystemManager()
1316
+ path = wx.env.USER_DATA_PATH
1317
+ if (that.tabList[tabIndex].dirList) {
1318
+ that.tabList[tabIndex].dirList.forEach((item) => {
1319
+ path = path + '/' + item
1320
+ })
1321
+ }
1322
+ let fileList = []
1323
+ let dirList = []
1324
+ let list = fs.readdirSync(path + '/')
1325
+ for (let i = 0; i < list.length; i++) {
1326
+ let name = list[i]
1327
+ let stats = fs.statSync(path + '/' + name)
1328
+ let row = {
1329
+ type: stats.isFile() ? 'file' : 'dir',
1330
+ size: stats.size,
1331
+ time: stats.lastModifiedTime,
1332
+ name,
1333
+ fileType: name.split('.').pop()
1334
+ }
1335
+ if (stats.isFile()) {
1336
+ fileList.push(row)
1337
+ } else {
1338
+ dirList.push(row)
1339
+ }
1340
+ }
1341
+ data = [...dirList, ...fileList]
1342
+ // #endif
1343
+
1344
+ data = data.map((x) => {
1345
+ x.date = timeFormat(x.time, 'yyyy-mm-dd hh:MM')
1346
+ x.sizeText = fileSize.getByteSize(x.size)
1347
+ x.icon = x.type == 'dir' ? dirReader.getDirIcon() : dirReader.getFileIcon(x.fileType)
1348
+ return x
1349
+ })
1350
+
1351
+ if (that.tabList[tabIndex].dirList.length > 0) {
1352
+ data.unshift({
1353
+ type: 'back',
1354
+ name: '返回上一级'
1355
+ })
1356
+ }
1357
+
1358
+ that.tabList[tabIndex].data = data
1359
+ that.finishRefresh(tabIndex, {
1360
+ updateType: true,
1361
+ notifySuccess
1362
+ })
1363
+ } catch (error) {
1364
+ console.log('getDirList error', error)
1365
+ that.finishRefresh(tabIndex, {
1366
+ success: false,
1367
+ updateType: true
1368
+ })
1369
+ }
1370
+ },
1371
+ /**
1372
+ * 打开文件夹
1373
+ */
1374
+ goChildDir(dirName) {
1375
+ let that = this
1376
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'FileSys')
1377
+ if (typeof dirName == 'string' && dirName.indexOf('_goIndex_') == 0) {
1378
+ let i = Number(dirName.replace('_goIndex_', ''))
1379
+ that.tabList[tabIndex].dirList.splice(i, 99999)
1380
+ } else if (dirName == '__back__') {
1381
+ if (that.tabList[tabIndex].dirList.length > 0) {
1382
+ that.tabList[tabIndex].dirList.splice(that.tabList[tabIndex].dirList.length - 1, 1)
1383
+ }
1384
+ } else {
1385
+ that.tabList[tabIndex].dirList.push(dirName)
1386
+ }
1387
+ that.getPage()
1388
+ },
1389
+ /**
1390
+ * 更改文件管理器地址
1391
+ */
1392
+ changeFileDirType(type) {
1393
+ let that = this
1394
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'FileSys')
1395
+ this.tabList[tabIndex].dirType = type
1396
+ this.tabList[tabIndex].dirList = []
1397
+ this.tabList[tabIndex].data = []
1398
+ this.getPage()
1399
+ },
1400
+ /**
1401
+ * 编辑文件夹或创建文件夹
1402
+ */
1403
+ editDirName(options) {
1404
+ this.$refs.createDir.show(options)
1405
+ },
1406
+ /**
1407
+ * 更改缓存类型
1408
+ */
1409
+ changeStorageType(type) {
1410
+ let that = this
1411
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Storage')
1412
+ this.tabList[tabIndex].storageType = type
1413
+ this.getPage()
1414
+ },
1415
+ /**
1416
+ * 运行js代码
1417
+ */
1418
+ runJs({ code, type }) {
1419
+ let that = this
1420
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'JsRunner')
1421
+ let id = new Date().getTime() + '_' + Math.random()
1422
+ this.tabList[tabIndex].data.push({
1423
+ id,
1424
+ code,
1425
+ result: '',
1426
+ isEnd: false
1427
+ })
1428
+ let logIndex = this.tabList[tabIndex].data.findIndex((x) => x.id == id)
1429
+ let context
1430
+ try {
1431
+ // #ifdef H5
1432
+ context = window
1433
+ // #endif
1434
+ // #ifdef APP-PLUS
1435
+ context = globalThis
1436
+ // #endif
1437
+ } catch (error) {}
1438
+ let result = undefined
1439
+ uni.hideKeyboard()
1440
+ if (type == 'h5') {
1441
+ try {
1442
+ let fun = ('ev' + '__混淆__' + 'al').replace('__混淆__', '')
1443
+ if (context && context[fun]) {
1444
+ result = context[fun](code)
1445
+ } else {
1446
+ result = '当前环境不支持运行js!'
1447
+ }
1448
+ } catch (error) {
1449
+ if (error && error.message) {
1450
+ result = error.message
1451
+ }
1452
+ }
1453
+ } else {
1454
+ setTimeout(() => {
1455
+ try {
1456
+ uni.$once('devTools_jsRunnerCallback', (result) => {
1457
+ console.log('result', result)
1458
+ this.$set(this.tabList[this.tabIndex].data[logIndex], 'result', result)
1459
+ this.$set(this.tabList[this.tabIndex].data[logIndex], 'isEnd', true)
1460
+ this.$refs.mobileSwiperScroll.scrollToBottom()
1461
+ })
1462
+ uni.$emit('devTools_jsRunner', code)
1463
+ } catch (error) {}
1464
+ }, 1)
1465
+ }
1466
+
1467
+ let his = devCache.get('codeRunHis')
1468
+ if (!his) his = []
1469
+ let i = his.indexOf(code)
1470
+ if (i > -1) {
1471
+ his.splice(i, 1)
1472
+ }
1473
+ his.unshift(code)
1474
+ if (his.length > 100) {
1475
+ his.splice(100, 9999999)
1476
+ }
1477
+ devCache.set('codeRunHis', his)
1478
+
1479
+ this.$set(this.tabList[this.tabIndex].data[logIndex], 'result', result)
1480
+ this.$set(this.tabList[this.tabIndex].data[logIndex], 'isEnd', true)
1481
+ this.$refs.mobileSwiperScroll.scrollToBottom()
1482
+ },
1483
+ /**
1484
+ * 清空js运行记录
1485
+ */
1486
+ emptyCodeHis() {
1487
+ let that = this
1488
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'JsRunner')
1489
+ devUi.showToast({
1490
+ title: '清空成功!',
1491
+ icon: 'success'
1492
+ })
1493
+ that.tabList[tabIndex].data = []
1494
+ },
1495
+ /**
1496
+ * Vuex变量类型改变事件
1497
+ */
1498
+ changeStateType(type) {
1499
+ let that = this
1500
+ let tabIndex = that.tabList.findIndex((x) => x.title == 'Vuex')
1501
+ this.tabList[tabIndex].stateType = type
1502
+ this.getPage()
1503
+ }
1504
+ }
1505
+ }
1506
+ </script>
1507
+ <style lang="scss" scoped>
1508
+ /* #ifndef APP-PLUS */
1509
+ view,
1510
+ text {
1511
+ box-sizing: border-box;
1512
+ }
1513
+ /* #endif */
1514
+
1515
+ .devTools {
1516
+ /* #ifdef APP-PLUS */
1517
+ flex: 1;
1518
+ /* #endif */
1519
+ /* #ifndef APP-PLUS */
1520
+ height: 100vh;
1521
+ /* #endif */
1522
+ width: 100%;
1523
+ position: relative;
1524
+ .panel {
1525
+ position: fixed;
1526
+ z-index: 2;
1527
+ bottom: 0px;
1528
+ left: 0px;
1529
+ right: 0px;
1530
+ background-color: #ffffff;
1531
+ display: flex;
1532
+ flex-direction: column;
1533
+ width: 100%;
1534
+ box-sizing: border-box;
1535
+ overflow-x: hidden;
1536
+ color: #333;
1537
+ box-shadow: 0 -12rpx 42rpx rgba(2, 6, 23, 0.2);
1538
+ /* #ifdef APP-PLUS */
1539
+ border-radius: 20rpx 20rpx 0 0;
1540
+ /* #endif */
1541
+ .head {
1542
+ width: 100%;
1543
+ display: flex;
1544
+ flex-direction: row;
1545
+ align-items: center;
1546
+ justify-content: space-between;
1547
+ height: 80rpx;
1548
+ border-bottom: 1px solid rgba(15, 23, 42, 0.06);
1549
+ background-color: #fff;
1550
+ .tabList {
1551
+ height: 80rpx;
1552
+ width: calc(100% - 84rpx);
1553
+ display: flex;
1554
+ flex-direction: row;
1555
+ background: #fff;
1556
+ border-bottom: 1px solid rgba(15, 23, 42, 0.05);
1557
+ white-space: nowrap;
1558
+ touch-action: pan-x;
1559
+ user-select: none;
1560
+ -webkit-user-select: none;
1561
+ &.tab-with-actions {
1562
+ width: calc(100% - 168rpx);
1563
+ }
1564
+ ::v-deep .uni-scroll-view-content {
1565
+ white-space: nowrap;
1566
+ }
1567
+ .tabListInner {
1568
+ display: inline-block;
1569
+ white-space: nowrap;
1570
+ min-width: 100%;
1571
+ }
1572
+ .tabItem {
1573
+ display: inline-flex;
1574
+ flex-direction: row;
1575
+ align-items: center;
1576
+ justify-content: center;
1577
+ flex-shrink: 0;
1578
+ vertical-align: top;
1579
+ height: 80rpx;
1580
+ padding: 0 20rpx;
1581
+ /* #ifndef APP-PLUS */
1582
+ min-width: 90rpx;
1583
+ /* #endif */
1584
+ position: relative;
1585
+ .tabTextWrap {
1586
+ height: 80rpx;
1587
+ display: flex;
1588
+ flex-direction: column;
1589
+ justify-content: center;
1590
+ align-items: center;
1591
+ min-width: 96rpx;
1592
+ }
1593
+ .tabText {
1594
+ display: block;
1595
+ white-space: nowrap;
1596
+ font-size: 24rpx;
1597
+ color: #6b7280;
1598
+ line-height: 30rpx;
1599
+ padding: 0 10rpx;
1600
+ border-radius: 8rpx;
1601
+ }
1602
+ .tabText.active {
1603
+ font-size: 24rpx;
1604
+ color: #3b82f6;
1605
+ font-weight: 400;
1606
+ }
1607
+ .tabDesc {
1608
+ display: block;
1609
+ white-space: nowrap;
1610
+ font-size: 17rpx;
1611
+ line-height: 22rpx;
1612
+ color: #94a3b8;
1613
+ }
1614
+ .tabDesc.active {
1615
+ color: #3b82f6;
1616
+ }
1617
+ }
1618
+ }
1619
+ .headActions {
1620
+ height: 80rpx;
1621
+ display: flex;
1622
+ flex-direction: row;
1623
+ align-items: center;
1624
+ }
1625
+ .headRefresh {
1626
+ height: 80rpx;
1627
+ width: 84rpx;
1628
+ display: flex;
1629
+ flex-direction: row;
1630
+ align-items: center;
1631
+ justify-content: center;
1632
+ position: relative;
1633
+ .line {
1634
+ position: absolute;
1635
+ left: 0;
1636
+ height: 40rpx;
1637
+ width: 1px;
1638
+ background-color: rgba(0, 0, 0, 0.05);
1639
+ }
1640
+ .headRefreshIcon {
1641
+ font-size: 38rpx;
1642
+ line-height: 38rpx;
1643
+ color: #3b82f6;
1644
+ }
1645
+ .headRefreshIcon.refreshing {
1646
+ color: #93c5fd;
1647
+ }
1648
+ }
1649
+ .close {
1650
+ height: 80rpx;
1651
+ width: 84rpx;
1652
+ display: flex;
1653
+ flex-direction: row;
1654
+ align-items: center;
1655
+ justify-content: center;
1656
+ position: relative;
1657
+ .icon {
1658
+ font-size: 44rpx;
1659
+ line-height: 44rpx;
1660
+ text-align: center;
1661
+ color: #ef4444;
1662
+ }
1663
+ .line {
1664
+ position: absolute;
1665
+ left: 0;
1666
+ height: 40rpx;
1667
+ width: 1px;
1668
+ background-color: rgba(0, 0, 0, 0.05);
1669
+ }
1670
+ }
1671
+ }
1672
+ }
1673
+ }
1674
+ .cellDivisionLine {
1675
+ height: 0;
1676
+ width: 100%;
1677
+ background-color: transparent;
1678
+ }
1679
+ .loadAll:active {
1680
+ background-color: rgba(0, 0, 0, 0.03);
1681
+ }
1682
+ .loadAll {
1683
+ width: 100%;
1684
+ height: 80rpx;
1685
+ display: flex;
1686
+ flex-direction: row;
1687
+ align-items: center;
1688
+ justify-content: center;
1689
+ .loadAllFold {
1690
+ width: 30rpx;
1691
+ height: 30rpx;
1692
+ }
1693
+ .loadAllText {
1694
+ font-size: 26rpx;
1695
+ color: #333;
1696
+ margin: 0 10rpx;
1697
+ }
1698
+ }
1699
+ .devEmpty {
1700
+ display: flex;
1701
+ flex-direction: row;
1702
+ align-items: center;
1703
+ justify-content: center;
1704
+ height: 240rpx;
1705
+ width: 100%;
1706
+ .devEmptyText {
1707
+ font-size: 24rpx;
1708
+ color: #64748b;
1709
+ line-height: 34rpx;
1710
+ background: #f8fafc;
1711
+ border: 1px solid rgba(148, 163, 184, 0.2);
1712
+ border-radius: 999rpx;
1713
+ padding: 8rpx 20rpx;
1714
+ }
1715
+ }
1716
+ .eventItem {
1717
+ display: flex;
1718
+ flex-direction: column;
1719
+ width: calc(100% - 40rpx);
1720
+ box-sizing: border-box;
1721
+ margin-left: 20rpx;
1722
+ margin-top: 10rpx;
1723
+ padding: 14rpx 16rpx;
1724
+ border-radius: 16rpx;
1725
+ border: 1px solid rgba(148, 163, 184, 0.2);
1726
+ background: #fff;
1727
+ box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.05);
1728
+ .eventName {
1729
+ font-size: 22rpx;
1730
+ color: #0f172a;
1731
+ }
1732
+ .eventHead {
1733
+ display: flex;
1734
+ flex-direction: row;
1735
+ align-items: center;
1736
+ justify-content: space-between;
1737
+ gap: 10rpx;
1738
+ }
1739
+ .eventCount {
1740
+ margin-top: 8rpx;
1741
+ display: flex;
1742
+ flex-direction: row;
1743
+ flex-wrap: wrap;
1744
+ justify-content: space-between;
1745
+ .eventCountItem {
1746
+ width: 170rpx;
1747
+ /* #ifndef APP-PLUS */
1748
+ max-width: 170rpx;
1749
+ /* #endif */
1750
+ font-size: 20rpx;
1751
+ color: #334155;
1752
+ line-height: 28rpx;
1753
+ }
1754
+ }
1755
+ }
1756
+ .eventLogItem {
1757
+ display: flex;
1758
+ flex-direction: column;
1759
+ width: calc(100% - 40rpx);
1760
+ box-sizing: border-box;
1761
+ margin-left: 20rpx;
1762
+ margin-top: 10rpx;
1763
+ padding: 14rpx 16rpx;
1764
+ border-radius: 16rpx;
1765
+ border: 1px solid rgba(148, 163, 184, 0.2);
1766
+ background: #fff;
1767
+ box-shadow: 0 4rpx 16rpx rgba(15, 23, 42, 0.05);
1768
+ .logText {
1769
+ font-size: 22rpx;
1770
+ color: #0f172a;
1771
+ line-height: 30rpx;
1772
+ }
1773
+ .logTime {
1774
+ font-size: 20rpx;
1775
+ color: #64748b;
1776
+ line-height: 28rpx;
1777
+ }
1778
+ .eventLogFoot {
1779
+ margin-top: 6rpx;
1780
+ display: flex;
1781
+ flex-direction: row;
1782
+ align-items: center;
1783
+ justify-content: space-between;
1784
+ gap: 10rpx;
1785
+ }
1786
+ }
1787
+ .eventActionBtn {
1788
+ height: 40rpx;
1789
+ border-radius: 999rpx;
1790
+ border: 1px solid #cbd5e1;
1791
+ background: #f8fafc;
1792
+ padding: 0 14rpx;
1793
+ display: flex;
1794
+ flex-direction: row;
1795
+ align-items: center;
1796
+ justify-content: center;
1797
+ &:active {
1798
+ background: #f1f5f9;
1799
+ }
1800
+ .eventActionText {
1801
+ font-size: 20rpx;
1802
+ line-height: 20rpx;
1803
+ color: #334155;
1804
+ }
1805
+ }
1806
+ .listCenterView {
1807
+ width: 100%;
1808
+ /* #ifndef APP-PLUS */
1809
+ min-height: 200rpx;
1810
+ /* #endif */
1811
+ display: flex;
1812
+ flex-direction: row;
1813
+ align-items: center;
1814
+ justify-content: center;
1815
+ .listCenterText {
1816
+ font-size: 24rpx;
1817
+ color: #64748b;
1818
+ background: #f8fafc;
1819
+ border: 1px solid rgba(148, 163, 184, 0.2);
1820
+ border-radius: 999rpx;
1821
+ padding: 8rpx 20rpx;
1822
+ }
1823
+ }
1824
+ </style>