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.
- package/README.md +57 -0
- package/dist/{ErrorImage-Ao9kEEUg.js → ErrorImage-CFVt1ht_.js} +2 -2
- package/dist/FgCascader.css +24 -0
- package/dist/{FgCascader.vue_vue_type_style_index_0_lang-CM8FxFLJ.js → FgCascader.vue_vue_type_style_index_0_lang-Bm4HR37D.js} +45 -4
- package/dist/{HSelect-BFkWiCFi.js → HSelect-DgFjd08Y.js} +3 -3
- package/dist/{HSelectAll.vue_vue_type_script_setup_true_lang-BZX7ch2I.js → HSelectAll.vue_vue_type_script_setup_true_lang-C6qzdQT-.js} +1 -1
- package/dist/{HSelectSJ-DZmtdyjF.js → HSelectSJ-DOFUzTZV.js} +3 -3
- package/dist/ImgViewerHost.vue_vue_type_script_setup_true_lang-CMoh7eWo.js +52 -0
- package/dist/LazyPopover-7ebuh-QG.js +188 -0
- package/dist/LazyPopover.css +5 -0
- package/dist/{SelectTree-DHbWogEU.js → SelectTree-DUH92Iwr.js} +2 -2
- package/dist/{TextCopy-th0FAxwl.js → TextCopy-lpbeqOUI.js} +1 -1
- package/dist/ViewImg-Bg1AQ0T6.js +247 -0
- package/dist/ViewImg.css +56 -0
- package/dist/ViewImgPopover-b9PDEYbP.js +275 -0
- package/dist/ViewImgPopover.css +33 -0
- package/dist/ViewImgPreview.css +100 -0
- package/dist/ViewImgPreview.vue_vue_type_style_index_0_lang-CYuLovBR.js +306 -0
- package/dist/{common-B1nSpTGn.js → common-D0EYVGB2.js} +1 -1
- package/dist/components/cascader/index.js +1 -1
- package/dist/components/errorImage/index.js +2 -2
- package/dist/components/hSelect/index.js +1 -1
- package/dist/components/hSelectAll/index.js +1 -1
- package/dist/components/hSelectSJ/index.js +1 -1
- package/dist/components/imgViewerHost/ImgViewerHost.vue.d.ts +2 -0
- package/dist/components/imgViewerHost/imgViewerStore.d.ts +195 -0
- package/dist/components/imgViewerHost/index.d.ts +4 -0
- package/dist/components/imgViewerHost/index.js +10 -0
- package/dist/components/imgViewerHost/utils.d.ts +4 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +45 -18
- package/dist/components/lazyPopover/LazyPopover.vue.d.ts +12 -15
- package/dist/components/lazyPopover/index.js +2 -2
- package/dist/components/selectTree/index.js +1 -1
- package/dist/components/textCopy/index.js +1 -1
- package/dist/components/viewImg/ViewImg.vue.d.ts +141 -0
- package/dist/components/viewImg/index.d.ts +1 -0
- package/dist/components/viewImg/index.js +4 -0
- package/dist/components/viewImgPopover/ViewImgPopover.vue.d.ts +705 -0
- package/dist/components/viewImgPopover/index.d.ts +1 -0
- package/dist/components/viewImgPopover/index.js +4 -0
- package/dist/components/viewImgPreview/ViewImgPreview.vue.d.ts +50 -0
- package/dist/components/viewImgPreview/index.d.ts +3 -0
- package/dist/components/viewImgPreview/index.js +17 -0
- package/dist/components/viewImgPreview/types.d.ts +78 -0
- package/dist/imgViewerStore-C5n16uYa.js +241 -0
- package/dist/{index-DzdLpetc.js → index-BtQgIf7F.js} +1414 -1402
- package/dist/{index-uQXqC9BF.js → index-CckJZ8N-.js} +40 -13
- package/dist/{index-BPnixsfc.js → index-Qkq7I01c.js} +15 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.js +103 -60
- package/dist/montageImgUrl-CwgYnB2h.js +204 -0
- package/dist/tools/ImageParserUtils/index.js +346 -346
- package/dist/tools/common/index.js +1 -1
- package/dist/tools/imgUrl/config.d.ts +10 -0
- package/dist/tools/imgUrl/index.d.ts +4 -0
- package/dist/tools/imgUrl/index.js +16 -0
- package/dist/tools/imgUrl/montageImgUrl.d.ts +15 -0
- package/dist/tools/imgUrl/networkAdaptive.d.ts +7 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +29 -15
- package/dist/types-BNFeGRer.js +32 -0
- package/package.json +92 -92
- package/dist/LazyPopover.vue_vue_type_script_setup_true_lang-B2vtU4f4.js +0 -34
|
@@ -0,0 +1,247 @@
|
|
|
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-C5n16uYa.js";
|
|
34
|
+
import { D as DEFAULT_ORIGINAL_TOOLBAR, k as DEFAULT_TOOLBAR_ICON_COLOR, j 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, i 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, h as DEFAULT_PREVIEW_TELEPORTED } from "./types-BNFeGRer.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
|
+
},
|
|
90
|
+
emits: ["load", "error", "retry", "show", "close", "switch"],
|
|
91
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
92
|
+
const props = __props;
|
|
93
|
+
const emit = __emit;
|
|
94
|
+
const attrs = useAttrs();
|
|
95
|
+
const displaySrc = ref("");
|
|
96
|
+
const retried = ref(false);
|
|
97
|
+
const internalLoading = ref(false);
|
|
98
|
+
const loadError = ref(false);
|
|
99
|
+
const imgAttrs = computed(() => {
|
|
100
|
+
const _a = attrs, { class: _, style: __ } = _a, rest = __objRest(_a, ["class", "style"]);
|
|
101
|
+
return rest;
|
|
102
|
+
});
|
|
103
|
+
const imgStyle = computed(() => {
|
|
104
|
+
if (!props.fit) return {};
|
|
105
|
+
return { objectFit: props.fit };
|
|
106
|
+
});
|
|
107
|
+
const showPlaceholder = computed(
|
|
108
|
+
() => !!props.src && (props.loading || internalLoading.value) && !loadError.value
|
|
109
|
+
);
|
|
110
|
+
const previewEnabled = computed(() => (props.preview || (props.previewSrcList || []).length > 0) && !!displaySrc.value && !loadError.value);
|
|
111
|
+
const previewUrlList = computed(() => {
|
|
112
|
+
const rawList = props.previewSrcList.length ? props.previewSrcList : props.src ? [props.src] : [];
|
|
113
|
+
return rawList.map((url) => applyPreviewUrlFallback(url));
|
|
114
|
+
});
|
|
115
|
+
const previewInitialIndex = computed(() => {
|
|
116
|
+
if (props.defImgPreviewIndex != null) return props.defImgPreviewIndex;
|
|
117
|
+
if (props.initialIndex != null) return props.initialIndex;
|
|
118
|
+
const index = previewUrlList.value.indexOf(applyPreviewUrlFallback(props.src));
|
|
119
|
+
return index >= 0 ? index : 0;
|
|
120
|
+
});
|
|
121
|
+
const resolvedToolbarBgColor = computed(() => props.toolbarBgColor || props.backgroundColor || DEFAULT_TOOLBAR_BG_COLOR);
|
|
122
|
+
const resolvedPreviewTeleported = computed(
|
|
123
|
+
() => {
|
|
124
|
+
var _a, _b;
|
|
125
|
+
return (_b = (_a = props.previewTeleported) != null ? _a : props.teleported) != null ? _b : DEFAULT_PREVIEW_TELEPORTED;
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
function stripQueryParams(url) {
|
|
129
|
+
const index = url.indexOf("?");
|
|
130
|
+
return index === -1 ? url : url.slice(0, index);
|
|
131
|
+
}
|
|
132
|
+
function resolveImgUrl(url, imgSize) {
|
|
133
|
+
if (!props.ossProcess) return url;
|
|
134
|
+
return montageImgUrl(url, imgSize, props.ossLinks ? { ossLinks: props.ossLinks } : void 0);
|
|
135
|
+
}
|
|
136
|
+
function applyPreviewUrlFallback(url) {
|
|
137
|
+
if (!props.previewStripQuery || !url) return url;
|
|
138
|
+
return stripQueryParams(url);
|
|
139
|
+
}
|
|
140
|
+
function resetState(src) {
|
|
141
|
+
retried.value = false;
|
|
142
|
+
loadError.value = false;
|
|
143
|
+
internalLoading.value = !!src;
|
|
144
|
+
displaySrc.value = resolveImgUrl(src, props.imgSize);
|
|
145
|
+
}
|
|
146
|
+
function handleLoad(event) {
|
|
147
|
+
internalLoading.value = false;
|
|
148
|
+
loadError.value = false;
|
|
149
|
+
emit("load", event);
|
|
150
|
+
}
|
|
151
|
+
function markLoadFailed(event) {
|
|
152
|
+
internalLoading.value = false;
|
|
153
|
+
loadError.value = true;
|
|
154
|
+
emit("error", event);
|
|
155
|
+
}
|
|
156
|
+
function handleError(event) {
|
|
157
|
+
if (retried.value) {
|
|
158
|
+
markLoadFailed(event);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const stripped = stripQueryParams(displaySrc.value);
|
|
162
|
+
if (stripped === displaySrc.value) {
|
|
163
|
+
markLoadFailed(event);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const urlBefore = displaySrc.value;
|
|
167
|
+
retried.value = true;
|
|
168
|
+
internalLoading.value = true;
|
|
169
|
+
displaySrc.value = stripped;
|
|
170
|
+
emit("retry", { from: urlBefore, to: stripped });
|
|
171
|
+
}
|
|
172
|
+
function handlePreviewClick() {
|
|
173
|
+
if (!previewEnabled.value || !previewUrlList.value.length) return;
|
|
174
|
+
ImgViewerStore().showImgViewer({
|
|
175
|
+
previewImgList: previewUrlList.value,
|
|
176
|
+
defImgPreviewIndex: previewInitialIndex.value,
|
|
177
|
+
toolbarBgColor: resolvedToolbarBgColor.value,
|
|
178
|
+
toolbarIconColor: props.toolbarIconColor,
|
|
179
|
+
infinite: props.infinite,
|
|
180
|
+
zIndex: props.zIndex,
|
|
181
|
+
hideOnClickModal: props.hideOnClickModal,
|
|
182
|
+
closeOnPressEscape: props.closeOnPressEscape,
|
|
183
|
+
teleported: resolvedPreviewTeleported.value,
|
|
184
|
+
zoomRate: props.zoomRate,
|
|
185
|
+
scale: props.scale,
|
|
186
|
+
minScale: props.minScale,
|
|
187
|
+
maxScale: props.maxScale,
|
|
188
|
+
showProgress: props.showProgress,
|
|
189
|
+
simpleExtraTools: props.simpleExtraTools,
|
|
190
|
+
renderExtraTools: props.renderExtraTools,
|
|
191
|
+
originalToolbar: props.originalToolbar,
|
|
192
|
+
onShow: (payload) => emit("show", payload),
|
|
193
|
+
onClose: () => emit("close"),
|
|
194
|
+
onSwitch: (index) => emit("switch", index)
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
watch(
|
|
198
|
+
[() => props.src, () => props.ossProcess, () => props.ossLinks, () => props.imgSize, networkKey, imgUrlConfigKey],
|
|
199
|
+
([src]) => {
|
|
200
|
+
resetState(src);
|
|
201
|
+
},
|
|
202
|
+
{ immediate: true, deep: true }
|
|
203
|
+
);
|
|
204
|
+
__expose({
|
|
205
|
+
displaySrc,
|
|
206
|
+
retried
|
|
207
|
+
});
|
|
208
|
+
return (_ctx, _cache) => {
|
|
209
|
+
return openBlock(), createElementBlock("span", {
|
|
210
|
+
class: normalizeClass(["fg-view-img", unref(attrs).class]),
|
|
211
|
+
style: normalizeStyle(unref(attrs).style)
|
|
212
|
+
}, [
|
|
213
|
+
withDirectives(createElementVNode("img", mergeProps({
|
|
214
|
+
class: ["fg-view-img__inner", { "fg-view-img__inner--preview": previewEnabled.value }]
|
|
215
|
+
}, imgAttrs.value, {
|
|
216
|
+
src: displaySrc.value || void 0,
|
|
217
|
+
loading: __props.lazy ? "lazy" : "eager",
|
|
218
|
+
style: imgStyle.value,
|
|
219
|
+
onLoad: handleLoad,
|
|
220
|
+
onError: handleError,
|
|
221
|
+
onClick: handlePreviewClick
|
|
222
|
+
}), null, 16, _hoisted_1), [
|
|
223
|
+
[vShow, !loadError.value]
|
|
224
|
+
]),
|
|
225
|
+
showPlaceholder.value ? (openBlock(), createElementBlock("span", _hoisted_2, [
|
|
226
|
+
renderSlot(_ctx.$slots, "placeholder", {}, void 0, true)
|
|
227
|
+
])) : createCommentVNode("", true),
|
|
228
|
+
loadError.value ? (openBlock(), createElementBlock("span", _hoisted_3, [
|
|
229
|
+
renderSlot(_ctx.$slots, "error", {}, () => [
|
|
230
|
+
createElementVNode("div", _hoisted_4, [
|
|
231
|
+
!__props.errorText ? (openBlock(), createBlock(unref(FgErrorImage), {
|
|
232
|
+
key: 0,
|
|
233
|
+
color: __props.errorColor,
|
|
234
|
+
offset: __props.errorOffset,
|
|
235
|
+
class: "fg-view-img__error-icon"
|
|
236
|
+
}, null, 8, ["color", "offset"])) : (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(__props.errorText), 1))
|
|
237
|
+
])
|
|
238
|
+
], true)
|
|
239
|
+
])) : createCommentVNode("", true)
|
|
240
|
+
], 6);
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
}));
|
|
244
|
+
const FgViewImg = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-498a112d"]]);
|
|
245
|
+
export {
|
|
246
|
+
FgViewImg as F
|
|
247
|
+
};
|
package/dist/ViewImg.css
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.fg-view-img[data-v-498a112d] {
|
|
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-498a112d] {
|
|
11
|
+
display: block;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
.fg-view-img__inner--preview[data-v-498a112d] {
|
|
16
|
+
cursor: zoom-in;
|
|
17
|
+
}
|
|
18
|
+
.fg-view-img__placeholder[data-v-498a112d],
|
|
19
|
+
.fg-view-img__error[data-v-498a112d] {
|
|
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-498a112d] .error-image {
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 100%;
|
|
30
|
+
}
|
|
31
|
+
.fg-view-img__error-default[data-v-498a112d] {
|
|
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-498a112d] {
|
|
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-498a112d] {
|
|
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,275 @@
|
|
|
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 } from "element-plus/es";
|
|
33
|
+
import { defineComponent, useAttrs, ref, computed, openBlock, createBlock, withCtx, createElementBlock, Fragment, normalizeStyle, createSlots, renderSlot, createVNode, createCommentVNode, mergeProps, unref } from "vue";
|
|
34
|
+
import { L as LazyPopover } from "./LazyPopover-7ebuh-QG.js";
|
|
35
|
+
import { F as FgViewImg } from "./ViewImg-Bg1AQ0T6.js";
|
|
36
|
+
import { m as montageImgUrl } from "./montageImgUrl-CwgYnB2h.js";
|
|
37
|
+
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
|
|
38
|
+
const HOVER_POPOVER_PADDING = 10;
|
|
39
|
+
const HOVER_POPOVER_MAX_HEIGHT = 400;
|
|
40
|
+
const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
|
|
41
|
+
inheritAttrs: false
|
|
42
|
+
}), {
|
|
43
|
+
__name: "ViewImgPopover",
|
|
44
|
+
props: {
|
|
45
|
+
src: { default: "" },
|
|
46
|
+
fit: {},
|
|
47
|
+
lazy: { type: Boolean },
|
|
48
|
+
loading: { type: Boolean },
|
|
49
|
+
preview: { type: Boolean },
|
|
50
|
+
previewSrcList: {},
|
|
51
|
+
initialIndex: {},
|
|
52
|
+
defImgPreviewIndex: {},
|
|
53
|
+
infinite: { type: Boolean },
|
|
54
|
+
zIndex: {},
|
|
55
|
+
hideOnClickModal: { type: Boolean },
|
|
56
|
+
closeOnPressEscape: { type: Boolean },
|
|
57
|
+
previewTeleported: { type: Boolean },
|
|
58
|
+
teleported: { type: Boolean },
|
|
59
|
+
zoomRate: {},
|
|
60
|
+
scale: {},
|
|
61
|
+
minScale: {},
|
|
62
|
+
maxScale: {},
|
|
63
|
+
showProgress: { type: Boolean },
|
|
64
|
+
toolbarBgColor: {},
|
|
65
|
+
backgroundColor: {},
|
|
66
|
+
toolbarIconColor: {},
|
|
67
|
+
simpleExtraTools: {},
|
|
68
|
+
renderExtraTools: {},
|
|
69
|
+
originalToolbar: {},
|
|
70
|
+
errorColor: {},
|
|
71
|
+
errorOffset: {},
|
|
72
|
+
errorText: {},
|
|
73
|
+
ossProcess: { type: Boolean },
|
|
74
|
+
ossLinks: {},
|
|
75
|
+
imgSize: {},
|
|
76
|
+
previewStripQuery: { type: Boolean },
|
|
77
|
+
hoverSrc: { default: "" },
|
|
78
|
+
hoverImgSize: { default: void 0 },
|
|
79
|
+
hoverPopoverProps: { default: () => ({}) },
|
|
80
|
+
isShowWatermark: { type: Boolean, default: false },
|
|
81
|
+
waterMarkTitle: { default: "" }
|
|
82
|
+
},
|
|
83
|
+
emits: ["load", "error", "retry", "show", "close", "switch"],
|
|
84
|
+
setup(__props, { emit: __emit }) {
|
|
85
|
+
const props = __props;
|
|
86
|
+
const emit = __emit;
|
|
87
|
+
const attrs = useAttrs();
|
|
88
|
+
const viewImgRef = ref(null);
|
|
89
|
+
const viewImgProps = computed(() => {
|
|
90
|
+
const _a = props, {
|
|
91
|
+
hoverSrc: _h,
|
|
92
|
+
hoverImgSize: _hi,
|
|
93
|
+
hoverPopoverProps: _hp,
|
|
94
|
+
isShowWatermark: _w,
|
|
95
|
+
waterMarkTitle: _wt
|
|
96
|
+
} = _a, rest = __objRest(_a, [
|
|
97
|
+
"hoverSrc",
|
|
98
|
+
"hoverImgSize",
|
|
99
|
+
"hoverPopoverProps",
|
|
100
|
+
"isShowWatermark",
|
|
101
|
+
"waterMarkTitle"
|
|
102
|
+
]);
|
|
103
|
+
return rest;
|
|
104
|
+
});
|
|
105
|
+
function mergePopperStyle(base, extra) {
|
|
106
|
+
if (!extra) return base;
|
|
107
|
+
if (typeof extra === "string") return extra;
|
|
108
|
+
return __spreadValues(__spreadValues({}, base), extra);
|
|
109
|
+
}
|
|
110
|
+
const HOVER_POPOVER_MAX_HEIGHT_CSS = `${HOVER_POPOVER_MAX_HEIGHT}px`;
|
|
111
|
+
const HOVER_IMAGE_MAX_HEIGHT_CSS = `${HOVER_POPOVER_MAX_HEIGHT - HOVER_POPOVER_PADDING * 2}px`;
|
|
112
|
+
const hoverPopoverPropsMerged = computed(() => {
|
|
113
|
+
var _a;
|
|
114
|
+
const _b = (_a = props.hoverPopoverProps) != null ? _a : {}, { popperStyle: userPopperStyle, popperClass: userPopperClass } = _b, restHoverPopoverProps = __objRest(_b, ["popperStyle", "popperClass"]);
|
|
115
|
+
const popperClass = [userPopperClass, "fg-view-img-popover"].filter(Boolean).join(" ");
|
|
116
|
+
return __spreadValues({
|
|
117
|
+
placement: "right",
|
|
118
|
+
trigger: "hover",
|
|
119
|
+
width: 400,
|
|
120
|
+
teleported: true,
|
|
121
|
+
popperClass,
|
|
122
|
+
popperStyle: mergePopperStyle(
|
|
123
|
+
{
|
|
124
|
+
maxHeight: HOVER_POPOVER_MAX_HEIGHT_CSS,
|
|
125
|
+
overflow: "hidden",
|
|
126
|
+
padding: `${HOVER_POPOVER_PADDING}px`,
|
|
127
|
+
boxSizing: "border-box"
|
|
128
|
+
},
|
|
129
|
+
userPopperStyle
|
|
130
|
+
)
|
|
131
|
+
}, restHoverPopoverProps);
|
|
132
|
+
});
|
|
133
|
+
function stripQueryParams(url) {
|
|
134
|
+
const index = url.indexOf("?");
|
|
135
|
+
return index === -1 ? url : url.slice(0, index);
|
|
136
|
+
}
|
|
137
|
+
function resolveImgUrl(url, imgSize) {
|
|
138
|
+
if (!props.ossProcess) return url;
|
|
139
|
+
return montageImgUrl(url, imgSize, props.ossLinks ? { ossLinks: props.ossLinks } : void 0);
|
|
140
|
+
}
|
|
141
|
+
function applyPreviewUrlFallback(url) {
|
|
142
|
+
if (!props.previewStripQuery || !url) return url;
|
|
143
|
+
return stripQueryParams(url);
|
|
144
|
+
}
|
|
145
|
+
function resolvePreviewImgUrl(url, imgSize) {
|
|
146
|
+
return applyPreviewUrlFallback(resolveImgUrl(url, imgSize));
|
|
147
|
+
}
|
|
148
|
+
function resolveViewImgDisplaySrc() {
|
|
149
|
+
var _a;
|
|
150
|
+
const fromRef = (_a = viewImgRef.value) == null ? void 0 : _a.displaySrc;
|
|
151
|
+
if (fromRef) return fromRef;
|
|
152
|
+
if (!props.src) return "";
|
|
153
|
+
return resolveImgUrl(props.src, props.imgSize);
|
|
154
|
+
}
|
|
155
|
+
const hoverPreviewSrc = computed(() => {
|
|
156
|
+
var _a, _b, _c;
|
|
157
|
+
const displaySrc = resolveViewImgDisplaySrc();
|
|
158
|
+
const retried = (_b = (_a = viewImgRef.value) == null ? void 0 : _a.retried) != null ? _b : false;
|
|
159
|
+
if (props.hoverSrc) {
|
|
160
|
+
return resolvePreviewImgUrl(props.hoverSrc, (_c = props.hoverImgSize) != null ? _c : props.imgSize);
|
|
161
|
+
}
|
|
162
|
+
if (!props.src) return displaySrc || "";
|
|
163
|
+
if (!props.hoverImgSize) return displaySrc || "";
|
|
164
|
+
let url = resolveImgUrl(props.src, props.hoverImgSize);
|
|
165
|
+
if (retried) url = stripQueryParams(url);
|
|
166
|
+
return applyPreviewUrlFallback(url);
|
|
167
|
+
});
|
|
168
|
+
const hoverImgStyle = computed(() => ({
|
|
169
|
+
display: "block",
|
|
170
|
+
maxWidth: "100%",
|
|
171
|
+
maxHeight: HOVER_IMAGE_MAX_HEIGHT_CSS,
|
|
172
|
+
width: "auto",
|
|
173
|
+
height: "auto",
|
|
174
|
+
minWidth: "120px",
|
|
175
|
+
minHeight: "120px",
|
|
176
|
+
objectFit: "contain"
|
|
177
|
+
}));
|
|
178
|
+
return (_ctx, _cache) => {
|
|
179
|
+
const _component_el_watermark = ElWatermark;
|
|
180
|
+
return openBlock(), createBlock(LazyPopover, {
|
|
181
|
+
class: "fg-view-img-popover__trigger",
|
|
182
|
+
props: hoverPopoverPropsMerged.value
|
|
183
|
+
}, {
|
|
184
|
+
reference: withCtx(() => [
|
|
185
|
+
createVNode(FgViewImg, mergeProps({
|
|
186
|
+
ref_key: "viewImgRef",
|
|
187
|
+
ref: viewImgRef,
|
|
188
|
+
class: unref(attrs).class,
|
|
189
|
+
style: unref(attrs).style
|
|
190
|
+
}, viewImgProps.value, {
|
|
191
|
+
onLoad: _cache[0] || (_cache[0] = (e) => emit("load", e)),
|
|
192
|
+
onError: _cache[1] || (_cache[1] = (e) => emit("error", e)),
|
|
193
|
+
onRetry: _cache[2] || (_cache[2] = (p) => emit("retry", p)),
|
|
194
|
+
onShow: _cache[3] || (_cache[3] = (p) => emit("show", p)),
|
|
195
|
+
onClose: _cache[4] || (_cache[4] = ($event) => emit("close")),
|
|
196
|
+
onSwitch: _cache[5] || (_cache[5] = (i) => emit("switch", i))
|
|
197
|
+
}), createSlots({ _: 2 }, [
|
|
198
|
+
_ctx.$slots.placeholder ? {
|
|
199
|
+
name: "placeholder",
|
|
200
|
+
fn: withCtx(() => [
|
|
201
|
+
renderSlot(_ctx.$slots, "placeholder", {}, void 0, true)
|
|
202
|
+
]),
|
|
203
|
+
key: "0"
|
|
204
|
+
} : void 0,
|
|
205
|
+
_ctx.$slots.error ? {
|
|
206
|
+
name: "error",
|
|
207
|
+
fn: withCtx(() => [
|
|
208
|
+
renderSlot(_ctx.$slots, "error", {}, void 0, true)
|
|
209
|
+
]),
|
|
210
|
+
key: "1"
|
|
211
|
+
} : void 0
|
|
212
|
+
]), 1040, ["class", "style"])
|
|
213
|
+
]),
|
|
214
|
+
default: withCtx(() => [
|
|
215
|
+
hoverPreviewSrc.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
216
|
+
!__props.isShowWatermark ? (openBlock(), createBlock(FgViewImg, {
|
|
217
|
+
key: 0,
|
|
218
|
+
class: "fg-view-img-popover__hover-image",
|
|
219
|
+
src: hoverPreviewSrc.value,
|
|
220
|
+
style: normalizeStyle(hoverImgStyle.value),
|
|
221
|
+
preview: false,
|
|
222
|
+
"oss-process": false,
|
|
223
|
+
"error-color": __props.errorColor,
|
|
224
|
+
"error-offset": __props.errorOffset,
|
|
225
|
+
"error-text": __props.errorText,
|
|
226
|
+
fit: "contain"
|
|
227
|
+
}, createSlots({ _: 2 }, [
|
|
228
|
+
_ctx.$slots.error ? {
|
|
229
|
+
name: "error",
|
|
230
|
+
fn: withCtx(() => [
|
|
231
|
+
renderSlot(_ctx.$slots, "error", {}, void 0, true)
|
|
232
|
+
]),
|
|
233
|
+
key: "0"
|
|
234
|
+
} : void 0
|
|
235
|
+
]), 1032, ["src", "style", "error-color", "error-offset", "error-text"])) : (openBlock(), createBlock(_component_el_watermark, {
|
|
236
|
+
key: 1,
|
|
237
|
+
class: "fg-view-img-popover__watermark",
|
|
238
|
+
content: [__props.waterMarkTitle],
|
|
239
|
+
gap: [10, 10],
|
|
240
|
+
font: { fontSize: 16, color: "rgba(0, 0, 0, 0.3)" }
|
|
241
|
+
}, {
|
|
242
|
+
default: withCtx(() => [
|
|
243
|
+
createVNode(FgViewImg, {
|
|
244
|
+
class: "fg-view-img-popover__hover-image",
|
|
245
|
+
src: hoverPreviewSrc.value,
|
|
246
|
+
style: normalizeStyle(hoverImgStyle.value),
|
|
247
|
+
preview: false,
|
|
248
|
+
"oss-process": false,
|
|
249
|
+
"error-color": __props.errorColor,
|
|
250
|
+
"error-offset": __props.errorOffset,
|
|
251
|
+
"error-text": __props.errorText,
|
|
252
|
+
fit: "contain"
|
|
253
|
+
}, createSlots({ _: 2 }, [
|
|
254
|
+
_ctx.$slots.error ? {
|
|
255
|
+
name: "error",
|
|
256
|
+
fn: withCtx(() => [
|
|
257
|
+
renderSlot(_ctx.$slots, "error", {}, void 0, true)
|
|
258
|
+
]),
|
|
259
|
+
key: "0"
|
|
260
|
+
} : void 0
|
|
261
|
+
]), 1032, ["src", "style", "error-color", "error-offset", "error-text"])
|
|
262
|
+
]),
|
|
263
|
+
_: 3
|
|
264
|
+
}, 8, ["content"]))
|
|
265
|
+
], 64)) : createCommentVNode("", true)
|
|
266
|
+
]),
|
|
267
|
+
_: 3
|
|
268
|
+
}, 8, ["props"]);
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}));
|
|
272
|
+
const ViewImgPopover = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6955cede"]]);
|
|
273
|
+
export {
|
|
274
|
+
ViewImgPopover as V
|
|
275
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.fg-view-img-popover__hover-image[data-v-6955cede] {
|
|
2
|
+
vertical-align: top;
|
|
3
|
+
}
|
|
4
|
+
.fg-view-img-popover__hover-image[data-v-6955cede] .fg-view-img__inner {
|
|
5
|
+
width: auto;
|
|
6
|
+
height: auto;
|
|
7
|
+
max-width: 100%;
|
|
8
|
+
max-height: 100%;
|
|
9
|
+
}.fg-view-img-popover__trigger {
|
|
10
|
+
display: block;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
max-width: 100%;
|
|
14
|
+
}
|
|
15
|
+
.fg-view-img-popover.el-popper {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
.fg-view-img-popover.el-popper .fg-lazy-popover__content {
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
align-items: center;
|
|
26
|
+
max-width: 100%;
|
|
27
|
+
line-height: 0;
|
|
28
|
+
}
|
|
29
|
+
.fg-view-img-popover.el-popper .fg-view-img-popover__watermark {
|
|
30
|
+
display: block;
|
|
31
|
+
max-width: 100%;
|
|
32
|
+
max-height: 380px;
|
|
33
|
+
}
|