ソースを参照

Merge branch 'master' of http://git.ycjcjy.com/state_grid/training-wx

[baozhangchao] 3 年 前
コミット
ee844954de
共有1 個のファイルを変更した22 個の追加0 個の削除を含む
  1. 22
    0
      src/util/index.js

+ 22
- 0
src/util/index.js ファイルの表示

@@ -0,0 +1,22 @@
1
+
2
+/**
3
+ * 压缩图片
4
+ * @param {*} url 
5
+ * @returns 
6
+ */
7
+ export function compressImage(url, typ) {
8
+  if (!url) return url;
9
+
10
+  // GIF 不压缩
11
+  if (url.indexOf('.gif') > -1) return url;
12
+
13
+  const style = typ || 'cmp80'
14
+
15
+  // eslint-disable-next-line no-undef
16
+  const ossLike = 'aliyuncs.com'
17
+  if (url.indexOf(ossLike) > -1) {
18
+    return `${url}?x-oss-process=style/${style}` //.replace('http://', 'https://')
19
+  }
20
+
21
+  return url;
22
+}