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,379 @@
1
+ <template>
2
+ <view>
3
+ <view
4
+ class="dialogMask"
5
+ v-if="isShow"
6
+ :style="{
7
+ height: height + 'px'
8
+ }"
9
+ >
10
+ <view class="dialogContent" @click.stop>
11
+ <view class="dialogHead">
12
+ <view>
13
+ <text class="title">{{ title }}</text>
14
+ </view>
15
+ <view class="closeBtn" @click.stop="hide">
16
+ <text class="closeText">关闭</text>
17
+ <text class="closeIcon">×</text>
18
+ </view>
19
+ </view>
20
+ <scroll-view
21
+ scroll-y
22
+ class="scrollList"
23
+ :style="{
24
+ height: dialogHeight + 'px'
25
+ }"
26
+ >
27
+ <textarea
28
+ :style="{
29
+ height: dialogHeight - (canSave ? 90 : 40) + 'px'
30
+ }"
31
+ v-model="value"
32
+ type="text"
33
+ placeholder="请输入..."
34
+ class="fileEditInput"
35
+ maxlength="-1"
36
+ />
37
+ <view class="saveBtn" v-if="canSave" @click="saveFile">
38
+ <text class="saveBtnText">保存</text>
39
+ </view>
40
+ </scroll-view>
41
+ </view>
42
+ </view>
43
+ </view>
44
+ </template>
45
+ <script>
46
+ import devUi from '../../../core/libs/devUi.js'
47
+ let success, error
48
+ export default {
49
+ data() {
50
+ return {
51
+ /**
52
+ * 是否展示
53
+ */
54
+ isShow: false,
55
+ /**
56
+ * 屏幕高度
57
+ */
58
+ height: uni.getSystemInfoSync().windowHeight,
59
+ dialogHeight: uni.getSystemInfoSync().windowHeight * 0.8,
60
+ /**
61
+ * 弹窗标题
62
+ */
63
+ title: '',
64
+ /**
65
+ * 文本内容
66
+ */
67
+ value: '',
68
+ /**
69
+ * 是否为文件编辑模式
70
+ */
71
+ isFileEdit: true,
72
+ /**
73
+ * 文件路径
74
+ */
75
+ path: '',
76
+ /**
77
+ * 是否允许保存
78
+ */
79
+ canSave: false,
80
+ /**
81
+ * 是否为新建文件
82
+ */
83
+ isNewFile: false
84
+ }
85
+ },
86
+ mounted() {
87
+ let that = this
88
+ uni.$on('devTools_showTextEditDialog', (options) => {
89
+ that
90
+ .show(options)
91
+ .then((val) => {
92
+ uni.$emit('devTools_showTextEditDialogSave', val)
93
+ })
94
+ .catch(() => {
95
+ uni.$emit('devTools_showTextEditDialogHide')
96
+ })
97
+ })
98
+ },
99
+ unmounted() {
100
+ uni.$off('devTools_showTextEditDialog')
101
+ },
102
+ methods: {
103
+ /**
104
+ * 展示弹窗
105
+ */
106
+ show(options) {
107
+ let that = this
108
+ return new Promise((yes, err) => {
109
+ success = yes
110
+ error = err
111
+ that.title = options.title
112
+ that.canSave = Boolean(options.canSave)
113
+ that.isShow = true
114
+
115
+ if (options.isFileEdit === false) {
116
+ // 仅为文件编辑模式
117
+ that.isFileEdit = false
118
+ try {
119
+ that.value = JSON.stringify(JSON.parse(options.value), null, 2)
120
+ } catch (error) {
121
+ that.value = options.value
122
+ }
123
+ return
124
+ }
125
+ that.isFileEdit = true
126
+ that.value = '文件读取中...'
127
+ that.path = options.path
128
+ that.isNewFile = Boolean(options.isNewFile)
129
+
130
+ // #ifdef APP-PLUS
131
+ if (that.isNewFile) {
132
+ that.value = ''
133
+ } else {
134
+ plus.io.resolveLocalFileSystemURL(
135
+ that.path,
136
+ (entry) => {
137
+ // 可通过entry对象操作test.html文件
138
+ entry.file((file) => {
139
+ var fileReader = new plus.io.FileReader()
140
+ fileReader.readAsText(file, 'utf-8')
141
+ fileReader.onloadend = function (evt) {
142
+ let res = ''
143
+ try {
144
+ res = JSON.stringify(JSON.parse(evt.target.result), null, 2)
145
+ } catch (error) {
146
+ res = evt.target.result
147
+ }
148
+ that.value = res
149
+ }
150
+ fileReader.onerror = function () {
151
+ that.value = `[${that.path}]文件读取失败!_code_2`
152
+ }
153
+ })
154
+ },
155
+ function (e) {
156
+ that.value = `[${that.path}]文件读取失败!` + e.message
157
+ }
158
+ )
159
+ }
160
+ // #endif
161
+
162
+ // #ifdef MP-WEIXIN
163
+ let fs = wx.getFileSystemManager()
164
+ if (options.size != 0) {
165
+ fs.readFile({
166
+ filePath: that.path,
167
+ encoding: 'utf8',
168
+ position: 0,
169
+ length: options.size,
170
+ success({ data }) {
171
+ try {
172
+ that.value = JSON.stringify(JSON.parse(data), null, 2)
173
+ } catch (error) {
174
+ that.value = data
175
+ }
176
+ },
177
+ fail(e) {
178
+ console.log(e)
179
+ that.value = `[${that.path}]文件读取失败!` + e
180
+ }
181
+ })
182
+ } else {
183
+ that.value = ''
184
+ }
185
+ // #endif
186
+ })
187
+ },
188
+ /**
189
+ * 关闭弹窗
190
+ */
191
+ hide() {
192
+ this.isShow = false
193
+ error()
194
+ },
195
+ /**
196
+ * 保存
197
+ */
198
+ save() {
199
+ this.isShow = false
200
+ success(this.value)
201
+ },
202
+ /**
203
+ * 保存文件
204
+ */
205
+ saveFile() {
206
+ let that = this
207
+
208
+ if (!that.isFileEdit) {
209
+ // 非文件编辑模式
210
+
211
+ that.isShow = false
212
+ success(that.value)
213
+
214
+ return
215
+ }
216
+
217
+ devUi.showLoading({
218
+ title: '保存中'
219
+ })
220
+
221
+ // #ifdef APP-PLUS
222
+
223
+ let fileName = that.path.split('/').pop()
224
+ let path = that.path.substring(0, that.path.length - fileName.length)
225
+
226
+ plus.io.resolveLocalFileSystemURL(
227
+ path,
228
+ (entry) => {
229
+ entry.getFile(
230
+ fileName,
231
+ {
232
+ create: true
233
+ },
234
+ (fileEntry) => {
235
+ fileEntry.createWriter((writer) => {
236
+ writer.onwrite = (e) => {
237
+ devUi.hideLoading()
238
+ devUi.showToast({
239
+ title: '文件保存成功!',
240
+ icon: 'success'
241
+ })
242
+ that.isShow = false
243
+ that.$emit('getPage')
244
+ }
245
+ writer.onerror = () => {
246
+ devUi.hideLoading()
247
+ devUi.showToast({
248
+ title: '文件保存失败!_写入文件失败',
249
+ icon: 'none'
250
+ })
251
+ }
252
+ writer.write(that.value)
253
+ })
254
+ }
255
+ )
256
+ },
257
+ () => {
258
+ devUi.hideLoading()
259
+ devUi.showToast({
260
+ title: '文件保存失败!_打开目录失败',
261
+ icon: 'none'
262
+ })
263
+ }
264
+ )
265
+ // #endif
266
+
267
+ // #ifdef MP-WEIXIN
268
+
269
+ let fs = wx.getFileSystemManager()
270
+ fs.writeFile({
271
+ filePath: that.path,
272
+ encoding: 'utf-8',
273
+ data: that.value,
274
+ success() {
275
+ devUi.hideLoading()
276
+ devUi.showToast({
277
+ title: '文件保存成功!',
278
+ icon: 'success'
279
+ })
280
+ that.isShow = false
281
+ that.$emit('getPage')
282
+ },
283
+ fail() {
284
+ devUi.hideLoading()
285
+ devUi.showToast({
286
+ title: '文件保存失败!_打开目录失败',
287
+ icon: 'none'
288
+ })
289
+ }
290
+ })
291
+
292
+ // #endif
293
+ }
294
+ }
295
+ }
296
+ </script>
297
+ <style lang="scss" scoped>
298
+ .dialogMask {
299
+ display: flex;
300
+ flex-direction: column-reverse;
301
+ background-color: rgba(0, 0, 0, 0.3);
302
+ width: 750rpx;
303
+ flex: 1;
304
+ /* #ifndef APP-PLUS */
305
+ height: 100vh;
306
+ backdrop-filter: blur(1px);
307
+ /* #endif */
308
+ position: fixed;
309
+ left: 0;
310
+ top: 0;
311
+ z-index: 999;
312
+ .dialogContent {
313
+ display: flex;
314
+ flex-direction: column;
315
+ width: 750rpx;
316
+ background-color: #fff;
317
+ border-radius: 20rpx 20rpx 0 0;
318
+ .dialogHead {
319
+ display: flex;
320
+ flex-direction: row;
321
+ align-items: center;
322
+ justify-content: space-between;
323
+ height: 80rpx;
324
+ border-bottom: 1px solid rgba(0, 0, 0, 0.05);
325
+ width: 750rpx;
326
+ .title {
327
+ margin-left: 20rpx;
328
+ font-size: 24rpx;
329
+ line-height: 24rpx;
330
+ color: #333;
331
+ }
332
+ .closeBtn {
333
+ margin-right: 20rpx;
334
+ padding: 8rpx 14rpx;
335
+ border-radius: 999rpx;
336
+ border: 1px solid rgba(100, 116, 139, 0.28);
337
+ background-color: #f8fafc;
338
+ display: flex;
339
+ flex-direction: row;
340
+ align-items: center;
341
+ }
342
+ .closeText {
343
+ font-size: 22rpx;
344
+ color: #64748b;
345
+ line-height: 22rpx;
346
+ }
347
+ .closeIcon {
348
+ margin-left: 8rpx;
349
+ font-size: 24rpx;
350
+ line-height: 24rpx;
351
+ color: #334155;
352
+ }
353
+ }
354
+ .scrollList {
355
+ width: 750rpx;
356
+ padding: 20rpx;
357
+ .fileEditInput {
358
+ font-size: 20rpx;
359
+ }
360
+ .saveBtn {
361
+ display: flex;
362
+ flex-direction: row;
363
+ align-items: center;
364
+ justify-content: center;
365
+ margin-top: 20rpx;
366
+ height: 35px;
367
+ width: 710rpx;
368
+ border-radius: 10rpx;
369
+ background-color: #3b82f6;
370
+ .saveBtnText {
371
+ color: #fff;
372
+ font-size: 24rpx;
373
+ line-height: 24rpx;
374
+ }
375
+ }
376
+ }
377
+ }
378
+ }
379
+ </style>
@@ -0,0 +1,77 @@
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 (info.directoryCount > 0 || info.fileCount > 0) {
15
+ await appDelDir(path + item.name + '/')
16
+ } else {
17
+ await delDir(path + item.name + '/')
18
+ }
19
+ } else {
20
+ await delFile(path + item.name)
21
+ }
22
+ } catch (error) {}
23
+ }
24
+ try {
25
+ if (needDelSelf) {
26
+ await delDir(path)
27
+ }
28
+ } catch (error) {}
29
+ yes()
30
+ })
31
+ }
32
+
33
+ function delFile(path) {
34
+ return new Promise((yes, err) => {
35
+ plus.io.resolveLocalFileSystemURL(
36
+ path,
37
+ (entry) => {
38
+ entry.remove(yes, err)
39
+ },
40
+ err
41
+ )
42
+ })
43
+ }
44
+
45
+ function delDir(path) {
46
+ return new Promise((yes, err) => {
47
+ plus.io.resolveLocalFileSystemURL(
48
+ path,
49
+ (entry) => {
50
+ entry.remove(yes, err)
51
+ },
52
+ err
53
+ )
54
+ })
55
+ }
56
+
57
+ /**
58
+ * 获取文件夹内信息
59
+ * @returns {Promise<PlusIoMetadata>}
60
+ */
61
+ function getMeteInfo(path) {
62
+ return new Promise((yes, err) => {
63
+ plus.io.resolveLocalFileSystemURL(
64
+ path,
65
+ (entry) => {
66
+ if (entry.isDirectory) {
67
+ entry.getMetadata((metadata) => {
68
+ yes(metadata)
69
+ }, err)
70
+ } else {
71
+ err()
72
+ }
73
+ },
74
+ err
75
+ )
76
+ })
77
+ }
@@ -0,0 +1,239 @@
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: ['mp4', 'avi', 'wmv', 'mpg', 'mpeg', 'mov', 'flv', '3gp', 'mp3gp', 'mkv', 'rmvb'],
74
+ mime: 'mp4',
75
+ icon: iconVideo
76
+ },
77
+ {
78
+ type: ['skp'],
79
+ mime: 'skp',
80
+ icon: iconSkp
81
+ },
82
+ {
83
+ type: ['svg'],
84
+ mime: 'svg',
85
+ icon: iconSvg
86
+ },
87
+ {
88
+ type: ['png', 'jpeg', 'jpg', 'webp', 'bmp'],
89
+ mime: 'img',
90
+ icon: iconImage
91
+ },
92
+ {
93
+ type: ['txt', 'sql', 'js', 'css', 'log', 'json'],
94
+ mime: 'txt',
95
+ icon: iconTxt
96
+ },
97
+ {
98
+ type: ['word'],
99
+ mime: 'word',
100
+ icon: iconWord
101
+ },
102
+ {
103
+ type: ['zip', 'rar', 'gz', '7z'],
104
+ mime: 'zip',
105
+ icon: iconZip
106
+ },
107
+ {
108
+ type: ['mp3', 'wma', 'wav', 'aac', 'flac'],
109
+ mime: '',
110
+ icon: iconAudio
111
+ }
112
+ ]
113
+
114
+ export default {
115
+ /**
116
+ * 获取文件和目录列表
117
+ */
118
+ getDirFileList(path) {
119
+ return new Promise((yes) => {
120
+ // #ifdef APP-PLUS
121
+ plus.io.resolveLocalFileSystemURL(
122
+ path,
123
+ function (entry) {
124
+ if (entry.isDirectory) {
125
+ let reader = entry.createReader()
126
+ reader.readEntries(
127
+ async (entries) => {
128
+ let dirList = []
129
+ let fileList = []
130
+ for (let i = 0; i < entries.length; i++) {
131
+ /**
132
+ * @type {PlusIoDirectoryEntry}
133
+ */
134
+ const item = entries[i]
135
+ let meta = await getMetaData(item)
136
+ let row = {
137
+ type: item.isDirectory ? 'dir' : 'file',
138
+ name: item.name,
139
+ fileType: getFileType(item.name),
140
+ ...meta
141
+ }
142
+ if (item.isDirectory) {
143
+ dirList.push(row)
144
+ } else {
145
+ fileList.push(row)
146
+ }
147
+ }
148
+
149
+ dirList = dirList.sort((a, b) => (b.time || 0) - (a.time || 0))
150
+ fileList = fileList.sort((a, b) => (b.time || 0) - (a.time || 0))
151
+
152
+ yes([...dirList, ...fileList])
153
+ },
154
+ (e) => {
155
+ console.log('readEntries error', e)
156
+ devUi.showToast({
157
+ title: '文件读取失败: ' + e.message,
158
+ icon: 'none'
159
+ })
160
+ yes([])
161
+ }
162
+ )
163
+ } else {
164
+ devUi.showToast({
165
+ title: '路径读取失败_b',
166
+ icon: 'none'
167
+ })
168
+ yes([])
169
+ }
170
+ },
171
+ () => {
172
+ devUi.showToast({
173
+ title: '路径读取失败_a',
174
+ icon: 'none'
175
+ })
176
+ yes([])
177
+ }
178
+ )
179
+ // #endif
180
+ })
181
+ },
182
+ /**
183
+ * 获取文件图片
184
+ */
185
+ getFileIcon(type) {
186
+ for (let i = 0; i < iconConfig.length; i++) {
187
+ const item = iconConfig[i]
188
+ for (let _i = 0; _i < item.type.length; _i++) {
189
+ const typeName = item.type[_i]
190
+ if (type == typeName) {
191
+ return item.icon
192
+ }
193
+ }
194
+ }
195
+ return iconUnknown
196
+ },
197
+ getDirIcon() {
198
+ return iconDir
199
+ }
200
+ }
201
+
202
+ /**
203
+ * @param {PlusIoDirectoryEntry} entry
204
+ */
205
+ function getMetaData(entry) {
206
+ return new Promise((yes) => {
207
+ entry.getMetadata(
208
+ function (metadata) {
209
+ yes({
210
+ size: metadata.size,
211
+ time: metadata.modificationTime.getTime(),
212
+ fileCount: metadata.fileCount,
213
+ directoryCount: metadata.directoryCount
214
+ })
215
+ },
216
+ function () {
217
+ yes({
218
+ size: 0,
219
+ time: 0,
220
+ fileCount: 0,
221
+ directoryCount: 0
222
+ })
223
+ }
224
+ )
225
+ })
226
+ }
227
+
228
+ function getFileType(name) {
229
+ if (typeof name == 'string') {
230
+ let tList = name.split('.')
231
+ if (tList.length > 1) {
232
+ return tList.pop().toLocaleLowerCase()
233
+ } else {
234
+ return ''
235
+ }
236
+ } else {
237
+ return ''
238
+ }
239
+ }
@@ -0,0 +1,15 @@
1
+ export default {
2
+ /**
3
+ * 获取字节大小,b转kb mb
4
+ */
5
+ getByteSize(size) {
6
+ if (null == size || size == '') return '0 B'
7
+ var unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
8
+ var index = 0
9
+ var srcsize = parseFloat(size)
10
+ index = Math.floor(Math.log(srcsize) / Math.log(1024))
11
+ var size = srcsize / Math.pow(1024, index)
12
+ size = size.toFixed(2) //保留的小数位数
13
+ return size + unitArr[index]
14
+ }
15
+ }