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 @@
|
|
|
1
|
+
export { default as FgViewImgPopover } from './ViewImgPopover.vue';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OriginalToolbarItem, SimpleCustomTool, PreviewShowPayload } from './types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
visible?: boolean;
|
|
4
|
+
urlList?: string[];
|
|
5
|
+
initialIndex?: number;
|
|
6
|
+
infinite?: boolean;
|
|
7
|
+
zIndex?: number;
|
|
8
|
+
toolbarBgColor?: string;
|
|
9
|
+
toolbarIconColor?: string;
|
|
10
|
+
hideOnClickModal?: boolean;
|
|
11
|
+
closeOnPressEscape?: boolean;
|
|
12
|
+
teleported?: boolean;
|
|
13
|
+
zoomRate?: number;
|
|
14
|
+
scale?: number;
|
|
15
|
+
minScale?: number;
|
|
16
|
+
maxScale?: number;
|
|
17
|
+
showProgress?: boolean;
|
|
18
|
+
simpleExtraTools?: SimpleCustomTool[];
|
|
19
|
+
renderExtraTools?: import('vue').VNode | null;
|
|
20
|
+
originalToolbar?: OriginalToolbarItem[];
|
|
21
|
+
};
|
|
22
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
23
|
+
switch: (index: number) => any;
|
|
24
|
+
show: (payload: PreviewShowPayload) => any;
|
|
25
|
+
close: () => any;
|
|
26
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
27
|
+
onSwitch?: (index: number) => any;
|
|
28
|
+
onShow?: (payload: PreviewShowPayload) => any;
|
|
29
|
+
onClose?: () => any;
|
|
30
|
+
}>, {
|
|
31
|
+
scale: number;
|
|
32
|
+
zIndex: number;
|
|
33
|
+
infinite: boolean;
|
|
34
|
+
visible: boolean;
|
|
35
|
+
teleported: boolean;
|
|
36
|
+
closeOnPressEscape: boolean;
|
|
37
|
+
hideOnClickModal: boolean;
|
|
38
|
+
toolbarBgColor: string;
|
|
39
|
+
toolbarIconColor: string;
|
|
40
|
+
simpleExtraTools: SimpleCustomTool[];
|
|
41
|
+
renderExtraTools: import('vue').VNode | null;
|
|
42
|
+
originalToolbar: OriginalToolbarItem[];
|
|
43
|
+
zoomRate: number;
|
|
44
|
+
minScale: number;
|
|
45
|
+
maxScale: number;
|
|
46
|
+
showProgress: boolean;
|
|
47
|
+
initialIndex: number;
|
|
48
|
+
urlList: string[];
|
|
49
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as FgViewImgPreview } from './ViewImgPreview.vue';
|
|
2
|
+
export type { OriginalToolbarItem, SimpleCustomTool, ToolHandlerParams, ViewImgPreviewProps, ViewImgPreviewViewerOptions, PreviewShowPayload, } from './types';
|
|
3
|
+
export { DEFAULT_ORIGINAL_TOOLBAR, DEFAULT_TOOLBAR_BG_COLOR, DEFAULT_TOOLBAR_ICON_COLOR, DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL, DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE, DEFAULT_PREVIEW_TELEPORTED, DEFAULT_PREVIEW_INFINITE, DEFAULT_PREVIEW_ZOOM_RATE, DEFAULT_PREVIEW_SCALE, DEFAULT_PREVIEW_MIN_SCALE, DEFAULT_PREVIEW_MAX_SCALE, DEFAULT_PREVIEW_SHOW_PROGRESS, } from './types';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { _ } from "../../ViewImgPreview.vue_vue_type_style_index_0_lang-CYuLovBR.js";
|
|
2
|
+
import { D, a, b, c, d, e, f, g, h, i, j, k } from "../../types-BNFeGRer.js";
|
|
3
|
+
export {
|
|
4
|
+
D as DEFAULT_ORIGINAL_TOOLBAR,
|
|
5
|
+
a as DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE,
|
|
6
|
+
b as DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL,
|
|
7
|
+
c as DEFAULT_PREVIEW_INFINITE,
|
|
8
|
+
d as DEFAULT_PREVIEW_MAX_SCALE,
|
|
9
|
+
e as DEFAULT_PREVIEW_MIN_SCALE,
|
|
10
|
+
f as DEFAULT_PREVIEW_SCALE,
|
|
11
|
+
g as DEFAULT_PREVIEW_SHOW_PROGRESS,
|
|
12
|
+
h as DEFAULT_PREVIEW_TELEPORTED,
|
|
13
|
+
i as DEFAULT_PREVIEW_ZOOM_RATE,
|
|
14
|
+
j as DEFAULT_TOOLBAR_BG_COLOR,
|
|
15
|
+
k as DEFAULT_TOOLBAR_ICON_COLOR,
|
|
16
|
+
_ as FgViewImgPreview
|
|
17
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Component, VNode } from 'vue';
|
|
2
|
+
import { ImageViewerAction } from 'element-plus';
|
|
3
|
+
export type OriginalToolbarItem = "prev" | "next" | "fistImg" | "lastImg" | "zoomOut" | "zoomIn" | "anticlockwise" | "clockwise" | "reset";
|
|
4
|
+
export interface ToolHandlerParams {
|
|
5
|
+
/** 当前图片 URL */
|
|
6
|
+
url: string;
|
|
7
|
+
/** 当前索引 */
|
|
8
|
+
index: number;
|
|
9
|
+
/** 原生 actions 方法,控制缩放旋转 */
|
|
10
|
+
actions: (action: ImageViewerAction, options?: Record<string, unknown>) => void;
|
|
11
|
+
/** 重置方法 */
|
|
12
|
+
reset: () => void;
|
|
13
|
+
/** 切换到上一张 */
|
|
14
|
+
prev: () => void;
|
|
15
|
+
/** 切换到下一张 */
|
|
16
|
+
next: () => void;
|
|
17
|
+
/** 切换到指定索引 */
|
|
18
|
+
setActiveItem: (index: number) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface SimpleCustomTool extends Record<string, unknown> {
|
|
21
|
+
label: string;
|
|
22
|
+
icon: Component;
|
|
23
|
+
handler: (params: ToolHandlerParams) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_ORIGINAL_TOOLBAR: OriginalToolbarItem[];
|
|
26
|
+
/** 预览工具栏默认背景色(与 Element Plus ImageViewer 工具栏一致) */
|
|
27
|
+
export declare const DEFAULT_TOOLBAR_BG_COLOR = "#606266";
|
|
28
|
+
/** 预览工具栏默认图标色 */
|
|
29
|
+
export declare const DEFAULT_TOOLBAR_ICON_COLOR = "#ffffff";
|
|
30
|
+
/** ElImageViewer 预览默认:点击遮罩关闭 */
|
|
31
|
+
export declare const DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL = false;
|
|
32
|
+
/** ElImageViewer 预览默认:ESC 关闭 */
|
|
33
|
+
export declare const DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE = true;
|
|
34
|
+
/** ElImageViewer 预览默认:teleport 到 body(与 Element Plus 一致,避免在表格/transform 容器内铺满错位) */
|
|
35
|
+
export declare const DEFAULT_PREVIEW_TELEPORTED = true;
|
|
36
|
+
/** ElImageViewer 预览默认:无限循环 */
|
|
37
|
+
export declare const DEFAULT_PREVIEW_INFINITE = true;
|
|
38
|
+
/** ElImageViewer 预览默认:缩放速率 */
|
|
39
|
+
export declare const DEFAULT_PREVIEW_ZOOM_RATE = 1.2;
|
|
40
|
+
/** ElImageViewer 预览默认:初始缩放 */
|
|
41
|
+
export declare const DEFAULT_PREVIEW_SCALE = 1;
|
|
42
|
+
/** ElImageViewer 预览默认:最小缩放 */
|
|
43
|
+
export declare const DEFAULT_PREVIEW_MIN_SCALE = 0.2;
|
|
44
|
+
/** ElImageViewer 预览默认:最大缩放 */
|
|
45
|
+
export declare const DEFAULT_PREVIEW_MAX_SCALE = 7;
|
|
46
|
+
/** ElImageViewer 预览默认:显示进度 */
|
|
47
|
+
export declare const DEFAULT_PREVIEW_SHOW_PROGRESS = false;
|
|
48
|
+
/** 透传给 ElImageViewer 的预览配置(与 Element Plus ImageViewer 对齐) */
|
|
49
|
+
export type ViewImgPreviewViewerOptions = {
|
|
50
|
+
hideOnClickModal?: boolean;
|
|
51
|
+
closeOnPressEscape?: boolean;
|
|
52
|
+
teleported?: boolean;
|
|
53
|
+
infinite?: boolean;
|
|
54
|
+
zIndex?: number;
|
|
55
|
+
zoomRate?: number;
|
|
56
|
+
scale?: number;
|
|
57
|
+
minScale?: number;
|
|
58
|
+
maxScale?: number;
|
|
59
|
+
showProgress?: boolean;
|
|
60
|
+
};
|
|
61
|
+
export type ViewImgPreviewProps = ViewImgPreviewViewerOptions & {
|
|
62
|
+
urlList: string[];
|
|
63
|
+
initialIndex?: number;
|
|
64
|
+
/** 预览工具栏背景色 */
|
|
65
|
+
toolbarBgColor?: string;
|
|
66
|
+
/** 预览工具栏图标/文字颜色 */
|
|
67
|
+
toolbarIconColor?: string;
|
|
68
|
+
simpleExtraTools?: SimpleCustomTool[];
|
|
69
|
+
renderExtraTools?: VNode | null;
|
|
70
|
+
originalToolbar?: OriginalToolbarItem[];
|
|
71
|
+
};
|
|
72
|
+
/** 预览层打开时回调参数 */
|
|
73
|
+
export type PreviewShowPayload = {
|
|
74
|
+
/** 当前展示索引 */
|
|
75
|
+
index: number;
|
|
76
|
+
/** 预览图片列表 */
|
|
77
|
+
urlList: string[];
|
|
78
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { reactive } from "vue";
|
|
2
|
+
import { D as DEFAULT_ORIGINAL_TOOLBAR, 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, h as DEFAULT_PREVIEW_TELEPORTED, a as DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE, b as DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL, k as DEFAULT_TOOLBAR_ICON_COLOR, j as DEFAULT_TOOLBAR_BG_COLOR, c as DEFAULT_PREVIEW_INFINITE } from "./types-BNFeGRer.js";
|
|
3
|
+
const PREVIEW_BASE_Z_INDEX = 2e3;
|
|
4
|
+
function getDialogZindex() {
|
|
5
|
+
const dialogs = Array.from(document.querySelectorAll(".el-overlay"));
|
|
6
|
+
let maxZIndex = 0;
|
|
7
|
+
dialogs.forEach((dialog) => {
|
|
8
|
+
const zIndex = Number.parseInt(window.getComputedStyle(dialog).zIndex, 10);
|
|
9
|
+
if (zIndex > maxZIndex) maxZIndex = zIndex;
|
|
10
|
+
});
|
|
11
|
+
return Math.max(maxZIndex, PREVIEW_BASE_Z_INDEX);
|
|
12
|
+
}
|
|
13
|
+
const state = reactive({
|
|
14
|
+
hostActivated: false,
|
|
15
|
+
showImgPreview: false,
|
|
16
|
+
previewImgList: [],
|
|
17
|
+
defImgPreviewIndex: 0,
|
|
18
|
+
infinite: DEFAULT_PREVIEW_INFINITE,
|
|
19
|
+
zIndex: 2e3,
|
|
20
|
+
toolbarBgColor: DEFAULT_TOOLBAR_BG_COLOR,
|
|
21
|
+
toolbarIconColor: DEFAULT_TOOLBAR_ICON_COLOR,
|
|
22
|
+
hideOnClickModal: DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL,
|
|
23
|
+
closeOnPressEscape: DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE,
|
|
24
|
+
teleported: DEFAULT_PREVIEW_TELEPORTED,
|
|
25
|
+
zoomRate: DEFAULT_PREVIEW_ZOOM_RATE,
|
|
26
|
+
scale: DEFAULT_PREVIEW_SCALE,
|
|
27
|
+
minScale: DEFAULT_PREVIEW_MIN_SCALE,
|
|
28
|
+
maxScale: DEFAULT_PREVIEW_MAX_SCALE,
|
|
29
|
+
showProgress: DEFAULT_PREVIEW_SHOW_PROGRESS,
|
|
30
|
+
simpleExtraTools: [],
|
|
31
|
+
renderExtraTools: null,
|
|
32
|
+
originalToolbar: [...DEFAULT_ORIGINAL_TOOLBAR],
|
|
33
|
+
onShow: null,
|
|
34
|
+
onClose: null,
|
|
35
|
+
onSwitch: null
|
|
36
|
+
});
|
|
37
|
+
function createImgViewerStore() {
|
|
38
|
+
return {
|
|
39
|
+
// 预览宿主是否已经被激活过
|
|
40
|
+
get hostActivated() {
|
|
41
|
+
return state.hostActivated;
|
|
42
|
+
},
|
|
43
|
+
// 显示预览层
|
|
44
|
+
get showImgPreview() {
|
|
45
|
+
return state.showImgPreview;
|
|
46
|
+
},
|
|
47
|
+
// 预览图片列表
|
|
48
|
+
get previewImgList() {
|
|
49
|
+
return state.previewImgList;
|
|
50
|
+
},
|
|
51
|
+
// 默认预览图片索引
|
|
52
|
+
get defImgPreviewIndex() {
|
|
53
|
+
return state.defImgPreviewIndex;
|
|
54
|
+
},
|
|
55
|
+
// 无限循环
|
|
56
|
+
get infinite() {
|
|
57
|
+
return state.infinite;
|
|
58
|
+
},
|
|
59
|
+
// 预览层 z-index
|
|
60
|
+
get zIndex() {
|
|
61
|
+
return state.zIndex;
|
|
62
|
+
},
|
|
63
|
+
// 工具栏背景色
|
|
64
|
+
get toolbarBgColor() {
|
|
65
|
+
return state.toolbarBgColor;
|
|
66
|
+
},
|
|
67
|
+
// 工具栏图标颜色
|
|
68
|
+
get toolbarIconColor() {
|
|
69
|
+
return state.toolbarIconColor;
|
|
70
|
+
},
|
|
71
|
+
// 点击蒙层关闭
|
|
72
|
+
get hideOnClickModal() {
|
|
73
|
+
return state.hideOnClickModal;
|
|
74
|
+
},
|
|
75
|
+
// 按下 ESC 关闭
|
|
76
|
+
get closeOnPressEscape() {
|
|
77
|
+
return state.closeOnPressEscape;
|
|
78
|
+
},
|
|
79
|
+
// 是否使用 teleport
|
|
80
|
+
get teleported() {
|
|
81
|
+
return state.teleported;
|
|
82
|
+
},
|
|
83
|
+
// 缩放率
|
|
84
|
+
get zoomRate() {
|
|
85
|
+
return state.zoomRate;
|
|
86
|
+
},
|
|
87
|
+
// 缩放比例
|
|
88
|
+
get scale() {
|
|
89
|
+
return state.scale;
|
|
90
|
+
},
|
|
91
|
+
// 最小缩放比例
|
|
92
|
+
get minScale() {
|
|
93
|
+
return state.minScale;
|
|
94
|
+
},
|
|
95
|
+
// 最大缩放比例
|
|
96
|
+
get maxScale() {
|
|
97
|
+
return state.maxScale;
|
|
98
|
+
},
|
|
99
|
+
// 是否显示进度
|
|
100
|
+
get showProgress() {
|
|
101
|
+
return state.showProgress;
|
|
102
|
+
},
|
|
103
|
+
// 自定义工具
|
|
104
|
+
get simpleExtraTools() {
|
|
105
|
+
return state.simpleExtraTools;
|
|
106
|
+
},
|
|
107
|
+
// 自定义工具栏
|
|
108
|
+
get renderExtraTools() {
|
|
109
|
+
return state.renderExtraTools;
|
|
110
|
+
},
|
|
111
|
+
// 内置工具栏
|
|
112
|
+
get originalToolbar() {
|
|
113
|
+
return state.originalToolbar;
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* 显示预览层
|
|
117
|
+
* @param options 配置选项
|
|
118
|
+
* @param options.previewImgList 预览图片列表
|
|
119
|
+
* @param options.defImgPreviewIndex 默认预览图片索引
|
|
120
|
+
* @param options.backgroundColor 背景颜色
|
|
121
|
+
* @param options.toolbarBgColor 工具栏背景颜色
|
|
122
|
+
* @param options.toolbarIconColor 工具栏图标颜色
|
|
123
|
+
* @param options.infinite 是否无限循环
|
|
124
|
+
* @param options.zIndex z-index
|
|
125
|
+
* @param options.hideOnClickModal 点击蒙层关闭
|
|
126
|
+
* @param options.closeOnPressEscape 按下 ESC 关闭
|
|
127
|
+
* @param options.teleported 是否使用 teleport
|
|
128
|
+
* @param options.zoomRate 缩放率
|
|
129
|
+
* @param options.scale 缩放比例
|
|
130
|
+
* @param options.minScale 最小缩放比例
|
|
131
|
+
* @param options.maxScale 最大缩放比例
|
|
132
|
+
* @param options.showProgress 是否显示进度
|
|
133
|
+
* @param options.simpleExtraTools 自定义工具
|
|
134
|
+
* @param options.renderExtraTools 自定义工具栏
|
|
135
|
+
* @param options.originalToolbar 内置工具栏
|
|
136
|
+
* @param options.onShow 预览层打开时回调
|
|
137
|
+
* @param options.onClose 预览层关闭时回调
|
|
138
|
+
* @param options.onSwitch 预览切换图片时回调
|
|
139
|
+
*/
|
|
140
|
+
showImgViewer(options = {}) {
|
|
141
|
+
const {
|
|
142
|
+
previewImgList = [],
|
|
143
|
+
defImgPreviewIndex = 0,
|
|
144
|
+
backgroundColor = "",
|
|
145
|
+
toolbarBgColor,
|
|
146
|
+
toolbarIconColor,
|
|
147
|
+
infinite = DEFAULT_PREVIEW_INFINITE,
|
|
148
|
+
zIndex,
|
|
149
|
+
hideOnClickModal = DEFAULT_PREVIEW_HIDE_ON_CLICK_MODAL,
|
|
150
|
+
closeOnPressEscape = DEFAULT_PREVIEW_CLOSE_ON_PRESS_ESCAPE,
|
|
151
|
+
teleported = DEFAULT_PREVIEW_TELEPORTED,
|
|
152
|
+
zoomRate = DEFAULT_PREVIEW_ZOOM_RATE,
|
|
153
|
+
scale = DEFAULT_PREVIEW_SCALE,
|
|
154
|
+
minScale = DEFAULT_PREVIEW_MIN_SCALE,
|
|
155
|
+
maxScale = DEFAULT_PREVIEW_MAX_SCALE,
|
|
156
|
+
showProgress = DEFAULT_PREVIEW_SHOW_PROGRESS,
|
|
157
|
+
simpleExtraTools = [],
|
|
158
|
+
renderExtraTools = null,
|
|
159
|
+
originalToolbar = [...DEFAULT_ORIGINAL_TOOLBAR],
|
|
160
|
+
onShow,
|
|
161
|
+
onClose,
|
|
162
|
+
onSwitch
|
|
163
|
+
} = options;
|
|
164
|
+
state.zIndex = zIndex != null ? zIndex : getDialogZindex() + 1;
|
|
165
|
+
if (previewImgList.length) {
|
|
166
|
+
state.previewImgList = previewImgList;
|
|
167
|
+
}
|
|
168
|
+
if (defImgPreviewIndex != null) {
|
|
169
|
+
state.defImgPreviewIndex = defImgPreviewIndex;
|
|
170
|
+
}
|
|
171
|
+
const bgColor = toolbarBgColor || backgroundColor;
|
|
172
|
+
state.toolbarBgColor = bgColor || DEFAULT_TOOLBAR_BG_COLOR;
|
|
173
|
+
state.toolbarIconColor = toolbarIconColor || DEFAULT_TOOLBAR_ICON_COLOR;
|
|
174
|
+
state.infinite = infinite;
|
|
175
|
+
state.hideOnClickModal = hideOnClickModal;
|
|
176
|
+
state.closeOnPressEscape = closeOnPressEscape;
|
|
177
|
+
state.teleported = teleported;
|
|
178
|
+
state.zoomRate = zoomRate;
|
|
179
|
+
state.scale = scale;
|
|
180
|
+
state.minScale = minScale;
|
|
181
|
+
state.maxScale = maxScale;
|
|
182
|
+
state.showProgress = showProgress;
|
|
183
|
+
state.simpleExtraTools = simpleExtraTools;
|
|
184
|
+
state.renderExtraTools = renderExtraTools;
|
|
185
|
+
state.originalToolbar = originalToolbar;
|
|
186
|
+
state.onShow = onShow != null ? onShow : null;
|
|
187
|
+
state.onClose = onClose != null ? onClose : null;
|
|
188
|
+
state.onSwitch = onSwitch != null ? onSwitch : null;
|
|
189
|
+
state.hostActivated = true;
|
|
190
|
+
state.showImgPreview = true;
|
|
191
|
+
},
|
|
192
|
+
// 隐藏预览层
|
|
193
|
+
hideImgViewer() {
|
|
194
|
+
state.showImgPreview = false;
|
|
195
|
+
state.onShow = null;
|
|
196
|
+
state.onClose = null;
|
|
197
|
+
state.onSwitch = null;
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* 设置默认预览图片索引
|
|
201
|
+
* @param defImgPreviewIndex 目标索引
|
|
202
|
+
*/
|
|
203
|
+
setDefImgPreviewIndex(defImgPreviewIndex) {
|
|
204
|
+
state.defImgPreviewIndex = defImgPreviewIndex;
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* 设置是否无限循环
|
|
208
|
+
* @param bol 是否无限循环
|
|
209
|
+
*/
|
|
210
|
+
setInfinite(bol) {
|
|
211
|
+
state.infinite = bol;
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* 设置预览层 z-index
|
|
215
|
+
* @param index z-index 数值
|
|
216
|
+
*/
|
|
217
|
+
setZindex(index) {
|
|
218
|
+
state.zIndex = index;
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
let storeInstance = null;
|
|
223
|
+
function useImgViewerStore() {
|
|
224
|
+
if (!storeInstance) {
|
|
225
|
+
storeInstance = createImgViewerStore();
|
|
226
|
+
}
|
|
227
|
+
return storeInstance;
|
|
228
|
+
}
|
|
229
|
+
function ImgViewerStore() {
|
|
230
|
+
return useImgViewerStore();
|
|
231
|
+
}
|
|
232
|
+
function useImgViewerState() {
|
|
233
|
+
return state;
|
|
234
|
+
}
|
|
235
|
+
export {
|
|
236
|
+
ImgViewerStore as I,
|
|
237
|
+
PREVIEW_BASE_Z_INDEX as P,
|
|
238
|
+
useImgViewerStore as a,
|
|
239
|
+
getDialogZindex as g,
|
|
240
|
+
useImgViewerState as u
|
|
241
|
+
};
|