fangguo-component 1.2.4 → 1.2.6

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.
@@ -1,18 +1,14 @@
1
1
 
2
- .fg-doc-view-img-loading__box[data-v-b5803c68] {
2
+ .fg-doc-view-img-loading__box[data-v-436c9599] {
3
3
  width: 200px;
4
4
  height: 120px;
5
5
  background: #fafafa;
6
6
  border: 1px dashed var(--el-border-color);
7
7
  border-radius: 8px;
8
8
  }
9
- .fg-doc-view-img-loading__box[data-v-b5803c68] .fg-view-img {
9
+ .fg-doc-view-img-loading__box[data-v-436c9599] .fg-view-img {
10
10
  width: 100%;
11
11
  height: 100%;
12
- }
13
- .fg-doc-view-img-loading__ph[data-v-b5803c68] {
14
- font-size: 13px;
15
- color: var(--el-color-primary);
16
12
  }
17
13
  .cascader-virtual-list[data-v-a251fab9] {
18
14
  height: 100%;
@@ -50,13 +50,13 @@ var __async = (__this, __arguments, generator) => {
50
50
  step((generator = generator.apply(__this, __arguments)).next());
51
51
  });
52
52
  };
53
- import { getCurrentScope, onScopeDispose, watch, computed, toValue, shallowRef, getCurrentInstance, onMounted, warn, defineComponent, ref, openBlock, createElementBlock, createElementVNode, createVNode, unref, withCtx, h, inject, resolveComponent, normalizeClass, createBlock, withModifiers, createCommentVNode, Fragment, normalizeStyle, createTextVNode, toDisplayString, provide, reactive, onBeforeUpdate, nextTick, renderList, useAttrs, withDirectives, vShow, renderSlot, withKeys, vModelText, useSlots, useModel, onBeforeUnmount, mergeProps, mergeModels, render } from "vue";
53
+ import { getCurrentScope, onScopeDispose, watch, computed, toValue, shallowRef, getCurrentInstance, onMounted, warn, defineComponent, ref, openBlock, createElementBlock, createVNode, withCtx, createTextVNode, toDisplayString, createElementVNode, unref, h, inject, resolveComponent, normalizeClass, createBlock, withModifiers, createCommentVNode, Fragment, normalizeStyle, provide, reactive, onBeforeUpdate, nextTick, renderList, useAttrs, withDirectives, vShow, renderSlot, withKeys, vModelText, useSlots, useModel, onBeforeUnmount, mergeProps, mergeModels, render } from "vue";
54
54
  import { p as process$1 } from "./index-C9zyi90j.js";
55
55
  import { fromPairs, isEqual, flattenDeep, cloneDeep, debounce } from "lodash-unified";
56
56
  import { ArrowRight, Loading, Check, CircleClose, ArrowDown } from "@element-plus/icons-vue";
57
57
  import { useNamespace, ElIcon, ElRadio, ElCheckbox, ElScrollbar, useLocale, UPDATE_MODEL_EVENT, CHANGE_EVENT, EVENT_CODE, tagProps, useTooltipContentProps, CommonProps as CommonProps$1, useSizeProp, useFormItem, useFormSize, ElConfigProvider, ElTooltip, ElInput, ElTag, ClickOutside } from "element-plus";
58
- import { ElCheckbox as ElCheckbox$1, ElRadio as ElRadio$1, ElIcon as ElIcon$1 } from "element-plus/es";
59
- import { F as FgViewImg } from "./ViewImg-CD4QJK4R.js";
58
+ import { ElButton, ElCheckbox as ElCheckbox$1, ElRadio as ElRadio$1, ElIcon as ElIcon$1 } from "element-plus/es";
59
+ import { F as FgViewImg } from "./ViewImg-CLRjYOUN.js";
60
60
  import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
61
61
  import { b as script$2 } from "./vue-virtual-scroller.esm-ZgBoGAjX.js";
62
62
  !!(process$1.env.NODE_ENV !== "production") ? Object.freeze({}) : {};
@@ -316,37 +316,40 @@ const castArray = (arr) => {
316
316
  };
317
317
  const isKorean = (text) => /([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(text);
318
318
  const generateId = () => Math.floor(Math.random() * 1e4);
319
- const _hoisted_1$2 = { class: "fg-doc-view-img-loading pt-1" };
319
+ const _hoisted_1$2 = { class: "fg-doc-view-img-loading flex flex-col items-start gap-3 pt-1" };
320
320
  const _hoisted_2$1 = { class: "fg-doc-view-img-loading__box" };
321
321
  const src = "https://element-plus.org/images/element-plus-logo.svg";
322
322
  const _sfc_main$5 = /* @__PURE__ */ defineComponent({
323
323
  __name: "Loading",
324
324
  setup(__props) {
325
325
  const loading = ref(true);
326
- onMounted(() => {
327
- window.setTimeout(() => {
328
- loading.value = false;
329
- }, 2e3);
330
- });
326
+ function toggleLoading() {
327
+ loading.value = !loading.value;
328
+ }
331
329
  return (_ctx, _cache) => {
330
+ const _component_el_button = ElButton;
332
331
  return openBlock(), createElementBlock("div", _hoisted_1$2, [
332
+ createVNode(_component_el_button, {
333
+ size: "small",
334
+ onClick: toggleLoading
335
+ }, {
336
+ default: withCtx(() => [
337
+ createTextVNode(toDisplayString(loading.value ? "关闭加载中" : "开启加载中"), 1)
338
+ ]),
339
+ _: 1
340
+ }),
333
341
  createElementVNode("div", _hoisted_2$1, [
334
342
  createVNode(unref(FgViewImg), {
335
343
  src,
336
344
  loading: loading.value,
337
345
  "oss-process": false
338
- }, {
339
- placeholder: withCtx(() => [..._cache[0] || (_cache[0] = [
340
- createElementVNode("span", { class: "fg-doc-view-img-loading__ph" }, "加载中…", -1)
341
- ])]),
342
- _: 1
343
- }, 8, ["loading"])
346
+ }, null, 8, ["loading"])
344
347
  ])
345
348
  ]);
346
349
  };
347
350
  }
348
351
  });
349
- const __unplugin_components_0 = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-b5803c68"]]);
352
+ const __unplugin_components_0 = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-436c9599"]]);
350
353
  const NodeContent = defineComponent({
351
354
  name: "NodeContent",
352
355
  setup() {
@@ -29,70 +29,165 @@ var __objRest = (source, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { defineComponent, computed, openBlock, createElementBlock, Fragment, createElementVNode, toDisplayString, reactive, useAttrs, ref, watch, normalizeStyle, unref, normalizeClass, withDirectives, mergeProps, vShow, renderSlot, normalizeProps, guardReactiveProps, createBlock, resolveDynamicComponent, createCommentVNode } from "vue";
32
+ import { defineComponent, computed, openBlock, createElementBlock, createElementVNode, Fragment, normalizeStyle, toDisplayString, reactive, useAttrs, ref, watch, nextTick, onMounted, onUnmounted, unref, normalizeClass, withDirectives, mergeProps, vShow, renderSlot, normalizeProps, guardReactiveProps, createBlock, resolveDynamicComponent, createCommentVNode } from "vue";
33
33
  import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
34
34
  import { I as ImgViewerStore } from "./imgViewerStore-Ajm-L7R5.js";
35
35
  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";
36
- import { n as networkKey, i as imgUrlConfigKey, m as montageImgUrl } from "./montageImgUrl-DP5jMHCX.js";
36
+ import { n as networkKey, i as imgUrlConfigKey, m as montageImgUrl } from "./montageImgUrl-B9ZmJ7TF.js";
37
37
  const _hoisted_1$1 = { class: "fg-view-img__error-default" };
38
- const _hoisted_2$1 = {
38
+ const _hoisted_2$1 = { class: "fg-view-img__error-default-body" };
39
+ const _hoisted_3$1 = {
40
+ class: "fg-view-img__error-icon",
41
+ viewBox: "0 0 1280 1024",
42
+ xmlns: "http://www.w3.org/2000/svg"
43
+ };
44
+ const _hoisted_4 = ["fill"];
45
+ const _hoisted_5 = {
46
+ class: "fg-view-img__error-icon",
47
+ viewBox: "0 0 1131 1024",
48
+ xmlns: "http://www.w3.org/2000/svg"
49
+ };
50
+ const _hoisted_6 = ["fill"];
51
+ const _hoisted_7 = ["fill"];
52
+ const _hoisted_8 = {
39
53
  class: "fg-view-img__error-icon",
40
54
  viewBox: "0 0 1088 1024",
41
55
  xmlns: "http://www.w3.org/2000/svg"
42
56
  };
43
- const _hoisted_3$1 = ["fill"];
44
- const _hoisted_4 = { class: "fg-view-img__error-label" };
45
- const DEFAULT_FAIL_COLOR = "#c3c6ca";
46
- const LEGACY_ERROR_COLOR = "#f5f5f5";
57
+ const _hoisted_9 = ["fill"];
58
+ const DEFAULT_PRIMARY = "#D4DADC";
59
+ const DEFAULT_SECONDARY = "#E1E4E5";
60
+ const DEFAULT_ICON_COLOR = "#c3c6ca";
61
+ const DEFAULT_LOADING_COLOR = "#cfd2d7";
47
62
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
48
63
  __name: "ViewImgErrorFallback",
49
64
  props: {
65
+ loading: { type: Boolean, default: false },
50
66
  src: { default: "" },
51
67
  errorText: { default: "" },
52
- errorColor: { default: "" }
68
+ fallbackColor: { default: "" }
53
69
  },
54
70
  setup(__props) {
55
71
  const props = __props;
56
72
  const isEmptySrc = computed(() => !props.src.trim());
57
73
  const resolvedLabel = computed(() => props.errorText || "加载失败");
58
- const resolvedFailColor = computed(() => {
74
+ const customColor = computed(() => {
59
75
  var _a;
60
- const color = (_a = props.errorColor) == null ? void 0 : _a.trim();
61
- if (!color || color === LEGACY_ERROR_COLOR) return DEFAULT_FAIL_COLOR;
62
- return color;
76
+ return ((_a = props.fallbackColor) == null ? void 0 : _a.trim()) || "";
77
+ });
78
+ function parseHexColor(input) {
79
+ const hex = input.startsWith("#") ? input.slice(1) : input;
80
+ if (/^[0-9a-fA-F]{3}$/.test(hex)) {
81
+ return [0, 1, 2].map((i) => parseInt(hex[i] + hex[i], 16));
82
+ }
83
+ if (/^[0-9a-fA-F]{6}$/.test(hex)) {
84
+ return [0, 2, 4].map((i) => parseInt(hex.slice(i, i + 2), 16));
85
+ }
86
+ return null;
87
+ }
88
+ function parseRgbCss(input) {
89
+ const m = input.match(/rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);
90
+ if (!m) return null;
91
+ return [Number(m[1]), Number(m[2]), Number(m[3])];
92
+ }
93
+ function resolveCssColor(input) {
94
+ const fromHex = parseHexColor(input);
95
+ if (fromHex) return fromHex;
96
+ const fromRgb = parseRgbCss(input);
97
+ if (fromRgb) return fromRgb;
98
+ if (typeof document === "undefined") return null;
99
+ const ctx = document.createElement("canvas").getContext("2d");
100
+ if (!ctx) return null;
101
+ ctx.fillStyle = "#000000";
102
+ ctx.fillStyle = input;
103
+ const afterDark = String(ctx.fillStyle);
104
+ ctx.fillStyle = "#ffffff";
105
+ ctx.fillStyle = input;
106
+ const afterLight = String(ctx.fillStyle);
107
+ if (afterDark === "#000000" && afterLight === "#ffffff") return null;
108
+ return parseHexColor(afterDark !== "#000000" ? afterDark : afterLight) || parseRgbCss(afterDark);
109
+ }
110
+ function toHex([r, g, b]) {
111
+ return `#${[r, g, b].map((n) => Math.round(n).toString(16).padStart(2, "0")).join("")}`;
112
+ }
113
+ function tint(rgb, amount) {
114
+ return toHex(rgb.map((c) => c + (255 - c) * amount));
115
+ }
116
+ const colorPalette = computed(() => {
117
+ const base = customColor.value;
118
+ const rgb = base ? resolveCssColor(base) : null;
119
+ if (!rgb) {
120
+ return {
121
+ primary: DEFAULT_PRIMARY,
122
+ secondary: DEFAULT_SECONDARY,
123
+ icon: DEFAULT_ICON_COLOR,
124
+ loading: DEFAULT_LOADING_COLOR,
125
+ label: ""
126
+ };
127
+ }
128
+ return {
129
+ primary: tint(rgb, 0.28),
130
+ secondary: tint(rgb, 0.52),
131
+ icon: tint(rgb, 0.36),
132
+ loading: tint(rgb, 0.32),
133
+ label: tint(rgb, 0.45)
134
+ };
135
+ });
136
+ const resolvedPrimary = computed(() => colorPalette.value.primary);
137
+ const resolvedSecondary = computed(() => colorPalette.value.secondary);
138
+ const resolvedIconColor = computed(() => colorPalette.value.icon);
139
+ const resolvedLoadingColor = computed(() => colorPalette.value.loading);
140
+ const labelStyle = computed(() => {
141
+ if (!colorPalette.value.label) return {};
142
+ return { color: colorPalette.value.label };
63
143
  });
64
144
  return (_ctx, _cache) => {
65
145
  return openBlock(), createElementBlock("div", _hoisted_1$1, [
66
- isEmptySrc.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
67
- _cache[0] || (_cache[0] = createElementVNode("svg", {
68
- class: "fg-view-img__error-icon",
69
- viewBox: "0 0 1131 1024",
70
- xmlns: "http://www.w3.org/2000/svg"
71
- }, [
72
- createElementVNode("path", {
73
- d: "M764.191528 125.736421a125.844211 125.844211 0 0 0 125.898106 125.763368 125.844211 125.844211 0 0 0 125.898105-125.763368A125.844211 125.844211 0 0 0 890.089634 0a125.844211 125.844211 0 0 0-125.898106 125.736421zM317.269423 317.493895L18.261423 807.909053c-50.364632 84.884211 9.431579 191.757474 107.008 191.757473h601.168842c97.549474 0 157.372632-106.873263 106.981053-191.757473L534.465213 317.493895c-50.364632-78.578526-166.804211-78.578526-217.19579 0z",
74
- fill: "#D4DADC"
75
- }),
76
- createElementVNode("path", {
77
- d: "M742.148581 556.409263l-157.372632 257.778526c-50.337684 84.884211 9.458526 191.784421 107.034948 191.784422h314.745263c97.549474 0 157.372632-106.900211 107.008-191.784422l-157.372632-257.778526c-47.211789-81.731368-166.804211-81.731368-214.016 0z",
78
- fill: "#E1E4E5"
79
- })
80
- ], -1)),
81
- _cache[1] || (_cache[1] = createElementVNode("span", { class: "fg-view-img__error-label" }, "无图", -1))
82
- ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
83
- (openBlock(), createElementBlock("svg", _hoisted_2$1, [
84
- createElementVNode("path", {
85
- d: "M640 138.688a32 32 0 0 1 27.456 48.448L613.76 276.416l31.488 47.232a32 32 0 0 1-12.288 46.336L482.944 444.928l18.112 126.592a32.064 32.064 0 0 1-22.912 35.264l-118.976 33.92 55.68 204.224a32 32 0 0 1-30.848 40.448H149.376a74.688 74.688 0 0 1-74.688-74.688V213.376c0-41.216 33.472-74.688 74.688-74.688H640z m234.624 0c41.216 0 74.688 33.472 74.688 74.688v597.312c0 41.216-33.472 74.688-74.688 74.688H512a32.064 32.064 0 0 1-30.784-23.232l-42.624-149.312a32 32 0 0 1 21.888-39.552l122.944-35.2-17.92-143.36a32 32 0 0 1 18.816-33.28l158.912-70.72-45.376-75.584a32 32 0 0 1 0.832-34.176l85.312-128a32 32 0 0 1 26.624-14.272h64z m-725.248 64a10.688 10.688 0 0 0-10.688 10.688v597.312c0 5.888 4.8 10.688 10.688 10.688h192.768l-52.992-194.24a32 32 0 0 1 22.08-39.168l122.432-35.072-17.344-121.728a32 32 0 0 1 17.344-33.088l138.24-69.12-22.528-33.856a32.064 32.064 0 0 1-0.832-34.24l34.944-58.176H149.376z m613.76 96.896l53.632 89.28a32 32 0 0 1-14.464 45.76L632 510.272l18.368 147.072a32 32 0 0 1-22.912 34.752l-118.656 33.92 27.328 95.36h338.496a10.688 10.688 0 0 0 10.688-10.688V213.376a10.688 10.688 0 0 0-10.688-10.688h-46.848l-64.64 96.896zM309.312 288a64 64 0 1 1 0 128 64 64 0 0 1 0-128z",
86
- fill: resolvedFailColor.value
87
- }, null, 8, _hoisted_3$1)
88
- ])),
89
- createElementVNode("span", _hoisted_4, toDisplayString(resolvedLabel.value), 1)
90
- ], 64))
146
+ createElementVNode("div", _hoisted_2$1, [
147
+ __props.loading ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
148
+ (openBlock(), createElementBlock("svg", _hoisted_3$1, [
149
+ createElementVNode("path", {
150
+ d: "M1174.826667 0H105.216A105.258667 105.258667 0 0 0-0.042667 105.258667V918.613333a105.258667 105.258667 0 0 0 105.258667 105.258667h1069.653333A105.258667 105.258667 0 0 0 1280.085333 918.613333V105.258667A105.344 105.344 0 0 0 1174.826667 0z m-402.773334 181.461333a105.386667 105.386667 0 1 1-0.042666 210.773334 105.386667 105.386667 0 0 1 0-210.773334zM104.746667 883.882667S191.018667 381.098667 391.509333 381.098667c196.48 0 246.528 351.616 384.810667 351.616 87.210667 0 78.08-158.72 216.490667-158.72 99.242667 0 162.304 309.888 162.304 309.888H104.789333z",
151
+ fill: resolvedLoadingColor.value
152
+ }, null, 8, _hoisted_4)
153
+ ])),
154
+ createElementVNode("span", {
155
+ class: "fg-view-img__error-label",
156
+ style: normalizeStyle(labelStyle.value)
157
+ }, "加载中", 4)
158
+ ], 64)) : isEmptySrc.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
159
+ (openBlock(), createElementBlock("svg", _hoisted_5, [
160
+ createElementVNode("path", {
161
+ d: "M764.191528 125.736421a125.844211 125.844211 0 0 0 125.898106 125.763368 125.844211 125.844211 0 0 0 125.898105-125.763368A125.844211 125.844211 0 0 0 890.089634 0a125.844211 125.844211 0 0 0-125.898106 125.736421zM317.269423 317.493895L18.261423 807.909053c-50.364632 84.884211 9.431579 191.757474 107.008 191.757473h601.168842c97.549474 0 157.372632-106.873263 106.981053-191.757473L534.465213 317.493895c-50.364632-78.578526-166.804211-78.578526-217.19579 0z",
162
+ fill: resolvedPrimary.value
163
+ }, null, 8, _hoisted_6),
164
+ createElementVNode("path", {
165
+ d: "M742.148581 556.409263l-157.372632 257.778526c-50.337684 84.884211 9.458526 191.784421 107.034948 191.784422h314.745263c97.549474 0 157.372632-106.900211 107.008-191.784422l-157.372632-257.778526c-47.211789-81.731368-166.804211-81.731368-214.016 0z",
166
+ fill: resolvedSecondary.value
167
+ }, null, 8, _hoisted_7)
168
+ ])),
169
+ createElementVNode("span", {
170
+ class: "fg-view-img__error-label",
171
+ style: normalizeStyle(labelStyle.value)
172
+ }, "无图", 4)
173
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 2 }, [
174
+ (openBlock(), createElementBlock("svg", _hoisted_8, [
175
+ createElementVNode("path", {
176
+ d: "M640 138.688a32 32 0 0 1 27.456 48.448L613.76 276.416l31.488 47.232a32 32 0 0 1-12.288 46.336L482.944 444.928l18.112 126.592a32.064 32.064 0 0 1-22.912 35.264l-118.976 33.92 55.68 204.224a32 32 0 0 1-30.848 40.448H149.376a74.688 74.688 0 0 1-74.688-74.688V213.376c0-41.216 33.472-74.688 74.688-74.688H640z m234.624 0c41.216 0 74.688 33.472 74.688 74.688v597.312c0 41.216-33.472 74.688-74.688 74.688H512a32.064 32.064 0 0 1-30.784-23.232l-42.624-149.312a32 32 0 0 1 21.888-39.552l122.944-35.2-17.92-143.36a32 32 0 0 1 18.816-33.28l158.912-70.72-45.376-75.584a32 32 0 0 1 0.832-34.176l85.312-128a32 32 0 0 1 26.624-14.272h64z m-725.248 64a10.688 10.688 0 0 0-10.688 10.688v597.312c0 5.888 4.8 10.688 10.688 10.688h192.768l-52.992-194.24a32 32 0 0 1 22.08-39.168l122.432-35.072-17.344-121.728a32 32 0 0 1 17.344-33.088l138.24-69.12-22.528-33.856a32.064 32.064 0 0 1-0.832-34.24l34.944-58.176H149.376z m613.76 96.896l53.632 89.28a32 32 0 0 1-14.464 45.76L632 510.272l18.368 147.072a32 32 0 0 1-22.912 34.752l-118.656 33.92 27.328 95.36h338.496a10.688 10.688 0 0 0 10.688-10.688V213.376a10.688 10.688 0 0 0-10.688-10.688h-46.848l-64.64 96.896zM309.312 288a64 64 0 1 1 0 128 64 64 0 0 1 0-128z",
177
+ fill: resolvedIconColor.value
178
+ }, null, 8, _hoisted_9)
179
+ ])),
180
+ createElementVNode("span", {
181
+ class: "fg-view-img__error-label",
182
+ style: normalizeStyle(labelStyle.value)
183
+ }, toDisplayString(resolvedLabel.value), 5)
184
+ ], 64))
185
+ ])
91
186
  ]);
92
187
  };
