@aochuang/common 1.0.132 → 1.0.134

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.
@@ -5,6 +5,13 @@
5
5
  "css_prefix_text": "icon-",
6
6
  "description": "私域方舟",
7
7
  "glyphs": [
8
+ {
9
+ "icon_id": "29524819",
10
+ "name": "upload-2-fill",
11
+ "font_class": "upload-2-fill",
12
+ "unicode": "e89b",
13
+ "unicode_decimal": 59547
14
+ },
8
15
  {
9
16
  "icon_id": "29523203",
10
17
  "name": "bookmark-3-line",
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  import Image from './image'
2
- import { setImageClickFn, getThumbnailSrc as _getThumbnailSrc } from './util'
2
+ import { setImageClickFn, getThumbnailSrc as _getThumbnailSrc, removeThumbnailSrc as _removeThumbnailSrc } from './util'
3
3
 
4
4
  Image.install = (Vue, options) => {
5
5
  options = Object.assign({
@@ -10,5 +10,6 @@ Image.install = (Vue, options) => {
10
10
  }
11
11
 
12
12
  export const getThumbnailSrc = _getThumbnailSrc
13
+ export const removeThumbnailSrc = _removeThumbnailSrc
13
14
 
14
15
  export default Image
@@ -105,3 +105,37 @@ export function getThumbnailSrc (url, width) {
105
105
  return url
106
106
  }
107
107
  }
108
+
109
+ /**
110
+ * 移除图片缩略图裁剪参数,保留其他查询参数及 hash
111
+ */
112
+ export function removeThumbnailSrc (url) {
113
+ if (!url) {
114
+ return url
115
+ }
116
+
117
+ const hashIndex = url.indexOf('#')
118
+ const hash = hashIndex >= 0 ? url.substr(hashIndex) : ''
119
+ let source = hashIndex >= 0 ? url.substr(0, hashIndex) : url
120
+
121
+ // /oss/view 和 /oss/ 地址的真实图片在 url 参数中,递归处理后再重新编码
122
+ if (source.indexOf('/oss/view') > -1 || source.indexOf('/oss/') > -1) {
123
+ const marker = source.indexOf('/oss/view') > -1 ? '/oss/view' : '/oss/'
124
+ const markerIndex = source.indexOf(marker)
125
+ const prefix = source.substr(0, markerIndex + marker.length)
126
+ const params = getUrlParams(source)
127
+ if (params.url) {
128
+ params.url = removeThumbnailSrc(params.url)
129
+ source = buildUrl(prefix, params)
130
+ return source + hash
131
+ }
132
+ }
133
+
134
+ // 阿里云参数是普通 query 参数;腾讯云参数是无等号的 query path
135
+ source = source
136
+ .replace(/([?&])x-oss-process=image\/resize(?:,[^&#]*)?(?=&|$)/ig, '$1')
137
+ .replace(/([?&])imageMogr2\/thumbnail\/[^&#]*(?=&|$)/ig, '$1')
138
+ .replace('?&', '?')
139
+ .replace(/[?&]$/, '')
140
+ return source + hash
141
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aochuang/common",
3
- "version": "1.0.132",
3
+ "version": "1.0.134",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "publishConfig": {