@kengic/uni 0.3.2-beta.10
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.
- package/README.md +1 -0
- package/dist/index.css +1 -0
- package/dist/kengic-uni.js +5 -0
- package/dist/src/consts/i18n/en.d.ts +45 -0
- package/dist/src/consts/i18n/index.d.ts +90 -0
- package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
- package/dist/src/consts/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/kg.util.d.ts +5 -0
- package/dist/uni-ui/index.ts +11 -0
- package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
- package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
- package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
- package/dist/uni-ui/uni-calendar/calendar.js +546 -0
- package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
- package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
- package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
- package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
- package/dist/uni-ui/uni-calendar/util.js +360 -0
- package/dist/uni-ui/uni-card/uni-card.vue +281 -0
- package/dist/uni-ui/uni-col/uni-col.vue +317 -0
- package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
- package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
- package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
- package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
- package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
- package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
- package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
- package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
- package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
- package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
- package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
- package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
- package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
- package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
- package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
- package/dist/uni-ui/uni-drawer/keypress.js +45 -0
- package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
- package/dist/uni-ui/uni-easyinput/common.js +56 -0
- package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
- package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
- package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
- package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
- package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
- package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
- package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
- package/dist/uni-ui/uni-file-picker/utils.js +109 -0
- package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
- package/dist/uni-ui/uni-forms/utils.js +293 -0
- package/dist/uni-ui/uni-forms/validate.js +486 -0
- package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
- package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
- package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
- package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
- package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
- package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
- package/dist/uni-ui/uni-group/uni-group.vue +134 -0
- package/dist/uni-ui/uni-icons/icons.js +1169 -0
- package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
- package/dist/uni-ui/uni-icons/uniicons.css +663 -0
- package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
- package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
- package/dist/uni-ui/uni-link/uni-link.vue +128 -0
- package/dist/uni-ui/uni-list/uni-list.vue +123 -0
- package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
- package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
- package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
- package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
- package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
- package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
- package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
- package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
- package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
- package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
- package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
- package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
- package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
- package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
- package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
- package/dist/uni-ui/uni-popup/keypress.js +45 -0
- package/dist/uni-ui/uni-popup/popup.js +23 -0
- package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
- package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
- package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
- package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
- package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
- package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
- package/dist/uni-ui/uni-row/uni-row.vue +190 -0
- package/dist/uni-ui/uni-scss/changelog.md +8 -0
- package/dist/uni-ui/uni-scss/index.scss +1 -0
- package/dist/uni-ui/uni-scss/package.json +82 -0
- package/dist/uni-ui/uni-scss/readme.md +4 -0
- package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
- package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
- package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
- package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
- package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
- package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
- package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
- package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
- package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
- package/dist/uni-ui/uni-scss/theme.scss +31 -0
- package/dist/uni-ui/uni-scss/variables.scss +62 -0
- package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
- package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
- package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
- package/dist/uni-ui/uni-section/uni-section.vue +167 -0
- package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
- package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
- package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
- package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
- package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
- package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
- package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
- package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
- package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
- package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
- package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
- package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
- package/dist/uni-ui/uni-table/uni-table.vue +455 -0
- package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
- package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
- package/dist/uni-ui/uni-td/uni-td.vue +90 -0
- package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
- package/dist/uni-ui/uni-th/uni-th.vue +285 -0
- package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
- package/dist/uni-ui/uni-title/uni-title.vue +171 -0
- package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
- package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
- package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
- package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
- package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
- package/package.json +90 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ERR_MSG_OK = 'chooseAndUploadFile:ok';
|
|
4
|
+
const ERR_MSG_FAIL = 'chooseAndUploadFile:fail';
|
|
5
|
+
|
|
6
|
+
function chooseImage(opts) {
|
|
7
|
+
const {
|
|
8
|
+
count,
|
|
9
|
+
sizeType = ['original', 'compressed'],
|
|
10
|
+
sourceType,
|
|
11
|
+
extension
|
|
12
|
+
} = opts
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
uni.chooseImage({
|
|
15
|
+
count,
|
|
16
|
+
sizeType,
|
|
17
|
+
sourceType,
|
|
18
|
+
extension,
|
|
19
|
+
success(res) {
|
|
20
|
+
resolve(normalizeChooseAndUploadFileRes(res, 'image'));
|
|
21
|
+
},
|
|
22
|
+
fail(res) {
|
|
23
|
+
reject({
|
|
24
|
+
errMsg: res.errMsg.replace('chooseImage:fail', ERR_MSG_FAIL),
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function chooseVideo(opts) {
|
|
32
|
+
const {
|
|
33
|
+
camera,
|
|
34
|
+
compressed,
|
|
35
|
+
maxDuration,
|
|
36
|
+
sourceType,
|
|
37
|
+
extension
|
|
38
|
+
} = opts;
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
uni.chooseVideo({
|
|
41
|
+
camera,
|
|
42
|
+
compressed,
|
|
43
|
+
maxDuration,
|
|
44
|
+
sourceType,
|
|
45
|
+
extension,
|
|
46
|
+
success(res) {
|
|
47
|
+
const {
|
|
48
|
+
tempFilePath,
|
|
49
|
+
duration,
|
|
50
|
+
size,
|
|
51
|
+
height,
|
|
52
|
+
width
|
|
53
|
+
} = res;
|
|
54
|
+
resolve(normalizeChooseAndUploadFileRes({
|
|
55
|
+
errMsg: 'chooseVideo:ok',
|
|
56
|
+
tempFilePaths: [tempFilePath],
|
|
57
|
+
tempFiles: [
|
|
58
|
+
{
|
|
59
|
+
name: (res.tempFile && res.tempFile.name) || '',
|
|
60
|
+
path: tempFilePath,
|
|
61
|
+
size,
|
|
62
|
+
type: (res.tempFile && res.tempFile.type) || '',
|
|
63
|
+
width,
|
|
64
|
+
height,
|
|
65
|
+
duration,
|
|
66
|
+
fileType: 'video',
|
|
67
|
+
cloudPath: '',
|
|
68
|
+
}, ],
|
|
69
|
+
}, 'video'));
|
|
70
|
+
},
|
|
71
|
+
fail(res) {
|
|
72
|
+
reject({
|
|
73
|
+
errMsg: res.errMsg.replace('chooseVideo:fail', ERR_MSG_FAIL),
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function chooseAll(opts) {
|
|
81
|
+
const {
|
|
82
|
+
count,
|
|
83
|
+
extension
|
|
84
|
+
} = opts;
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
let chooseFile = uni.chooseFile;
|
|
87
|
+
if (typeof wx !== 'undefined' &&
|
|
88
|
+
typeof wx.chooseMessageFile === 'function') {
|
|
89
|
+
chooseFile = wx.chooseMessageFile;
|
|
90
|
+
}
|
|
91
|
+
if (typeof chooseFile !== 'function') {
|
|
92
|
+
return reject({
|
|
93
|
+
errMsg: ERR_MSG_FAIL + ' 请指定 type 类型,该平台仅支持选择 image 或 video。',
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
chooseFile({
|
|
97
|
+
type: 'all',
|
|
98
|
+
count,
|
|
99
|
+
extension,
|
|
100
|
+
success(res) {
|
|
101
|
+
resolve(normalizeChooseAndUploadFileRes(res));
|
|
102
|
+
},
|
|
103
|
+
fail(res) {
|
|
104
|
+
reject({
|
|
105
|
+
errMsg: res.errMsg.replace('chooseFile:fail', ERR_MSG_FAIL),
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function normalizeChooseAndUploadFileRes(res, fileType) {
|
|
113
|
+
res.tempFiles.forEach((item, index) => {
|
|
114
|
+
if (!item.name) {
|
|
115
|
+
item.name = item.path.substring(item.path.lastIndexOf('/') + 1);
|
|
116
|
+
}
|
|
117
|
+
if (fileType) {
|
|
118
|
+
item.fileType = fileType;
|
|
119
|
+
}
|
|
120
|
+
item.cloudPath =
|
|
121
|
+
Date.now() + '_' + index + item.name.substring(item.name.lastIndexOf('.'));
|
|
122
|
+
});
|
|
123
|
+
if (!res.tempFilePaths) {
|
|
124
|
+
res.tempFilePaths = res.tempFiles.map((file) => file.path);
|
|
125
|
+
}
|
|
126
|
+
return res;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function uploadCloudFiles(files, max = 5, onUploadProgress) {
|
|
130
|
+
files = JSON.parse(JSON.stringify(files))
|
|
131
|
+
const len = files.length
|
|
132
|
+
let count = 0
|
|
133
|
+
let self = this
|
|
134
|
+
return new Promise(resolve => {
|
|
135
|
+
while (count < max) {
|
|
136
|
+
next()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function next() {
|
|
140
|
+
let cur = count++
|
|
141
|
+
if (cur >= len) {
|
|
142
|
+
!files.find(item => !item.url && !item.errMsg) && resolve(files)
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
const fileItem = files[cur]
|
|
146
|
+
const index = self.files.findIndex(v => v.uuid === fileItem.uuid)
|
|
147
|
+
fileItem.url = ''
|
|
148
|
+
delete fileItem.errMsg
|
|
149
|
+
|
|
150
|
+
uniCloud
|
|
151
|
+
.uploadFile({
|
|
152
|
+
filePath: fileItem.path,
|
|
153
|
+
cloudPath: fileItem.cloudPath,
|
|
154
|
+
fileType: fileItem.fileType,
|
|
155
|
+
onUploadProgress: res => {
|
|
156
|
+
res.index = index
|
|
157
|
+
onUploadProgress && onUploadProgress(res)
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
.then(res => {
|
|
161
|
+
fileItem.url = res.fileID
|
|
162
|
+
fileItem.index = index
|
|
163
|
+
if (cur < len) {
|
|
164
|
+
next()
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
.catch(res => {
|
|
168
|
+
fileItem.errMsg = res.errMsg || res.message
|
|
169
|
+
fileItem.index = index
|
|
170
|
+
if (cur < len) {
|
|
171
|
+
next()
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
function uploadFiles(choosePromise, {
|
|
183
|
+
onChooseFile,
|
|
184
|
+
onUploadProgress
|
|
185
|
+
}) {
|
|
186
|
+
return choosePromise
|
|
187
|
+
.then((res) => {
|
|
188
|
+
if (onChooseFile) {
|
|
189
|
+
const customChooseRes = onChooseFile(res);
|
|
190
|
+
if (typeof customChooseRes !== 'undefined') {
|
|
191
|
+
return Promise.resolve(customChooseRes).then((chooseRes) => typeof chooseRes === 'undefined' ?
|
|
192
|
+
res : chooseRes);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return res;
|
|
196
|
+
})
|
|
197
|
+
.then((res) => {
|
|
198
|
+
if (res === false) {
|
|
199
|
+
return {
|
|
200
|
+
errMsg: ERR_MSG_OK,
|
|
201
|
+
tempFilePaths: [],
|
|
202
|
+
tempFiles: [],
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return res
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function chooseAndUploadFile(opts = {
|
|
210
|
+
type: 'all'
|
|
211
|
+
}) {
|
|
212
|
+
if (opts.type === 'image') {
|
|
213
|
+
return uploadFiles(chooseImage(opts), opts);
|
|
214
|
+
}
|
|
215
|
+
else if (opts.type === 'video') {
|
|
216
|
+
return uploadFiles(chooseVideo(opts), opts);
|
|
217
|
+
}
|
|
218
|
+
return uploadFiles(chooseAll(opts), opts);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export {
|
|
222
|
+
chooseAndUploadFile,
|
|
223
|
+
uploadCloudFiles
|
|
224
|
+
};
|