fangguo-component 1.1.5 → 1.2.1

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-CstlYwHs.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-DBs42WOq.js +53 -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-DXhF20SL.js +254 -0
  14. package/dist/ViewImg.css +56 -0
  15. package/dist/ViewImgPopover-QblZG0z5.js +343 -0
  16. package/dist/ViewImgPopover.css +106 -0
  17. package/dist/ViewImgPreview.css +132 -0
  18. package/dist/ViewImgPreview.vue_vue_type_style_index_0_lang-C2i0p5IK.js +316 -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 +199 -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 +49 -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 +149 -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 +726 -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 +53 -0
  43. package/dist/components/viewImgPreview/index.d.ts +3 -0
  44. package/dist/components/viewImgPreview/index.js +21 -0
  45. package/dist/components/viewImgPreview/types.d.ts +93 -0
  46. package/dist/imgViewerStore-DK3zvGf4.js +247 -0
  47. package/dist/{index-DzdLpetc.js → index-BtQgIf7F.js} +1414 -1402
  48. package/dist/{index-uQXqC9BF.js → index-Ce_edAQB.js} +44 -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 +114 -67
  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-Ccn_sb6f.js +49 -0
  63. package/package.json +1 -1
  64. package/dist/LazyPopover.vue_vue_type_script_setup_true_lang-B2vtU4f4.js +0 -34