93
188
  }
94
189
  });
95
- const ViewImgErrorFallback = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-454f216f"]]);
190
+ const ViewImgErrorFallback = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-4588a25e"]]);
96
191
  const viewImgDefaults = reactive({});
97
192
  function configureViewImgDefaults(defaults) {
98
193
  resetViewImgDefaults();
@@ -107,7 +202,7 @@ function resetViewImgDefaults() {
107
202
  function useViewImgDefaults() {
108
203
  return viewImgDefaults;
109
204
  }
110
- const _hoisted_1 = ["src", "loading"];
205
+ const _hoisted_1 = ["src"];
111
206
  const _hoisted_2 = {
112
207
  key: 0,
113
208
  class: "fg-view-img__placeholder"
@@ -116,6 +211,7 @@ const _hoisted_3 = {
116
211
  key: 1,
117
212
  class: "fg-view-img__error"
118
213
  };
214
+ const LAZY_ROOT_MARGIN = "200px";
119
215
  const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
120
216
  inheritAttrs: false
121
217
  }), {
@@ -124,6 +220,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
124
220
  src: { default: "" },
125
221
  fit: { default: "" },
126
222
  lazy: { type: Boolean, default: false },
223
+ scrollContainer: { default: null },
127
224
  loading: { type: Boolean, default: false },
128
225
  preview: { type: Boolean, default: false },
129
226
  previewSrcList: { default: () => [] },
@@ -146,8 +243,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
146
243
  simpleExtraTools: { default: () => [] },
147
244
  renderExtraTools: { default: null },
148
245
  originalToolbar: { default: () => [...DEFAULT_ORIGINAL_TOOLBAR] },
149
- errorColor: { default: "#f5f5f5" },
150
- errorOffset: { default: 0 },
246
+ fallbackColor: { default: "" },
151
247
  errorText: { default: "" },
152
248
  ossProcess: { type: Boolean, default: true },
153
249
  ossLinks: { default: void 0 },
@@ -160,11 +256,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
160
256
  const props = __props;
161
257
  const emit = __emit;
162
258
  const attrs = useAttrs();
259
+ const rootRef = ref(null);
163
260
  const displaySrc = ref("");
164
261
  const retried = ref(false);
165
262
  const internalLoading = ref(false);
166
263
  const loadError = ref(false);
264
+ const lazyActivated = ref(!props.lazy);
167
265
  const viewImgDefaults2 = useViewImgDefaults();
266
+ let lazyObserver = null;
168
267
  const imgAttrs = computed(() => {
169
268
  const _a = attrs, { class: _, style: __ } = _a, rest = __objRest(_a, ["class", "style"]);
170
269
  return rest;
@@ -182,8 +281,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
182
281
  loading: props.loading || internalLoading.value,
183
282
  loadError: loadError.value,
184
283
  errorText: props.errorText,
185
- errorColor: props.errorColor,
186
- errorOffset: props.errorOffset
284
+ fallbackColor: props.fallbackColor
187
285
  }));
188
286
  const globalPlaceholderComponent = computed(() => {
189
287
  const renderPlaceholder = viewImgDefaults2.placeholder;
@@ -242,6 +340,67 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
242
340
  internalLoading.value = true;
243
341
  displaySrc.value = resolveImgUrl(src, props.imgSize);
244
342
  }
343
+ function setLazyPending(src) {
344
+ retried.value = false;
345
+ displaySrc.value = "";
346
+ if (!src.trim()) {
347
+ loadError.value = true;
348
+ internalLoading.value = false;
349
+ return;
350
+ }
351
+ loadError.value = false;
352
+ internalLoading.value = true;
353
+ }
354
+ function resolveScrollRoot() {
355
+ const container = props.scrollContainer;
356
+ if (!container) return null;
357
+ if (typeof container === "string") {
358
+ return document.querySelector(container);
359
+ }
360
+ return container;
361
+ }
362
+ function stopLazyObserver() {
363
+ if (lazyObserver) {
364
+ lazyObserver.disconnect();
365
+ lazyObserver = null;
366
+ }
367
+ }
368
+ function activateLazyLoad() {
369
+ if (lazyActivated.value) return;
370
+ lazyActivated.value = true;
371
+ stopLazyObserver();
372
+ resetState(props.src);
373
+ }
374
+ function startLazyObserver() {
375
+ stopLazyObserver();
376
+ if (!props.lazy || lazyActivated.value) return;
377
+ if (typeof window === "undefined" || !("IntersectionObserver" in window)) {
378
+ activateLazyLoad();
379
+ return;
380
+ }
381
+ const el = rootRef.value;
382
+ if (!el) return;
383
+ lazyObserver = new IntersectionObserver(
384
+ (entries) => {
385
+ if (entries.some((entry) => entry.isIntersecting)) {
386
+ activateLazyLoad();
387
+ }
388
+ },
389
+ {
390
+ root: resolveScrollRoot(),
391
+ rootMargin: LAZY_ROOT_MARGIN,
392
+ threshold: 0
393
+ }
394
+ );
395
+ lazyObserver.observe(el);
396
+ }
397
+ function applySrc(src) {
398
+ if (props.lazy && !lazyActivated.value) {
399
+ setLazyPending(src);
400
+ return;
401
+ }
402
+ resetState(src);
403
+ }
245
404
  function handleLoad(event) {
246
405
  internalLoading.value = false;
247
406
  loadError.value = false;
@@ -302,10 +461,40 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
302
461
  watch(
303
462
  [() => props.src, () => props.ossProcess, () => props.ossLinks, () => props.imgSize, networkKey, imgUrlConfigKey],
304
463
  ([src]) => {
305
- resetState(src);
464
+ applySrc(src);
306
465
  },
307
466
  { immediate: true, deep: true }
308
467
  );
468
+ watch(
469
+ () => props.lazy,
470
+ (lazy) => {
471
+ if (!lazy) {
472
+ if (!lazyActivated.value) {
473
+ activateLazyLoad();
474
+ }
475
+ return;
476
+ }
477
+ if (!lazyActivated.value) {
478
+ nextTick(() => startLazyObserver());
479
+ }
480
+ }
481
+ );
482
+ watch(
483
+ () => props.scrollContainer,
484
+ () => {
485
+ if (props.lazy && !lazyActivated.value) {
486
+ nextTick(() => startLazyObserver());
487
+ }
488
+ }
489
+ );
490
+ onMounted(() => {
491
+ if (props.lazy && !lazyActivated.value) {
492
+ startLazyObserver();
493
+ }
494
+ });
495
+ onUnmounted(() => {
496
+ stopLazyObserver();
497
+ });
309
498
  __expose({
310
499
  displaySrc,
311
500
  retried,
@@ -313,24 +502,34 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
313
502
  });
314
503
  return (_ctx, _cache) => {
315
504
  return openBlock(), createElementBlock("span", {
505
+ ref_key: "rootRef",
506
+ ref: rootRef,
316
507
  class: normalizeClass(["fg-view-img", unref(attrs).class]),
317
508
  style: normalizeStyle(unref(attrs).style)
318
509
  }, [
319
510
  withDirectives(createElementVNode("img", mergeProps({
320
- class: ["fg-view-img__inner", { "fg-view-img__inner--preview": previewEnabled.value }]
511
+ class: ["fg-view-img__inner", {
512
+ "fg-view-img__inner--preview": previewEnabled.value,
513
+ "fg-view-img__inner--loading": showPlaceholder.value
514
+ }]
321
515
  }, imgAttrs.value, {
322
516
  src: displaySrc.value || void 0,
323
- loading: __props.lazy ? "lazy" : "eager",
517
+ loading: "eager",
324
518
  style: imgStyle.value,
325
519
  onLoad: handleLoad,
326
520
  onError: handleError,
327
521
  onClick: handlePreviewClick
328
522
  }), null, 16, _hoisted_1), [
329
- [vShow, !loadError.value && !showPlaceholder.value]
523
+ [vShow, !loadError.value && !!displaySrc.value]
330
524
  ]),
331
525
  showPlaceholder.value ? (openBlock(), createElementBlock("span", _hoisted_2, [
332
526
  renderSlot(_ctx.$slots, "placeholder", normalizeProps(guardReactiveProps(defaultSlotPayload.value)), () => [
333
- globalPlaceholderComponent.value ? (openBlock(), createBlock(resolveDynamicComponent(globalPlaceholderComponent.value), { key: 0 })) : createCommentVNode("", true)
527
+ globalPlaceholderComponent.value ? (openBlock(), createBlock(resolveDynamicComponent(globalPlaceholderComponent.value), { key: 0 })) : (openBlock(), createBlock(ViewImgErrorFallback, {
528
+ key: 1,
529
+ loading: "",
530
+ src: __props.src,
531
+ "fallback-color": __props.fallbackColor
532
+ }, null, 8, ["src", "fallback-color"]))
334
533
  ], true)
335
534
  ])) : createCommentVNode("", true),
336
535
  loadError.value ? (openBlock(), createElementBlock("span", _hoisted_3, [
@@ -339,15 +538,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
339
538
  key: 1,
340
539
  src: __props.src,
341
540
  "error-text": __props.errorText,
342
- "error-color": __props.errorColor
343
- }, null, 8, ["src", "error-text", "error-color"]))
541
+ "fallback-color": __props.fallbackColor
542
+ }, null, 8, ["src", "error-text", "fallback-color"]))
344
543
  ], true)
345
544
  ])) : createCommentVNode("", true)
