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