@dcloudio/uni-app-x 0.7.7 → 0.7.8

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 (215) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +1 -1
  3. package/options.d.ts +9 -9
  4. package/package.json +27 -27
  5. package/types/app.d.ts +843 -843
  6. package/types/index.d.ts +7 -7
  7. package/types/native/AsyncApiResult.d.ts +7 -7
  8. package/types/native/CSSStyleDeclaration.d.ts +25 -25
  9. package/types/native/DOMRect.d.ts +56 -56
  10. package/types/native/DrawableContext.d.ts +162 -162
  11. package/types/native/INavigationBar.d.ts +22 -22
  12. package/types/native/IUniElement.d.ts +762 -755
  13. package/types/native/IUniError.d.ts +20 -20
  14. package/types/native/IUniForm.d.ts +9 -9
  15. package/types/native/NativeLoadFontFaceOptions.d.ts +11 -11
  16. package/types/native/NodeData.d.ts +22 -22
  17. package/types/native/PageNode.d.ts +6 -6
  18. package/types/native/SnapshotOptions.d.ts +63 -63
  19. package/types/native/SourceError.d.ts +46 -46
  20. package/types/native/UTSAndroidHookProxy.d.ts +14 -14
  21. package/types/native/UniAggregateError.d.ts +19 -19
  22. package/types/native/UniApp.d.ts +66 -66
  23. package/types/native/UniCallbackWrapper.d.ts +7 -7
  24. package/types/native/UniCustomEvent.d.ts +24 -24
  25. package/types/native/UniDocument.d.ts +35 -35
  26. package/types/native/UniElement.d.ts +74 -74
  27. package/types/native/UniError.d.ts +70 -70
  28. package/types/native/UniEvent.d.ts +62 -62
  29. package/types/native/UniFormControl.d.ts +8 -8
  30. package/types/native/UniFormControlElement.d.ts +14 -14
  31. package/types/native/UniImageErrorEvent.d.ts +15 -15
  32. package/types/native/UniImageLoadEvent.d.ts +19 -19
  33. package/types/native/UniInputBlurEvent.d.ts +19 -19
  34. package/types/native/UniInputConfirmEvent.d.ts +15 -15
  35. package/types/native/UniInputEvent.d.ts +33 -24
  36. package/types/native/UniInputFocusEvent.d.ts +33 -33
  37. package/types/native/{UniPage.d.ts → UniNativePage.d.ts} +141 -96
  38. package/types/native/UniPageEvent.d.ts +10 -10
  39. package/types/native/UniPageManager.d.ts +17 -17
  40. package/types/native/UniPageScrollEvent.d.ts +13 -13
  41. package/types/native/UniPointerEvent.d.ts +74 -73
  42. package/types/native/UniRefresherEvent.d.ts +18 -14
  43. package/types/native/UniResizeEvent.d.ts +34 -34
  44. package/types/native/UniRichTextItemClickEvent.d.ts +23 -23
  45. package/types/native/UniScrollEvent.d.ts +42 -36
  46. package/types/native/UniScrollToLowerEvent.d.ts +23 -16
  47. package/types/native/UniScrollToUpperEvent.d.ts +23 -16
  48. package/types/native/UniStartNestedScrollEvent.d.ts +33 -33
  49. package/types/native/UniStopNestedScrollEvent.d.ts +28 -28
  50. package/types/native/UniSwiperAnimationFinishEvent.d.ts +19 -19
  51. package/types/native/UniSwiperChangeEvent.d.ts +19 -19
  52. package/types/native/UniSwiperTransitionEvent.d.ts +19 -19
  53. package/types/native/UniTabTapEvent.d.ts +18 -18
  54. package/types/native/UniTabsElement.d.ts +29 -29
  55. package/types/native/UniTextElement.d.ts +17 -17
  56. package/types/native/UniTextareaFocusEvent.d.ts +34 -34
  57. package/types/native/UniTouchEvent.d.ts +64 -60
  58. package/types/native/UniVideoElement.d.ts +70 -70
  59. package/types/native/UniWebViewDownloadEvent.d.ts +42 -42
  60. package/types/native/UniWebViewElement.d.ts +10 -10
  61. package/types/native/UniWebViewErrorEvent.d.ts +37 -37
  62. package/types/native/UniWebViewLoadEvent.d.ts +26 -26
  63. package/types/native/UniWebViewLoadingEvent.d.ts +27 -27
  64. package/types/native/UniWebViewMessageEvent.d.ts +26 -26
  65. package/types/native/UniWebViewServiceMessageEvent.d.ts +8 -8
  66. package/types/native/ViewToTempFilePathOptions.d.ts +47 -47
  67. package/types/native/WebViewStyles.d.ts +20 -20
  68. package/types/native/global.d.ts +446 -429
  69. package/types/native/index.d.ts +65 -65
  70. package/types/native-global/index.d.ts +1 -1
  71. package/types/page.d.ts +1593 -1593
  72. package/types/process.d.ts +5 -5
  73. package/types/uni/base/index.d.ts +3 -3
  74. package/types/uni/core/global.d.ts +13 -13
  75. package/types/uni/core/index.d.ts +13 -13
  76. package/types/uni/core/lib/base/event/global.d.ts +16 -16
  77. package/types/uni/core/lib/base/event/index.d.ts +7 -7
  78. package/types/uni/core/lib/base/event/interface.d.ts +277 -277
  79. package/types/uni/core/lib/base/interceptor/global.d.ts +18 -18
  80. package/types/uni/core/lib/base/interceptor/index.d.ts +8 -8
  81. package/types/uni/core/lib/base/interceptor/interface.d.ts +150 -150
  82. package/types/uni/core/lib/interface.d.ts +28 -28
  83. package/types/uni/core/lib/lifecycle/global.d.ts +10 -10
  84. package/types/uni/core/lib/lifecycle/index.d.ts +4 -4
  85. package/types/uni/core/lib/lifecycle/interface.d.ts +37 -37
  86. package/types/uni/core/lib/performance/global.d.ts +22 -22
  87. package/types/uni/core/lib/performance/index.d.ts +10 -10
  88. package/types/uni/core/lib/performance/interface.d.ts +157 -157
  89. package/types/uni/core/lib/route/global.d.ts +68 -68
  90. package/types/uni/core/lib/route/index.d.ts +33 -33
  91. package/types/uni/core/lib/route/interface.d.ts +2031 -2031
  92. package/types/uni/core/lib/ui/create-selector-query/global.d.ts +20 -20
  93. package/types/uni/core/lib/ui/create-selector-query/index.d.ts +9 -9
  94. package/types/uni/core/lib/ui/create-selector-query/interface.d.ts +412 -412
  95. package/types/uni/core/lib/ui/get-element-by-id/global.d.ts +10 -10
  96. package/types/uni/core/lib/ui/get-element-by-id/index.d.ts +4 -4
  97. package/types/uni/core/lib/ui/get-element-by-id/interface.d.ts +73 -73
  98. package/types/uni/core/lib/ui/load-font-face/global.d.ts +26 -26
  99. package/types/uni/core/lib/ui/load-font-face/index.d.ts +12 -12
  100. package/types/uni/core/lib/ui/load-font-face/interface.d.ts +560 -560
  101. package/types/uni/core/lib/ui/page-scroll-to/global.d.ts +26 -26
  102. package/types/uni/core/lib/ui/page-scroll-to/index.d.ts +12 -12
  103. package/types/uni/core/lib/ui/page-scroll-to/interface.d.ts +145 -145
  104. package/types/uni/core/lib/ui/pull-down-refresh/global.d.ts +28 -28
  105. package/types/uni/core/lib/ui/pull-down-refresh/index.d.ts +13 -13
  106. package/types/uni/core/lib/ui/pull-down-refresh/interface.d.ts +176 -176
  107. package/types/uni/core/lib/ui/set-navigation-bar-color/global.d.ts +28 -28
  108. package/types/uni/core/lib/ui/set-navigation-bar-color/index.d.ts +13 -13
  109. package/types/uni/core/lib/ui/set-navigation-bar-color/interface.d.ts +431 -431
  110. package/types/uni/core/lib/ui/set-navigation-bar-title/global.d.ts +28 -28
  111. package/types/uni/core/lib/ui/set-navigation-bar-title/index.d.ts +13 -13
  112. package/types/uni/core/lib/ui/set-navigation-bar-title/interface.d.ts +368 -368
  113. package/types/uni/core/lib/ui/tab-bar/global.d.ts +130 -130
  114. package/types/uni/core/lib/ui/tab-bar/index.d.ts +64 -64
  115. package/types/uni/core/lib/ui/tab-bar/interface.d.ts +928 -928
  116. package/types/uni/env/index.d.ts +64 -64
  117. package/types/uni/global.d.ts +6 -6
  118. package/types/uni/index.d.ts +3 -3
  119. package/types/uni/uts-plugin-api/global.d.ts +23 -22
  120. package/types/uni/uts-plugin-api/index.d.ts +23 -22
  121. package/types/uni/uts-plugin-api/lib/uni-createRequestPermissionListener/utssdk/global.d.ts +18 -18
  122. package/types/uni/uts-plugin-api/lib/uni-createRequestPermissionListener/utssdk/index.d.ts +8 -8
  123. package/types/uni/uts-plugin-api/lib/uni-createRequestPermissionListener/utssdk/interface.d.ts +43 -43
  124. package/types/uni/uts-plugin-api/lib/uni-createWebviewContext/utssdk/global.d.ts +12 -12
  125. package/types/uni/uts-plugin-api/lib/uni-createWebviewContext/utssdk/index.d.ts +5 -5
  126. package/types/uni/uts-plugin-api/lib/uni-createWebviewContext/utssdk/interface.d.ts +101 -101
  127. package/types/uni/uts-plugin-api/lib/uni-exit/utssdk/global.d.ts +26 -26
  128. package/types/uni/uts-plugin-api/lib/uni-exit/utssdk/index.d.ts +12 -12
  129. package/types/uni/uts-plugin-api/lib/uni-exit/utssdk/interface.d.ts +82 -82
  130. package/types/uni/uts-plugin-api/lib/uni-fileSystemManager/utssdk/global.d.ts +66 -66
  131. package/types/uni/uts-plugin-api/lib/uni-fileSystemManager/utssdk/index.d.ts +32 -32
  132. package/types/uni/uts-plugin-api/lib/uni-fileSystemManager/utssdk/interface.d.ts +423 -423
  133. package/types/uni/uts-plugin-api/lib/uni-getAccessibilityInfo/utssdk/global.d.ts +10 -10
  134. package/types/uni/uts-plugin-api/lib/uni-getAccessibilityInfo/utssdk/index.d.ts +4 -4
  135. package/types/uni/uts-plugin-api/lib/uni-getAppAuthorizeSetting/utssdk/global.d.ts +12 -12
  136. package/types/uni/uts-plugin-api/lib/uni-getAppAuthorizeSetting/utssdk/index.d.ts +5 -5
  137. package/types/uni/uts-plugin-api/lib/uni-getAppBaseInfo/utssdk/global.d.ts +14 -14
  138. package/types/uni/uts-plugin-api/lib/uni-getAppBaseInfo/utssdk/index.d.ts +6 -6
  139. package/types/uni/uts-plugin-api/lib/uni-getAppBaseInfo/utssdk/interface.d.ts +350 -350
  140. package/types/uni/uts-plugin-api/lib/uni-getDeviceInfo/utssdk/global.d.ts +14 -14
  141. package/types/uni/uts-plugin-api/lib/uni-getDeviceInfo/utssdk/index.d.ts +6 -6
  142. package/types/uni/uts-plugin-api/lib/uni-getLocation-system/utssdk/global.d.ts +20 -20
  143. package/types/uni/uts-plugin-api/lib/uni-getLocation-system/utssdk/index.d.ts +9 -9
  144. package/types/uni/uts-plugin-api/lib/uni-getLocation-system/utssdk/interface.d.ts +151 -151
  145. package/types/uni/uts-plugin-api/lib/uni-getNetworkType/utssdk/global.d.ts +24 -24
  146. package/types/uni/uts-plugin-api/lib/uni-getNetworkType/utssdk/index.d.ts +11 -11
  147. package/types/uni/uts-plugin-api/lib/uni-getProvider/utssdk/global.d.ts +24 -0
  148. package/types/uni/uts-plugin-api/lib/uni-getProvider/utssdk/index.d.ts +11 -0
  149. package/types/uni/uts-plugin-api/lib/uni-getProvider/utssdk/interface.d.ts +87 -0
  150. package/types/uni/uts-plugin-api/lib/uni-getSystemInfo/utssdk/global.d.ts +30 -30
  151. package/types/uni/uts-plugin-api/lib/uni-getSystemInfo/utssdk/index.d.ts +14 -14
  152. package/types/uni/uts-plugin-api/lib/uni-getSystemSetting/utssdk/global.d.ts +12 -12
  153. package/types/uni/uts-plugin-api/lib/uni-getSystemSetting/utssdk/index.d.ts +5 -5
  154. package/types/uni/uts-plugin-api/lib/uni-installApk/utssdk/global.d.ts +24 -24
  155. package/types/uni/uts-plugin-api/lib/uni-installApk/utssdk/index.d.ts +11 -11
  156. package/types/uni/uts-plugin-api/lib/uni-media/utssdk/global.d.ts +158 -158
  157. package/types/uni/uts-plugin-api/lib/uni-media/utssdk/index.d.ts +78 -78
  158. package/types/uni/uts-plugin-api/lib/uni-media/utssdk/interface.d.ts +906 -906
  159. package/types/uni/uts-plugin-api/lib/uni-network/utssdk/app-ios/global.d.ts +68 -68
  160. package/types/uni/uts-plugin-api/lib/uni-network/utssdk/app-ios/index.d.ts +33 -33
  161. package/types/uni/uts-plugin-api/lib/uni-network/utssdk/global.d.ts +72 -72
  162. package/types/uni/uts-plugin-api/lib/uni-network/utssdk/index.d.ts +35 -35
  163. package/types/uni/uts-plugin-api/lib/uni-openAppAuthorizeSetting/utssdk/global.d.ts +24 -24
  164. package/types/uni/uts-plugin-api/lib/uni-openAppAuthorizeSetting/utssdk/index.d.ts +11 -11
  165. package/types/uni/uts-plugin-api/lib/uni-prompt/utssdk/global.d.ts +74 -62
  166. package/types/uni/uts-plugin-api/lib/uni-prompt/utssdk/index.d.ts +36 -30
  167. package/types/uni/uts-plugin-api/lib/uni-prompt/utssdk/interface.d.ts +40 -8
  168. package/types/uni/uts-plugin-api/lib/uni-requestPayment-alipay/utssdk/global.d.ts +28 -28
  169. package/types/uni/uts-plugin-api/lib/uni-requestPayment-alipay/utssdk/index.d.ts +13 -13
  170. package/types/uni/uts-plugin-api/lib/uni-requestPayment-alipay/utssdk/interface.d.ts +1 -1
  171. package/types/uni/uts-plugin-api/lib/uni-rpx2px/utssdk/global.d.ts +10 -10
  172. package/types/uni/uts-plugin-api/lib/uni-rpx2px/utssdk/index.d.ts +4 -4
  173. package/types/uni/uts-plugin-api/lib/uni-rpx2px/utssdk/interface.d.ts +33 -33
  174. package/types/uni/uts-plugin-api/lib/uni-storage/utssdk/global.d.ts +78 -78
  175. package/types/uni/uts-plugin-api/lib/uni-storage/utssdk/index.d.ts +38 -38
  176. package/types/uni/uts-plugin-api/lib/uni-storage/utssdk/interface.d.ts +531 -531
  177. package/types/uni/uts-plugin-api/lib/uni-websocket/utssdk/global.d.ts +58 -58
  178. package/types/uni/uts-plugin-api/lib/uni-websocket/utssdk/index.d.ts +28 -28
  179. package/types/uni/uts-plugin-biz/global.d.ts +4 -4
  180. package/types/uni/uts-plugin-biz/index.d.ts +4 -4
  181. package/types/uni/uts-plugin-biz/lib/uni-ad/utssdk/global.d.ts +36 -36
  182. package/types/uni/uts-plugin-biz/lib/uni-ad/utssdk/index.d.ts +17 -17
  183. package/types/uni/uts-plugin-biz/lib/uni-ad/utssdk/interface.d.ts +132 -132
  184. package/types/uni/uts-plugin-biz/lib/uni-facialRecognitionVerify/utssdk/global.d.ts +28 -28
  185. package/types/uni/uts-plugin-biz/lib/uni-facialRecognitionVerify/utssdk/index.d.ts +13 -13
  186. package/types/uni/uts-plugin-biz/lib/uni-facialRecognitionVerify/utssdk/interface.d.ts +141 -141
  187. package/types/uni/uts-plugin-biz/lib/uni-push/utssdk/global.d.ts +56 -56
  188. package/types/uni/uts-plugin-biz/lib/uni-push/utssdk/index.d.ts +27 -27
  189. package/types/uni/uts-plugin-biz/lib/uni-verify/utssdk/global.d.ts +46 -46
  190. package/types/uni/uts-plugin-biz/lib/uni-verify/utssdk/index.d.ts +22 -22
  191. package/types/uni/uts-plugin-biz/lib/uni-verify/utssdk/interface.d.ts +203 -203
  192. package/types/uni/uts-plugin-component/global.d.ts +1 -1
  193. package/types/uni/uts-plugin-component/index.d.ts +1 -1
  194. package/types/uni/uts-plugin-component/lib/uni-video/utssdk/global.d.ts +64 -64
  195. package/types/uni/uts-plugin-component/lib/uni-video/utssdk/index.d.ts +31 -31
  196. package/types/uni/uts-plugin-component/lib/uni-video/utssdk/interface.d.ts +356 -356
  197. package/types/uni-cloud/index.d.ts +59 -59
  198. package/types/uni-cloud/interface.d.ts +801 -801
  199. package/types/uni-cloud/unicloud-db/index.ts +313 -313
  200. package/types/uni-global/index.d.ts +1 -1
  201. package/types/vue/CheckboxGroupChangeEvent.d.ts +36 -36
  202. package/types/vue/LifeCycle.d.ts +55 -55
  203. package/types/vue/PickerViewChangeEvent.d.ts +36 -36
  204. package/types/vue/ProgressActiveendEvent.d.ts +30 -30
  205. package/types/vue/RadioGroupChangeEvent.d.ts +36 -36
  206. package/types/vue/SliderChangeEvent.d.ts +32 -32
  207. package/types/vue/SwitchChangeEvent.d.ts +30 -30
  208. package/types/vue/UniCanvasElement.d.ts +270 -270
  209. package/types/vue/UniCloudDBElement.d.ts +215 -215
  210. package/types/vue/UniFormElement.d.ts +51 -51
  211. package/types/vue/UniNavigatorElement.d.ts +7 -7
  212. package/types/vue/index.d.ts +11 -11
  213. package/uts-plugin.d.ts +26 -26
  214. package/types/uni-cloud/unicloud-db/index.d.ts +0 -81
  215. package/types/vue/UniButtonElement.d.ts +0 -7