346
545
  ], 6);
347
546
  };
348
547
  }
349
548
  }));
350
- const FgViewImg = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f968b8c2"]]);
549
+ const FgViewImg = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b5064f2e"]]);
351
550
  export {
352
551
  FgViewImg as F,
353
552
  ViewImgErrorFallback as V,
package/dist/ViewImg.css CHANGED
@@ -1,30 +1,54 @@
1
- .fg-view-img__error-default[data-v-454f216f] {
1
+ @charset "UTF-8";
2
+ /* 外层建立尺寸容器,内层用 cqmin 随格子缩放 */
3
+ .fg-view-img__error-default[data-v-4588a25e] {
4
+ container-type: size;
5
+ width: 100%;
6
+ height: 100%;
7
+ overflow: hidden;
8
+ }
9
+ .fg-view-img__error-default-body[data-v-4588a25e] {
2
10
  width: 100%;
3
11
  height: 100%;
4
12
  display: flex;
5
13
  flex-direction: column;
6
14
  align-items: center;
7
15
  justify-content: center;
8
- gap: 6px;
16
+ gap: clamp(2px, 4cqmin, 6px);
9
17
  box-sizing: border-box;
10
- padding: 8px;
18
+ padding: clamp(2px, 6cqmin, 8px);
11
19
  }
12
- .fg-view-img__error-icon[data-v-454f216f] {
20
+ .fg-view-img__error-icon[data-v-4588a25e] {
13
21
  display: block;
14
22
  flex: none;
15
- width: 40%;
23
+ width: clamp(16px, 36cqmin, 56px);
16
24
  height: auto;
17
25
  max-width: 56px;
18
26
  max-height: 48px;
19
27
  aspect-ratio: 1;
20
28
  }
21
- .fg-view-img__error-label[data-v-454f216f] {
29
+ .fg-view-img__error-label[data-v-4588a25e] {
22
30
  flex: none;
23
31
  color: #a8abb2;
24
- font-size: 12px;
32
+ font-size: clamp(8px, 10cqmin, 12px);
25
33
  line-height: 1.2;
26
34
  text-align: center;
27
- }.fg-view-img[data-v-f968b8c2] {
35
+ white-space: nowrap;
36
+ max-width: 100%;
37
+ overflow: hidden;
38
+ text-overflow: ellipsis;
39
+ }
40
+
41
+ /* 极小格子隐藏文案,只留图标 */
42
+ @container (max-width: 56px) or (max-height: 48px) {
43
+ .fg-view-img__error-label[data-v-4588a25e] {
44
+ display: none;
45
+ }
46
+ .fg-view-img__error-default-body[data-v-4588a25e] {
47
+ gap: 0;
48
+ padding: 2px;
49
+ }
50
+ }
51
+ .fg-view-img[data-v-b5064f2e] {
28
52
  display: block;
29
53
  position: relative;
30
54
  overflow: hidden;
@@ -33,16 +57,21 @@
33
57
  vertical-align: top;
34
58
  line-height: 0;
35
59
  }
36
- .fg-view-img__inner[data-v-f968b8c2] {
60
+ .fg-view-img__inner[data-v-b5064f2e] {
37
61
  display: block;
38
62
  width: 100%;
39
63
  height: 100%;
40
64
  }
41
- .fg-view-img__inner--preview[data-v-f968b8c2] {
65
+
66
+ /* 加载中仍占位渲染,避免 display:none + 原生 lazy 导致永不请求 */
67
+ .fg-view-img__inner--loading[data-v-b5064f2e] {
68
+ opacity: 0;
69
+ }
70
+ .fg-view-img__inner--preview[data-v-b5064f2e] {
42
71
  cursor: zoom-in;
43
72
  }
44
- .fg-view-img__placeholder[data-v-f968b8c2],
45
- .fg-view-img__error[data-v-f968b8c2] {
73
+ .fg-view-img__placeholder[data-v-b5064f2e],
74
+ .fg-view-img__error[data-v-b5064f2e] {
46
75
  position: absolute;
47
76
  inset: 0;
48
77
  display: flex;