fangguo-component 1.2.3 → 1.2.5

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.
Files changed (52) hide show
  1. package/dist/{ErrorImage-CFVt1ht_.js → ErrorImage-Ao9kEEUg.js} +2 -2
  2. package/dist/FgCascader.css +2 -14
  3. package/dist/{FgCascader.vue_vue_type_style_index_0_lang-CstlYwHs.js → FgCascader.vue_vue_type_style_index_0_lang-CtUPO8fk.js} +20 -26
  4. package/dist/{HSelect-DgFjd08Y.js → HSelect-0w2mSrtm.js} +1 -1
  5. package/dist/{HSelectAll.vue_vue_type_script_setup_true_lang-C6qzdQT-.js → HSelectAll.vue_vue_type_script_setup_true_lang-xHFbYs59.js} +1 -1
  6. package/dist/{HSelectSJ-DOFUzTZV.js → HSelectSJ-Cm573j6B.js} +1 -1
  7. package/dist/{ImgViewerHost.vue_vue_type_script_setup_true_lang-DBs42WOq.js → ImgViewerHost.vue_vue_type_script_setup_true_lang-DO9s-b9s.js} +42 -3
  8. package/dist/{LazyPopover-7ebuh-QG.js → LazyPopover-CcvilJ6U.js} +25 -3
  9. package/dist/LazyPopover.css +1 -1
  10. package/dist/{SelectTree-DUH92Iwr.js → SelectTree-BHvvkiQi.js} +1 -1
  11. package/dist/ViewImg-CLRjYOUN.js +556 -0
  12. package/dist/ViewImg.css +60 -35
  13. package/dist/ViewImgPopover-BtFnYval.js +463 -0
  14. package/dist/ViewImgPopover.css +28 -26
  15. package/dist/components/cascader/index.js +1 -1
  16. package/dist/components/errorImage/index.js +2 -2
  17. package/dist/components/hSelect/index.js +1 -1
  18. package/dist/components/hSelectAll/index.js +1 -1
  19. package/dist/components/hSelectSJ/index.js +1 -1
  20. package/dist/components/imgViewerHost/ImgViewerHost.vue.d.ts +7 -1
  21. package/dist/components/imgViewerHost/imgViewerAutoHost.d.ts +2 -0
  22. package/dist/components/imgViewerHost/imgViewerHostRegistry.d.ts +5 -0
  23. package/dist/components/imgViewerHost/index.js +2 -2
  24. package/dist/components/index.js +22 -18
  25. package/dist/components/lazyPopover/LazyPopover.vue.d.ts +2 -0
  26. package/dist/components/lazyPopover/index.js +1 -1
  27. package/dist/components/selectTree/index.js +1 -1
  28. package/dist/components/viewImg/ViewImg.vue.d.ts +44 -19
  29. package/dist/components/viewImg/ViewImgErrorFallback.vue.d.ts +17 -0
  30. package/dist/components/viewImg/defaults.d.ts +28 -0
  31. package/dist/components/viewImg/index.d.ts +3 -0
  32. package/dist/components/viewImg/index.js +6 -2
  33. package/dist/components/viewImgPopover/ViewImgPopover.vue.d.ts +207 -99
  34. package/dist/components/viewImgPopover/index.js +1 -1
  35. package/dist/components/viewImgPreview/ViewImgPreview.vue.d.ts +6 -6
  36. package/dist/imgViewerAutoHost-BQVVGop1.js +32 -0
  37. package/dist/{imgViewerStore-DK3zvGf4.js → imgViewerStore-Ajm-L7R5.js} +7 -0
  38. package/dist/{index-Qkq7I01c.js → index-DsfY1yqo.js} +6 -1
  39. package/dist/{index-Ce_edAQB.js → index-wDrpgKQT.js} +17 -13
  40. package/dist/index.d.ts +8 -3
  41. package/dist/index.js +58 -49
  42. package/dist/montageImgUrl-B9ZmJ7TF.js +464 -0
  43. package/dist/tools/ImageParserUtils/index.d.ts +1 -1
  44. package/dist/tools/imgUrl/imageUrl.d.ts +246 -0
  45. package/dist/tools/imgUrl/index.d.ts +2 -0
  46. package/dist/tools/imgUrl/index.js +13 -8
  47. package/dist/tools/imgUrl/montageImgUrl.d.ts +11 -5
  48. package/dist/tools/index.js +19 -14
  49. package/package.json +2 -2
  50. package/dist/ViewImg-DXhF20SL.js +0 -254
  51. package/dist/ViewImgPopover-QblZG0z5.js +0 -343
  52. package/dist/montageImgUrl-CwgYnB2h.js +0 -204