@@ -0,0 +1,254 @@
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
+ };
@@ -0,0 +1,56 @@
1
+ .fg-view-img[data-v-c6ff5d38] {
2
+ display: block;
3
+ position: relative;
4
+ overflow: hidden;
5
+ min-width: 0;
6
+ min-height: 0;
7
+ vertical-align: top;
8
+ line-height: 0;
9
+ }
10
+ .fg-view-img__inner[data-v-c6ff5d38] {
11
+ display: block;
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+ .fg-view-img__inner--preview[data-v-c6ff5d38] {
16
+ cursor: zoom-in;
17
+ }
18
+ .fg-view-img__placeholder[data-v-c6ff5d38],
19
+ .fg-view-img__error[data-v-c6ff5d38] {
20
+ position: absolute;
21
+ inset: 0;
22
+ display: flex;
23
+ align-items: center;
24
+ justify-content: center;
25
+ background: #f5f7fa;
26
+ }
27
+ .fg-view-img__error[data-v-c6ff5d38] .error-image {
28
+ width: 100%;
29
+ height: 100%;
30
+ }
31
+ .fg-view-img__error-default[data-v-c6ff5d38] {
32
+ position: relative;
33
+ width: 100%;
34
+ height: 100%;
35
+ display: flex;
36
+ flex-direction: column;
37
+ align-items: center;
38
+ justify-content: center;
39
+ gap: 8px;
40
+ padding: 8px;
41
+ box-sizing: border-box;
42
+ }
43
+ .fg-view-img__error-icon[data-v-c6ff5d38] {
44
+ flex: none;
45
+ width: 56%;
46
+ height: 56%;
47
+ max-width: 80px;
48
+ max-height: 80px;
49
+ }
50
+ .fg-view-img__error-text[data-v-c6ff5d38] {
51
+ font-size: 13px;
52
+ line-height: 1.4;
53
+ color: #909399;
54
+ text-align: center;
55
+ word-break: break-all;
56
+ }
@@ -0,0 +1,343 @@
1
+ import './ViewImgPopover.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 { ElWatermark, ElIcon } from "element-plus/es";
33
+ import { defineComponent, useAttrs, ref, computed, watch, openBlock, createElementBlock, createVNode, withCtx, Fragment, normalizeStyle, renderSlot, toDisplayString, createBlock, createElementVNode, createSlots, createCommentVNode, mergeProps, unref, withModifiers } from "vue";
34
+ import { CirclePlus } from "@element-plus/icons-vue";
35
+ import { L as LazyPopover } from "./LazyPopover-7ebuh-QG.js";
36
+ import { F as FgViewImg } from "./ViewImg-DXhF20SL.js";
37
+ import { m as montageImgUrl } from "./montageImgUrl-CwgYnB2h.js";
38
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
39
+ const _hoisted_1 = { class: "fg-view-img-popover__reference" };
40
+ const _hoisted_2 = {
41
+ key: 1,
42
+ class: "fg-view-img-popover__hover-error-text"
43
+ };
44
+ const _hoisted_3 = {
45
+ key: 1,
46
+ class: "fg-view-img-popover__hover-error-text"
47
+ };
48
+ const HOVER_POPOVER_PADDING = 10;
49
+ const HOVER_POPOVER_MAX_HEIGHT = 400;
50
+ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
51
+ inheritAttrs: false
52
+ }), {
53
+ __name: "ViewImgPopover",
54
+ props: {
55
+ src: { default: "" },
56
+ fit: {},
57
+ lazy: { type: Boolean },
58
+ loading: { type: Boolean },
59
+ preview: { type: Boolean },
60
+ previewSrcList: {},
61
+ initialIndex: {},
62
+ defImgPreviewIndex: {},
63
+ infinite: { type: Boolean },
64
+ zIndex: {},
65
+ hideOnClickModal: { type: Boolean },
66
+ closeOnPressEscape: { type: Boolean },
67
+ previewTeleported: { type: Boolean },
68
+ teleported: { type: Boolean },
69
+ zoomRate: {},
70
+ scale: {},
71
+ minScale: {},
72
+ maxScale: {},
73
+ showProgress: { type: Boolean },
74
+ toolbarBgColor: {},
75
+ backgroundColor: {},
76
+ toolbarIconColor: {},
77
+ simpleExtraTools: {},
78
+ renderExtraTools: {},
79
+ originalToolbar: {},
80
+ errorColor: {},
81
+ errorOffset: {},
82
+ errorText: {},
83
+ ossProcess: { type: Boolean },
84
+ ossLinks: {},
85
+ imgSize: {},
86
+ previewStripQuery: { type: Boolean },
87
+ hoverSrc: { default: "" },
88
+ hoverImgSize: { default: void 0 },
89
+ hoverPopoverProps: { default: () => ({}) },
90
+ isShowWatermark: { type: Boolean, default: false },
91
+ waterMarkTitle: { default: "" },
92
+ showPreviewIcon: { type: Boolean, default: false }
93
+ },
94
+ emits: ["load", "error", "retry", "show", "close", "switch"],
95
+ setup(__props, { emit: __emit }) {
96
+ const props = __props;
97
+ const emit = __emit;
98
+ const attrs = useAttrs();
99
+ const viewImgRef = ref(null);
100
+ const referenceLoadError = ref(false);
101
+ const viewImgProps = computed(() => {
102
+ const _a = props, {
103
+ hoverSrc: _h,
104
+ hoverImgSize: _hi,
105
+ hoverPopoverProps: _hp,
106
+ isShowWatermark: _w,
107
+ waterMarkTitle: _wt,
108
+ showPreviewIcon: _spi
109
+ } = _a, rest = __objRest(_a, [
110
+ "hoverSrc",
111
+ "hoverImgSize",
112
+ "hoverPopoverProps",
113
+ "isShowWatermark",
114
+ "waterMarkTitle",
115
+ "showPreviewIcon"
116
+ ]);
117
+ return rest;
118
+ });
119
+ function handlePreviewIconClick() {
120
+ var _a;
121
+ (_a = viewImgRef.value) == null ? void 0 : _a.openPreview();
122
+ }
123
+ function mergePopperStyle(base, extra) {
124
+ if (!extra) return base;
125
+ if (typeof extra === "string") return extra;
126
+ return __spreadValues(__spreadValues({}, base), extra);
127
+ }
128
+ const HOVER_POPOVER_MAX_HEIGHT_CSS = `${HOVER_POPOVER_MAX_HEIGHT}px`;
129
+ const HOVER_IMAGE_MAX_HEIGHT_CSS = `${HOVER_POPOVER_MAX_HEIGHT - HOVER_POPOVER_PADDING * 2}px`;
130
+ const hoverPopoverPropsMerged = computed(() => {
131
+ var _a;
132
+ const _b = (_a = props.hoverPopoverProps) != null ? _a : {}, { popperStyle: userPopperStyle, popperClass: userPopperClass } = _b, restHoverPopoverProps = __objRest(_b, ["popperStyle", "popperClass"]);
133
+ const popperClass = [userPopperClass, "fg-view-img-popover"].filter(Boolean).join(" ");
134
+ return __spreadValues({
135
+ placement: "right",
136
+ trigger: "hover",
137
+ width: 400,
138
+ teleported: true,
139
+ popperClass,
140
+ popperStyle: mergePopperStyle(
141
+ {
142
+ maxHeight: HOVER_POPOVER_MAX_HEIGHT_CSS,
143
+ overflow: "hidden",
144
+ padding: `${HOVER_POPOVER_PADDING}px`,
145
+ boxSizing: "border-box"
146
+ },
147
+ userPopperStyle
148
+ )
149
+ }, restHoverPopoverProps);
150
+ });
151
+ function stripQueryParams(url) {
152
+ const index = url.indexOf("?");
153
+ return index === -1 ? url : url.slice(0, index);
154
+ }
155
+ function resolveImgUrl(url, imgSize) {
156
+ if (!props.ossProcess) return url;
157
+ return montageImgUrl(url, imgSize, props.ossLinks ? { ossLinks: props.ossLinks } : void 0);
158
+ }
159
+ function applyPreviewUrlFallback(url) {
160
+ if (!props.previewStripQuery || !url) return url;
161
+ return stripQueryParams(url);
162
+ }
163
+ function resolvePreviewImgUrl(url, imgSize) {
164
+ return applyPreviewUrlFallback(resolveImgUrl(url, imgSize));
165
+ }
166
+ function handleReferenceLoad(event) {
167
+ referenceLoadError.value = false;
168
+ emit("load", event);
169
+ }
170
+ function handleReferenceError(event) {
171
+ referenceLoadError.value = true;
172
+ emit("error", event);
173
+ }
174
+ function handleReferenceRetry(payload) {
175
+ referenceLoadError.value = false;
176
+ emit("retry", payload);
177
+ }
178
+ watch(
179
+ () => props.src,
180
+ () => {
181
+ referenceLoadError.value = false;
182
+ }
183
+ );
184
+ function resolveViewImgDisplaySrc() {
185
+ var _a;
186
+ const fromRef = (_a = viewImgRef.value) == null ? void 0 : _a.displaySrc;
187
+ if (fromRef) return fromRef;
188
+ if (!props.src) return "";
189
+ return resolveImgUrl(props.src, props.imgSize);
190
+ }
191
+ const hoverPreviewSrc = computed(() => {
192
+ var _a, _b, _c;
193
+ const displaySrc = resolveViewImgDisplaySrc();
194
+ const retried = (_b = (_a = viewImgRef.value) == null ? void 0 : _a.retried) != null ? _b : false;
195
+ if (props.hoverSrc) {
196
+ return resolvePreviewImgUrl(props.hoverSrc, (_c = props.hoverImgSize) != null ? _c : props.imgSize);
197
+ }
198
+ if (!props.src) return displaySrc || "";
199
+ if (!props.hoverImgSize) return displaySrc || "";
200
+ let url = resolveImgUrl(props.src, props.hoverImgSize);
201
+ if (retried) url = stripQueryParams(url);
202
+ return applyPreviewUrlFallback(url);
203
+ });
204
+ const hoverImgStyle = computed(() => ({
205
+ width: "100%",
206
+ height: HOVER_IMAGE_MAX_HEIGHT_CSS
207
+ }));
208
+ return (_ctx, _cache) => {
209
+ const _component_el_watermark = ElWatermark;
210
+ const _component_el_icon = ElIcon;
211
+ return openBlock(), createElementBlock("div", _hoisted_1, [
212
+ createVNode(LazyPopover, {
213
+ class: "fg-view-img-popover__trigger",
214
+ props: hoverPopoverPropsMerged.value
215
+ }, {
216
+ reference: withCtx(() => [
217
+ createVNode(FgViewImg, mergeProps({
218
+ ref_key: "viewImgRef",
219
+ ref: viewImgRef,
220
+ class: unref(attrs).class,
221
+ style: unref(attrs).style
222
+ }, viewImgProps.value, {
223
+ onLoad: handleReferenceLoad,
224
+ onError: handleReferenceError,
225
+ onRetry: handleReferenceRetry,
226
+ onShow: _cache[0] || (_cache[0] = (p) => emit("show", p)),
227
+ onClose: _cache[1] || (_cache[1] = ($event) => emit("close")),
228
+ onSwitch: _cache[2] || (_cache[2] = (i) => emit("switch", i))
229
+ }), createSlots({ _: 2 }, [
230
+ _ctx.$slots.placeholder ? {
231
+ name: "placeholder",
232
+ fn: withCtx(() => [
233
+ renderSlot(_ctx.$slots, "placeholder", {}, void 0, true)
234
+ ]),
235
+ key: "0"
236
+ } : void 0,
237
+ _ctx.$slots.error ? {
238
+ name: "error",
239
+ fn: withCtx(() => [
240
+ renderSlot(_ctx.$slots, "error", {}, void 0, true)
241
+ ]),
242
+ key: "1"
243
+ } : void 0
244
+ ]), 1040, ["class", "style"])
245
+ ]),
246
+ default: withCtx(() => [
247
+ hoverPreviewSrc.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
248
+ referenceLoadError.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
249
+ !__props.isShowWatermark ? (openBlock(), createElementBlock("div", {
250
+ key: 0,
251
+ class: "fg-view-img-popover__hover-image fg-view-img-popover__hover-error",
252
+ style: normalizeStyle(hoverImgStyle.value)
253
+ }, [
254
+ _ctx.$slots.error ? renderSlot(_ctx.$slots, "error", { key: 0 }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.errorText || "加载失败"), 1))
255
+ ], 4)) : (openBlock(), createBlock(_component_el_watermark, {
256
+ key: 1,
257
+ class: "fg-view-img-popover__watermark",
258
+ content: [__props.waterMarkTitle],
259
+ gap: [10, 10],
260
+ font: { fontSize: 16, color: "rgba(0, 0, 0, 0.3)" }
261
+ }, {
262
+ default: withCtx(() => [
263
+ createElementVNode("div", {
264
+ class: "fg-view-img-popover__hover-image fg-view-img-popover__hover-error",
265
+ style: normalizeStyle(hoverImgStyle.value)
266
+ }, [
267
+ _ctx.$slots.error ? renderSlot(_ctx.$slots, "error", { key: 0 }, void 0, true) : (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.errorText || "加载失败"), 1))
268
+ ], 4)
269
+ ]),
270
+ _: 3
271
+ }, 8, ["content"]))
272
+ ], 64)) : !__props.isShowWatermark ? (openBlock(), createBlock(FgViewImg, {
273
+ key: 1,
274
+ class: "fg-view-img-popover__hover-image",
275
+ src: hoverPreviewSrc.value,
276
+ style: normalizeStyle(hoverImgStyle.value),
277
+ preview: false,
278
+ "oss-process": false,
279
+ "error-color": __props.errorColor,
280
+ "error-offset": __props.errorOffset,
281
+ "error-text": __props.errorText,
282
+ fit: "contain"
283
+ }, createSlots({ _: 2 }, [
284
+ _ctx.$slots.error ? {
285
+ name: "error",
286
+ fn: withCtx(() => [
287
+ renderSlot(_ctx.$slots, "error", {}, void 0, true)
288
+ ]),
289
+ key: "0"
290
+ } : void 0
291
+ ]), 1032, ["src", "style", "error-color", "error-offset", "error-text"])) : (openBlock(), createBlock(_component_el_watermark, {
292
+ key: 2,
293
+ class: "fg-view-img-popover__watermark",
294
+ content: [__props.waterMarkTitle],
295
+ gap: [10, 10],
296
+ font: { fontSize: 16, color: "rgba(0, 0, 0, 0.3)" }
297
+ }, {
298
+ default: withCtx(() => [
299
+ createVNode(FgViewImg, {
300
+ class: "fg-view-img-popover__hover-image",
301
+ src: hoverPreviewSrc.value,
302
+ style: normalizeStyle(hoverImgStyle.value),
303
+ preview: false,
304
+ "oss-process": false,
305
+ "error-color": __props.errorColor,
306
+ "error-offset": __props.errorOffset,
307
+ "error-text": __props.errorText,
308
+ fit: "contain"
309
+ }, createSlots({ _: 2 }, [
310
+ _ctx.$slots.error ? {
311
+ name: "error",
312
+ fn: withCtx(() => [
313
+ renderSlot(_ctx.$slots, "error", {}, void 0, true)
314
+ ]),
315
+ key: "0"
316
+ } : void 0
317
+ ]), 1032, ["src", "style", "error-color", "error-offset", "error-text"])
318
+ ]),
319
+ _: 3
320
+ }, 8, ["content"]))
321
+ ], 64)) : createCommentVNode("", true)
322
+ ]),
323
+ _: 3
324
+ }, 8, ["props"]),
325
+ __props.showPreviewIcon ? (openBlock(), createBlock(_component_el_icon, {
326
+ key: 0,
327
+ class: "fg-view-img-popover__preview-icon",
328
+ size: 14,
329
+ onClick: withModifiers(handlePreviewIconClick, ["stop"])
330
+ }, {
331
+ default: withCtx(() => [
332
+ createVNode(unref(CirclePlus))
333
+ ]),
334
+ _: 1
335
+ })) : createCommentVNode("", true)
336
+ ]);
337
+ };
338
+ }
339
+ }));
340
+ const ViewImgPopover = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-868c46fb"]]);
341
+ export {
342
+ ViewImgPopover as V
343
+ };