oxy-uni-ui 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/attributes.json +1 -1
  2. package/components/common/abstracts/variable.scss +13 -2
  3. package/components/oxy-checkbox/index.scss +37 -2
  4. package/components/oxy-sort-button/index.scss +3 -4
  5. package/components/oxy-tag/index.scss +157 -17
  6. package/components/oxy-tag/oxy-tag.vue +14 -2
  7. package/components/oxy-tag/types.ts +9 -0
  8. package/dev-tools.ts +2 -0
  9. package/devTools/components/DevToolsOverlay.vue +56 -0
  10. package/devTools/components/DevToolsUiHost.vue +589 -0
  11. package/devTools/config.js +55 -0
  12. package/devTools/core/components/mpDevBubble.vue +174 -0
  13. package/devTools/core/libs/createH5Bubble.js +156 -0
  14. package/devTools/core/libs/devCache.js +151 -0
  15. package/devTools/core/libs/devOptions.js +163 -0
  16. package/devTools/core/libs/devUi.js +219 -0
  17. package/devTools/core/libs/drawView.js +140 -0
  18. package/devTools/core/libs/errorReport.js +64 -0
  19. package/devTools/core/libs/jsonCompress.js +334 -0
  20. package/devTools/core/libs/logReport.js +59 -0
  21. package/devTools/core/libs/pageLinkList.js +125 -0
  22. package/devTools/core/libs/timeFormat.js +94 -0
  23. package/devTools/core/proxy/console.js +430 -0
  24. package/devTools/core/proxy/index.js +36 -0
  25. package/devTools/core/proxy/request.js +495 -0
  26. package/devTools/core/proxy/storage.js +113 -0
  27. package/devTools/core/proxy/uniBus.js +153 -0
  28. package/devTools/core/proxy/uniListen.js +192 -0
  29. package/devTools/core/proxy/vueMixin.js +120 -0
  30. package/devTools/index.js +168 -0
  31. package/devTools/page/components/bottomTools.vue +1046 -0
  32. package/devTools/page/components/dialog/addStorage.vue +204 -0
  33. package/devTools/page/components/dialog/createDir.vue +366 -0
  34. package/devTools/page/components/dialog/editDialog.vue +192 -0
  35. package/devTools/page/components/dialog/routeDialog.vue +184 -0
  36. package/devTools/page/components/dialog/sendRequest.vue +603 -0
  37. package/devTools/page/components/dialog/textFileEditDialog.vue +391 -0
  38. package/devTools/page/components/libs/appDelDir.js +86 -0
  39. package/devTools/page/components/libs/dirReader.js +248 -0
  40. package/devTools/page/components/libs/fileSize.js +15 -0
  41. package/devTools/page/components/libs/getRuntimeInfo.js +134 -0
  42. package/devTools/page/components/listItem/consoleItem.vue +314 -0
  43. package/devTools/page/components/listItem/errorItem.vue +292 -0
  44. package/devTools/page/components/listItem/fileSysItem.vue +533 -0
  45. package/devTools/page/components/listItem/infoList.vue +100 -0
  46. package/devTools/page/components/listItem/jsRunnerItem.vue +255 -0
  47. package/devTools/page/components/listItem/logItem.vue +193 -0
  48. package/devTools/page/components/listItem/networkItem.vue +398 -0
  49. package/devTools/page/components/listItem/objectAnalysis.vue +651 -0
  50. package/devTools/page/components/listItem/pages.vue +319 -0
  51. package/devTools/page/components/listItem/routeItem.vue +153 -0
  52. package/devTools/page/components/listItem/setting.vue +734 -0
  53. package/devTools/page/components/listItem/storageList.vue +681 -0
  54. package/devTools/page/components/listItem/tools.vue +315 -0
  55. package/devTools/page/components/listItem/vuexList.vue +599 -0
  56. package/devTools/page/components/main.vue +1867 -0
  57. package/devTools/page/components/mixins/animationControl.js +91 -0
  58. package/devTools/page/components/mixins/mp.js +83 -0
  59. package/devTools/page/components/ui/btnTabs.vue +90 -0
  60. package/devTools/page/components/ui/codeHisPicker.vue +172 -0
  61. package/devTools/page/components/ui/h5Cell.vue +13 -0
  62. package/devTools/page/components/ui/menuBtn.vue +94 -0
  63. package/devTools/page/components/ui/mobileSwiperScroll.vue +74 -0
  64. package/devTools/page/components/ui/requestSpeedLimit.vue +52 -0
  65. package/devTools/page/components/ui/requestTimeoutMock.vue +55 -0
  66. package/devTools/page/components/ui/subTitleBar.vue +101 -0
  67. package/devTools/page/static/copy.png +0 -0
  68. package/devTools/page/static/delete.png +0 -0
  69. package/devTools/page/static/fileSys/AI.png +0 -0
  70. package/devTools/page/static/fileSys/DWG.png +0 -0
  71. package/devTools/page/static/fileSys/EXE.png +0 -0
  72. package/devTools/page/static/fileSys/GIF.png +0 -0
  73. package/devTools/page/static/fileSys/HTML.png +0 -0
  74. package/devTools/page/static/fileSys/PSD.png +0 -0
  75. package/devTools/page/static/fileSys/RVT.png +0 -0
  76. package/devTools/page/static/fileSys/SKP.png +0 -0
  77. package/devTools/page/static/fileSys/SVG.png +0 -0
  78. package/devTools/page/static/fileSys/excel.png +0 -0
  79. package/devTools/page/static/fileSys/pdf.png +0 -0
  80. package/devTools/page/static/fileSys/pptl.png +0 -0
  81. package/devTools/page/static/fileSys/shipin.png +0 -0
  82. package/devTools/page/static/fileSys/tupian.png +0 -0
  83. package/devTools/page/static/fileSys/txt.png +0 -0
  84. package/devTools/page/static/fileSys/weizhiwenjian.png +0 -0
  85. package/devTools/page/static/fileSys/wenjianjia.png +0 -0
  86. package/devTools/page/static/fileSys/word.png +0 -0
  87. package/devTools/page/static/fileSys/yasuo.png +0 -0
  88. package/devTools/page/static/fileSys/yinpin.png +0 -0
  89. package/devTools/page/static/fold.png +0 -0
  90. package/devTools/page/static/menu.png +0 -0
  91. package/devTools/page/static/refresh.png +0 -0
  92. package/devTools/page/static/unfold.png +0 -0
  93. package/devTools/tools.vue +25 -0
  94. package/devTools/type/devTools.d.ts +406 -0
  95. package/oxy-dev-tools/components/DevToolsUiHost.vue +555 -0
  96. package/oxy-dev-tools/config.js +61 -0
  97. package/oxy-dev-tools/core/components/mpDevBubble.vue +176 -0
  98. package/oxy-dev-tools/core/libs/createH5Bubble.js +156 -0
  99. package/oxy-dev-tools/core/libs/devCache.js +149 -0
  100. package/oxy-dev-tools/core/libs/devOptions.js +160 -0
  101. package/oxy-dev-tools/core/libs/devUi.js +219 -0
  102. package/oxy-dev-tools/core/libs/drawView.js +144 -0
  103. package/oxy-dev-tools/core/libs/errorReport.js +60 -0
  104. package/oxy-dev-tools/core/libs/jsonCompress.js +328 -0
  105. package/oxy-dev-tools/core/libs/logReport.js +55 -0
  106. package/oxy-dev-tools/core/libs/pageLinkList.js +121 -0
  107. package/oxy-dev-tools/core/libs/timeFormat.js +93 -0
  108. package/oxy-dev-tools/core/proxy/console.js +398 -0
  109. package/oxy-dev-tools/core/proxy/index.js +33 -0
  110. package/oxy-dev-tools/core/proxy/request.js +473 -0
  111. package/oxy-dev-tools/core/proxy/storage.js +96 -0
  112. package/oxy-dev-tools/core/proxy/uniBus.js +148 -0
  113. package/oxy-dev-tools/core/proxy/uniListen.js +190 -0
  114. package/oxy-dev-tools/core/proxy/vueMixin.js +115 -0
  115. package/oxy-dev-tools/index.ts +183 -0
  116. package/oxy-dev-tools/oxy-dev-tools.vue +62 -0
  117. package/oxy-dev-tools/page/components/bottomTools.vue +933 -0
  118. package/oxy-dev-tools/page/components/dialog/addStorage.vue +184 -0
  119. package/oxy-dev-tools/page/components/dialog/createDir.vue +352 -0
  120. package/oxy-dev-tools/page/components/dialog/editDialog.vue +178 -0
  121. package/oxy-dev-tools/page/components/dialog/routeDialog.vue +170 -0
  122. package/oxy-dev-tools/page/components/dialog/sendRequest.vue +530 -0
  123. package/oxy-dev-tools/page/components/dialog/textFileEditDialog.vue +379 -0
  124. package/oxy-dev-tools/page/components/libs/appDelDir.js +77 -0
  125. package/oxy-dev-tools/page/components/libs/dirReader.js +239 -0
  126. package/oxy-dev-tools/page/components/libs/fileSize.js +15 -0
  127. package/oxy-dev-tools/page/components/libs/getRuntimeInfo.js +132 -0
  128. package/oxy-dev-tools/page/components/listItem/consoleItem.vue +292 -0
  129. package/oxy-dev-tools/page/components/listItem/errorItem.vue +268 -0
  130. package/oxy-dev-tools/page/components/listItem/fileSysItem.vue +511 -0
  131. package/oxy-dev-tools/page/components/listItem/infoList.vue +89 -0
  132. package/oxy-dev-tools/page/components/listItem/jsRunnerItem.vue +236 -0
  133. package/oxy-dev-tools/page/components/listItem/logItem.vue +185 -0
  134. package/oxy-dev-tools/page/components/listItem/networkItem.vue +362 -0
  135. package/oxy-dev-tools/page/components/listItem/objectAnalysis.vue +642 -0
  136. package/oxy-dev-tools/page/components/listItem/pages.vue +285 -0
  137. package/oxy-dev-tools/page/components/listItem/routeItem.vue +140 -0
  138. package/oxy-dev-tools/page/components/listItem/setting.vue +687 -0
  139. package/oxy-dev-tools/page/components/listItem/storageList.vue +623 -0
  140. package/oxy-dev-tools/page/components/listItem/tools.vue +273 -0
  141. package/oxy-dev-tools/page/components/listItem/vuexList.vue +559 -0
  142. package/oxy-dev-tools/page/components/main.vue +1824 -0
  143. package/oxy-dev-tools/page/components/mixins/animationControl.js +80 -0
  144. package/oxy-dev-tools/page/components/mixins/mp.js +76 -0
  145. package/oxy-dev-tools/page/components/ui/btnTabs.vue +77 -0
  146. package/oxy-dev-tools/page/components/ui/codeHisPicker.vue +161 -0
  147. package/oxy-dev-tools/page/components/ui/h5Cell.vue +13 -0
  148. package/oxy-dev-tools/page/components/ui/menuBtn.vue +87 -0
  149. package/oxy-dev-tools/page/components/ui/mobileSwiperScroll.vue +71 -0
  150. package/oxy-dev-tools/page/components/ui/requestSpeedLimit.vue +47 -0
  151. package/oxy-dev-tools/page/components/ui/requestTimeoutMock.vue +50 -0
  152. package/oxy-dev-tools/page/components/ui/subTitleBar.vue +87 -0
  153. package/oxy-dev-tools/page/static/copy.png +0 -0
  154. package/oxy-dev-tools/page/static/delete.png +0 -0
  155. package/oxy-dev-tools/page/static/fileSys/AI.png +0 -0
  156. package/oxy-dev-tools/page/static/fileSys/DWG.png +0 -0
  157. package/oxy-dev-tools/page/static/fileSys/EXE.png +0 -0
  158. package/oxy-dev-tools/page/static/fileSys/GIF.png +0 -0
  159. package/oxy-dev-tools/page/static/fileSys/HTML.png +0 -0
  160. package/oxy-dev-tools/page/static/fileSys/PSD.png +0 -0
  161. package/oxy-dev-tools/page/static/fileSys/RVT.png +0 -0
  162. package/oxy-dev-tools/page/static/fileSys/SKP.png +0 -0
  163. package/oxy-dev-tools/page/static/fileSys/SVG.png +0 -0
  164. package/oxy-dev-tools/page/static/fileSys/excel.png +0 -0
  165. package/oxy-dev-tools/page/static/fileSys/pdf.png +0 -0
  166. package/oxy-dev-tools/page/static/fileSys/pptl.png +0 -0
  167. package/oxy-dev-tools/page/static/fileSys/shipin.png +0 -0
  168. package/oxy-dev-tools/page/static/fileSys/tupian.png +0 -0
  169. package/oxy-dev-tools/page/static/fileSys/txt.png +0 -0
  170. package/oxy-dev-tools/page/static/fileSys/weizhiwenjian.png +0 -0
  171. package/oxy-dev-tools/page/static/fileSys/wenjianjia.png +0 -0
  172. package/oxy-dev-tools/page/static/fileSys/word.png +0 -0
  173. package/oxy-dev-tools/page/static/fileSys/yasuo.png +0 -0
  174. package/oxy-dev-tools/page/static/fileSys/yinpin.png +0 -0
  175. package/oxy-dev-tools/page/static/fold.png +0 -0
  176. package/oxy-dev-tools/page/static/menu.png +0 -0
  177. package/oxy-dev-tools/page/static/refresh.png +0 -0
  178. package/oxy-dev-tools/page/static/unfold.png +0 -0
  179. package/oxy-dev-tools/tools.vue +22 -0
  180. package/oxy-dev-tools/type/devTools.d.ts +406 -0
  181. package/package.json +1 -1
  182. package/tags.json +1 -1
  183. package/web-types.json +1 -1