@@ -0,0 +1,246 @@
1
+ type ImageSizeValue = number | string | null | undefined;
2
+ export type ImageResizeOptions = {
3
+ width?: ImageSizeValue;
4
+ height?: ImageSizeValue;
5
+ /** OSS 绝对质量 Q(1–100) */
6
+ Q?: number;
7
+ /** OSS 相对质量 q(1–100);与 Q 同时存在时优先 Q */
8
+ q?: number;
9
+ /** OSS 输出格式,如 webp */
10
+ format?: string;
11
+ /** 当前调用使用的 OSS 域名白名单;未传时使用 configureImgUrl 注入的全局配置 */
12
+ ossLinks?: string[];
13
+ };
14
+ /**
15
+ * 移除 URL query,保留 hash。
16
+ *
17
+ * @example
18
+ * removeImageUrlQuery('https://a.com/img.jpg?x=1#top')
19
+ * // 'https://a.com/img.jpg#top'
20
+ */
21
+ export declare function removeImageUrlQuery(url: string): string;
22
+ /**
23
+ * Temu / kwcdn 获取原图。
24
+ *
25
+ * 当前采集规则是直接去掉 query 参数。
26
+ *
27
+ * @example
28
+ * getTemuOriginalImageUrl(
29
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/150/q/50/format/avif%7CimageVqr/2'
30
+ * )
31
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg'
32
+ */
33
+ export declare function getTemuOriginalImageUrl(url: string): string;
34
+ /**
35
+ * Shein / ltwebstatic 获取原图。
36
+ *
37
+ * 当前采集规则:
38
+ * - _thumbnail.jpg / _thumbnail_405x552.jpg -> _thumbnail_fullx.jpg
39
+ * - _square_thumbnail.jpg / _square_thumbnail_405x552.jpg -> _square_thumbnail_fullx.jpg
40
+ *
41
+ * @example
42
+ * getSheinOriginalImageUrl(
43
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg'
44
+ * )
45
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_fullx.jpg'
46
+ *
47
+ * @example
48
+ * getSheinOriginalImageUrl(
49
+ * 'http://img.ltwebstatic.com/v4/j/spmp/a_thumbnail.jpg'
50
+ * )
51
+ * // 'http://img.ltwebstatic.com/v4/j/spmp/a_thumbnail_fullx.jpg'
52
+ */
53
+ export declare function getSheinOriginalImageUrl(url: string): string;
54
+ /**
55
+ * Amazon 获取原图。
56
+ *
57
+ * 当前采集规则是把 ._AC_ 后的尺寸段扩成 full,保留 QL/FMwebp 等非尺寸段。
58
+ *
59
+ * @example
60
+ * getAmazonOriginalImageUrl('https://m.media-amazon.com/images/I/abc._AC_UL450_SR450,320_.jpg')
61
+ * // 'https://m.media-amazon.com/images/I/abc._AC_ULfull_SRfull,full_.jpg'
62
+ */
63
+ export declare function getAmazonOriginalImageUrl(url: string): string;
64
+ /**
65
+ * Etsy 获取原图。
66
+ *
67
+ * 当前采集规则:il_75x75 / il_340x270 等改成 il_fullxfull。
68
+ *
69
+ * @example
70
+ * getEtsyOriginalImageUrl('https://i.etsystatic.com/123/r/il_340x270.456.jpg')
71
+ * // 'https://i.etsystatic.com/123/r/il_fullxfull.456.jpg'
72
+ */
73
+ export declare function getEtsyOriginalImageUrl(url: string): string;
74
+ /**
75
+ * Temu / kwcdn
76
+ *
77
+ * 优先使用 width;未传 width 时回退 height(组件侧常只传 h)。
78
+ * 原链接已有 query(含历史 imageView2 / 非法双 ? + imageMogr2)时,先清掉再统一换成 imageView2。
79
+ *
80
+ * @example
81
+ * buildTemuImageResizeUrl(
82
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/500/q/70/format/avif?imageMogr2/thumbnail/100x',
83
+ * { width: 100 }
84
+ * )
85
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/100/q/50/format/avif%7CimageVqr/2'
86
+ */
87
+ export declare function buildTemuImageResizeUrl(url: string, options?: ImageResizeOptions): string;
88
+ /**
89
+ * Shein / ltwebstatic
90
+ *
91
+ * Shein 尺寸在文件路径里,不在 query 中;通过替换路径里的 thumbnail 后缀实现。
92
+ * 支持:
93
+ * - `_thumbnail.jpg` / `_square_thumbnail.jpg`(无尺寸)
94
+ * - `_thumbnail_405x552.jpg` / `_thumbnail_fullx.jpg`
95
+ * 宽高缺一时用另一个回填。
96
+ *
97
+ * @example
98
+ * buildSheinImageResizeUrl(
99
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg',
100
+ * { width: 300, height: 409 }
101
+ * )
102
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_300x409.jpg'
103
+ *
104
+ * @example
105
+ * buildSheinImageResizeUrl(
106
+ * 'http://img.ltwebstatic.com/v4/j/spmp/a_thumbnail.jpg',
107
+ * { width: 420, height: 420 }
108
+ * )
109
+ * // 'http://img.ltwebstatic.com/v4/j/spmp/a_thumbnail_420x420.jpg'
110
+ */
111
+ export declare function buildSheinImageResizeUrl(url: string, options?: ImageResizeOptions): string;
112
+ /**
113
+ * Amazon
114
+ *
115
+ * 替换 ._AC_ 后 UL/SR/SX 等尺寸段;单值标签用 width(缺省用 height),
116
+ * 双值标签用 width,height(缺一则用另一个填充)。也支持把 full 改回具体尺寸。
117
+ *
118
+ * @example
119
+ * buildAmazonImageResizeUrl(
120
+ * 'https://m.media-amazon.com/images/I/abc._AC_UL450_SR450,320_.jpg',
121
+ * { width: 200, height: 150 }
122
+ * )
123
+ * // 'https://m.media-amazon.com/images/I/abc._AC_UL200_SR200,150_.jpg'
124
+ */
125
+ export declare function buildAmazonImageResizeUrl(url: string, options?: ImageResizeOptions): string;
126
+ /**
127
+ * Etsy
128
+ *
129
+ * 将路径里的 il_{w}x{h} / il_fullxfull 替换为 il_{width}x{height}。
130
+ * 宽高缺一时用另一个回填(组件侧常只传 w 或 h)。
131
+ *
132
+ * @example
133
+ * buildEtsyImageResizeUrl(
134
+ * 'https://i.etsystatic.com/123/r/il_340x270.456.jpg',
135
+ * { width: 200, height: 200 }
136
+ * )
137
+ * // 'https://i.etsystatic.com/123/r/il_200x200.456.jpg'
138
+ *
139
+ * @example
140
+ * buildEtsyImageResizeUrl(
141
+ * 'https://i.etsystatic.com/123/r/il_fullxfull.456.jpg',
142
+ * { width: 100 }
143
+ * )
144
+ * // 'https://i.etsystatic.com/123/r/il_100x100.456.jpg'
145
+ */
146
+ export declare function buildEtsyImageResizeUrl(url: string, options?: ImageResizeOptions): string;
147
+ /**
148
+ * OSS(阿里云等)图片处理参数拼接。
149
+ *
150
+ * 规则对齐 montageImgUrl:
151
+ * - 命中 ossLinks 白名单才新建 process
152
+ * - 已有 x-oss-process 时允许原地替换(即使未命中白名单,避免业务侧已拼参的 URL 悬停改不了尺寸)
153
+ * - 否则追加 ?x-oss-process=image/resize,w_{width}|h_{height}
154
+ * - 新建 process 且宽高都缺失时,默认 l_120(与 montageImgUrl 一致)
155
+ *
156
+ * @example
157
+ * buildOssImageResizeUrl(
158
+ * 'https://static.fangguo.com/a.jpg',
159
+ * { width: 200, Q: 90, ossLinks: ['static.fangguo.com'] }
160
+ * )
161
+ * // 'https://static.fangguo.com/a.jpg?x-oss-process=image/resize,w_200/quality,Q_90'
162
+ */
163
+ export declare function buildOssImageResizeUrl(url: string, options?: ImageResizeOptions): string;
164
+ /**
165
+ * 按图片域名/平台拼接对应尺寸参数。
166
+ * 未匹配或参数不足的平台会原链接返回。
167
+ *
168
+ * @example
169
+ * buildPlatformImageResizeUrl(
170
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg',
171
+ * { width: 150 }
172
+ * )
173
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/150/q/50/format/avif%7CimageVqr/2'
174
+ *
175
+ * @example
176
+ * buildPlatformImageResizeUrl(
177
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg',
178
+ * { width: 300, height: 409 }
179
+ * )
180
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_300x409.jpg'
181
+ *
182
+ * @example
183
+ * buildPlatformImageResizeUrl(
184
+ * 'https://img.fangguo.com/a.jpg',
185
+ * { width: 200, Q: 90, ossLinks: ['img.fangguo.com'] }
186
+ * )
187
+ * // 'https://img.fangguo.com/a.jpg?x-oss-process=image/resize,w_200/quality,Q_90'
188
+ *
189
+ * @example
190
+ * buildPlatformImageResizeUrl('https://example.com/a.jpg', { width: 100 })
191
+ * // 'https://example.com/a.jpg'
192
+ */
193
+ export declare function buildPlatformImageResizeUrl(url: string, options?: ImageResizeOptions): string;
194
+ /**
195
+ * 判断 URL 是否已带平台 / OSS 缩放参数(不是仅域名命中)。
196
+ * 用于悬停图:已有缩放参数时按 hoverImgSize 改写,而不是原样放大糊图。
197
+ *
198
+ * @example
199
+ * hasPlatformImageResizeParams(
200
+ * 'https://img.kwcdn.com/a.jpeg?imageView2/2/w/200/q/50/format/avif%7CimageVqr/2'
201
+ * )
202
+ * // true
203
+ *
204
+ * @example
205
+ * hasPlatformImageResizeParams(
206
+ * 'https://fangguo-dev.oss-cn-shenzhen.aliyuncs.com/a.jpeg?x-oss-process=image/resize,h_260'
207
+ * )
208
+ * // true
209
+ *
210
+ * @example
211
+ * hasPlatformImageResizeParams('https://img.kwcdn.com/a.jpeg')
212
+ * // false
213
+ */
214
+ export declare function hasPlatformImageResizeParams(url: string): boolean;
215
+ /**
216
+ * 按当前商品采集规则获取主图/原图。
217
+ * 未匹配的平台会原链接返回。
218
+ *
219
+ * @example
220
+ * getPlatformOriginalImageUrl(
221
+ * 'https://img.kwcdn.com/thumbnail/s/a.jpeg?imageView2/2/w/150/q/50/format/avif%7CimageVqr/2'
222
+ * )
223
+ * // 'https://img.kwcdn.com/thumbnail/s/a.jpeg'
224
+ *
225
+ * @example
226
+ * getPlatformOriginalImageUrl(
227
+ * '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_405x552.jpg'
228
+ * )
229
+ * // '//img.ltwebstatic.com/v4/j/pi/2025/12/12/22/a_thumbnail_fullx.jpg'
230
+ */
231
+ export declare function getPlatformOriginalImageUrl(url: string): string;
232
+ /**
233
+ * 获取当前图片地址命中的规则名,便于调试或埋点。
234
+ * OSS 规则依赖 configureImgUrl 注入的全局 ossLinks。
235
+ *
236
+ * @example
237
+ * getImageResizeRuleName('https://img.kwcdn.com/thumbnail/s/a.jpeg')
238
+ * // 'temu-kwcdn'
239
+ *
240
+ * @example
241
+ * // configureImgUrl({ ossLinks: ['img.fangguo.com'] }) 之后
242
+ * getImageResizeRuleName('https://img.fangguo.com/a.jpg')
243
+ * // 'oss'
244
+ */
245
+ export declare function getImageResizeRuleName(url: string): string;
246
+ export {};
@@ -1,4 +1,6 @@
1
1
  export { configureImgUrl, DEFAULT_IMG_FASTEN, getImgFasten, getOssLinks, imgUrlConfigKey } from './config';
