fangguo-component 1.1.4 → 1.2.0

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 (64) hide show
  1. package/README.md +57 -0
  2. package/dist/{ErrorImage-Ao9kEEUg.js → ErrorImage-CFVt1ht_.js} +2 -2
  3. package/dist/FgCascader.css +24 -0
  4. package/dist/{FgCascader.vue_vue_type_style_index_0_lang-CM8FxFLJ.js → FgCascader.vue_vue_type_style_index_0_lang-Bm4HR37D.js} +45 -4
  5. package/dist/{HSelect-BFkWiCFi.js → HSelect-DgFjd08Y.js} +3 -3
  6. package/dist/{HSelectAll.vue_vue_type_script_setup_true_lang-BZX7ch2I.js → HSelectAll.vue_vue_type_script_setup_true_lang-C6qzdQT-.js} +1 -1
  7. package/dist/{HSelectSJ-DZmtdyjF.js → HSelectSJ-DOFUzTZV.js} +3 -3
  8. package/dist/ImgViewerHost.vue_vue_type_script_setup_true_lang-CMoh7eWo.js +52 -0
  9. package/dist/LazyPopover-7ebuh-QG.js +188 -0
  10. package/dist/LazyPopover.css +5 -0
  11. package/dist/{SelectTree-DHbWogEU.js → SelectTree-DUH92Iwr.js} +2 -2
  12. package/dist/{TextCopy-th0FAxwl.js → TextCopy-lpbeqOUI.js} +1 -1
  13. package/dist/ViewImg-Bg1AQ0T6.js +247 -0
  14. package/dist/ViewImg.css +56 -0
  15. package/dist/ViewImgPopover-b9PDEYbP.js +275 -0
  16. package/dist/ViewImgPopover.css +33 -0
  17. package/dist/ViewImgPreview.css +100 -0
  18. package/dist/ViewImgPreview.vue_vue_type_style_index_0_lang-CYuLovBR.js +306 -0
  19. package/dist/{common-B1nSpTGn.js → common-D0EYVGB2.js} +1 -1
  20. package/dist/components/cascader/index.js +1 -1
  21. package/dist/components/errorImage/index.js +2 -2
  22. package/dist/components/hSelect/index.js +1 -1
  23. package/dist/components/hSelectAll/index.js +1 -1
  24. package/dist/components/hSelectSJ/index.js +1 -1
  25. package/dist/components/imgViewerHost/ImgViewerHost.vue.d.ts +2 -0
  26. package/dist/components/imgViewerHost/imgViewerStore.d.ts +195 -0
  27. package/dist/components/imgViewerHost/index.d.ts +4 -0
  28. package/dist/components/imgViewerHost/index.js +10 -0
  29. package/dist/components/imgViewerHost/utils.d.ts +4 -0
  30. package/dist/components/index.d.ts +4 -0
  31. package/dist/components/index.js +45 -18
  32. package/dist/components/lazyPopover/LazyPopover.vue.d.ts +12 -15
  33. package/dist/components/lazyPopover/index.js +2 -2
  34. package/dist/components/selectTree/index.js +1 -1
  35. package/dist/components/textCopy/index.js +1 -1
  36. package/dist/components/viewImg/ViewImg.vue.d.ts +141 -0
  37. package/dist/components/viewImg/index.d.ts +1 -0
  38. package/dist/components/viewImg/index.js +4 -0
  39. package/dist/components/viewImgPopover/ViewImgPopover.vue.d.ts +705 -0
  40. package/dist/components/viewImgPopover/index.d.ts +1 -0
  41. package/dist/components/viewImgPopover/index.js +4 -0
  42. package/dist/components/viewImgPreview/ViewImgPreview.vue.d.ts +50 -0
  43. package/dist/components/viewImgPreview/index.d.ts +3 -0
  44. package/dist/components/viewImgPreview/index.js +17 -0
  45. package/dist/components/viewImgPreview/types.d.ts +78 -0
  46. package/dist/imgViewerStore-C5n16uYa.js +241 -0
  47. package/dist/{index-DzdLpetc.js → index-BtQgIf7F.js} +1414 -1402
  48. package/dist/{index-uQXqC9BF.js → index-CckJZ8N-.js} +40 -13
  49. package/dist/{index-BPnixsfc.js → index-Qkq7I01c.js} +15 -1
  50. package/dist/index.d.ts +17 -3
  51. package/dist/index.js +103 -60
  52. package/dist/montageImgUrl-CwgYnB2h.js +204 -0
  53. package/dist/tools/ImageParserUtils/index.js +346 -346
  54. package/dist/tools/common/index.js +1 -1
  55. package/dist/tools/imgUrl/config.d.ts +10 -0
  56. package/dist/tools/imgUrl/index.d.ts +4 -0
  57. package/dist/tools/imgUrl/index.js +16 -0
  58. package/dist/tools/imgUrl/montageImgUrl.d.ts +15 -0
  59. package/dist/tools/imgUrl/networkAdaptive.d.ts +7 -0
  60. package/dist/tools/index.d.ts +1 -0
  61. package/dist/tools/index.js +29 -15
  62. package/dist/types-BNFeGRer.js +32 -0
  63. package/package.json +92 -92
  64. package/dist/LazyPopover.vue_vue_type_script_setup_true_lang-B2vtU4f4.js +0 -34
