@netang/quasar 0.1.96 → 0.1.98
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/components/search-item/index.vue +0 -2
- package/package.json +1 -1
- package/utils/getFile.js +27 -8
- package/utils/getImage.js +18 -6
- package/utils/uploader.js +8 -5
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import $n_get from 'lodash/get'
|
|
1
2
|
import $n_has from 'lodash/has'
|
|
2
3
|
import $n_isString from 'lodash/isString'
|
|
3
4
|
|
|
@@ -6,6 +7,7 @@ import $n_isValidObject from '@netang/utils/isValidObject'
|
|
|
6
7
|
import $n_isValidString from '@netang/utils/isValidString'
|
|
7
8
|
import $n_isNumeric from '@netang/utils/isNumeric'
|
|
8
9
|
import $n_split from '@netang/utils/split'
|
|
10
|
+
import $n_slash from '@netang/utils/slash'
|
|
9
11
|
|
|
10
12
|
import $n_uploader from './uploader'
|
|
11
13
|
|
|
@@ -28,9 +30,10 @@ export default function getImage(src, options) {
|
|
|
28
30
|
// 如果为数组, 则获取第一个
|
|
29
31
|
if ($n_isValidArray(src)) {
|
|
30
32
|
src = src[0]
|
|
33
|
+
}
|
|
31
34
|
|
|
32
35
|
// 如果为对象
|
|
33
|
-
|
|
36
|
+
if ($n_isValidObject(src)) {
|
|
34
37
|
|
|
35
38
|
if ($n_has(src, 'options')) {
|
|
36
39
|
options = src.options
|
|
@@ -77,10 +80,10 @@ export default function getImage(src, options) {
|
|
|
77
80
|
w = Number(w)
|
|
78
81
|
if (w > 0) {
|
|
79
82
|
|
|
80
|
-
// 获取设备像素比
|
|
81
83
|
/* #if IS_WEB */
|
|
82
84
|
// 如果开启缩放
|
|
83
85
|
if (zoom) {
|
|
86
|
+
// 获取设备像素比
|
|
84
87
|
const devicePixelRatio = window.devicePixelRatio || 1
|
|
85
88
|
if (devicePixelRatio > 2) {
|
|
86
89
|
w *= 2
|
|
@@ -104,7 +107,6 @@ export default function getImage(src, options) {
|
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
|
-
// --------------------------------------------------
|
|
108
110
|
|
|
109
111
|
} else {
|
|
110
112
|
options = {}
|
|
@@ -113,7 +115,7 @@ export default function getImage(src, options) {
|
|
|
113
115
|
const {
|
|
114
116
|
type,
|
|
115
117
|
domain,
|
|
116
|
-
} = $n_uploader.getUpload()
|
|
118
|
+
} = $n_uploader.getUpload(null, $n_get(options, 'upload', ''))
|
|
117
119
|
|
|
118
120
|
// 判断图片上传方式
|
|
119
121
|
switch (type) {
|
|
@@ -122,7 +124,7 @@ export default function getImage(src, options) {
|
|
|
122
124
|
case 'qiniu':
|
|
123
125
|
// minio
|
|
124
126
|
case 'minio':
|
|
125
|
-
|
|
127
|
+
|
|
126
128
|
const {
|
|
127
129
|
compress,
|
|
128
130
|
w,
|
|
@@ -168,9 +170,19 @@ export default function getImage(src, options) {
|
|
|
168
170
|
src += '/format/' + format
|
|
169
171
|
}
|
|
170
172
|
}
|
|
173
|
+
break
|
|
174
|
+
}
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
// 【调试模式】
|
|
177
|
+
// --------------------------------------------------
|
|
178
|
+
// #ifdef IS_DEBUG
|
|
179
|
+
if ($n_get(options, 'upload')) {
|
|
180
|
+
return $n_slash(domain, 'end', true) + src
|
|
173
181
|
}
|
|
182
|
+
// #endif
|
|
183
|
+
// --------------------------------------------------
|
|
184
|
+
|
|
185
|
+
return useFileUrl(domain, src)
|
|
174
186
|
}
|
|
175
187
|
}
|
|
176
188
|
|
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) {
|
|
@@ -1601,7 +1604,7 @@ function create(options) {
|
|
|
1601
1604
|
*/
|
|
1602
1605
|
export function getUpload(userConfig = null, defaultUpload = '') {
|
|
1603
1606
|
const uploadConfig = $n_get((userConfig ? userConfig : configs.userConfig), 'uploader.upload', {})
|
|
1604
|
-
const type = defaultUpload ? defaultUpload : uploadConfig.default
|
|
1607
|
+
const type = $n_isValidString(defaultUpload) ? defaultUpload : uploadConfig.default
|
|
1605
1608
|
return Object.assign(
|
|
1606
1609
|
{},
|
|
1607
1610
|
$n_get(uploadConfig, type, {}),
|