2
2
  export { getNetworkAdaptiveOptions, initNetworkListener, networkKey } from './networkAdaptive';
3
3
  export { isUnsupportedImg, montageImgUrl, notSupportedImgTypes, replaceUnsupportedImg, temuThumbUrl, } from './montageImgUrl';
4
+ export { buildPlatformImageResizeUrl, getImageResizeRuleName, getPlatformOriginalImageUrl, hasPlatformImageResizeParams, removeImageUrlQuery, } from './imageUrl';
5
+ export type { ImageResizeOptions } from './imageUrl';
4
6
  export type { ImgFastenConfig, ImgSizeOptions, ImgUrlConfig, MontageImgUrlOptions } from './types';
@@ -1,16 +1,21 @@
1
- import { D, c, g, a, b, i, d, e, m, n, f, r, t } from "../../montageImgUrl-CwgYnB2h.js";
1
+ import { D, b, c, g, a, d, e, f, h, i, j, k, m, n, l, r, o, t } from "../../montageImgUrl-B9ZmJ7TF.js";
2
2
  export {
3
3
  D as DEFAULT_IMG_FASTEN,
4
+ b as buildPlatformImageResizeUrl,
4
5
  c as configureImgUrl,
5
- g as getImgFasten,
6
- a as getNetworkAdaptiveOptions,
7
- b as getOssLinks,
6
+ g as getImageResizeRuleName,
7
+ a as getImgFasten,
8
+ d as getNetworkAdaptiveOptions,
9
+ e as getOssLinks,
10
+ f as getPlatformOriginalImageUrl,
11
+ h as hasPlatformImageResizeParams,
8
12
  i as imgUrlConfigKey,
9
- d as initNetworkListener,
10
- e as isUnsupportedImg,
13
+ j as initNetworkListener,
14
+ k as isUnsupportedImg,
11
15
  m as montageImgUrl,
12
16
  n as networkKey,
13
- f as notSupportedImgTypes,
14
- r as replaceUnsupportedImg,
17
+ l as notSupportedImgTypes,
18
+ r as removeImageUrlQuery,
19
+ o as replaceUnsupportedImg,
15
20
  t as temuThumbUrl
16
21
  };
