fangguo-component 1.2.0 → 1.2.2
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/CHANGELOG.md +28 -5
- package/README.md +11 -0
- package/dist/{FgCascader.vue_vue_type_style_index_0_lang-Bm4HR37D.js → FgCascader.vue_vue_type_style_index_0_lang-CstlYwHs.js} +1 -1
- package/dist/{ImgViewerHost.vue_vue_type_script_setup_true_lang-CMoh7eWo.js → ImgViewerHost.vue_vue_type_script_setup_true_lang-DBs42WOq.js} +4 -3
- package/dist/{ViewImg-Bg1AQ0T6.js → ViewImg-DXhF20SL.js} +14 -7
- package/dist/ViewImg.css +9 -9
- package/dist/ViewImgPopover-QblZG0z5.js +343 -0
- package/dist/ViewImgPopover.css +79 -6
- package/dist/ViewImgPreview.css +32 -0
- package/dist/{ViewImgPreview.vue_vue_type_style_index_0_lang-CYuLovBR.js → ViewImgPreview.vue_vue_type_style_index_0_lang-C2i0p5IK.js} +19 -9
- package/dist/components/cascader/index.js +1 -1
- package/dist/components/imgViewerHost/imgViewerStore.d.ts +5 -1
- package/dist/components/imgViewerHost/index.js +2 -2
- package/dist/components/index.js +15 -11
- package/dist/components/viewImg/ViewImg.vue.d.ts +9 -1
- package/dist/components/viewImg/index.js +1 -1
- package/dist/components/viewImgPopover/ViewImgPopover.vue.d.ts +25 -4
- package/dist/components/viewImgPopover/index.js +1 -1
- package/dist/components/viewImgPreview/ViewImgPreview.vue.d.ts +4 -1
- package/dist/components/viewImgPreview/index.d.ts +2 -2
- package/dist/components/viewImgPreview/index.js +11 -7
- package/dist/components/viewImgPreview/types.d.ts +15 -0
- package/dist/{imgViewerStore-C5n16uYa.js → imgViewerStore-DK3zvGf4.js} +7 -1
- package/dist/{index-CckJZ8N-.js → index-Ce_edAQB.js} +11 -7
- package/dist/index.js +25 -21
- package/dist/types-Ccn_sb6f.js +49 -0
- package/package.json +97 -92
- package/dist/ViewImgPopover-b9PDEYbP.js +0 -275
- package/dist/types-BNFeGRer.js +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
# 更新日志
|
|
2
2
|
|
|
3
|
-
本文件记录 **fangguo-component** 各 npm 版本变更;文档站通过 `@include` 同步展示。
|
|
4
|
-
|
|
5
|
-
## [1.1
|
|
6
|
-
|
|
7
|
-
###
|
|
3
|
+
本文件记录 **fangguo-component** 各 npm 版本变更;文档站通过 `@include` 同步展示。
|
|
4
|
+
|
|
5
|
+
## [1.2.1] - 2026-07-09
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
|
|
9
|
+
- ✨ **MCP 服务**:新增 `fangguo-component-mcp-server`,支持在 AI 客户端中按自然语言搜索组件、推荐用法、查询 Props / Events / Slots、读取真实 demo,并生成 Vue 使用片段。
|
|
10
|
+
- ✨ **MCP 工具集**:提供 `fangguo_recommend_usage`、`fangguo_generate_usage_snippet`、`fangguo_get_entry`、`fangguo_get_demo_code`、`fangguo_search_entries` 等工具,方便 AI 基于组件库真实文档写业务代码。
|
|
11
|
+
- ✨ **Catalog 索引**:新增组件、工具函数、指令和 Hook 的结构化索引,支持从线上 catalog、本地 JSON、本地源码或内置 catalog 加载。
|
|
12
|
+
|
|
13
|
+
### 优化
|
|
14
|
+
|
|
15
|
+
- ♻️ **MCP 搜索**:使用中文分词、catalog 动态短语和文档频率权重优化自然语言检索,降低“数据、选择、接口”等泛词噪音,提升不同组件场景下的推荐稳定性。
|
|
16
|
+
- ♻️ **MCP 运行方式**:支持 stdio 与 HTTP 两种传输方式,并提供 catalog 缓存刷新能力,便于本地调试和多客户端接入。
|
|
17
|
+
|
|
18
|
+
### 文档
|
|
19
|
+
|
|
20
|
+
- 📝 **MCP README**:补充业务项目快速接入、Codex 推荐配置、环境变量、本地调试、HTTP 接入和组件库开发者安装 / 构建 / 发布流程。
|
|
21
|
+
- 📝 **MCP 架构文档**:补充 MCP 数据来源、工具调用链路、搜索打分逻辑和具体查询示例,说明 catalog 与普通 JSON、向量数据库的区别。
|
|
22
|
+
|
|
23
|
+
### 构建与工程
|
|
24
|
+
|
|
25
|
+
- 🔧 **MCP 构建脚本**:新增根项目 `build:mcp`、`publish:mcp`、`start:mcp`、`start:mcp:http` 等脚本,并在文档构建流程中生成线上 `catalog.json`。
|
|
26
|
+
- 🔧 **MCP 子包发布准备**:补充 `@node-rs/jieba` 分词依赖和 MCP 子项目构建配置,当前 MCP 子包版本为 `0.1.12`。
|
|
27
|
+
|
|
28
|
+
## [1.1.0] - 2026-05-20
|
|
29
|
+
|
|
30
|
+
### 破坏性变更
|
|
8
31
|
|
|
9
32
|
- 💥 移除 **`SortTransfer`**、**`TipInput`** 组件及导出。
|
|
10
33
|
|
package/README.md
CHANGED
|
@@ -152,6 +152,17 @@ npm 不支持 `link:` 协议的 `overrides`,本地调试可用以下任一方
|
|
|
152
152
|
|
|
153
153
|
典型流程:改完组件、工具、指令、Hooks 源码或手写 md 后执行 `pnpm docs:gen`,再 `pnpm docs:dev` 查看效果;发布文档前执行 `pnpm docs:build`。
|
|
154
154
|
|
|
155
|
+
## AI 组件检索 MCP
|
|
156
|
+
|
|
157
|
+
仓库内置 `mcp/fangguo-component-mcp-server`,用于让 Cursor、Codex、Claude 等 AI 工具按需求快速检索组件库,而不是让 AI 从在线文档首页逐页阅读。MCP 会扫描 `src/docConfig.ts`、组件/工具/指令/Hook 文档、`demos/*.vue` 与各模块 `index.ts`,提供“搜索组件”“推荐用法”“读取 API”“读取 demo 源码”等工具。
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pnpm build:mcp
|
|
161
|
+
pnpm start:mcp
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
接入配置、HTTP 部署方式与工具说明见 [mcp/fangguo-component-mcp-server/README.md](mcp/fangguo-component-mcp-server/README.md)。
|
|
165
|
+
|
|
155
166
|
## 文档生成说明(`pnpm docs:gen`)
|
|
156
167
|
|
|
157
168
|
脚本入口:`scripts/gen-docs.ts`。在 `docs/components/`、`docs/tools/`、`docs/directives/`、`docs/hooks/` 下写入或更新各条目的 `@include` 或(工具无手写 md 时)自动生成 API 式 Markdown;**不再**生成上述目录下的 `index.md` 聚合页;并更新首页 `docs/index.md` 中 `features` 的链接,使其指向各分类**按目录名排序后的第一篇**文档。**不**修改 `docs/.vitepress/config.ts` 与 `src/docConfig.ts`。
|
|
@@ -56,7 +56,7 @@ import { fromPairs, isEqual, flattenDeep, cloneDeep, debounce } from "lodash-uni
|
|
|
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
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-
|
|
59
|
+
import { F as FgViewImg } from "./ViewImg-DXhF20SL.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({}) : {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, openBlock, createBlock, unref } from "vue";
|
|
2
|
-
import { _ as _sfc_main$1 } from "./ViewImgPreview.vue_vue_type_style_index_0_lang-
|
|
3
|
-
import { u as useImgViewerState, I as ImgViewerStore } from "./imgViewerStore-
|
|
2
|
+
import { _ as _sfc_main$1 } from "./ViewImgPreview.vue_vue_type_style_index_0_lang-C2i0p5IK.js";
|
|
3
|
+
import { u as useImgViewerState, I as ImgViewerStore } from "./imgViewerStore-DK3zvGf4.js";
|
|
4
4
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
5
|
__name: "ImgViewerHost",
|
|
6
6
|
setup(__props) {
|
|
@@ -40,10 +40,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
40
40
|
"simple-extra-tools": unref(state).simpleExtraTools,
|
|
41
41
|
"render-extra-tools": unref(state).renderExtraTools,
|
|
42
42
|
"original-toolbar": unref(state).originalToolbar,
|
|
43
|
+
"preview-side-nav": unref(state).previewSideNav,
|
|
43
44
|
onClose: handlePreviewClose,
|
|
44
45
|
onSwitch: handlePreviewSwitch,
|
|
45
46
|
onShow: handlePreviewShow
|
|
46
|
-
}, null, 8, ["visible", "url-list", "initial-index", "infinite", "z-index", "toolbar-bg-color", "toolbar-icon-color", "hide-on-click-modal", "close-on-press-escape", "teleported", "zoom-rate", "scale", "min-scale", "max-scale", "show-progress", "simple-extra-tools", "render-extra-tools", "original-toolbar"]);
|
|
47
|
+
}, null, 8, ["visible", "url-list", "initial-index", "infinite", "z-index", "toolbar-bg-color", "toolbar-icon-color", "hide-on-click-modal", "close-on-press-escape", "teleported", "zoom-rate", "scale", "min-scale", "max-scale", "show-progress", "simple-extra-tools", "render-extra-tools", "original-toolbar", "preview-side-nav"]);
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
});
|
|
@@ -30,8 +30,8 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
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-
|
|
34
|
-
import { D as DEFAULT_ORIGINAL_TOOLBAR,
|
|
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
35
|
import { n as networkKey, i as imgUrlConfigKey, m as montageImgUrl } from "./montageImgUrl-CwgYnB2h.js";
|
|
36
36
|
import { F as FgErrorImage } from "./ErrorImage-CFVt1ht_.js";
|
|
37
37
|
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
|
|
@@ -85,7 +85,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
85
85
|
ossProcess: { type: Boolean, default: true },
|
|
86
86
|
ossLinks: { default: void 0 },
|
|
87
87
|
imgSize: { default: () => ({}) },
|
|
88
|
-
previewStripQuery: { type: Boolean, default: true }
|
|
88
|
+
previewStripQuery: { type: Boolean, default: true },
|
|
89
|
+
previewSideNav: { type: [Boolean, String], default: DEFAULT_PREVIEW_SIDE_NAV }
|
|
89
90
|
},
|
|
90
91
|
emits: ["load", "error", "retry", "show", "close", "switch"],
|
|
91
92
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -169,8 +170,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
169
170
|
displaySrc.value = stripped;
|
|
170
171
|
emit("retry", { from: urlBefore, to: stripped });
|
|
171
172
|
}
|
|
172
|
-
function
|
|
173
|
-
if (!
|
|
173
|
+
function openPreview() {
|
|
174
|
+
if (!previewUrlList.value.length) return;
|
|
174
175
|
ImgViewerStore().showImgViewer({
|
|
175
176
|
previewImgList: previewUrlList.value,
|
|
176
177
|
defImgPreviewIndex: previewInitialIndex.value,
|
|
@@ -189,11 +190,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
189
190
|
simpleExtraTools: props.simpleExtraTools,
|
|
190
191
|
renderExtraTools: props.renderExtraTools,
|
|
191
192
|
originalToolbar: props.originalToolbar,
|
|
193
|
+
previewSideNav: props.previewSideNav,
|
|
192
194
|
onShow: (payload) => emit("show", payload),
|
|
193
195
|
onClose: () => emit("close"),
|
|
194
196
|
onSwitch: (index) => emit("switch", index)
|
|
195
197
|
});
|
|
196
198
|
}
|
|
199
|
+
function handlePreviewClick() {
|
|
200
|
+
if (!previewEnabled.value) return;
|
|
201
|
+
openPreview();
|
|
202
|
+
}
|
|
197
203
|
watch(
|
|
198
204
|
[() => props.src, () => props.ossProcess, () => props.ossLinks, () => props.imgSize, networkKey, imgUrlConfigKey],
|
|
199
205
|
([src]) => {
|
|
@@ -203,7 +209,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
203
209
|
);
|
|
204
210
|
__expose({
|
|
205
211
|
displaySrc,
|
|
206
|
-
retried
|
|
212
|
+
retried,
|
|
213
|
+
openPreview
|
|
207
214
|
});
|
|
208
215
|
return (_ctx, _cache) => {
|
|
209
216
|
return openBlock(), createElementBlock("span", {
|
|
@@ -241,7 +248,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({
|
|
|
241
248
|
};
|
|
242
249
|
}
|
|
243
250
|
}));
|
|
244
|
-
const FgViewImg = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
251
|
+
const FgViewImg = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c6ff5d38"]]);
|
|
245
252
|
export {
|
|
246
253
|
FgViewImg as F
|
|
247
254
|
};
|
package/dist/ViewImg.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.fg-view-img[data-v-
|
|
1
|
+
.fg-view-img[data-v-c6ff5d38] {
|
|
2
2
|
display: block;
|
|
3
3
|
position: relative;
|
|
4
4
|
overflow: hidden;
|
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
vertical-align: top;
|
|
8
8
|
line-height: 0;
|
|
9
9
|
}
|
|
10
|
-
.fg-view-img__inner[data-v-
|
|
10
|
+
.fg-view-img__inner[data-v-c6ff5d38] {
|
|
11
11
|
display: block;
|
|
12
12
|
width: 100%;
|
|
13
13
|
height: 100%;
|
|
14
14
|
}
|
|
15
|
-
.fg-view-img__inner--preview[data-v-
|
|
15
|
+
.fg-view-img__inner--preview[data-v-c6ff5d38] {
|
|
16
16
|
cursor: zoom-in;
|
|
17
17
|
}
|
|
18
|
-
.fg-view-img__placeholder[data-v-
|
|
19
|
-
.fg-view-img__error[data-v-
|
|
18
|
+
.fg-view-img__placeholder[data-v-c6ff5d38],
|
|
19
|
+
.fg-view-img__error[data-v-c6ff5d38] {
|
|
20
20
|
position: absolute;
|
|
21
21
|
inset: 0;
|
|
22
22
|
display: flex;
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
justify-content: center;
|
|
25
25
|
background: #f5f7fa;
|
|
26
26
|
}
|
|
27
|
-
.fg-view-img__error[data-v-
|
|
27
|
+
.fg-view-img__error[data-v-c6ff5d38] .error-image {
|
|
28
28
|
width: 100%;
|
|
29
29
|
height: 100%;
|
|
30
30
|
}
|
|
31
|
-
.fg-view-img__error-default[data-v-
|
|
31
|
+
.fg-view-img__error-default[data-v-c6ff5d38] {
|
|
32
32
|
position: relative;
|
|
33
33
|
width: 100%;
|
|
34
34
|
height: 100%;
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
padding: 8px;
|
|
41
41
|
box-sizing: border-box;
|
|
42
42
|
}
|
|
43
|
-
.fg-view-img__error-icon[data-v-
|
|
43
|
+
.fg-view-img__error-icon[data-v-c6ff5d38] {
|
|
44
44
|
flex: none;
|
|
45
45
|
width: 56%;
|
|
46
46
|
height: 56%;
|
|
47
47
|
max-width: 80px;
|
|
48
48
|
max-height: 80px;
|
|
49
49
|
}
|
|
50
|
-
.fg-view-img__error-text[data-v-
|
|
50
|
+
.fg-view-img__error-text[data-v-c6ff5d38] {
|
|
51
51
|
font-size: 13px;
|
|
52
52
|
line-height: 1.4;
|
|
53
53
|
color: #909399;
|
|
@@ -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
|
+
};
|
package/dist/ViewImgPopover.css
CHANGED
|
@@ -1,12 +1,74 @@
|
|
|
1
|
-
.fg-view-img-
|
|
1
|
+
.fg-view-img-popover__reference[data-v-868c46fb] {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: block;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
}
|
|
7
|
+
.fg-view-img-popover__preview-icon[data-v-868c46fb] {
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 4px;
|
|
10
|
+
right: 4px;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
line-height: 1;
|
|
13
|
+
color: var(--el-text-color-primary);
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
}
|
|
16
|
+
.fg-view-img-popover__preview-icon[data-v-868c46fb]:hover {
|
|
17
|
+
color: var(--el-color-primary);
|
|
18
|
+
}
|
|
19
|
+
.fg-view-img-popover__hover-image[data-v-868c46fb] {
|
|
20
|
+
display: block;
|
|
2
21
|
vertical-align: top;
|
|
22
|
+
background: #7f7f7f;
|
|
23
|
+
}
|
|
24
|
+
.fg-view-img-popover__hover-image[data-v-868c46fb] .fg-view-img__inner {
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
object-fit: contain;
|
|
28
|
+
}
|
|
29
|
+
.fg-view-img-popover__hover-image[data-v-868c46fb] .fg-view-img__placeholder,
|
|
30
|
+
.fg-view-img-popover__hover-image[data-v-868c46fb] .fg-view-img__error {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
background: #f5f7fa;
|
|
37
|
+
line-height: 1.4;
|
|
38
|
+
}
|
|
39
|
+
.fg-view-img-popover__hover-image[data-v-868c46fb] .fg-view-img__error-default {
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 100%;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
color: #909399;
|
|
46
|
+
font-size: 13px;
|
|
47
|
+
text-align: center;
|
|
3
48
|
}
|
|
4
|
-
.fg-view-img-popover__hover-image[data-v-
|
|
5
|
-
|
|
6
|
-
|
|
49
|
+
.fg-view-img-popover__hover-image[data-v-868c46fb] .fg-view-img__error-text {
|
|
50
|
+
color: #909399;
|
|
51
|
+
font-size: 13px;
|
|
52
|
+
line-height: 1.4;
|
|
53
|
+
text-align: center;
|
|
54
|
+
}
|
|
55
|
+
.fg-view-img-popover__hover-error[data-v-868c46fb] {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
width: 100%;
|
|
60
|
+
background: #f5f7fa;
|
|
61
|
+
color: #909399;
|
|
62
|
+
font-size: 13px;
|
|
63
|
+
line-height: 1.4;
|
|
64
|
+
text-align: center;
|
|
65
|
+
}.fg-view-img-popover__reference {
|
|
66
|
+
display: block;
|
|
67
|
+
width: 100%;
|
|
68
|
+
height: 100%;
|
|
7
69
|
max-width: 100%;
|
|
8
|
-
|
|
9
|
-
|
|
70
|
+
}
|
|
71
|
+
.fg-view-img-popover__trigger {
|
|
10
72
|
display: block;
|
|
11
73
|
width: 100%;
|
|
12
74
|
height: 100%;
|
|
@@ -23,11 +85,22 @@
|
|
|
23
85
|
display: flex;
|
|
24
86
|
justify-content: center;
|
|
25
87
|
align-items: center;
|
|
88
|
+
width: 100%;
|
|
26
89
|
max-width: 100%;
|
|
90
|
+
max-height: 100%;
|
|
27
91
|
line-height: 0;
|
|
28
92
|
}
|
|
29
93
|
.fg-view-img-popover.el-popper .fg-view-img-popover__watermark {
|
|
30
94
|
display: block;
|
|
95
|
+
width: 100%;
|
|
96
|
+
height: 380px;
|
|
31
97
|
max-width: 100%;
|
|
32
98
|
max-height: 380px;
|
|
99
|
+
}
|
|
100
|
+
.fg-view-img-popover.el-popper .fg-view-img-popover__watermark .el-watermark__content {
|
|
101
|
+
display: block;
|
|
102
|
+
width: 100%;
|
|
103
|
+
height: 100%;
|
|
104
|
+
max-width: 100%;
|
|
105
|
+
max-height: 100%;
|
|
33
106
|
}
|