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,204 @@
1
+ <template>
2
+ <view>
3
+ <view
4
+ class="editMask"
5
+ v-if="isShow"
6
+ :style="{
7
+ height: height + 'px',
8
+ }"
9
+ @click.stop
10
+ >
11
+ <view
12
+ class="editDialog"
13
+ @click.stop
14
+ >
15
+ <text class="title">新增缓存</text>
16
+ <input
17
+ type="text"
18
+ placeholder="请输入Key"
19
+ class="input"
20
+ v-model="key"
21
+ />
22
+ <input
23
+ type="text"
24
+ placeholder="请输入Value"
25
+ class="input"
26
+ v-model="value"
27
+ />
28
+ <view class="btnGroup">
29
+ <view
30
+ class="btnItem left"
31
+ @click="hide"
32
+ >
33
+ <text class="btnText">取消</text>
34
+ </view>
35
+ <view
36
+ class="btnItem right"
37
+ @click="save"
38
+ >
39
+ <text class="btnText">提交</text>
40
+ </view>
41
+ </view>
42
+ </view>
43
+ </view>
44
+ </view>
45
+ </template>
46
+ <script>
47
+ import devUi from "../../../core/libs/devUi.js";
48
+ let success, error;
49
+ export default {
50
+ props: {
51
+ /**
52
+ * 默认缓存类型
53
+ */
54
+ storageType: {
55
+ type: String,
56
+ default: "localStorage",
57
+ },
58
+ },
59
+ data() {
60
+ return {
61
+ /**
62
+ * 是否展示
63
+ */
64
+ isShow: false,
65
+ /**
66
+ * 键名称
67
+ */
68
+ key: "",
69
+ /**
70
+ * 值
71
+ */
72
+ value: "",
73
+ /**
74
+ * 屏幕高度
75
+ */
76
+ height: uni.getSystemInfoSync().windowHeight,
77
+ };
78
+ },
79
+ mounted() {
80
+ let that = this;
81
+ /**
82
+ * 挂载弹窗打开事件
83
+ */
84
+ uni.$on("devTools_showAddStorageDialog", () => {
85
+ that.key = "";
86
+ that.value = "";
87
+ that.isShow = true;
88
+ });
89
+ },
90
+ unmounted() {
91
+ uni.$off("devTools_showAddStorageDialog");
92
+ },
93
+ methods: {
94
+ /**
95
+ * 关闭弹窗
96
+ */
97
+ hide() {
98
+ this.isShow = false;
99
+ },
100
+ /**
101
+ * 保存
102
+ */
103
+ save() {
104
+ let that = this;
105
+ if (that.key == "") {
106
+ return devUi.showToast({
107
+ title: "请输入key",
108
+ icon: "none",
109
+ });
110
+ }
111
+ if (that.storageType == "localStorage") {
112
+ uni.setStorageSync(that.key, that.value);
113
+ } else if (that.storageType == "sessionStorage") {
114
+ sessionStorage.setItem(that.key, that.value);
115
+ } else if (that.storageType == "cookie") {
116
+ let key = encodeURIComponent(that.key);
117
+ let val = encodeURIComponent(that.value);
118
+ let cookie =
119
+ `${key}=${val}; path=/; expires=` + new Date(new Date().getTime() + 86400 * 1000 * 365).toGMTString();
120
+ document.cookie = cookie;
121
+ }
122
+ devUi.showToast({
123
+ title: "添加成功!",
124
+ icon: "success",
125
+ });
126
+ that.hide();
127
+ setTimeout(() => {
128
+ that.$emit("getPage");
129
+ }, 300);
130
+ },
131
+ },
132
+ };
133
+ </script>
134
+ <style lang="scss" scoped>
135
+ .editMask {
136
+ display: flex;
137
+ flex-direction: column;
138
+ align-items: center;
139
+ justify-content: center;
140
+ background-color: rgba(0, 0, 0, 0.3);
141
+ width: 750rpx;
142
+ flex: 1;
143
+ /* #ifndef APP-PLUS */
144
+ height: 100vh;
145
+ backdrop-filter: blur(1px);
146
+ /* #endif */
147
+ position: fixed;
148
+ left: 0;
149
+ top: 0;
150
+ z-index: 999;
151
+ .editDialog {
152
+ display: flex;
153
+ flex-direction: column;
154
+ align-items: center;
155
+ justify-content: center;
156
+ width: 690rpx;
157
+ background-color: #fff;
158
+ border-radius: 20rpx;
159
+ padding: 20rpx;
160
+ margin-bottom: 300rpx;
161
+ .title {
162
+ font-size: 28rpx;
163
+ color: #333;
164
+ height: 50rpx;
165
+ line-height: 50rpx;
166
+ }
167
+ .input {
168
+ margin-top: 20rpx;
169
+ margin-bottom: 20rpx;
170
+ width: 640rpx;
171
+ height: 70rpx;
172
+ padding: 5rpx;
173
+ border-radius: 8rpx;
174
+ border: 1px solid rgba(0, 0, 0, 0.05);
175
+ }
176
+ .btnGroup {
177
+ display: flex;
178
+ flex-direction: row;
179
+ width: 640rpx;
180
+ justify-content: space-between;
181
+ .btnItem {
182
+ height: 64rpx;
183
+ border-radius: 10rpx;
184
+ display: flex;
185
+ flex-direction: row;
186
+ align-items: center;
187
+ justify-content: center;
188
+ .btnText {
189
+ font-size: 24rpx;
190
+ color: #fff;
191
+ }
192
+ &.left {
193
+ width: 160rpx;
194
+ background-color: #8799a3;
195
+ }
196
+ &.right {
197
+ width: 450rpx;
198
+ background-color: #3cbb45;
199
+ }
200
+ }
201
+ }
202
+ }
203
+ }
204
+ </style>
@@ -0,0 +1,366 @@
1
+ <template>
2
+ <view>
3
+ <view
4
+ class="editMask"
5
+ v-if="isShow"
6
+ :style="{
7
+ height: height + 'px',
8
+ }"
9
+ @click.stop
10
+ >
11
+ <view
12
+ class="editDialog"
13
+ @click.stop
14
+ >
15
+ <text class="title">{{ title }}</text>
16
+ <input
17
+ type="text"
18
+ placeholder="请输入"
19
+ class="input"
20
+ v-model="value"
21
+ />
22
+ <view class="btnGroup">
23
+ <view
24
+ class="btn left"
25
+ @click="hide"
26
+ >
27
+ <text class="btnText">取消</text>
28
+ </view>
29
+ <view
30
+ class="btn right"
31
+ @click="save"
32
+ >
33
+ <text class="btnText">提交</text>
34
+ </view>
35
+ </view>
36
+ </view>
37
+ </view>
38
+ </view>
39
+ </template>
40
+ <script>
41
+ import devUi from "../../../core/libs/devUi.js";
42
+ let success, error;
43
+ export default {
44
+ props: {
45
+ /**
46
+ * 路径列表
47
+ */
48
+ dirList: {
49
+ type: Array,
50
+ default: () => [],
51
+ },
52
+ /**
53
+ * 路径类型
54
+ */
55
+ dirType: {
56
+ type: String,
57
+ default: "",
58
+ },
59
+ },
60
+ data() {
61
+ return {
62
+ /**
63
+ * 是否展示
64
+ */
65
+ isShow: false,
66
+ /**
67
+ * 是否为操作文件夹
68
+ */
69
+ isDir: false,
70
+ /**
71
+ * 是否编辑模式
72
+ */
73
+ isEdit: true,
74
+ /**
75
+ * 输入框的值
76
+ */
77
+ value: "",
78
+ /**
79
+ * 屏幕高度
80
+ */
81
+ height: uni.getSystemInfoSync().windowHeight,
82
+ /**
83
+ * 更改前名称
84
+ */
85
+ oldValue: "",
86
+ };
87
+ },
88
+ computed: {
89
+ /**
90
+ * 获取标题
91
+ */
92
+ title() {
93
+ if (this.isEdit) {
94
+ return this.isDir ? "更改文件夹名称" : "更改文件名称";
95
+ } else {
96
+ return this.isDir ? "创建文件夹" : "创建文件";
97
+ }
98
+ },
99
+ },
100
+ methods: {
101
+ /**
102
+ * 展示弹窗
103
+ */
104
+ show(options) {
105
+ let that = this;
106
+ return new Promise((yes, err) => {
107
+ success = yes;
108
+ error = err;
109
+
110
+ this.isDir = options.isDir;
111
+ this.isEdit = options.isEdit;
112
+ this.value = String(options.name ? options.name : "");
113
+ this.oldValue = String(options.name ? options.name : "");
114
+
115
+ that.isShow = true;
116
+ });
117
+ },
118
+ /**
119
+ * 关闭弹窗
120
+ */
121
+ hide() {
122
+ this.isShow = false;
123
+ },
124
+ /**
125
+ * 获取当前文件绝对路径
126
+ */
127
+ getPath() {
128
+ let that = this;
129
+ let path = "";
130
+ switch (that.dirType) {
131
+ case "wx":
132
+ path = wx.env.USER_DATA_PATH;
133
+ break;
134
+ case "PRIVATE_DOC":
135
+ path = "_doc";
136
+ break;
137
+ case "PRIVATE_WWW":
138
+ path = "_www";
139
+ break;
140
+ case "PUBLIC_DOCUMENTS":
141
+ path = "_documents";
142
+ break;
143
+ case "PUBLIC_DOWNLOADS":
144
+ path = "_downloads";
145
+ break;
146
+ default:
147
+ break;
148
+ }
149
+ that.dirList.map((x) => {
150
+ path += "/" + x;
151
+ });
152
+ return path + "/";
153
+ },
154
+ /**
155
+ * 保存
156
+ */
157
+ save() {
158
+ let that = this;
159
+ that.value = that.value.replace(" ", "");
160
+ if (that.value == "") {
161
+ return devUi.showToast({
162
+ title: "请输入...",
163
+ icon: "none",
164
+ });
165
+ }
166
+ let path = that.getPath();
167
+
168
+ function buildSuccess() {
169
+ devUi.showToast({
170
+ title: "操作成功!",
171
+ icon: "success",
172
+ });
173
+ that.isShow = false;
174
+ that.$emit("getPage");
175
+ }
176
+
177
+ function buildError(e) {
178
+ let msg = "";
179
+ if (e && e.message) {
180
+ msg = e.message;
181
+ }
182
+ devUi.showToast({
183
+ title: "重命名失败!" + msg,
184
+ icon: "none",
185
+ });
186
+ }
187
+
188
+ // #ifdef MP-WEIXIN
189
+ if (1) {
190
+ let fs = wx.getFileSystemManager();
191
+ if (that.isEdit) {
192
+ if (that.isDir) {
193
+ // ! 重命名文件夹
194
+ // ! 小程序不支持重命名文件夹
195
+ } else {
196
+ // ! 重命名文件
197
+ fs.rename({
198
+ oldPath: path + that.oldValue,
199
+ newPath: path + that.value,
200
+ success: buildSuccess,
201
+ fail: buildError,
202
+ });
203
+ }
204
+ } else {
205
+ if (that.isDir) {
206
+ // ! 创建目录
207
+ fs.mkdir({
208
+ dirPath: path + that.value,
209
+ recursive: false,
210
+ success: buildSuccess,
211
+ fail: buildError,
212
+ });
213
+ } else {
214
+ // ! 创建文件
215
+ // fs.open({
216
+ // filePath: path + that.value,
217
+ // flag: "wx+",
218
+ // success({ fd }) {
219
+ // fs.closeSync({ fd });
220
+ // buildSuccess();
221
+ // },
222
+ // fail: buildError,
223
+ // });
224
+ fs.writeFile({
225
+ filePath: path + that.value,
226
+ data: "",
227
+ encoding: "utf8",
228
+ success() {
229
+ buildSuccess();
230
+ },
231
+ fail: buildError,
232
+ });
233
+ }
234
+ }
235
+
236
+ return;
237
+ }
238
+ // #endif
239
+
240
+ if (that.isEdit) {
241
+ if (that.isDir) {
242
+ // ! 重命名文件夹
243
+ plus.io.resolveLocalFileSystemURL(
244
+ path + that.oldValue,
245
+ (entry) => {
246
+ plus.io.resolveLocalFileSystemURL(
247
+ path,
248
+ (faEntry) => {
249
+ entry.moveTo(faEntry, that.value, buildSuccess, buildError);
250
+ },
251
+ buildError
252
+ );
253
+ },
254
+ buildError
255
+ );
256
+ } else {
257
+ // ! 重命名文件
258
+ plus.io.resolveLocalFileSystemURL(
259
+ path + that.oldValue,
260
+ (entry) => {
261
+ plus.io.resolveLocalFileSystemURL(
262
+ path,
263
+ (faEntry) => {
264
+ entry.moveTo(faEntry, that.value, buildSuccess, buildError);
265
+ },
266
+ buildError
267
+ );
268
+ },
269
+ buildError
270
+ );
271
+ }
272
+ } else {
273
+ if (that.isDir) {
274
+ // ! 创建文件夹
275
+ plus.io.resolveLocalFileSystemURL(
276
+ path,
277
+ (entry) => {
278
+ entry.getDirectory(that.value, { create: true, exclusive: false }, buildSuccess, buildError);
279
+ },
280
+ buildError
281
+ );
282
+ } else {
283
+ // ! 创建文件
284
+ plus.io.resolveLocalFileSystemURL(
285
+ path,
286
+ (entry) => {
287
+ entry.getFile(that.value, { create: true }, buildSuccess, buildError);
288
+ },
289
+ buildError
290
+ );
291
+ }
292
+ }
293
+ },
294
+ },
295
+ };
296
+ </script>
297
+ <style lang="scss" scoped>
298
+ .editMask {
299
+ display: flex;
300
+ flex-direction: column;
301
+ align-items: center;
302
+ justify-content: center;
303
+ background-color: rgba(0, 0, 0, 0.3);
304
+ width: 750rpx;
305
+ flex: 1;
306
+ /* #ifndef APP-PLUS */
307
+ height: 100vh;
308
+ backdrop-filter: blur(1px);
309
+ /* #endif */
310
+ position: fixed;
311
+ left: 0;
312
+ top: 0;
313
+ z-index: 999;
314
+ .editDialog {
315
+ display: flex;
316
+ flex-direction: column;
317
+ align-items: center;
318
+ justify-content: center;
319
+ width: 690rpx;
320
+ background-color: #fff;
321
+ border-radius: 20rpx;
322
+ padding: 20rpx;
323
+ margin-bottom: 300rpx;
324
+ .title {
325
+ font-size: 28rpx;
326
+ line-height: 28rpx;
327
+ color: #333;
328
+ }
329
+ .input {
330
+ margin-top: 20rpx;
331
+ margin-bottom: 20rpx;
332
+ width: 640rpx;
333
+ height: 70rpx;
334
+ padding: 5rpx;
335
+ border-radius: 8rpx;
336
+ border: 1px solid rgba(0, 0, 0, 0.05);
337
+ }
338
+ .btnGroup {
339
+ display: flex;
340
+ flex-direction: row;
341
+ width: 640rpx;
342
+ justify-content: space-between;
343
+ .btn {
344
+ height: 64rpx;
345
+ border-radius: 10rpx;
346
+ display: flex;
347
+ flex-direction: row;
348
+ align-items: center;
349
+ justify-content: center;
350
+ .btnText {
351
+ font-size: 24rpx;
352
+ color: #fff;
353
+ }
354
+ }
355
+ .left {
356
+ width: 160rpx;
357
+ background-color: #8799a3;
358
+ }
359
+ .right {
360
+ width: 450rpx;
361
+ background-color: #3cbb45;
362
+ }
363
+ }
364
+ }
365
+ }
366
+ </style>