@@ -4,12 +4,18 @@ export declare const notSupportedImgTypes: string[];
4
4
  export declare function isUnsupportedImg(url: string): boolean;
5
5
  /** 命中不支持格式时返回占位图,否则返回原 url */
6
6
  export declare function replaceUnsupportedImg(url?: string): string;
7
- /** TEMU 平台缩略图 */
7
+ /**
8
+ * TEMU 平台缩略图。
9
+ * 统一走 imageView2(与 buildTemuImageResizeUrl 一致),会清掉原有 query(含非法双 ?)。
10
+ */
8
11
  export declare function temuThumbUrl(url: string, imgSize?: ImgSizeOptions): string;
9
12
  /**
10
- * 拼接图片 url(OSS / TEMU / 占位图)
11
- * @param url 原始图片地址
12
- * @param imgSize 图片缩放规则(w-宽, h-高, s-短边, l-长边)
13
- * @param options 当前调用配置;不传 ossLinks 时读取全局 configureImgUrl 配置
13
+ * 拼接图片 url(占位图 / 各平台 resize 规则)
14
+ *
15
+ * - 空图、不支持格式 占位图
16
+ * - oss 网络自适应后再拼接
17
+ * - 其余命中规则(temu / shein / amazon / etsy …)→ buildPlatformImageResizeUrl
18
+ *
19
+ * 注意:不会再拼接 imageMogr2;若结果里仍出现 imageMogr2,说明别处还在用旧 temuThumbUrl。
14
20
  */
