@netang/quasar 0.2.19 → 0.2.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
 
5
5
  "description": "netang-quasar",
6
6
  "scripts": {
package/utils/config.js CHANGED
@@ -43,6 +43,8 @@ export const configs = {
43
43
  formatUploadNet: null,
44
44
  // 获取文件地址
45
45
  getFileUrl: null,
46
+ // 上传请求
47
+ onUploadHttp: null,
46
48
  },
47
49
  }
48
50
 
package/utils/getImage.js CHANGED
@@ -217,6 +217,46 @@ export default function getImage(src, options) {
217
217
  }
218
218
  }
219
219
  break
220
+
221
+ // 【oss】
222
+ // -------------------------------------------------------------------------------------------------
223
+ // 文档: https://help.aliyun.com/document_detail/44686.html
224
+ case 'oss':
225
+
226
+ // 裁剪图片方式
227
+ src += `?x-oss-process=image`
228
+
229
+ // 缩放
230
+ if (w || h) {
231
+
232
+ src += '/resize'
233
+
234
+ // 宽
235
+ if (w) {
236
+ src += ',w_' + w
237
+ }
238
+
239
+ // 高
240
+ if (h) {
241
+ src += ',h_' + h
242
+ }
243
+ }
244
+
245
+ // 质量
246
+ if (q) {
247
+ src += '/quality,q_' + q
248
+ }
249
+
250
+ // 渐进显示
251
+ if (interlace) {
252
+ src += '/interlace,1'
253
+ }
254
+
255
+ // 格式化
256
+ if (format) {
257
+ src += '/format,' + format
258
+ }
259
+ break
220
260
  }
221
261
 
222
262
  // 【调试模式】
package/utils/uploader.js CHANGED
@@ -1886,6 +1886,11 @@ function create(options) {
1886
1886
  // 设置文件状态
1887
1887
  fileItem.status = UPLOAD_STATUS.uploading
1888
1888
 
1889
+ const {
1890
+ // 上传请求
1891
+ onUploadHttp,
1892
+ } = configs.uploader
1893
+
1889
1894
  // 上传文件
1890
1895
  const upload = async function(configUpload, uploadParams, startPercent, halfPercent) {
1891
1896
 
@@ -1907,7 +1912,7 @@ function create(options) {
1907
1912
  // 自定义文件 key
1908
1913
  httpData[keyName] = fileItem.hash
1909
1914
 
1910
- const { status, data: res } = await $n_http({
1915
+ let opts = {
1911
1916
  // 上传地址
1912
1917
  url,
1913
1918
  // 数据
@@ -1932,7 +1937,17 @@ function create(options) {
1932
1937
  // 设置上传进度
1933
1938
  fileItem.progress = Math.round(startPercent + (halfPercent ? percent / 2 : percent))
1934
1939
  },
1935
- })
1940
+ }
1941
+
1942
+ // 上传请求
1943
+ if ($n_isFunction(onUploadHttp)) {
1944
+ const res = onUploadHttp(opts, fileItem)
1945
+ if (res) {
1946
+ opts = res
1947
+ }
1948
+ }
1949
+
1950
+ const { status, data: res } = await $n_http(opts)
1936
1951
 
1937
1952
  // 如果请求失败
1938
1953
  if (! status) {