@netang/quasar 0.1.96 → 0.1.97
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/package.json +1 -1
- package/utils/getFile.js +27 -8
- package/utils/getImage.js +7 -6
- package/utils/uploader.js +7 -4
package/package.json
CHANGED
package/utils/getFile.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import $n_has from 'lodash/has'
|
|
2
|
+
|
|
1
3
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
4
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
2
5
|
import $n_isValidString from '@netang/utils/isValidString'
|
|
6
|
+
import $n_split from '@netang/utils/split'
|
|
3
7
|
|
|
4
8
|
import $n_uploader from './uploader'
|
|
5
9
|
|
|
@@ -12,11 +16,32 @@ export default function getFile(src) {
|
|
|
12
16
|
|
|
13
17
|
if (src) {
|
|
14
18
|
|
|
19
|
+
// 如果是字符串
|
|
20
|
+
if ($n_isValidString(src)) {
|
|
21
|
+
|
|
22
|
+
// 则按照逗号隔开转为数租
|
|
23
|
+
src = $n_split(src, ',')
|
|
24
|
+
}
|
|
25
|
+
|
|
15
26
|
// 如果为数组, 则获取第一个
|
|
16
27
|
if ($n_isValidArray(src)) {
|
|
17
28
|
src = src[0]
|
|
18
29
|
}
|
|
19
30
|
|
|
31
|
+
// 如果为对象
|
|
32
|
+
if ($n_isValidObject(src)) {
|
|
33
|
+
|
|
34
|
+
if ($n_has(src, 'img')) {
|
|
35
|
+
src = src.img
|
|
36
|
+
|
|
37
|
+
} else if ($n_has(src, 'file')) {
|
|
38
|
+
src = src.file
|
|
39
|
+
|
|
40
|
+
} else if ($n_has(src, 'video')) {
|
|
41
|
+
src = src.video
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
if ($n_isValidString(src)) {
|
|
21
46
|
|
|
22
47
|
// http(s):// 或 data: 或 blob: 开头的地址
|
|
@@ -25,17 +50,11 @@ export default function getFile(src) {
|
|
|
25
50
|
}
|
|
26
51
|
|
|
27
52
|
const {
|
|
28
|
-
type,
|
|
53
|
+
// type,
|
|
29
54
|
domain,
|
|
30
55
|
} = $n_uploader.getUpload()
|
|
31
56
|
|
|
32
|
-
|
|
33
|
-
// 七牛云
|
|
34
|
-
case 'qiniu':
|
|
35
|
-
// minio
|
|
36
|
-
case 'minio':
|
|
37
|
-
return useFileUrl(domain, src)
|
|
38
|
-
}
|
|
57
|
+
return useFileUrl(domain, src)
|
|
39
58
|
}
|
|
40
59
|
}
|
|
41
60
|
|
package/utils/getImage.js
CHANGED
|
@@ -28,9 +28,10 @@ export default function getImage(src, options) {
|
|
|
28
28
|
// 如果为数组, 则获取第一个
|
|
29
29
|
if ($n_isValidArray(src)) {
|
|
30
30
|
src = src[0]
|
|
31
|
+
}
|
|
31
32
|
|
|
32
33
|
// 如果为对象
|
|
33
|
-
|
|
34
|
+
if ($n_isValidObject(src)) {
|
|
34
35
|
|
|
35
36
|
if ($n_has(src, 'options')) {
|
|
36
37
|
options = src.options
|
|
@@ -77,10 +78,10 @@ export default function getImage(src, options) {
|
|
|
77
78
|
w = Number(w)
|
|
78
79
|
if (w > 0) {
|
|
79
80
|
|
|
80
|
-
// 获取设备像素比
|
|
81
81
|
/* #if IS_WEB */
|
|
82
82
|
// 如果开启缩放
|
|
83
83
|
if (zoom) {
|
|
84
|
+
// 获取设备像素比
|
|
84
85
|
const devicePixelRatio = window.devicePixelRatio || 1
|
|
85
86
|
if (devicePixelRatio > 2) {
|
|
86
87
|
w *= 2
|
|
@@ -104,7 +105,6 @@ export default function getImage(src, options) {
|
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
// --------------------------------------------------
|
|
108
108
|
|
|
109
109
|
} else {
|
|
110
110
|
options = {}
|
|
@@ -122,7 +122,7 @@ export default function getImage(src, options) {
|
|
|
122
122
|
case 'qiniu':
|
|
123
123
|
// minio
|
|
124
124
|
case 'minio':
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
const {
|
|
127
127
|
compress,
|
|
128
128
|
w,
|
|
@@ -168,9 +168,10 @@ export default function getImage(src, options) {
|
|
|
168
168
|
src += '/format/' + format
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
return useFileUrl(domain, src)
|
|
171
|
+
break
|
|
173
172
|
}
|
|
173
|
+
|
|
174
|
+
return useFileUrl(domain, src)
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
|
package/utils/uploader.js
CHANGED
|
@@ -116,10 +116,13 @@ function create(options) {
|
|
|
116
116
|
*/
|
|
117
117
|
const configUpload = getUpload()
|
|
118
118
|
|
|
119
|
-
const configLimit = Object.assign(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
const configLimit = Object.assign(
|
|
120
|
+
{
|
|
121
|
+
maxSize: 100,
|
|
122
|
+
exts: [],
|
|
123
|
+
},
|
|
124
|
+
$n_config('uploader.limit.' + props.type, {})
|
|
125
|
+
)
|
|
123
126
|
|
|
124
127
|
// 如果有单个文件的最大大小
|
|
125
128
|
if (props.maxSize) {
|