15
21
  export declare function montageImgUrl(url?: string, imgSize?: ImgSizeOptions, options?: MontageImgUrlOptions): string;
@@ -1,5 +1,5 @@
1
- import { D, c, g, a, b, i, d, e, m, n, f, r, t } from "../montageImgUrl-CwgYnB2h.js";
2
- import { a as a2, b as b2, c as c2, d as d2, e as e2, f as f2, g as g2, h, i as i2, j, k, l, m as m2, n as n2, o, p, q, r as r2, s, t as t2, u, v, w, x, y, z, A, B, C, D as D2, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, _, $, a0, a1, a2 as a22, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as } from "../common-D0EYVGB2.js";
1
+ import { D, b, c, g, a, d, e, f, h, i, j, k, m, n, l, r, o, t } from "../montageImgUrl-B9ZmJ7TF.js";
2
+ import { a as a2, b as b2, c as c2, d as d2, e as e2, f as f2, g as g2, h as h2, i as i2, j as j2, k as k2, l as l2, m as m2, n as n2, o as o2, p, q, r as r2, s, t as t2, u, v, w, x, y, z, A, B, C, D as D2, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, _, $, a0, a1, a2 as a22, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as } from "../common-D0EYVGB2.js";
3
3
  import { detectFileType, formatFileSize, parseFile, parseFiles, parseImage, parseImageFile, parsePSD, parsePSDFile, parseTIFF, parseTIFFFile } from "./ImageParserUtils/index.js";
4
4
  import { s as s2 } from "../dateShortcuts-DjFC_Txu.js";