@@ -0,0 +1,204 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ import { ref } from "vue";
18
+ const DEFAULT_IMG_FASTEN = {
19
+ notSupported: "//static.fangguo.com/assets/img/pic-fasten/not-supported.png",
20
+ error: "//static.fangguo.com/assets/img/pic-fasten/error.png",
21
+ empty: "//static.fangguo.com/assets/img/pic-fasten/empty.png"
22
+ };
23
+ let ossLinks = [];
24
+ let imgFasten = __spreadValues({}, DEFAULT_IMG_FASTEN);
25
+ const imgUrlConfigKey = ref(0);
26
+ function getOssLinks() {
27
+ return ossLinks;
28
+ }
29
+ function getImgFasten() {
30
+ return imgFasten;
31
+ }
32
+ function configureImgUrl(config = {}) {
33
+ let changed = false;
34
+ if (config.ossLinks) {
35
+ ossLinks = [...config.ossLinks];
36
+ changed = true;
37
+ }
38
+ if (config.imgFasten) {
39
+ imgFasten = __spreadValues(__spreadValues({}, imgFasten), config.imgFasten);
40
+ changed = true;
41
+ }
42
+ if (changed) {
43
+ imgUrlConfigKey.value++;
44
+ }
45
+ }
46
+ let lastEffectiveType = null;
47
+ let lastSaveData = null;
48
+ let networkListenerInitialized = false;
49
+ const cachedResults = /* @__PURE__ */ new Map();
50
+ const MAX_CACHE_ENTRIES = 500;
51
+ const networkKey = ref(0);
52
+ function normalizeCacheKeyOptions(baseOptions) {
53
+ const o = baseOptions != null ? baseOptions : {};
54
+ const w = typeof o.w === "number" ? o.w : "";
55
+ const h = typeof o.h === "number" ? o.h : "";
56
+ const Q = typeof o.Q === "number" ? o.Q : "";
57
+ const q = typeof o.q === "number" ? o.q : "";
58
+ const format = typeof o.format === "string" ? o.format : "";
59
+ return `w=${w}&h=${h}&Q=${Q}&q=${q}&format=${format}`;
60
+ }
61
+ function lruGet(key) {
62
+ const hit = cachedResults.get(key);
63
+ if (!hit) return null;
64
+ cachedResults.delete(key);
65
+ cachedResults.set(key, hit);
66
+ return hit;
67
+ }
68
+ function lruSet(key, value) {
69
+ if (cachedResults.has(key)) cachedResults.delete(key);
70
+ cachedResults.set(key, value);
71
+ if (cachedResults.size > MAX_CACHE_ENTRIES) {
72
+ const oldestKey = cachedResults.keys().next().value;
73
+ if (oldestKey) cachedResults.delete(oldestKey);
74
+ }
75
+ }
76
+ function getNetworkAdaptiveOptions(baseOptions = { h: 260, Q: 92 }) {
77
+ var _a;
78
+ const conn = navigator.connection;
79
+ const effectiveType = (conn == null ? void 0 : conn.effectiveType) || "4g";
80
+ const saveData = (_a = conn == null ? void 0 : conn.saveData) != null ? _a : false;
81
+ const key = `${effectiveType}|${String(saveData)}|${normalizeCacheKeyOptions(baseOptions)}`;
82
+ if (effectiveType === lastEffectiveType && saveData === lastSaveData) {
83
+ const hit = lruGet(key);
84
+ if (hit) return hit;
85
+ }
86
+ let scale = 1;
87
+ let quality = baseOptions.Q || 92;
88
+ switch (effectiveType) {
89
+ case "slow-2g":
90
+ case "2g":
91
+ scale = saveData ? 0.3 : 0.4;
92
+ quality = saveData ? 40 : 50;
93
+ break;
94
+ case "3g":
95
+ scale = saveData ? 0.5 : 0.7;
96
+ quality = saveData ? 60 : 82;
97
+ break;
98
+ case "4g":
99
+ default:
100
+ scale = saveData ? 0.7 : 1;
101
+ quality = saveData ? 85 : baseOptions.Q || 92;
102
+ break;
103
+ }
104
+ const options = __spreadValues({}, baseOptions);
105
+ if (options.w) options.w = Math.round(options.w * scale);
106
+ if (options.h) options.h = Math.round(options.h * scale);
107
+ options.Q = quality;
108
+ lastEffectiveType = effectiveType;
109
+ lastSaveData = saveData;
110
+ lruSet(key, options);
111
+ return options;
112
+ }
113
+ function initNetworkListener() {
114
+ if (networkListenerInitialized) return;
115
+ networkListenerInitialized = true;
116
+ const conn = navigator.connection;
117
+ if (conn == null ? void 0 : conn.addEventListener) {
118
+ conn.addEventListener("change", () => {
119
+ cachedResults.clear();
120
+ lastEffectiveType = null;
121
+ lastSaveData = null;
122
+ networkKey.value++;
123
+ });
124
+ }
125
+ getNetworkAdaptiveOptions();
126
+ }
127
+ const notSupportedImgTypes = ["tif", "tiff", "psd"];
128
+ function isUnsupportedImg(url) {
129
+ const pathname = url.split(/[?#]/)[0];
130
+ const filename = pathname.slice(pathname.lastIndexOf("/") + 1);
131
+ const dot = filename.lastIndexOf(".");
132
+ if (dot === -1) return false;
133
+ return notSupportedImgTypes.includes(filename.slice(dot + 1).toLowerCase());
134
+ }
135
+ function replaceUnsupportedImg(url = "") {
136
+ if (!url) return url;
137
+ return isUnsupportedImg(url) ? getImgFasten().notSupported : url;
138
+ }
139
+ function temuThumbUrl(url, imgSize) {
140
+ const { w, h } = imgSize || {};
141
+ if (url.indexOf("imageMogr2/thumbnail/") > -1) {
142
+ return url;
143
+ }
144
+ const resizeUrl = `?imageMogr2/thumbnail/${w || h || 200}x`;
145
+ return `${url}${resizeUrl}`;
146
+ }
147
+ function montageImgUrl(url = "", imgSize, options = {}) {
148
+ var _a;
149
+ const imgFasten2 = getImgFasten();
150
+ if (!url) return imgFasten2.empty;
151
+ if (isUnsupportedImg(url)) return imgFasten2.notSupported;
152
+ if (url.includes("/img.kwcdn.com")) {
153
+ return temuThumbUrl(url, imgSize);
154
+ }
155
+ const ossLinks2 = (_a = options.ossLinks) != null ? _a : getOssLinks();
156
+ if (ossLinks2.some((domain) => url.includes(domain))) {
157
+ const networkOpts = getNetworkAdaptiveOptions(imgSize || { h: 260, Q: 92 });
158
+ const finalParams = __spreadValues(__spreadValues({}, imgSize), networkOpts);
159
+ const { w, h, Q, q, format = "" } = finalParams;
160
+ const qualityVal = Q != null ? Q : q;
161
+ const formatPart = format ? `/format,${format}` : "";
162
+ let finalUrl = url;
163
+ const hasProcess = url.includes("x-oss-process=");
164
+ if (hasProcess) {
165
+ if (h) finalUrl = finalUrl.replace(/h_\d+/, `h_${h}`);
166
+ if (w) finalUrl = finalUrl.replace(/w_\d+/, `w_${w}`);
167
+ if (qualityVal) {
168
+ finalUrl = finalUrl.replace(/quality,[Qq]_\d+/, `quality,${Q ? "Q" : "q"}_${qualityVal}`);
169
+ }
170
+ if (format) {
171
+ if (finalUrl.includes("/format,")) {
172
+ finalUrl = finalUrl.replace(/\/format,\w+/, formatPart);
173
+ } else {
174
+ finalUrl += formatPart;
175
+ }
176
+ }
177
+ } else {
178
+ let resizeStr = "resize,";
179
+ if (w) resizeStr += `w_${w}`;
180
+ else if (h) resizeStr += `h_${h}`;
181
+ else resizeStr += "l_120";
182
+ const qualityPart = qualityVal && qualityVal >= 1 && qualityVal <= 100 ? `/quality,${Q ? "Q" : "q"}_${qualityVal}` : "";
183
+ const connector = url.includes("?") ? "&" : "?";
184
+ finalUrl = `${url}${connector}x-oss-process=image/${resizeStr}${qualityPart}${formatPart}`;
185
+ }
186
+ return finalUrl;
187
+ }
188
+ return url;
189
+ }
190
+ export {
191
+ DEFAULT_IMG_FASTEN as D,
192
+ getNetworkAdaptiveOptions as a,
193
+ getOssLinks as b,
194
+ configureImgUrl as c,
195
+ initNetworkListener as d,
196
+ isUnsupportedImg as e,
197
+ notSupportedImgTypes as f,
198
+ getImgFasten as g,
199
+ imgUrlConfigKey as i,
200
+ montageImgUrl as m,
201
+ networkKey as n,
202
+ replaceUnsupportedImg as r,
203
+ temuThumbUrl as t
204
+ };