@@ -0,0 +1,391 @@
1
+ <template>
2
+ <view>
3
+ <view
4
+ class="dialogMask"
5
+ v-if="isShow"
6
+ :style="{
7
+ height: height + 'px',
8
+ }"
9
+ >
10
+ <view
11
+ class="dialogContent"
12
+ @click.stop
13
+ >
14
+ <view
15
+ class="dialogHead"
16
+ >
17
+ <view>
18
+ <text class="title">{{ title }}</text>
19
+ </view>
20
+ <view
21
+ class="closeBtn"
22
+ @click.stop="hide"
23
+ >
24
+ <text class="closeText">关闭</text>
25
+ <text class="closeIcon">×</text>
26
+ </view>
27
+ </view>
28
+ <scroll-view
29
+ scroll-y
30
+ class="scrollList"
31
+ :style="{
32
+ height: dialogHeight + 'px',
33
+ }"
34
+ >
35
+ <textarea
36
+ :style="{
37
+ height: dialogHeight - (canSave ? 90 : 40) + 'px',
38
+ }"
39
+ v-model="value"
40
+ type="text"
41
+ placeholder="请输入..."
42
+ class="fileEditInput"
43
+ maxlength="-1"
44
+ />
45
+ <view
46
+ class="saveBtn"
47
+ v-if="canSave"
48
+ @click="saveFile"
49
+ >
50
+ <text class="saveBtnText">保存</text>
51
+ </view>
52
+ </scroll-view>
53
+ </view>
54
+ </view>
55
+ </view>
56
+ </template>
57
+ <script>
58
+ import devUi from "../../../core/libs/devUi.js";
59
+ let success, error;
60
+ export default {
61
+ data() {
62
+ return {
63
+ /**
64
+ * 是否展示
65
+ */
66
+ isShow: false,
67
+ /**
68
+ * 屏幕高度
69
+ */
70
+ height: uni.getSystemInfoSync().windowHeight,
71
+ dialogHeight: uni.getSystemInfoSync().windowHeight * 0.8,
72
+ /**
73
+ * 弹窗标题
74
+ */
75
+ title: "",
76
+ /**
77
+ * 文本内容
78
+ */
79
+ value: "",
80
+ /**
81
+ * 是否为文件编辑模式
82
+ */
83
+ isFileEdit: true,
84
+ /**
85
+ * 文件路径
86
+ */
87
+ path: "",
88
+ /**
89
+ * 是否允许保存
90
+ */
91
+ canSave: false,
92
+ /**
93
+ * 是否为新建文件
94
+ */
95
+ isNewFile: false,
96
+ };
97
+ },
98
+ mounted() {
99
+ let that = this;
100
+ uni.$on("devTools_showTextEditDialog", (options) => {
101
+ that
102
+ .show(options)
103
+ .then((val) => {
104
+ uni.$emit("devTools_showTextEditDialogSave", val);
105
+ })
106
+ .catch(() => {
107
+ uni.$emit("devTools_showTextEditDialogHide");
108
+ });
109
+ });
110
+ },
111
+ unmounted() {
112
+ uni.$off("devTools_showTextEditDialog");
113
+ },
114
+ methods: {
115
+ /**
116
+ * 展示弹窗
117
+ */
118
+ show(options) {
119
+ let that = this;
120
+ return new Promise((yes, err) => {
121
+ success = yes;
122
+ error = err;
123
+ that.title = options.title;
124
+ that.canSave = Boolean(options.canSave);
125
+ that.isShow = true;
126
+
127
+ if (options.isFileEdit === false) {
128
+ // 仅为文件编辑模式
129
+ that.isFileEdit = false;
130
+ try {
131
+ that.value = JSON.stringify(JSON.parse(options.value), null, 2);
132
+ } catch (error) {
133
+ that.value = options.value;
134
+ }
135
+ return;
136
+ }
137
+ that.isFileEdit = true;
138
+ that.value = "文件读取中...";
139
+ that.path = options.path;
140
+ that.isNewFile = Boolean(options.isNewFile);
141
+
142
+ // #ifdef APP-PLUS
143
+ if (that.isNewFile) {
144
+ that.value = "";
145
+ } else {
146
+ plus.io.resolveLocalFileSystemURL(
147
+ that.path,
148
+ (entry) => {
149
+ // 可通过entry对象操作test.html文件
150
+ entry.file((file) => {
151
+ var fileReader = new plus.io.FileReader();
152
+ fileReader.readAsText(file, "utf-8");
153
+ fileReader.onloadend = function (evt) {
154
+ let res = "";
155
+ try {
156
+ res = JSON.stringify(JSON.parse(evt.target.result), null, 2);
157
+ } catch (error) {
158
+ res = evt.target.result;
159
+ }
160
+ that.value = res;
161
+ };
162
+ fileReader.onerror = function () {
163
+ that.value = `[${that.path}]文件读取失败!_code_2`;
164
+ };
165
+ });
166
+ },
167
+ function (e) {
168
+ that.value = `[${that.path}]文件读取失败!` + e.message;
169
+ }
170
+ );
171
+ }
172
+ // #endif
173
+
174
+ // #ifdef MP-WEIXIN
175
+ let fs = wx.getFileSystemManager();
176
+ if (options.size != 0) {
177
+ fs.readFile({
178
+ filePath: that.path,
179
+ encoding: "utf8",
180
+ position: 0,
181
+ length: options.size,
182
+ success({ data }) {
183
+ try {
184
+ that.value = JSON.stringify(JSON.parse(data), null, 2);
185
+ } catch (error) {
186
+ that.value = data;
187
+ }
188
+ },
189
+ fail(e) {
190
+ console.log(e);
191
+ that.value = `[${that.path}]文件读取失败!` + e;
192
+ },
193
+ });
194
+ } else {
195
+ that.value = "";
196
+ }
197
+ // #endif
198
+ });
199
+ },
200
+ /**
201
+ * 关闭弹窗
202
+ */
203
+ hide() {
204
+ this.isShow = false;
205
+ error();
206
+ },
207
+ /**
208
+ * 保存
209
+ */
210
+ save() {
211
+ this.isShow = false;
212
+ success(this.value);
213
+ },
214
+ /**
215
+ * 保存文件
216
+ */
217
+ saveFile() {
218
+ let that = this;
219
+
220
+ if (!that.isFileEdit) {
221
+ // 非文件编辑模式
222
+
223
+ that.isShow = false;
224
+ success(that.value);
225
+
226
+ return;
227
+ }
228
+
229
+ devUi.showLoading({
230
+ title: "保存中",
231
+ });
232
+
233
+ // #ifdef APP-PLUS
234
+
235
+ let fileName = that.path.split("/").pop();
236
+ let path = that.path.substring(0, that.path.length - fileName.length);
237
+
238
+ plus.io.resolveLocalFileSystemURL(
239
+ path,
240
+ (entry) => {
241
+ entry.getFile(
242
+ fileName,
243
+ {
244
+ create: true,
245
+ },
246
+ (fileEntry) => {
247
+ fileEntry.createWriter((writer) => {
248
+ writer.onwrite = (e) => {
249
+ devUi.hideLoading();
250
+ devUi.showToast({
251
+ title: "文件保存成功!",
252
+ icon: "success",
253
+ });
254
+ that.isShow = false;
255
+ that.$emit("getPage");
256
+ };
257
+ writer.onerror = () => {
258
+ devUi.hideLoading();
259
+ devUi.showToast({
260
+ title: "文件保存失败!_写入文件失败",
261
+ icon: "none",
262
+ });
263
+ };
264
+ writer.write(that.value);
265
+ });
266
+ }
267
+ );
268
+ },
269
+ () => {
270
+ devUi.hideLoading();
271
+ devUi.showToast({
272
+ title: "文件保存失败!_打开目录失败",
273
+ icon: "none",
274
+ });
275
+ }
276
+ );
277
+ // #endif
278
+
279
+ // #ifdef MP-WEIXIN
280
+
281
+ let fs = wx.getFileSystemManager();
282
+ fs.writeFile({
283
+ filePath: that.path,
284
+ encoding: "utf-8",
285
+ data: that.value,
286
+ success() {
287
+ devUi.hideLoading();
288
+ devUi.showToast({
289
+ title: "文件保存成功!",
290
+ icon: "success",
291
+ });
292
+ that.isShow = false;
293
+ that.$emit("getPage");
294
+ },
295
+ fail() {
296
+ devUi.hideLoading();
297
+ devUi.showToast({
298
+ title: "文件保存失败!_打开目录失败",
299
+ icon: "none",
300
+ });
301
+ },
302
+ });
303
+
304
+ // #endif
305
+ },
306
+ },
307
+ };
308
+ </script>
309
+ <style lang="scss" scoped>
310
+ .dialogMask {
311
+ display: flex;
312
+ flex-direction: column-reverse;
313
+ background-color: rgba(0, 0, 0, 0.3);
314
+ width: 750rpx;
315
+ flex: 1;
316
+ /* #ifndef APP-PLUS */
317
+ height: 100vh;
318
+ backdrop-filter: blur(1px);
319
+ /* #endif */
320
+ position: fixed;
321
+ left: 0;
322
+ top: 0;
323
+ z-index: 999;
324
+ .dialogContent {
325
+ display: flex;
326
+ flex-direction: column;
327
+ width: 750rpx;
328
+ background-color: #fff;
329
+ border-radius: 20rpx 20rpx 0 0;
330
+ .dialogHead {
331
+ display: flex;
332
+ flex-direction: row;
333
+ align-items: center;
334
+ justify-content: space-between;
335
+ height: 80rpx;
336
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
337
+ width: 750rpx;
338
+ .title {
339
+ margin-left: 20rpx;
340
+ font-size: 24rpx;
341
+ line-height: 24rpx;
342
+ color: #333;
343
+ }
344
+ .closeBtn {
345
+ margin-right: 20rpx;
346
+ padding: 8rpx 14rpx;
347
+ border-radius: 999rpx;
348
+ border: 1px solid rgba(100, 116, 139, 0.28);
349
+ background-color: #f8fafc;
350
+ display: flex;
351
+ flex-direction: row;
352
+ align-items: center;
353
+ }
354
+ .closeText {
355
+ font-size: 22rpx;
356
+ color: #64748b;
357
+ line-height: 22rpx;
358
+ }
359
+ .closeIcon {
360
+ margin-left: 8rpx;
361
+ font-size: 24rpx;
362
+ line-height: 24rpx;
363
+ color: #334155;
364
+ }
365
+ }
366
+ .scrollList {
367
+ width: 750rpx;
368
+ padding: 20rpx;
369
+ .fileEditInput {
370
+ font-size: 20rpx;
371
+ }
372
+ .saveBtn {
373
+ display: flex;
374
+ flex-direction: row;
375
+ align-items: center;
376
+ justify-content: center;
377
+ margin-top: 20rpx;
378
+ height: 35px;
379
+ width: 710rpx;
380
+ border-radius: 10rpx;
381
+ background-color: #3b82f6;
382
+ .saveBtnText {
383
+ color: #fff;
384
+ font-size: 24rpx;
385
+ line-height: 24rpx;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+ </style>
@@ -0,0 +1,86 @@
1
+ import dirReader from "./dirReader"
2
+
3
+ /**
4
+ * 遍历删除整个文件夹,以“/”结尾
5
+ */
6
+ export default function appDelDir(path, needDelSelf = true) {
7
+ return new Promise(async (yes, err) => {
8
+ let dirList = await dirReader.getDirFileList(path)
9
+ for (let i = 0; i < dirList.length; i++) {
10
+ let item = dirList[i];
11
+ try {
12
+ if (item.type == "dir") {
13
+ let info = await getMeteInfo(path + item.name + "/")
14
+ if (
15
+ info.directoryCount > 0
16
+ || info.fileCount > 0
17
+ ) {
18
+ await appDelDir(path + item.name + "/")
19
+ } else {
20
+ await delDir(path + item.name + "/")
21
+ }
22
+ } else {
23
+ await delFile(path + item.name)
24
+ }
25
+ } catch (error) { }
26
+ }
27
+ try {
28
+ if (needDelSelf) {
29
+ await delDir(path)
30
+ }
31
+ } catch (error) { }
32
+ yes()
33
+ })
34
+ }
35
+
36
+ function delFile(path) {
37
+ return new Promise((yes, err) => {
38
+ plus.io.resolveLocalFileSystemURL(
39
+ path,
40
+ (entry) => {
41
+ entry.remove(
42
+ yes,
43
+ err
44
+ )
45
+ },
46
+ err
47
+ );
48
+ })
49
+ }
50
+
51
+ function delDir(path) {
52
+ return new Promise((yes, err) => {
53
+ plus.io.resolveLocalFileSystemURL(
54
+ path,
55
+ (entry) => {
56
+ entry.remove(
57
+ yes,
58
+ err
59
+ )
60
+ },
61
+ err
62
+ );
63
+ })
64
+ }
65
+
66
+ /**
67
+ * 获取文件夹内信息
68
+ * @returns {Promise<PlusIoMetadata>}
69
+ */
70
+ function getMeteInfo(path) {
71
+ return new Promise((yes, err) => {
72
+ plus.io.resolveLocalFileSystemURL(
73
+ path,
74
+ (entry) => {
75
+ if (entry.isDirectory) {
76
+ entry.getMetadata((metadata) => {
77
+ yes(metadata)
78
+ }, err)
79
+ } else {
80
+ err()
81
+ }
82
+ },
83
+ err
84
+ );
85
+ })
86
+ }
@@ -0,0 +1,248 @@
1
+ import devUi from "../../../core/libs/devUi.js";
2
+ import iconUnknown from "../../static/fileSys/weizhiwenjian.png";
3
+ import iconDwg from "../../static/fileSys/DWG.png";
4
+ import iconExcel from "../../static/fileSys/excel.png";
5
+ import iconExe from "../../static/fileSys/EXE.png";
6
+ import iconGif from "../../static/fileSys/GIF.png";
7
+ import iconHtml from "../../static/fileSys/HTML.png";
8
+ import iconPdf from "../../static/fileSys/pdf.png";
9
+ import iconPpt from "../../static/fileSys/pptl.png";
10
+ import iconPsd from "../../static/fileSys/PSD.png";
11
+ import iconRvt from "../../static/fileSys/RVT.png";
12
+ import iconVideo from "../../static/fileSys/shipin.png";
13
+ import iconSkp from "../../static/fileSys/SKP.png";
14
+ import iconSvg from "../../static/fileSys/SVG.png";
15
+ import iconImage from "../../static/fileSys/tupian.png";
16
+ import iconTxt from "../../static/fileSys/txt.png";
17
+ import iconWord from "../../static/fileSys/word.png";
18
+ import iconZip from "../../static/fileSys/yasuo.png";
19
+ import iconAudio from "../../static/fileSys/yinpin.png";
20
+ import iconDir from "../../static/fileSys/wenjianjia.png";
21
+ const iconConfig = [
22
+ {
23
+ type: ["", undefined, null],
24
+ mime: "",
25
+ icon: iconUnknown,
26
+ },
27
+ {
28
+ type: ["dwg"],
29
+ mime: "dwg",
30
+ icon: iconDwg,
31
+ },
32
+ {
33
+ type: ["xls", "xlsx", "csv"],
34
+ mime: "xls",
35
+ icon: iconExcel,
36
+ },
37
+ {
38
+ type: ["exe"],
39
+ mime: "exe",
40
+ icon: iconExe,
41
+ },
42
+ {
43
+ type: ["gif"],
44
+ mime: "gif",
45
+ icon: iconGif,
46
+ },
47
+ {
48
+ type: ["html"],
49
+ mime: "html",
50
+ icon: iconHtml,
51
+ },
52
+ {
53
+ type: ["pdf"],
54
+ mime: "pdf",
55
+ icon: iconPdf,
56
+ },
57
+ {
58
+ type: ["ppt"],
59
+ mime: "ppt",
60
+ icon: iconPpt,
61
+ },
62
+ {
63
+ type: ["psd"],
64
+ mime: "psd",
65
+ icon: iconPsd,
66
+ },
67
+ {
68
+ type: ["rvt"],
69
+ mime: "rvt",
70
+ icon: iconRvt,
71
+ },
72
+ {
73
+ type: [
74
+ "mp4",
75
+ "avi",
76
+ "wmv",
77
+ "mpg",
78
+ "mpeg",
79
+ "mov",
80
+ "flv",
81
+ "3gp",
82
+ "mp3gp",
83
+ "mkv",
84
+ "rmvb",
85
+ ],
86
+ mime: "mp4",
87
+ icon: iconVideo,
88
+ },
89
+ {
90
+ type: ["skp"],
91
+ mime: "skp",
92
+ icon: iconSkp,
93
+ },
94
+ {
95
+ type: ["svg"],
96
+ mime: "svg",
97
+ icon: iconSvg,
98
+ },
99
+ {
100
+ type: ["png", "jpeg", "jpg", "webp", "bmp"],
101
+ mime: "img",
102
+ icon: iconImage,
103
+ },
104
+ {
105
+ type: ["txt", "sql", "js", "css", "log", "json"],
106
+ mime: "txt",
107
+ icon: iconTxt,
108
+ },
109
+ {
110
+ type: ["word"],
111
+ mime: "word",
112
+ icon: iconWord,
113
+ },
114
+ {
115
+ type: ["zip", "rar", "gz", "7z"],
116
+ mime: "zip",
117
+ icon: iconZip,
118
+ },
119
+ {
120
+ type: ["mp3", "wma", "wav", "aac", "flac"],
121
+ mime: "",
122
+ icon: iconAudio,
123
+ },
124
+ ];
125
+
126
+
127
+ export default {
128
+ /**
129
+ * 获取文件和目录列表
130
+ */
131
+ getDirFileList(path) {
132
+ return new Promise((yes) => {
133
+ // #ifdef APP-PLUS
134
+ plus.io.resolveLocalFileSystemURL(path, function (entry) {
135
+ if (entry.isDirectory) {
136
+ let reader = entry.createReader();
137
+ reader.readEntries(
138
+ async (entries) => {
139
+ let dirList = [];
140
+ let fileList = [];
141
+ for (let i = 0; i < entries.length; i++) {
142
+ /**
143
+ * @type {PlusIoDirectoryEntry}
144
+ */
145
+ const item = entries[i];
146
+ let meta = await getMetaData(item)
147
+ let row = {
148
+ type: item.isDirectory ? 'dir' : 'file',
149
+ name: item.name,
150
+ fileType: getFileType(item.name),
151
+ ...meta,
152
+ }
153
+ if (item.isDirectory) {
154
+ dirList.push(row)
155
+ } else {
156
+ fileList.push(row)
157
+ }
158
+ }
159
+
160
+ dirList = dirList.sort((a, b) => (b.time || 0) - (a.time || 0))
161
+ fileList = fileList.sort((a, b) => (b.time || 0) - (a.time || 0))
162
+
163
+ yes([
164
+ ...dirList,
165
+ ...fileList,
166
+ ])
167
+ },
168
+ (e) => {
169
+ console.log("readEntries error", e);
170
+ devUi.showToast({
171
+ title: "文件读取失败: " + e.message,
172
+ icon: "none",
173
+ });
174
+ yes([])
175
+ }
176
+ );
177
+ } else {
178
+ devUi.showToast({
179
+ title: "路径读取失败_b",
180
+ icon: "none",
181
+ });
182
+ yes([])
183
+ }
184
+ }, () => {
185
+ devUi.showToast({
186
+ title: "路径读取失败_a",
187
+ icon: "none",
188
+ });
189
+ yes([])
190
+ });
191
+ // #endif
192
+ })
193
+ },
194
+ /**
195
+ * 获取文件图片
196
+ */
197
+ getFileIcon(type) {
198
+ for (let i = 0; i < iconConfig.length; i++) {
199
+ const item = iconConfig[i];
200
+ for (let _i = 0; _i < item.type.length; _i++) {
201
+ const typeName = item.type[_i];
202
+ if (type == typeName) {
203
+ return item.icon;
204
+ }
205
+ }
206
+ }
207
+ return iconUnknown;
208
+ },
209
+ getDirIcon() {
210
+ return iconDir;
211
+ }
212
+ }
213
+
214
+ /**
215
+ * @param {PlusIoDirectoryEntry} entry
216
+ */
217
+ function getMetaData(entry) {
218
+ return new Promise((yes) => {
219
+ entry.getMetadata(function (metadata) {
220
+ yes({
221
+ size: metadata.size,
222
+ time: metadata.modificationTime.getTime(),
223
+ fileCount: metadata.fileCount,
224
+ directoryCount: metadata.directoryCount,
225
+ })
226
+ }, function () {
227
+ yes({
228
+ size: 0,
229
+ time: 0,
230
+ fileCount: 0,
231
+ directoryCount: 0,
232
+ })
233
+ });
234
+ })
235
+ }
236
+
237
+ function getFileType(name) {
238
+ if (typeof name == "string") {
239
+ let tList = name.split(".");
240
+ if (tList.length > 1) {
241
+ return tList.pop().toLocaleLowerCase()
242
+ } else {
243
+ return ""
244
+ }
245
+ } else {
246
+ return ""
247
+ }
248
+ }