@@ -1,314 +1,314 @@
1
- type SuccessCallback<T> = (res : T | null) => void | null
2
- type FailCallback = (err : any | null) => void | null
3
- type CompleteCallback = () => void | null
4
-
5
- export type MixinDatacomPaginationType = {
6
- current : number,
7
- size : number,
8
- count : number
9
- }
10
-
11
- export type MixinDatacomGetOptions = {
12
- collection ?: UTSJSONObject,
13
- field ?: string,
14
- orderBy ?: string,
15
- where ?: any,
16
- pageData ?: string,
17
- pageCurrent ?: number,
18
- pageSize ?: number,
19
- getCount ?: boolean,
20
- getTree ?: any,
21
- getTreePath ?: UTSJSONObject,
22
- startWith ?: string,
23
- limitLevel ?: number,
24
- groupBy ?: string,
25
- groupField ?: string,
26
- distinct ?: boolean,
27
- pageIndistinct ?: boolean,
28
- foreignKey ?: string,
29
- loadtime ?: string,
30
- manual ?: boolean
31
- }
32
-
33
- export type MixinDatacomEasyGetOptions = {
34
- success ?: SuccessCallback<UniCloudDBGetResult>,
35
- fail ?: FailCallback,
36
- complete ?: CompleteCallback,
37
- }
38
-
39
- export const mixinDatacom = defineMixin({
40
- slots: Object as SlotsType<{
41
- default : {
42
- data : Array<UTSJSONObject>,
43
- loading : boolean,
44
- hasMore : boolean,
45
- pagination : MixinDatacomPaginationType,
46
- error : UniCloudError | null
47
- }
48
- }>,
49
- props: {
50
- localdata: {
51
- type: Array as PropType<Array<UTSJSONObject>>,
52
- default: [] as Array<UTSJSONObject>
53
- },
54
- collection: {
55
- type: Object,
56
- default: ''
57
- },
58
- field: {
59
- type: String,
60
- default: ''
61
- },
62
- orderby: {
63
- type: String,
64
- default: ''
65
- },
66
- where: {
67
- type: Object,
68
- default: ''
69
- },
70
- pageData: {
71
- type: String,
72
- default: 'add'
73
- },
74
- pageCurrent: {
75
- type: Number,
76
- default: 1
77
- },
78
- pageSize: {
79
- type: Number,
80
- default: 20
81
- },
82
- getcount: {
83
- type: Boolean,
84
- default: false
85
- },
86
- gettree: {
87
- type: Object,
88
- default: ''
89
- },
90
- gettreepath: {
91
- type: Boolean,
92
- default: false
93
- },
94
- startwith: {
95
- type: String,
96
- default: ''
97
- },
98
- limitlevel: {
99
- type: Number,
100
- default: 10
101
- },
102
- groupby: {
103
- type: String,
104
- default: ''
105
- },
106
- groupField: {
107
- type: String,
108
- default: ''
109
- },
110
- distinct: {
111
- type: Boolean,
112
- default: false
113
- },
114
- pageIndistinct: {
115
- type: Boolean,
116
- default: false
117
- },
118
- foreignKey: {
119
- type: String,
120
- default: ''
121
- },
122
- loadtime: {
123
- type: String,
124
- default: 'auto'
125
- },
126
- manual: {
127
- type: Boolean,
128
- default: false
129
- }
130
- },
131
- data() {
132
- return {
133
- mixinDatacomResData: [] as Array<UTSJSONObject>, // 请求返回的数据,调用 loadData 后会更新
134
- mixinDatacomLoading: false, // 网络请求状态
135
- mixinDatacomHasMore: false, // 是否有更多数据
136
- mixinDatacomPage: {
137
- current: 1,
138
- size: 20,
139
- count: 0,
140
- } as MixinDatacomPaginationType, // 分页信息,详情见 created 生命周期
141
- mixinDatacomError: null as UniCloudError | null, // 请求出错时的错误消息
142
- }
143
- },
144
- created() {
145
- this.mixinDatacomPage.current = this.pageCurrent
146
- this.mixinDatacomPage.size = this.pageSize
147
-
148
- const PROPS_NAME = ['', '', 'collection', 'field', 'getcount', 'orderby', 'where', 'groupby', 'groupField', 'distinct']
149
-
150
- this.$watch(
151
- () : any => [
152
- this.pageCurrent,
153
- this.pageSize,
154
- this.collection,
155
- this.field,
156
- this.getcount,
157
- this.orderby,
158
- this.where,
159
- this.groupby,
160
- this.groupField,
161
- this.distinct
162
- ],
163
- (newValue : Array<any>, oldValue : Array<any>) => {
164
- this.mixinDatacomPage.size = this.pageSize
165
- if (newValue[0] !== oldValue[0]) {
166
- this.mixinDatacomPage.current = this.pageCurrent
167
- }
168
-
169
- let needReset = false
170
- let changed : Array<string> = []
171
- for (let i = 2; i < newValue.length; i++) {
172
- if (newValue[i] !== oldValue[i]) {
173
- needReset = true
174
- changed.push(PROPS_NAME[i])
175
- }
176
- }
177
-
178
- this.onMixinDatacomPropsChange(needReset, changed)
179
- }
180
- )
181
- },
182
- methods: {
183
- // props发生变化时被调用,在组件中覆盖此方法
184
- // 非 pageCurrent,pageSize 改变时 needReset=true,需要重置数据
185
- // changed,发生变化的属性名,类型为Array,例如 ['collection', 'action']
186
- onMixinDatacomPropsChange(_ : boolean, changed : Array<string>) {
187
- },
188
- mixinDatacomEasyGet(options ?: MixinDatacomEasyGetOptions) {
189
- if (this.mixinDatacomLoading) {
190
- return
191
- }
192
-
193
- this.mixinDatacomLoading = true
194
- this.mixinDatacomError = null
195
-
196
- this.mixinDatacomGet(null).then((res : UniCloudDBGetResult) => {
197
- const data = res.data
198
- const count = res.count
199
-
200
- if (this.getcount && count != null) {
201
- this.mixinDatacomPage.count = count
202
- }
203
-
204
- this.mixinDatacomHasMore = !((count !== null) ? (this.mixinDatacomPage.current * this.mixinDatacomPage.size >= count) : (data.length < this.pageSize))
205
- this.mixinDatacomResData = data
206
-
207
- options?.success?.(res)
208
- }).catch((err : any | null) => {
209
- this.mixinDatacomError = err as UniCloudError
210
- options?.fail?.(err)
211
- }).finally(() => {
212
- this.mixinDatacomLoading = false
213
- options?.complete?.()
214
- })
215
- },
216
- mixinDatacomGet(options ?: MixinDatacomGetOptions) : Promise<UniCloudDBGetResult> {
217
- let db = uniCloud.databaseForJQL()
218
-
219
- let collection = Array.isArray(this.collection) ? db.collection(...(this.collection as Array<any>)) : db.collection(this.collection)
220
-
221
- let filter : UniCloudDBFilter | null = null
222
- if (this.foreignKey.length > 0) {
223
- filter = collection.foreignKey(this.foreignKey)
224
- }
225
-
226
- const where : any = options?.where ?? this.where
227
- if (typeof where == 'string') {
228
- const whereString = where as string
229
- if (whereString.length > 0) {
230
- filter = (filter != null) ? filter.where(where) : collection.where(where)
231
- }
232
- } else {
233
- filter = (filter != null) ? filter.where(where) : collection.where(where)
234
- }
235
-
236
- let query : UniCloudDBQuery | null = null
237
- if (this.field.length > 0) {
238
- query = (filter != null) ? filter.field(this.field) : collection.field(this.field)
239
- }
240
- if (this.groupby.length > 0) {
241
- if (query != null) {
242
- query = query.groupBy(this.groupby)
243
- } else if (filter != null) {
244
- query = filter.groupBy(this.groupby)
245
- }
246
- }
247
- if (this.groupField.length > 0) {
248
- if (query != null) {
249
- query = query.groupField(this.groupField)
250
- } else if (filter != null) {
251
- query = filter.groupField(this.groupField)
252
- }
253
- }
254
- if (this.distinct == true) {
255
- if (query != null) {
256
- query = query.distinct(this.field)
257
- } else if (filter != null) {
258
- query = filter.distinct(this.field)
259
- }
260
- }
261
- if (this.orderby.length > 0) {
262
- if (query != null) {
263
- query = query.orderBy(this.orderby)
264
- } else if (filter != null) {
265
- query = filter.orderBy(this.orderby)
266
- }
267
- }
268
-
269
- const size = this.mixinDatacomPage.size
270
- const current = this.mixinDatacomPage.current
271
- if (query != null) {
272
- query = query.skip(size * (current - 1)).limit(size)
273
- } else if (filter != null) {
274
- query = filter.skip(size * (current - 1)).limit(size)
275
- } else {
276
- query = collection.skip(size * (current - 1)).limit(size)
277
- }
278
-
279
- const getOptions = {}
280
- const treeOptions = {
281
- limitLevel: this.limitlevel,
282
- startWith: this.startwith
283
- }
284
- const getCount : boolean = options?.getCount ?? this.getcount
285
- if (this.getcount == true) {
286
- getOptions['getCount'] = getCount
287
- }
288
-
289
- const getTree : any = options?.getTree ?? this.gettree
290
- if (typeof getTree == 'string') {
291
- const getTreeString = getTree as string
292
- if (getTreeString.length > 0) {
293
- getOptions['getTree'] = treeOptions
294
- }
295
- } else if (typeof getTree == 'object') {
296
- getOptions['getTree'] = treeOptions
297
- } else {
298
- getOptions['getTree'] = getTree
299
- }
300
-
301
- const getTreePath = options?.getTreePath ?? this.gettreepath
302
- if (typeof getTreePath == 'string') {
303
- const getTreePathString = getTreePath as string
304
- if (getTreePathString.length > 0) {
305
- getOptions['getTreePath'] = getTreePath
306
- }
307
- } else {
308
- getOptions['getTreePath'] = getTreePath
309
- }
310
-
311
- return query.get(getOptions)
312
- }
313
- }
1
+ type SuccessCallback<T> = (res : T | null) => void | null
2
+ type FailCallback = (err : any | null) => void | null
3
+ type CompleteCallback = () => void | null
4
+
5
+ export type MixinDatacomPaginationType = {
6
+ current : number,
7
+ size : number,
8
+ count : number
9
+ }
10
+
11
+ export type MixinDatacomGetOptions = {
12
+ collection ?: UTSJSONObject,
13
+ field ?: string,
14
+ orderBy ?: string,
15
+ where ?: any,
16
+ pageData ?: string,
17
+ pageCurrent ?: number,
18
+ pageSize ?: number,
19
+ getCount ?: boolean,
20
+ getTree ?: any,
21
+ getTreePath ?: UTSJSONObject,
22
+ startWith ?: string,
23
+ limitLevel ?: number,
24
+ groupBy ?: string,
25
+ groupField ?: string,
26
+ distinct ?: boolean,
27
+ pageIndistinct ?: boolean,
28
+ foreignKey ?: string,
29
+ loadtime ?: string,
30
+ manual ?: boolean
31
+ }
32
+
33
+ export type MixinDatacomEasyGetOptions = {
34
+ success ?: SuccessCallback<UniCloudDBGetResult>,
35
+ fail ?: FailCallback,
36
+ complete ?: CompleteCallback,
37
+ }
38
+
39
+ export const mixinDatacom = defineMixin({
40
+ slots: Object as SlotsType<{
41
+ default : {
42
+ data : Array<UTSJSONObject>,
43
+ loading : boolean,
44
+ hasMore : boolean,
45
+ pagination : MixinDatacomPaginationType,
46
+ error : UniCloudError | null
47
+ }
48
+ }>,
49
+ props: {
50
+ localdata: {
51
+ type: Array as PropType<Array<UTSJSONObject>>,
52
+ default: [] as Array<UTSJSONObject>
53
+ },
54
+ collection: {
55
+ type: Object,
56
+ default: ''
57
+ },
58
+ field: {
59
+ type: String,
60
+ default: ''
61
+ },
62
+ orderby: {
63
+ type: String,
64
+ default: ''
65
+ },
66
+ where: {
67
+ type: Object,
68
+ default: ''
69
+ },
70
+ pageData: {
71
+ type: String,
72
+ default: 'add'
73
+ },
74
+ pageCurrent: {
75
+ type: Number,
76
+ default: 1
77
+ },
78
+ pageSize: {
79
+ type: Number,
80
+ default: 20
81
+ },
82
+ getcount: {
83
+ type: Boolean,
84
+ default: false
85
+ },
86
+ gettree: {
87
+ type: Object,
88
+ default: ''
89
+ },
90
+ gettreepath: {
91
+ type: Boolean,
92
+ default: false
93
+ },
94
+ startwith: {
95
+ type: String,
96
+ default: ''
97
+ },
98
+ limitlevel: {
99
+ type: Number,
100
+ default: 10
101
+ },
102
+ groupby: {
103
+ type: String,
104
+ default: ''
105
+ },
106
+ groupField: {
107
+ type: String,
108
+ default: ''
109
+ },
110
+ distinct: {
111
+ type: Boolean,
112
+ default: false
113
+ },
114
+ pageIndistinct: {
115
+ type: Boolean,
116
+ default: false
117
+ },
118
+ foreignKey: {
119
+ type: String,
120
+ default: ''
121
+ },
122
+ loadtime: {
123
+ type: String,
124
+ default: 'auto'
125
+ },
126
+ manual: {
127
+ type: Boolean,
128
+ default: false
129
+ }
130
+ },
131
+ data() {
132
+ return {
133
+ mixinDatacomResData: [] as Array<UTSJSONObject>, // 请求返回的数据,调用 loadData 后会更新
134
+ mixinDatacomLoading: false, // 网络请求状态
135
+ mixinDatacomHasMore: false, // 是否有更多数据
136
+ mixinDatacomPage: {
137
+ current: 1,
138
+ size: 20,
139
+ count: 0,
140
+ } as MixinDatacomPaginationType, // 分页信息,详情见 created 生命周期
141
+ mixinDatacomError: null as UniCloudError | null, // 请求出错时的错误消息
142
+ }
143
+ },
144
+ created() {
145
+ this.mixinDatacomPage.current = this.pageCurrent
146
+ this.mixinDatacomPage.size = this.pageSize
147
+
148
+ const PROPS_NAME = ['', '', 'collection', 'field', 'getcount', 'orderby', 'where', 'groupby', 'groupField', 'distinct']
149
+
150
+ this.$watch(
151
+ () : any => [
152
+ this.pageCurrent,
153
+ this.pageSize,
154
+ this.collection,
155
+ this.field,
156
+ this.getcount,
157
+ this.orderby,
158
+ this.where,
159
+ this.groupby,
160
+ this.groupField,
161
+ this.distinct
162
+ ],
163
+ (newValue : Array<any>, oldValue : Array<any>) => {
164
+ this.mixinDatacomPage.size = this.pageSize
165
+ if (newValue[0] !== oldValue[0]) {
166
+ this.mixinDatacomPage.current = this.pageCurrent
167
+ }
168
+
169
+ let needReset = false
170
+ let changed : Array<string> = []
171
+ for (let i = 2; i < newValue.length; i++) {
172
+ if (newValue[i] !== oldValue[i]) {
173
+ needReset = true
174
+ changed.push(PROPS_NAME[i])
175
+ }
176
+ }
177
+
178
+ this.onMixinDatacomPropsChange(needReset, changed)
179
+ }
180
+ )
181
+ },
182
+ methods: {
183
+ // props发生变化时被调用,在组件中覆盖此方法
184
+ // 非 pageCurrent,pageSize 改变时 needReset=true,需要重置数据
185
+ // changed,发生变化的属性名,类型为Array,例如 ['collection', 'action']
186
+ onMixinDatacomPropsChange(_ : boolean, changed : Array<string>) {
187
+ },
188
+ mixinDatacomEasyGet(options ?: MixinDatacomEasyGetOptions) {
189
+ if (this.mixinDatacomLoading) {
190
+ return
191
+ }
192
+
193
+ this.mixinDatacomLoading = true
194
+ this.mixinDatacomError = null
195
+
196
+ this.mixinDatacomGet(null).then((res : UniCloudDBGetResult) => {
197
+ const data = res.data
198
+ const count = res.count
199
+
200
+ if (this.getcount && count != null) {
201
+ this.mixinDatacomPage.count = count
202
+ }
203
+
204
+ this.mixinDatacomHasMore = !((count !== null) ? (this.mixinDatacomPage.current * this.mixinDatacomPage.size >= count) : (data.length < this.pageSize))
205
+ this.mixinDatacomResData = data
206
+
207
+ options?.success?.(res)
208
+ }).catch((err : any | null) => {
209
+ this.mixinDatacomError = err as UniCloudError
210
+ options?.fail?.(err)
211
+ }).finally(() => {
212
+ this.mixinDatacomLoading = false
213
+ options?.complete?.()
214
+ })
215
+ },
216
+ mixinDatacomGet(options ?: MixinDatacomGetOptions) : Promise<UniCloudDBGetResult> {
217
+ let db = uniCloud.databaseForJQL()
218
+
219
+ let collection = Array.isArray(this.collection) ? db.collection(...(this.collection as Array<any>)) : db.collection(this.collection)
220
+
221
+ let filter : UniCloudDBFilter | null = null
222
+ if (this.foreignKey.length > 0) {
223
+ filter = collection.foreignKey(this.foreignKey)
224
+ }
225
+
226
+ const where : any = options?.where ?? this.where
227
+ if (typeof where == 'string') {
228
+ const whereString = where as string
229
+ if (whereString.length > 0) {
230
+ filter = (filter != null) ? filter.where(where) : collection.where(where)
231
+ }
232
+ } else {
233
+ filter = (filter != null) ? filter.where(where) : collection.where(where)
234
+ }
235
+
236
+ let query : UniCloudDBQuery | null = null
237
+ if (this.field.length > 0) {
238
+ query = (filter != null) ? filter.field(this.field) : collection.field(this.field)
239
+ }
240
+ if (this.groupby.length > 0) {
241
+ if (query != null) {
242
+ query = query.groupBy(this.groupby)
243
+ } else if (filter != null) {
244
+ query = filter.groupBy(this.groupby)
245
+ }
246
+ }
247
+ if (this.groupField.length > 0) {
248
+ if (query != null) {
249
+ query = query.groupField(this.groupField)
250
+ } else if (filter != null) {
251
+ query = filter.groupField(this.groupField)
252
+ }
253
+ }
254
+ if (this.distinct == true) {
255
+ if (query != null) {
256
+ query = query.distinct(this.field)
257
+ } else if (filter != null) {
258
+ query = filter.distinct(this.field)
259
+ }
260
+ }
261
+ if (this.orderby.length > 0) {
262
+ if (query != null) {
263
+ query = query.orderBy(this.orderby)
264
+ } else if (filter != null) {
265
+ query = filter.orderBy(this.orderby)
266
+ }
267
+ }
268
+
269
+ const size = this.mixinDatacomPage.size
270
+ const current = this.mixinDatacomPage.current
271
+ if (query != null) {
272
+ query = query.skip(size * (current - 1)).limit(size)
273
+ } else if (filter != null) {
274
+ query = filter.skip(size * (current - 1)).limit(size)
275
+ } else {
276
+ query = collection.skip(size * (current - 1)).limit(size)
277
+ }
278
+
279
+ const getOptions = {}
280
+ const treeOptions = {
281
+ limitLevel: this.limitlevel,
282
+ startWith: this.startwith
283
+ }
284
+ const getCount : boolean = options?.getCount ?? this.getcount
285
+ if (this.getcount == true) {
286
+ getOptions['getCount'] = getCount
287
+ }
288
+
289
+ const getTree : any = options?.getTree ?? this.gettree
290
+ if (typeof getTree == 'string') {
291
+ const getTreeString = getTree as string
292
+ if (getTreeString.length > 0) {
293
+ getOptions['getTree'] = treeOptions
294
+ }
295
+ } else if (typeof getTree == 'object') {
296
+ getOptions['getTree'] = treeOptions
297
+ } else {
298
+ getOptions['getTree'] = getTree
299
+ }
300
+
301
+ const getTreePath = options?.getTreePath ?? this.gettreepath
302
+ if (typeof getTreePath == 'string') {
303
+ const getTreePathString = getTreePath as string
304
+ if (getTreePathString.length > 0) {
305
+ getOptions['getTreePath'] = getTreePath
306
+ }
307
+ } else {
308
+ getOptions['getTreePath'] = getTreePath
309
+ }
310
+
311
+ return query.get(getOptions)
312
+ }
313
+ }
314
314
  })
@@ -1 +1 @@
1
- /// <reference path='../uni/global.d.ts' />
1
+ /// <reference path='../uni/global.d.ts' />