5
5
  export {
@@ -11,15 +11,16 @@ export {
11
11
  e2 as argFormate,
12
12
  f2 as base64ToBlob,
13
13
  g2 as base64ToFile,
14
- h as boldPoint,
14
+ h2 as boldPoint,
15
+ b as buildPlatformImageResizeUrl,
15
16
  i2 as checkGoodValue,
16
- j as cleanEmptyFields,
17
+ j2 as cleanEmptyFields,
17
18
  c as configureImgUrl,
18
- k as convertImageFormat,
19
- l as copyText,
19
+ k2 as convertImageFormat,
20
+ l2 as copyText,
20
21
  m2 as copyWord,
21
22
  n2 as createFileLocalUrl,
22
- o as createUuid,
23
+ o2 as createUuid,
23
24
  p as currentDaysLessFivedays,
24
25
  q as debounce,
25
26
  detectFileType,
@@ -46,24 +47,27 @@ export {
46
47
  K as getArrayBufferFromInput,
47
48
  L as getFileFolderToEnums,
48
49
  M as getFilenameAndExtension,
50
+ g as getImageResizeRuleName,
49
51
  N as getImageSizeByFile,
50
- g as getImgFasten,
52
+ a as getImgFasten,
51
53
  O as getMobileSubmitParams,
52
- a as getNetworkAdaptiveOptions,
53
- b as getOssLinks,
54
+ d as getNetworkAdaptiveOptions,
55
+ e as getOssLinks,
56
+ f as getPlatformOriginalImageUrl,
54
57
  P as getQueryParams,
55
58
  Q as getUUID,
56
59
  R as getUrlSuffix,
57
60
  S as getXmlKeyValue,
58
61
  T as hasInvalidFileNameChars,
62
+ h as hasPlatformImageResizeParams,
59
63
  i as imgUrlConfigKey,
60
- d as initNetworkListener,
64
+ j as initNetworkListener,
61
65
  U as isCmykPsd,
62
66
  V as isFuction,
63
67
  W as isMobileDevice,
64
68
  X as isPdfUrl,
65
69
  Y as isSameDay,
66
- e as isUnsupportedImg,
70
+ k as isUnsupportedImg,
67
71
  Z as localUrlToFile,
68
72
  _ as longestContinuousMatch,
69
73
  $ as mergeColumns,
@@ -74,7 +78,7 @@ export {
74
78
  m as montageImgUrl,
75
79
  a4 as nameReg,
76
80
  n as networkKey,
77
- f as notSupportedImgTypes,
81
+ l as notSupportedImgTypes,
78
82
  a5 as numberFilter,
79
83
  a6 as numberToChinese,
80
84
  a7 as numberToRatio,
@@ -96,7 +100,8 @@ export {
96
100
  af as preventDefaultHandler,
97
101
  ag as pwdReg,
98
102
  ah as ratioToNumber,
99
- r as replaceUnsupportedImg,
103
+ r as removeImageUrlQuery,
104
+ o as replaceUnsupportedImg,
100
105
  s2 as shortcuts,
101
106
  ai as sleep,
102
107
  aj as splitArray,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fangguo-component",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "lint:fix": "oxlint --fix",
85
85
  "typecheck": "vue-tsc --noEmit -p tsconfig.check-src.json",
86
86
  "build:npm": "vite build --mode npm",
87
- "publish:npm": "pnpm publish --no-git-checks",
87
+ "publish:npm": "pnpm build:npm && pnpm publish --no-git-checks",
88
88
  "docs:gen": "npx tsx scripts/gen-docs.ts",
89
89
  "docs:dev": "vitepress dev docs",
90
90
  "docs:build": "vitepress build docs && pnpm --dir mcp/fangguo-component-mcp-server exec tsx src/generateCatalog.ts --out ../../docs/.vitepress/dist/catalog.json",
@@ -1,254 +0,0 @@
1
- import './ViewImg.css';var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- import { defineComponent, useAttrs, ref, computed, watch, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, withDirectives, createElementVNode, mergeProps, vShow, renderSlot, createCommentVNode, createBlock, toDisplayString } from "vue";
33
- import { I as ImgViewerStore } from "./imgViewerStore-DK3zvGf4.js";
34
- import { h as DEFAULT_PREVIEW_SIDE_NAV, D as DEFAULT_ORIGINAL_TOOLBAR, l as DEFAULT_TOOLBAR_ICON_COLOR, k as DEFAULT_TOOLBAR_BG_COLOR, g as DEFAULT_PREVIEW_SHOW_PROGRESS, d as DEFAULT_PREVIEW_MAX_SCALE, e as DEFAULT_PREVIEW_MIN_SCALE, f as DEFAULT_PREVIEW_SCALE, j as DEFAULT_PREVIEW_ZOOM_RATE, a as DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE, b as DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL, c as DEFAULT_PREVIEW_INFINITE, i as DEFAULT_PREVIEW_TELEPORTED } from "./types-Ccn_sb6f.js";
35
- import { n as networkKey, i as imgUrlConfigKey, m as montageImgUrl } from "./montageImgUrl-CwgYnB2h.js";
36
- import { F as FgErrorImage } from "./ErrorImage-CFVt1ht_.js";
37
- import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
38
- const _hoisted_1 = ["src", "loading"];
39
- const _hoisted_2 = {
40
- key: 0,
41
- class: "fg-view-img__placeholder"
42
- };
43
- const _hoisted_3 = {
44
- key: 1,
45
- class: "fg-view-img__error"
46
- };
47
- const _hoisted_4 = { class: "fg-view-img__error-default" };
48
- const _hoisted_5 = {
49
- key: 1,
50
- class: "fg-view-img__error-text"
51
- };
52
- const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
53
- inheritAttrs: false
54
- }), {
55
- __name: "ViewImg",
56
- props: {
57
- src: { default: "" },
58
- fit: { default: "" },
59
- lazy: { type: Boolean, default: false },
60
- loading: { type: Boolean, default: false },
61
- preview: { type: Boolean, default: false },
62
- previewSrcList: { default: () => [] },
63
- initialIndex: { default: void 0 },
64
- defImgPreviewIndex: { default: void 0 },
65
- infinite: { type: Boolean, default: DEFAULT_PREVIEW_INFINITE },
66
- zIndex: { default: void 0 },
67
- hideOnClickModal: { type: Boolean, default: DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL },
68
- closeOnPressEscape: { type: Boolean, default: DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE },
69
- previewTeleported: { type: Boolean, default: void 0 },
70
- teleported: { type: Boolean, default: void 0 },
71
- zoomRate: { default: DEFAULT_PREVIEW_ZOOM_RATE },
72
- scale: { default: DEFAULT_PREVIEW_SCALE },
73
- minScale: { default: DEFAULT_PREVIEW_MIN_SCALE },
74
- maxScale: { default: DEFAULT_PREVIEW_MAX_SCALE },
75
- showProgress: { type: Boolean, default: DEFAULT_PREVIEW_SHOW_PROGRESS },
76
- toolbarBgColor: { default: DEFAULT_TOOLBAR_BG_COLOR },
77
- backgroundColor: { default: "" },
78
- toolbarIconColor: { default: DEFAULT_TOOLBAR_ICON_COLOR },
79
- simpleExtraTools: { default: () => [] },
80
- renderExtraTools: { default: null },
81
- originalToolbar: { default: () => [...DEFAULT_ORIGINAL_TOOLBAR] },
82
- errorColor: { default: "#f5f5f5" },
83
- errorOffset: { default: 0 },
84
- errorText: { default: "" },
85
- ossProcess: { type: Boolean, default: true },
86
- ossLinks: { default: void 0 },
87
- imgSize: { default: () => ({}) },
88
- previewStripQuery: { type: Boolean, default: true },
89
- previewSideNav: { type: [Boolean, String], default: DEFAULT_PREVIEW_SIDE_NAV }
90
- },
91
- emits: ["load", "error", "retry", "show", "close", "switch"],
92
- setup(__props, { expose: __expose, emit: __emit }) {
93
- const props = __props;
94
- const emit = __emit;
95
- const attrs = useAttrs();
96
- const displaySrc = ref("");
97
- const retried = ref(false);
98
- const internalLoading = ref(false);
99
- const loadError = ref(false);
100
- const imgAttrs = computed(() => {
101
- const _a = attrs, { class: _, style: __ } = _a, rest = __objRest(_a, ["class", "style"]);
102
- return rest;
103
- });
104
- const imgStyle = computed(() => {
105
- if (!props.fit) return {};
106
- return { objectFit: props.fit };
107
- });
108
- const showPlaceholder = computed(
109
- () => !!props.src && (props.loading || internalLoading.value) && !loadError.value
110
- );
111
- const previewEnabled = computed(() => (props.preview || (props.previewSrcList || []).length > 0) && !!displaySrc.value && !loadError.value);
112
- const previewUrlList = computed(() => {
113
- const rawList = props.previewSrcList.length ? props.previewSrcList : props.src ? [props.src] : [];
114
- return rawList.map((url) => applyPreviewUrlFallback(url));
115
- });
116
- const previewInitialIndex = computed(() => {
117
- if (props.defImgPreviewIndex != null) return props.defImgPreviewIndex;
118
- if (props.initialIndex != null) return props.initialIndex;
119
- const index = previewUrlList.value.indexOf(applyPreviewUrlFallback(props.src));
120
- return index >= 0 ? index : 0;
121
- });
122
- const resolvedToolbarBgColor = computed(() => props.toolbarBgColor || props.backgroundColor || DEFAULT_TOOLBAR_BG_COLOR);
123
- const resolvedPreviewTeleported = computed(
124
- () => {
125
- var _a, _b;
126
- return (_b = (_a = props.previewTeleported) != null ? _a : props.teleported) != null ? _b : DEFAULT_PREVIEW_TELEPORTED;
127
- }
128
- );
129
- function stripQueryParams(url) {
130
- const index = url.indexOf("?");
131
- return index === -1 ? url : url.slice(0, index);
132
- }
133
- function resolveImgUrl(url, imgSize) {
134
- if (!props.ossProcess) return url;
135
- return montageImgUrl(url, imgSize, props.ossLinks ? { ossLinks: props.ossLinks } : void 0);
136
- }
137
- function applyPreviewUrlFallback(url) {
138
- if (!props.previewStripQuery || !url) return url;
139
- return stripQueryParams(url);
140
- }
141
- function resetState(src) {
142
- retried.value = false;
143
- loadError.value = false;
144
- internalLoading.value = !!src;
145
- displaySrc.value = resolveImgUrl(src, props.imgSize);
146
- }
147
- function handleLoad(event) {
148
- internalLoading.value = false;
149
- loadError.value = false;
150
- emit("load", event);
151
- }
152
- function markLoadFailed(event) {
153
- internalLoading.value = false;
154
- loadError.value = true;
155
- emit("error", event);
156
- }
157
- function handleError(event) {
158
- if (retried.value) {
159
- markLoadFailed(event);
160
- return;
161
- }
162
- const stripped = stripQueryParams(displaySrc.value);
163
- if (stripped === displaySrc.value) {
164
- markLoadFailed(event);
165
- return;
166
- }
167
- const urlBefore = displaySrc.value;
168
- retried.value = true;
169
- internalLoading.value = true;
170
- displaySrc.value = stripped;
171
- emit("retry", { from: urlBefore, to: stripped });
172
- }
173
- function openPreview() {
174
- if (!previewUrlList.value.length) return;
175
- ImgViewerStore().showImgViewer({
176
- previewImgList: previewUrlList.value,
177
- defImgPreviewIndex: previewInitialIndex.value,
178
- toolbarBgColor: resolvedToolbarBgColor.value,
179
- toolbarIconColor: props.toolbarIconColor,
180
- infinite: props.infinite,
181
- zIndex: props.zIndex,
182
- hideOnClickModal: props.hideOnClickModal,
183
- closeOnPressEscape: props.closeOnPressEscape,
184
- teleported: resolvedPreviewTeleported.value,
185
- zoomRate: props.zoomRate,
186
- scale: props.scale,
187
- minScale: props.minScale,
188
- maxScale: props.maxScale,
189
- showProgress: props.showProgress,
190
- simpleExtraTools: props.simpleExtraTools,
191
- renderExtraTools: props.renderExtraTools,
192
- originalToolbar: props.originalToolbar,
193
- previewSideNav: props.previewSideNav,
194
- onShow: (payload) => emit("show", payload),
195
- onClose: () => emit("close"),
196
- onSwitch: (index) => emit("switch", index)
197
- });
198
- }
199
- function handlePreviewClick() {
200
- if (!previewEnabled.value) return;
201
- openPreview();
202
- }
203
- watch(
204
- [() => props.src, () => props.ossProcess, () => props.ossLinks, () => props.imgSize, networkKey, imgUrlConfigKey],
205
- ([src]) => {
206
- resetState(src);
207
- },
208
- { immediate: true, deep: true }
209
- );
210
- __expose({
211
- displaySrc,
212
- retried,
213
- openPreview
214
- });
215
- return (_ctx, _cache) => {
216
- return openBlock(), createElementBlock("span", {
217
- class: normalizeClass(["fg-view-img", unref(attrs).class]),
218
- style: normalizeStyle(unref(attrs).style)
219
- }, [
220
- withDirectives(createElementVNode("img", mergeProps({
221
- class: ["fg-view-img__inner", { "fg-view-img__inner--preview": previewEnabled.value }]
222
- }, imgAttrs.value, {
223
- src: displaySrc.value || void 0,
224
- loading: __props.lazy ? "lazy" : "eager",
225
- style: imgStyle.value,
226
- onLoad: handleLoad,
227
- onError: handleError,
228
- onClick: handlePreviewClick
229
- }), null, 16, _hoisted_1), [
230
- [vShow, !loadError.value]
231
- ]),
232
- showPlaceholder.value ? (openBlock(), createElementBlock("span", _hoisted_2, [
233
- renderSlot(_ctx.$slots, "placeholder", {}, void 0, true)
234
- ])) : createCommentVNode("", true),
235
- loadError.value ? (openBlock(), createElementBlock("span", _hoisted_3, [
236
- renderSlot(_ctx.$slots, "error", {}, () => [
237
- createElementVNode("div", _hoisted_4, [
238
- !__props.errorText ? (openBlock(), createBlock(unref(FgErrorImage), {
239
- key: 0,
240
- color: __props.errorColor,
241
- offset: __props.errorOffset,
242
- class: "fg-view-img__error-icon"
243
- }, null, 8, ["color", "offset"])) : (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(__props.errorText), 1))
244
- ])
245
- ], true)
246
- ])) : createCommentVNode("", true)
247
- ], 6);
248
- };
249
- }
250
- }));
251
- const FgViewImg = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c6ff5d38"]]);
252
- export {
253
- FgViewImg as F
254
- };