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,599 @@
1
+ <template>
2
+ <view class="vuexList">
3
+ <view
4
+ v-if="!isLoaded"
5
+ class="dataLoading"
6
+ >
7
+ <text class="status">加载中</text>
8
+ </view>
9
+
10
+ <view
11
+ v-else-if="isEmpty"
12
+ class="dataLoading"
13
+ >
14
+ <text class="status">暂无状态数据</text>
15
+ </view>
16
+
17
+ <template v-else>
18
+ <view
19
+ v-for="(item, index) in stateRows"
20
+ :key="`${item.key}_${index}`"
21
+ class="stateRow"
22
+ @click="openValueViewer(item)"
23
+ >
24
+ <view class="section keySection">
25
+ <text class="sectionLabel">KEY</text>
26
+ <view class="keyContentRow">
27
+ <text class="keyText">{{ item.key }}</text>
28
+ <view
29
+ class="detailBtn"
30
+ @click.stop="openValueViewer(item)"
31
+ >
32
+ <text class="detailBtnText">查看详情</text>
33
+ </view>
34
+ </view>
35
+ </view>
36
+
37
+ <view class="sectionDivider" />
38
+
39
+ <view class="section valueSection">
40
+ <text class="sectionLabel">VALUE</text>
41
+ <text class="sectionText valueText">{{ item.preview }}</text>
42
+ </view>
43
+ </view>
44
+ </template>
45
+
46
+ <view
47
+ v-if="valueViewer.show"
48
+ class="valueViewerMask"
49
+ @click="closeValueViewer"
50
+ >
51
+ <view
52
+ class="valueViewerCard"
53
+ @click.stop
54
+ >
55
+ <view class="viewerHead">
56
+ <text class="viewerTitle">键值详情</text>
57
+ <text
58
+ class="viewerClose"
59
+ @click.stop="closeValueViewer"
60
+ >
61
+ ×
62
+ </text>
63
+ </view>
64
+
65
+ <view class="viewerSection">
66
+ <view class="viewerKeyRow">
67
+ <text class="sectionLabel">KEY</text>
68
+ <text class="viewerKey">{{ valueViewer.key }}</text>
69
+ </view>
70
+ </view>
71
+
72
+ <view class="viewerSection">
73
+ <text class="sectionLabel">VALUE</text>
74
+ <scroll-view
75
+ scroll-y
76
+ class="viewerBody"
77
+ >
78
+ <text class="viewerText">{{ valueViewer.fullText }}</text>
79
+ </scroll-view>
80
+ </view>
81
+
82
+ <view class="viewerActions">
83
+ <view
84
+ class="viewerBtn"
85
+ @click.stop="copyViewerValue"
86
+ >
87
+ <text class="viewerBtnText">复制</text>
88
+ </view>
89
+
90
+ <view
91
+ v-if="valueViewer.canEdit"
92
+ class="viewerBtn"
93
+ @click.stop="editViewerValue"
94
+ >
95
+ <text class="viewerBtnText">编辑</text>
96
+ </view>
97
+ </view>
98
+ </view>
99
+ </view>
100
+ </view>
101
+ </template>
102
+
103
+ <script>
104
+ import devUi from "../../../core/libs/devUi.js";
105
+
106
+ function isPrimitiveEditable(value) {
107
+ const vType = typeof value;
108
+ return value === null || vType === "string" || vType === "number" || vType === "boolean" || vType === "undefined";
109
+ }
110
+
111
+ export default {
112
+ props: {
113
+ /**
114
+ * 全局变量类型
115
+ */
116
+ stateType: {
117
+ type: String,
118
+ default: "vuex",
119
+ },
120
+ },
121
+ data() {
122
+ return {
123
+ isLoaded: false,
124
+ isEmpty: false,
125
+ stateRows: [],
126
+ loadToken: 0,
127
+ maxPreviewLength: 120,
128
+ valueViewer: {
129
+ show: false,
130
+ key: "",
131
+ fullText: "",
132
+ path: [],
133
+ canEdit: false,
134
+ },
135
+ };
136
+ },
137
+ mounted() {
138
+ this.getData();
139
+ },
140
+ beforeUnmount() {
141
+ this.loadToken += 1;
142
+ uni.$emit("devTools_valueViewer_hide");
143
+ },
144
+ beforeDestroy() {
145
+ this.loadToken += 1;
146
+ uni.$emit("devTools_valueViewer_hide");
147
+ },
148
+ watch: {
149
+ stateType() {
150
+ this.getData();
151
+ },
152
+ },
153
+ methods: {
154
+ /**
155
+ * 加载数据
156
+ */
157
+ async getData() {
158
+ const loadToken = ++this.loadToken;
159
+ this.isLoaded = false;
160
+ this.isEmpty = false;
161
+
162
+ const snapshot = this.getStateSnapshot();
163
+ if (loadToken !== this.loadToken) {
164
+ return false;
165
+ }
166
+
167
+ this.stateRows = this.buildStateRows(snapshot);
168
+ this.isEmpty = this.stateRows.length === 0;
169
+ this.isLoaded = true;
170
+ this.closeValueViewer();
171
+ return true;
172
+ },
173
+ getStateSnapshot() {
174
+ let data = {};
175
+ if (this.stateType == "vuex") {
176
+ try {
177
+ data = JSON.parse(JSON.stringify(this.$store.state));
178
+ } catch (error) {}
179
+ } else if (this.stateType == "pinia") {
180
+ try {
181
+ if (uni.Pinia) {
182
+ data = JSON.parse(JSON.stringify(uni.Pinia.getActivePinia().state.value));
183
+ } else if (this.$pinia) {
184
+ data = JSON.parse(JSON.stringify(this.$pinia.state.value));
185
+ }
186
+ } catch (error) {}
187
+ } else if (this.stateType == "globalData") {
188
+ try {
189
+ data = JSON.parse(JSON.stringify(getApp().globalData));
190
+ } catch (error) {}
191
+ }
192
+ return data;
193
+ },
194
+ getMutableStateRoot() {
195
+ if (this.stateType == "vuex") {
196
+ return this.$store ? this.$store.state : null;
197
+ }
198
+ if (this.stateType == "pinia") {
199
+ if (uni.Pinia) {
200
+ return uni.Pinia.getActivePinia().state.value;
201
+ }
202
+ if (this.$pinia) {
203
+ return this.$pinia.state.value;
204
+ }
205
+ return null;
206
+ }
207
+ if (this.stateType == "globalData") {
208
+ try {
209
+ return getApp().globalData;
210
+ } catch (error) {
211
+ return null;
212
+ }
213
+ }
214
+ return null;
215
+ },
216
+ buildStateRows(data) {
217
+ if (!data || typeof data != "object") {
218
+ return [];
219
+ }
220
+
221
+ const keys = Reflect.ownKeys(data).filter((key) => typeof key != "symbol");
222
+ return keys.map((key) => {
223
+ const value = data[key];
224
+ const fullText = this.stringifyValue(value, true);
225
+ return {
226
+ key: String(key),
227
+ path: [key],
228
+ value,
229
+ fullText,
230
+ preview: this.getPreviewText(fullText),
231
+ canEdit: isPrimitiveEditable(value),
232
+ };
233
+ });
234
+ },
235
+ getPreviewText(fullText) {
236
+ const singleLine = String(fullText || "")
237
+ .replace(/\s+/g, " ")
238
+ .trim();
239
+ if (singleLine.length <= this.maxPreviewLength) {
240
+ return singleLine;
241
+ }
242
+ return `${singleLine.slice(0, this.maxPreviewLength)}...`;
243
+ },
244
+ stringifyValue(data, pretty = false) {
245
+ try {
246
+ if (data === undefined) return "undefined";
247
+ if (data === null) return "null";
248
+ if (typeof data == "boolean") return data ? "true" : "false";
249
+ if (typeof data == "number") {
250
+ if (Number.isFinite(data)) return String(data);
251
+ return isNaN(data) ? "NaN" : "Infinity";
252
+ }
253
+ if (typeof data == "string") return data;
254
+ if (typeof data == "object") return JSON.stringify(data, null, pretty ? 2 : 0);
255
+ return data.toString();
256
+ } catch (error) {
257
+ return "尝试解析失败!" + error;
258
+ }
259
+ },
260
+ openValueViewer(item) {
261
+ uni.$emit("devTools_valueViewer_show");
262
+ this.valueViewer = {
263
+ show: true,
264
+ key: item.key,
265
+ fullText: item.fullText,
266
+ path: item.path || [],
267
+ canEdit: item.canEdit === true,
268
+ };
269
+ },
270
+ closeValueViewer() {
271
+ if (this.valueViewer.show) {
272
+ uni.$emit("devTools_valueViewer_hide");
273
+ }
274
+ this.valueViewer = {
275
+ ...this.valueViewer,
276
+ show: false,
277
+ };
278
+ },
279
+ copyViewerValue() {
280
+ if (!this.valueViewer.show) {
281
+ return;
282
+ }
283
+ this.copyToClipboard(this.buildCopyText(this.valueViewer.key, this.valueViewer.fullText));
284
+ },
285
+ copyToClipboard(data) {
286
+ uni.setClipboardData({
287
+ data,
288
+ success: () => {
289
+ devUi.showToast({
290
+ icon: "success",
291
+ title: "复制成功",
292
+ });
293
+ },
294
+ });
295
+ },
296
+ buildCopyText(key, valueText) {
297
+ return `KEY: ${key}\nVALUE:\n${valueText}`;
298
+ },
299
+ editViewerValue() {
300
+ if (!this.valueViewer.show || !this.valueViewer.canEdit) {
301
+ return;
302
+ }
303
+ const row = this.stateRows.find((x) => x.key === this.valueViewer.key);
304
+ if (!row) {
305
+ this.closeValueViewer();
306
+ return;
307
+ }
308
+ this.closeValueViewer();
309
+ this.editStateValue(row);
310
+ },
311
+ getValueByPath(root, path) {
312
+ let cursor = root;
313
+ for (let i = 0; i < path.length; i++) {
314
+ if (!cursor || typeof cursor != "object") {
315
+ return undefined;
316
+ }
317
+ cursor = cursor[path[i]];
318
+ }
319
+ return cursor;
320
+ },
321
+ setValueByPath(root, path, val) {
322
+ if (!root || typeof root != "object" || !Array.isArray(path) || path.length == 0) {
323
+ return false;
324
+ }
325
+ let cursor = root;
326
+ for (let i = 0; i < path.length - 1; i++) {
327
+ if (!cursor || typeof cursor != "object") {
328
+ return false;
329
+ }
330
+ cursor = cursor[path[i]];
331
+ }
332
+
333
+ if (!cursor || typeof cursor != "object") {
334
+ return false;
335
+ }
336
+
337
+ const lastKey = path[path.length - 1];
338
+ if (this.$set) {
339
+ this.$set(cursor, lastKey, val);
340
+ } else {
341
+ cursor[lastKey] = val;
342
+ }
343
+ return true;
344
+ },
345
+ editStateValue(item) {
346
+ const root = this.getMutableStateRoot();
347
+ if (!root || !item || !item.path || item.path.length == 0) {
348
+ this.getData();
349
+ return;
350
+ }
351
+
352
+ const oldValue = this.getValueByPath(root, item.path);
353
+ const oldType = typeof oldValue;
354
+ const isBool = oldType == "boolean";
355
+
356
+ let value = oldValue;
357
+ if (isBool) {
358
+ value = value ? "true" : "false";
359
+ } else if (value === undefined || value === null) {
360
+ value = "";
361
+ } else {
362
+ value = String(value);
363
+ }
364
+
365
+ uni.$emit("devTools_showEditDialog", {
366
+ title: item.key,
367
+ value,
368
+ });
369
+
370
+ uni.$on("devTools_editDialogClose", () => {
371
+ uni.$off("devTools_editDialogSaveSuccess");
372
+ uni.$off("devTools_editDialogClose");
373
+ });
374
+
375
+ uni.$on("devTools_editDialogSaveSuccess", (val) => {
376
+ uni.$off("devTools_editDialogSaveSuccess");
377
+ uni.$off("devTools_editDialogClose");
378
+
379
+ if (isBool && (val == "true" || val == "false")) {
380
+ val = val == "true";
381
+ }
382
+
383
+ this.setValueByPath(root, item.path, val);
384
+ this.getData();
385
+ });
386
+ },
387
+ },
388
+ };
389
+ </script>
390
+
391
+ <style lang="scss" scoped>
392
+ .vuexList {
393
+ padding: 16rpx 20rpx;
394
+ width: 100%;
395
+ box-sizing: border-box;
396
+ }
397
+
398
+ .dataLoading {
399
+ width: 100%;
400
+ box-sizing: border-box;
401
+ height: 220rpx;
402
+ margin: 10rpx 0;
403
+ border-radius: 16rpx;
404
+ border: 1px solid rgba(148, 163, 184, 0.2);
405
+ background: #f8fafc;
406
+ display: flex;
407
+ flex-direction: row;
408
+ align-items: center;
409
+ justify-content: center;
410
+
411
+ .status {
412
+ font-size: 24rpx;
413
+ color: #64748b;
414
+ line-height: 34rpx;
415
+ }
416
+ }
417
+
418
+ .stateRow {
419
+ width: 100%;
420
+ box-sizing: border-box;
421
+ border-radius: 16rpx;
422
+ border: 1px solid rgba(148, 163, 184, 0.18);
423
+ background: #fff;
424
+ margin: 0 0 12rpx;
425
+ padding: 14rpx 16rpx;
426
+ box-shadow: 0 4rpx 12rpx rgba(15, 23, 42, 0.04);
427
+ }
428
+
429
+ .section {
430
+ display: flex;
431
+ flex-direction: column;
432
+ }
433
+
434
+ .sectionLabel {
435
+ font-size: 18rpx;
436
+ line-height: 24rpx;
437
+ color: #94a3b8;
438
+ letter-spacing: 1rpx;
439
+ text-transform: uppercase;
440
+ }
441
+
442
+ .sectionText {
443
+ margin-top: 6rpx;
444
+ word-break: break-all;
445
+ }
446
+
447
+ .keyText {
448
+ flex: 1;
449
+ font-size: 24rpx;
450
+ line-height: 32rpx;
451
+ color: #0f172a;
452
+ font-weight: 500;
453
+ word-break: break-all;
454
+ padding-right: 12rpx;
455
+ }
456
+
457
+ .keyContentRow {
458
+ margin-top: 6rpx;
459
+ display: flex;
460
+ flex-direction: row;
461
+ align-items: center;
462
+ }
463
+
464
+ .detailBtn {
465
+ height: 44rpx;
466
+ padding: 0 14rpx;
467
+ border-radius: 22rpx;
468
+ border: 1px solid rgba(59, 130, 246, 0.26);
469
+ background: #eff6ff;
470
+ display: flex;
471
+ flex-direction: row;
472
+ align-items: center;
473
+ justify-content: center;
474
+ flex-shrink: 0;
475
+ }
476
+
477
+ .detailBtnText {
478
+ font-size: 20rpx;
479
+ line-height: 28rpx;
480
+ color: #2563eb;
481
+ }
482
+
483
+ .sectionDivider {
484
+ margin: 10rpx 0;
485
+ height: 1px;
486
+ background: rgba(148, 163, 184, 0.22);
487
+ }
488
+
489
+ .valueText {
490
+ font-size: 22rpx;
491
+ line-height: 30rpx;
492
+ color: #334155;
493
+ }
494
+
495
+ .valueViewerMask {
496
+ position: fixed;
497
+ left: 0;
498
+ right: 0;
499
+ top: var(--devtools-panel-top, 40vh);
500
+ bottom: 0;
501
+ background: rgba(15, 23, 42, 0.45);
502
+ z-index: 20;
503
+ display: flex;
504
+ align-items: center;
505
+ justify-content: center;
506
+ }
507
+
508
+ .valueViewerCard {
509
+ width: 700rpx;
510
+ max-height: calc(var(--devtools-panel-height, 60vh) - 40rpx);
511
+ border-radius: 16rpx;
512
+ background: #fff;
513
+ border: 1px solid rgba(148, 163, 184, 0.25);
514
+ padding: 14rpx;
515
+ display: flex;
516
+ flex-direction: column;
517
+ }
518
+
519
+ .viewerHead {
520
+ display: flex;
521
+ align-items: center;
522
+ justify-content: space-between;
523
+ }
524
+
525
+ .viewerTitle {
526
+ flex: 1;
527
+ font-size: 24rpx;
528
+ line-height: 32rpx;
529
+ color: #0f172a;
530
+ font-weight: 500;
531
+ }
532
+
533
+ .viewerClose {
534
+ width: 44rpx;
535
+ text-align: center;
536
+ font-size: 42rpx;
537
+ line-height: 32rpx;
538
+ color: #64748b;
539
+ }
540
+
541
+ .viewerSection {
542
+ margin-top: 12rpx;
543
+ }
544
+
545
+ .viewerKey {
546
+ margin-left: 10rpx;
547
+ font-size: 22rpx;
548
+ line-height: 32rpx;
549
+ color: #0f172a;
550
+ word-break: break-all;
551
+ }
552
+
553
+ .viewerKeyRow {
554
+ margin-top: 6rpx;
555
+ display: flex;
556
+ flex-direction: row;
557
+ align-items: center;
558
+ }
559
+
560
+ .viewerBody {
561
+ margin-top: 8rpx;
562
+ height: 560rpx;
563
+ padding: 10rpx;
564
+ background: #f8fafc;
565
+ border-radius: 10rpx;
566
+ border: 1px solid rgba(148, 163, 184, 0.16);
567
+ }
568
+
569
+ .viewerText {
570
+ font-size: 22rpx;
571
+ line-height: 32rpx;
572
+ color: #334155;
573
+ word-break: break-all;
574
+ white-space: pre-wrap;
575
+ }
576
+
577
+ .viewerActions {
578
+ margin-top: 12rpx;
579
+ display: flex;
580
+ justify-content: flex-end;
581
+ }
582
+
583
+ .viewerBtn {
584
+ min-width: 108rpx;
585
+ height: 56rpx;
586
+ border-radius: 10rpx;
587
+ background: #f1f5f9;
588
+ border: 1px solid rgba(148, 163, 184, 0.25);
589
+ display: flex;
590
+ align-items: center;
591
+ justify-content: center;
592
+ margin-left: 8rpx;
593
+ }
594
+
595
+ .viewerBtnText {
596
+ font-size: 22rpx;
597
+ color: #334155;
598
+ }
599
+ </style>