sakura-preview-file 1.0.5 → 1.0.7
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/dist/index.es.js +671 -343
- package/dist/index.umd.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/hooks/index.d.ts +6 -0
- package/dist/types/hooks/use-file-preview-tools/index.d.ts +19 -0
- package/dist/types/hooks/use-file-state/index.d.ts +5 -0
- package/dist/types/hooks/use-mouse-event/index.d.ts +7 -0
- package/dist/types/hooks/use-namespace/index.d.ts +26 -0
- package/dist/types/hooks/use-preview-file/index.d.ts +5 -0
- package/dist/types/hooks/use-wheel-event/index.d.ts +14 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/preview-file/Dialog/Dialog.vue.d.ts +37 -0
- package/dist/types/preview-file/Dialog/Overlay.vue.d.ts +18 -0
- package/dist/types/preview-file/Dialog/index.d.ts +2 -0
- package/dist/types/preview-file/Image/Close.vue.d.ts +7 -0
- package/dist/types/preview-file/Image/Image.vue.d.ts +12 -0
- package/dist/types/preview-file/Image/Preview.vue.d.ts +14 -0
- package/dist/types/preview-file/Image/ZoomIn.vue.d.ts +2 -0
- package/dist/types/preview-file/Image/ZoomOut.vue.d.ts +2 -0
- package/dist/types/preview-file/Loading/Circle.vue.d.ts +7 -0
- package/dist/types/preview-file/Loading/Cube.vue.d.ts +7 -0
- package/dist/types/preview-file/Loading/Dot.vue.d.ts +8 -0
- package/dist/types/preview-file/Loading/Progress.vue.d.ts +9 -0
- package/dist/types/preview-file/Loading/index.d.ts +26 -0
- package/dist/types/preview-file/Loading/props.d.ts +40 -0
- package/dist/types/preview-file/Pdf/Pdf.vue.d.ts +44 -0
- package/dist/types/preview-file/Pdf/use-preview-pdf.d.ts +9 -0
- package/dist/types/preview-file/Tools.vue.d.ts +37 -0
- package/dist/types/preview-file/Word/Word.vue.d.ts +39 -0
- package/dist/types/preview-file/constant.d.ts +6 -0
- package/dist/types/preview-file/event.d.ts +29 -0
- package/dist/types/preview-file/index.d.ts +7 -0
- package/dist/types/preview-file/preview-file-dialog.vue.d.ts +5 -0
- package/dist/types/preview-file/preview-file.vue.d.ts +53 -0
- package/dist/types/preview-file/register-component.d.ts +11 -0
- package/dist/types/preview-file/type.d.ts +110 -0
- package/dist/types/preview-file/utils.d.ts +6 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts +23 -0
- package/package.json +7 -5
- package/index.d.ts +0 -103
package/dist/index.es.js
CHANGED
|
@@ -1,168 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { unref, ref, computed, watchEffect, watch, getCurrentInstance, defineComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, mergeModels, useModel, onMounted, onBeforeUnmount, createBlock, Teleport, createVNode, withCtx, normalizeStyle, toDisplayString, createCommentVNode, Fragment, renderList, withDirectives, vModelText, reactive, toRefs, isRef, nextTick, useTemplateRef, provide, resolveDynamicComponent, normalizeProps, guardReactiveProps, vShow, mergeProps, render } from "vue";
|
|
2
|
+
import { isEmpty, FILE_TYPE, getFileType, base64ToFileUrl, blobToBase64, isBase64File, networkFileUrlToLocalFileUrl, numberToFixed, addUnit, sleep, extend, base64ToFile, generateId, isPdfFile, isWordFile, isImageFile } from "sakura-utils";
|
|
3
|
+
import { useThrottleFn, useWindowSize } from "@vueuse/core";
|
|
3
4
|
import VuePdfEmbed from "vue-pdf-embed";
|
|
4
5
|
import "pdfjs-dist";
|
|
5
|
-
import { useThrottleFn, useWindowSize } from "@vueuse/core";
|
|
6
6
|
import { renderAsync } from "docx-preview";
|
|
7
|
-
const index = "";
|
|
8
|
-
const _hoisted_1$7 = ["stroke"];
|
|
9
|
-
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
10
|
-
__name: "Circle",
|
|
11
|
-
props: {
|
|
12
|
-
size: { default: 50 },
|
|
13
|
-
color: { default: "#409eff" },
|
|
14
|
-
duration: { default: 2 }
|
|
15
|
-
},
|
|
16
|
-
setup(__props) {
|
|
17
|
-
const props = __props;
|
|
18
|
-
const circleStyle = computed(() => {
|
|
19
|
-
const { size, duration } = props;
|
|
20
|
-
const style = {
|
|
21
|
-
"--circle-size": addUnit(size),
|
|
22
|
-
"--circle-duration": `${duration}s`
|
|
23
|
-
};
|
|
24
|
-
return style;
|
|
25
|
-
});
|
|
26
|
-
return (_ctx, _cache) => {
|
|
27
|
-
return openBlock(), createElementBlock("svg", {
|
|
28
|
-
class: "circular",
|
|
29
|
-
viewBox: "0 0 50 50",
|
|
30
|
-
style: normalizeStyle([circleStyle.value])
|
|
31
|
-
}, [
|
|
32
|
-
createElementVNode("circle", {
|
|
33
|
-
class: "circular__path-inner",
|
|
34
|
-
cx: "25",
|
|
35
|
-
cy: "25",
|
|
36
|
-
r: "20",
|
|
37
|
-
fill: "none",
|
|
38
|
-
stroke: __props.color,
|
|
39
|
-
"stroke-width": "4",
|
|
40
|
-
"stroke-miterlimit": "10"
|
|
41
|
-
}, null, 8, _hoisted_1$7)
|
|
42
|
-
], 4);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const Circle_vue_vue_type_style_index_0_scoped_51d1fa15_lang = "";
|
|
47
|
-
const _export_sfc = (sfc, props) => {
|
|
48
|
-
const target = sfc.__vccOpts || sfc;
|
|
49
|
-
for (const [key, val] of props) {
|
|
50
|
-
target[key] = val;
|
|
51
|
-
}
|
|
52
|
-
return target;
|
|
53
|
-
};
|
|
54
|
-
const Circle = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-51d1fa15"]]);
|
|
55
|
-
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
56
|
-
__name: "Dot",
|
|
57
|
-
props: {
|
|
58
|
-
gap: { default: 6 },
|
|
59
|
-
color: { default: "var(--preview-file-primary-color)" },
|
|
60
|
-
size: { default: 10 },
|
|
61
|
-
duration: { default: 1.4 }
|
|
62
|
-
},
|
|
63
|
-
setup(__props) {
|
|
64
|
-
const props = __props;
|
|
65
|
-
const dotStyle = computed(() => {
|
|
66
|
-
const { size, gap, duration, color } = props;
|
|
67
|
-
const style = {
|
|
68
|
-
"--dot-size": addUnit(size),
|
|
69
|
-
"--dot-duration": `${duration}s`,
|
|
70
|
-
"--dot-gap": addUnit(gap),
|
|
71
|
-
"--dot-color": color
|
|
72
|
-
};
|
|
73
|
-
return style;
|
|
74
|
-
});
|
|
75
|
-
return (_ctx, _cache) => {
|
|
76
|
-
return openBlock(), createElementBlock("div", {
|
|
77
|
-
class: "dot",
|
|
78
|
-
style: normalizeStyle([dotStyle.value])
|
|
79
|
-
}, [..._cache[0] || (_cache[0] = [
|
|
80
|
-
createElementVNode("div", { class: "dot__item" }, null, -1),
|
|
81
|
-
createElementVNode("div", { class: "dot__item" }, null, -1),
|
|
82
|
-
createElementVNode("div", { class: "dot__item" }, null, -1)
|
|
83
|
-
])], 4);
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
const Dot_vue_vue_type_style_index_0_scoped_2acd99b5_lang = "";
|
|
88
|
-
const Dot = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-2acd99b5"]]);
|
|
89
|
-
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
90
|
-
__name: "Progress",
|
|
91
|
-
props: {
|
|
92
|
-
width: { default: 200 },
|
|
93
|
-
height: { default: 4 },
|
|
94
|
-
background: { default: "#ebeef5" },
|
|
95
|
-
radius: {},
|
|
96
|
-
color: { default: "var(--preview-file-primary-color)" },
|
|
97
|
-
duration: { default: 2 }
|
|
98
|
-
},
|
|
99
|
-
setup(__props) {
|
|
100
|
-
const props = __props;
|
|
101
|
-
const progressStyle = computed(() => {
|
|
102
|
-
const { width, height, color, duration, radius, background } = props;
|
|
103
|
-
const style = {
|
|
104
|
-
"--progress-width": addUnit(width),
|
|
105
|
-
"--progress-height": addUnit(height),
|
|
106
|
-
"--progress-border-radius": addUnit(radius ? radius : Number(height) / 2),
|
|
107
|
-
"--progress-background": background,
|
|
108
|
-
"--progress-duration": `${duration}s`,
|
|
109
|
-
"--progress-color": color
|
|
110
|
-
};
|
|
111
|
-
return style;
|
|
112
|
-
});
|
|
113
|
-
return (_ctx, _cache) => {
|
|
114
|
-
return openBlock(), createElementBlock("div", {
|
|
115
|
-
class: "progress",
|
|
116
|
-
style: normalizeStyle([progressStyle.value])
|
|
117
|
-
}, [..._cache[0] || (_cache[0] = [
|
|
118
|
-
createElementVNode("div", { class: "progress__bar" }, null, -1)
|
|
119
|
-
])], 4);
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
const Progress_vue_vue_type_style_index_0_scoped_3a710001_lang = "";
|
|
124
|
-
const Progress = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-3a710001"]]);
|
|
125
|
-
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
126
|
-
__name: "Cube",
|
|
127
|
-
props: {
|
|
128
|
-
size: { default: 40 },
|
|
129
|
-
color: { default: "var(--preview-file-primary-color)" },
|
|
130
|
-
duration: { default: 1.3 }
|
|
131
|
-
},
|
|
132
|
-
setup(__props) {
|
|
133
|
-
const props = __props;
|
|
134
|
-
const cubeStyle = computed(() => {
|
|
135
|
-
const { size, duration, color } = props;
|
|
136
|
-
const style = {
|
|
137
|
-
"--cube-size": addUnit(size),
|
|
138
|
-
"--cube-color": color,
|
|
139
|
-
"--cube-duration": `${duration}s`
|
|
140
|
-
};
|
|
141
|
-
return style;
|
|
142
|
-
});
|
|
143
|
-
return (_ctx, _cache) => {
|
|
144
|
-
return openBlock(), createElementBlock("div", {
|
|
145
|
-
class: "cube",
|
|
146
|
-
style: normalizeStyle([cubeStyle.value])
|
|
147
|
-
}, [
|
|
148
|
-
(openBlock(), createElementBlock(Fragment, null, renderList(9, (v) => {
|
|
149
|
-
return createElementVNode("div", {
|
|
150
|
-
key: v,
|
|
151
|
-
class: "cube__item"
|
|
152
|
-
});
|
|
153
|
-
}), 64))
|
|
154
|
-
], 4);
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
const Cube_vue_vue_type_style_index_0_scoped_0e6bb9d0_lang = "";
|
|
159
|
-
const Cube = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["__scopeId", "data-v-0e6bb9d0"]]);
|
|
160
|
-
const Loading = {
|
|
161
|
-
Circle,
|
|
162
|
-
Dot,
|
|
163
|
-
Progress,
|
|
164
|
-
Cube
|
|
165
|
-
};
|
|
166
7
|
const defaultNamespace = "sakura";
|
|
167
8
|
const statePrefix = "is-";
|
|
168
9
|
const _bem = (namespace, block, blockSuffix, element, modifier) => {
|
|
@@ -381,35 +222,369 @@ const usePreviewFileTools = (fileUrl, pageNum) => {
|
|
|
381
222
|
transform: `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
|
|
382
223
|
transformOrigin: "center center"
|
|
383
224
|
};
|
|
384
|
-
});
|
|
385
|
-
const resetPdfData = () => {
|
|
386
|
-
resetMouseState();
|
|
387
|
-
resetWheelState();
|
|
388
|
-
};
|
|
389
|
-
watch(() => pageNum == null ? void 0 : pageNum.value, resetPdfData);
|
|
390
|
-
const wrapperRef = ref(null);
|
|
391
|
-
watch(() => fileUrl.value, () => {
|
|
392
|
-
if (!wrapperRef.value) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
wrapperRef.value.scrollTop = 0;
|
|
396
|
-
resetPdfData();
|
|
397
|
-
});
|
|
398
|
-
return {
|
|
399
|
-
wrapperRef,
|
|
400
|
-
onWheel,
|
|
401
|
-
clickMinusScale,
|
|
402
|
-
clickPlusScale,
|
|
403
|
-
resetWheelState,
|
|
404
|
-
scale,
|
|
405
|
-
scaleText,
|
|
406
|
-
isMouseDown,
|
|
407
|
-
onMouseStart,
|
|
408
|
-
resetMouseState,
|
|
409
|
-
translateX,
|
|
410
|
-
translateY,
|
|
411
|
-
wrapperStyle
|
|
412
|
-
};
|
|
225
|
+
});
|
|
226
|
+
const resetPdfData = () => {
|
|
227
|
+
resetMouseState();
|
|
228
|
+
resetWheelState();
|
|
229
|
+
};
|
|
230
|
+
watch(() => pageNum == null ? void 0 : pageNum.value, resetPdfData);
|
|
231
|
+
const wrapperRef = ref(null);
|
|
232
|
+
watch(() => fileUrl.value, () => {
|
|
233
|
+
if (!wrapperRef.value) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
wrapperRef.value.scrollTop = 0;
|
|
237
|
+
resetPdfData();
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
wrapperRef,
|
|
241
|
+
onWheel,
|
|
242
|
+
clickMinusScale,
|
|
243
|
+
clickPlusScale,
|
|
244
|
+
resetWheelState,
|
|
245
|
+
scale,
|
|
246
|
+
scaleText,
|
|
247
|
+
isMouseDown,
|
|
248
|
+
onMouseStart,
|
|
249
|
+
resetMouseState,
|
|
250
|
+
translateX,
|
|
251
|
+
translateY,
|
|
252
|
+
wrapperStyle
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
const usePreviewFile = () => {
|
|
256
|
+
const proxy = getCurrentInstance();
|
|
257
|
+
return proxy == null ? void 0 : proxy.appContext.config.globalProperties.$previewFile;
|
|
258
|
+
};
|
|
259
|
+
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
260
|
+
__name: "Overlay",
|
|
261
|
+
props: {
|
|
262
|
+
visible: { type: Boolean }
|
|
263
|
+
},
|
|
264
|
+
setup(__props) {
|
|
265
|
+
const ns = useNamespace("overlay");
|
|
266
|
+
return (_ctx, _cache) => {
|
|
267
|
+
return openBlock(), createElementBlock("div", {
|
|
268
|
+
class: normalizeClass([
|
|
269
|
+
unref(ns).b(),
|
|
270
|
+
unref(ns).is("active", __props.visible)
|
|
271
|
+
])
|
|
272
|
+
}, [
|
|
273
|
+
createElementVNode("div", {
|
|
274
|
+
class: normalizeClass([unref(ns).e("content")]),
|
|
275
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
276
|
+
}, ["prevent", "stop"]))
|
|
277
|
+
}, [
|
|
278
|
+
renderSlot(_ctx.$slots, "default")
|
|
279
|
+
], 2)
|
|
280
|
+
], 2);
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const _hoisted_1$5 = {
|
|
285
|
+
width: "24",
|
|
286
|
+
height: "24",
|
|
287
|
+
viewBox: "0 0 24 24",
|
|
288
|
+
fill: "none",
|
|
289
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
290
|
+
};
|
|
291
|
+
const _hoisted_2 = ["stroke"];
|
|
292
|
+
const _hoisted_3 = ["stroke"];
|
|
293
|
+
const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
294
|
+
__name: "Close",
|
|
295
|
+
props: {
|
|
296
|
+
color: { default: "#fff" }
|
|
297
|
+
},
|
|
298
|
+
setup(__props) {
|
|
299
|
+
return (_ctx, _cache) => {
|
|
300
|
+
return openBlock(), createElementBlock("svg", _hoisted_1$5, [
|
|
301
|
+
createElementVNode("path", {
|
|
302
|
+
d: "M7 7L17 17",
|
|
303
|
+
stroke: __props.color,
|
|
304
|
+
"stroke-width": "2",
|
|
305
|
+
"stroke-linecap": "round",
|
|
306
|
+
"stroke-linejoin": "round"
|
|
307
|
+
}, null, 8, _hoisted_2),
|
|
308
|
+
createElementVNode("path", {
|
|
309
|
+
d: "M7 17L17 7",
|
|
310
|
+
stroke: __props.color,
|
|
311
|
+
"stroke-width": "2",
|
|
312
|
+
"stroke-linecap": "round",
|
|
313
|
+
"stroke-linejoin": "round"
|
|
314
|
+
}, null, 8, _hoisted_3)
|
|
315
|
+
]);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
320
|
+
__name: "Dialog",
|
|
321
|
+
props: /* @__PURE__ */ mergeModels({
|
|
322
|
+
title: {},
|
|
323
|
+
top: { default: "15vh" },
|
|
324
|
+
width: { default: "50vw" },
|
|
325
|
+
background: { default: "white" },
|
|
326
|
+
radius: { default: 12 },
|
|
327
|
+
showClose: { type: Boolean, default: true },
|
|
328
|
+
closeOnClickModal: { type: Boolean, default: true },
|
|
329
|
+
closeOnPressEscape: { type: Boolean, default: true }
|
|
330
|
+
}, {
|
|
331
|
+
"modelValue": {
|
|
332
|
+
type: Boolean,
|
|
333
|
+
default: false
|
|
334
|
+
},
|
|
335
|
+
"modelModifiers": {}
|
|
336
|
+
}),
|
|
337
|
+
emits: ["update:modelValue"],
|
|
338
|
+
setup(__props) {
|
|
339
|
+
const ns = useNamespace("dialog");
|
|
340
|
+
const props = __props;
|
|
341
|
+
const dialogStyle = computed(() => {
|
|
342
|
+
const { width, top, radius, background } = props;
|
|
343
|
+
return ns.cssBlockVar("dialog", {
|
|
344
|
+
width: addUnit(width),
|
|
345
|
+
top: addUnit(top),
|
|
346
|
+
"border-radius": addUnit(radius),
|
|
347
|
+
background: addUnit(background)
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
const showDialog = useModel(__props, "modelValue");
|
|
351
|
+
const handleShowDialog = useThrottleFn(() => {
|
|
352
|
+
showDialog.value = !showDialog.value;
|
|
353
|
+
}, 500);
|
|
354
|
+
const isInit = ref(false);
|
|
355
|
+
const initWatch = watch(() => showDialog.value, (value) => {
|
|
356
|
+
if (!isInit.value && value) {
|
|
357
|
+
isInit.value = true;
|
|
358
|
+
initWatch.stop();
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
const onKeyDown = useThrottleFn((e) => {
|
|
362
|
+
if (e.key !== "Escape") {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (!showDialog.value) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
handleShowDialog();
|
|
369
|
+
}, 500);
|
|
370
|
+
onMounted(() => {
|
|
371
|
+
props.closeOnPressEscape && window.addEventListener("keydown", onKeyDown);
|
|
372
|
+
});
|
|
373
|
+
onBeforeUnmount(() => {
|
|
374
|
+
props.closeOnPressEscape && window.removeEventListener("keydown", onKeyDown);
|
|
375
|
+
});
|
|
376
|
+
const overlayClick = () => {
|
|
377
|
+
props.closeOnClickModal && handleShowDialog();
|
|
378
|
+
};
|
|
379
|
+
return (_ctx, _cache) => {
|
|
380
|
+
return openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
381
|
+
createVNode(_sfc_main$f, {
|
|
382
|
+
visible: showDialog.value,
|
|
383
|
+
onClick: overlayClick
|
|
384
|
+
}, {
|
|
385
|
+
default: withCtx(() => [
|
|
386
|
+
isInit.value ? (openBlock(), createElementBlock("div", {
|
|
387
|
+
key: 0,
|
|
388
|
+
class: normalizeClass([
|
|
389
|
+
unref(ns).b(),
|
|
390
|
+
unref(ns).is("active", showDialog.value)
|
|
391
|
+
]),
|
|
392
|
+
style: normalizeStyle([dialogStyle.value])
|
|
393
|
+
}, [
|
|
394
|
+
_ctx.$slots.header || !unref(isEmpty)(__props.title) ? (openBlock(), createElementBlock("div", {
|
|
395
|
+
key: 0,
|
|
396
|
+
class: normalizeClass([unref(ns).e("header")])
|
|
397
|
+
}, [
|
|
398
|
+
__props.title ? (openBlock(), createElementBlock("span", {
|
|
399
|
+
key: 0,
|
|
400
|
+
class: normalizeClass([unref(ns).e("title")])
|
|
401
|
+
}, toDisplayString(__props.title), 3)) : createCommentVNode("", true),
|
|
402
|
+
renderSlot(_ctx.$slots, "header")
|
|
403
|
+
], 2)) : createCommentVNode("", true),
|
|
404
|
+
__props.showClose ? (openBlock(), createElementBlock("div", {
|
|
405
|
+
key: 1,
|
|
406
|
+
class: normalizeClass([unref(ns).e("icon")]),
|
|
407
|
+
onClick: _cache[0] || (_cache[0] = //@ts-ignore
|
|
408
|
+
(...args) => unref(handleShowDialog) && unref(handleShowDialog)(...args))
|
|
409
|
+
}, [
|
|
410
|
+
createVNode(_sfc_main$e, { color: "#909399" })
|
|
411
|
+
], 2)) : createCommentVNode("", true),
|
|
412
|
+
createElementVNode("div", {
|
|
413
|
+
class: normalizeClass([unref(ns).e("body")])
|
|
414
|
+
}, [
|
|
415
|
+
renderSlot(_ctx.$slots, "default")
|
|
416
|
+
], 2),
|
|
417
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("div", {
|
|
418
|
+
key: 2,
|
|
419
|
+
class: normalizeClass([unref(ns).e("footer")])
|
|
420
|
+
}, [
|
|
421
|
+
renderSlot(_ctx.$slots, "footer")
|
|
422
|
+
], 2)) : createCommentVNode("", true)
|
|
423
|
+
], 6)) : createCommentVNode("", true)
|
|
424
|
+
]),
|
|
425
|
+
_: 3
|
|
426
|
+
}, 8, ["visible"])
|
|
427
|
+
]);
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
const _hoisted_1$4 = ["stroke"];
|
|
432
|
+
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
433
|
+
__name: "Circle",
|
|
434
|
+
props: {
|
|
435
|
+
size: { default: 50 },
|
|
436
|
+
color: { default: "#409eff" },
|
|
437
|
+
duration: { default: 2 }
|
|
438
|
+
},
|
|
439
|
+
setup(__props) {
|
|
440
|
+
const props = __props;
|
|
441
|
+
const circleStyle = computed(() => {
|
|
442
|
+
const { size, duration } = props;
|
|
443
|
+
const style = {
|
|
444
|
+
"--circle-size": addUnit(size),
|
|
445
|
+
"--circle-duration": `${duration}s`
|
|
446
|
+
};
|
|
447
|
+
return style;
|
|
448
|
+
});
|
|
449
|
+
return (_ctx, _cache) => {
|
|
450
|
+
return openBlock(), createElementBlock("svg", {
|
|
451
|
+
class: "circular",
|
|
452
|
+
viewBox: "0 0 50 50",
|
|
453
|
+
style: normalizeStyle([circleStyle.value])
|
|
454
|
+
}, [
|
|
455
|
+
createElementVNode("circle", {
|
|
456
|
+
class: "circular__path-inner",
|
|
457
|
+
cx: "25",
|
|
458
|
+
cy: "25",
|
|
459
|
+
r: "20",
|
|
460
|
+
fill: "none",
|
|
461
|
+
stroke: __props.color,
|
|
462
|
+
"stroke-width": "4",
|
|
463
|
+
"stroke-miterlimit": "10"
|
|
464
|
+
}, null, 8, _hoisted_1$4)
|
|
465
|
+
], 4);
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
const Circle_vue_vue_type_style_index_0_scoped_51d1fa15_lang = "";
|
|
470
|
+
const _export_sfc = (sfc, props) => {
|
|
471
|
+
const target = sfc.__vccOpts || sfc;
|
|
472
|
+
for (const [key, val] of props) {
|
|
473
|
+
target[key] = val;
|
|
474
|
+
}
|
|
475
|
+
return target;
|
|
476
|
+
};
|
|
477
|
+
const Circle = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-51d1fa15"]]);
|
|
478
|
+
const _sfc_main$b = /* @__PURE__ */ defineComponent({
|
|
479
|
+
__name: "Dot",
|
|
480
|
+
props: {
|
|
481
|
+
gap: { default: 6 },
|
|
482
|
+
color: { default: "var(--preview-file-primary-color)" },
|
|
483
|
+
size: { default: 10 },
|
|
484
|
+
duration: { default: 1.4 }
|
|
485
|
+
},
|
|
486
|
+
setup(__props) {
|
|
487
|
+
const props = __props;
|
|
488
|
+
const dotStyle = computed(() => {
|
|
489
|
+
const { size, gap, duration, color } = props;
|
|
490
|
+
const style = {
|
|
491
|
+
"--dot-size": addUnit(size),
|
|
492
|
+
"--dot-duration": `${duration}s`,
|
|
493
|
+
"--dot-gap": addUnit(gap),
|
|
494
|
+
"--dot-color": color
|
|
495
|
+
};
|
|
496
|
+
return style;
|
|
497
|
+
});
|
|
498
|
+
return (_ctx, _cache) => {
|
|
499
|
+
return openBlock(), createElementBlock("div", {
|
|
500
|
+
class: "dot",
|
|
501
|
+
style: normalizeStyle([dotStyle.value])
|
|
502
|
+
}, [..._cache[0] || (_cache[0] = [
|
|
503
|
+
createElementVNode("div", { class: "dot__item" }, null, -1),
|
|
504
|
+
createElementVNode("div", { class: "dot__item" }, null, -1),
|
|
505
|
+
createElementVNode("div", { class: "dot__item" }, null, -1)
|
|
506
|
+
])], 4);
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
const Dot_vue_vue_type_style_index_0_scoped_2acd99b5_lang = "";
|
|
511
|
+
const Dot = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-2acd99b5"]]);
|
|
512
|
+
const _sfc_main$a = /* @__PURE__ */ defineComponent({
|
|
513
|
+
__name: "Progress",
|
|
514
|
+
props: {
|
|
515
|
+
width: { default: 200 },
|
|
516
|
+
height: { default: 4 },
|
|
517
|
+
background: { default: "#ebeef5" },
|
|
518
|
+
radius: {},
|
|
519
|
+
color: { default: "var(--preview-file-primary-color)" },
|
|
520
|
+
duration: { default: 2 }
|
|
521
|
+
},
|
|
522
|
+
setup(__props) {
|
|
523
|
+
const props = __props;
|
|
524
|
+
const progressStyle = computed(() => {
|
|
525
|
+
const { width, height, color, duration, radius, background } = props;
|
|
526
|
+
const style = {
|
|
527
|
+
"--progress-width": addUnit(width),
|
|
528
|
+
"--progress-height": addUnit(height),
|
|
529
|
+
"--progress-border-radius": addUnit(radius ? radius : Number(height) / 2),
|
|
530
|
+
"--progress-background": background,
|
|
531
|
+
"--progress-duration": `${duration}s`,
|
|
532
|
+
"--progress-color": color
|
|
533
|
+
};
|
|
534
|
+
return style;
|
|
535
|
+
});
|
|
536
|
+
return (_ctx, _cache) => {
|
|
537
|
+
return openBlock(), createElementBlock("div", {
|
|
538
|
+
class: "progress",
|
|
539
|
+
style: normalizeStyle([progressStyle.value])
|
|
540
|
+
}, [..._cache[0] || (_cache[0] = [
|
|
541
|
+
createElementVNode("div", { class: "progress__bar" }, null, -1)
|
|
542
|
+
])], 4);
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
const Progress_vue_vue_type_style_index_0_scoped_3a710001_lang = "";
|
|
547
|
+
const Progress = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-3a710001"]]);
|
|
548
|
+
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
|
|
549
|
+
__name: "Cube",
|
|
550
|
+
props: {
|
|
551
|
+
size: { default: 40 },
|
|
552
|
+
color: { default: "var(--preview-file-primary-color)" },
|
|
553
|
+
duration: { default: 1.3 }
|
|
554
|
+
},
|
|
555
|
+
setup(__props) {
|
|
556
|
+
const props = __props;
|
|
557
|
+
const cubeStyle = computed(() => {
|
|
558
|
+
const { size, duration, color } = props;
|
|
559
|
+
const style = {
|
|
560
|
+
"--cube-size": addUnit(size),
|
|
561
|
+
"--cube-color": color,
|
|
562
|
+
"--cube-duration": `${duration}s`
|
|
563
|
+
};
|
|
564
|
+
return style;
|
|
565
|
+
});
|
|
566
|
+
return (_ctx, _cache) => {
|
|
567
|
+
return openBlock(), createElementBlock("div", {
|
|
568
|
+
class: "cube",
|
|
569
|
+
style: normalizeStyle([cubeStyle.value])
|
|
570
|
+
}, [
|
|
571
|
+
(openBlock(), createElementBlock(Fragment, null, renderList(9, (v) => {
|
|
572
|
+
return createElementVNode("div", {
|
|
573
|
+
key: v,
|
|
574
|
+
class: "cube__item"
|
|
575
|
+
});
|
|
576
|
+
}), 64))
|
|
577
|
+
], 4);
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
const Cube_vue_vue_type_style_index_0_scoped_0e6bb9d0_lang = "";
|
|
582
|
+
const Cube = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-0e6bb9d0"]]);
|
|
583
|
+
const Loading = {
|
|
584
|
+
Circle,
|
|
585
|
+
Dot,
|
|
586
|
+
Progress,
|
|
587
|
+
Cube
|
|
413
588
|
};
|
|
414
589
|
var EVENT_NAME = /* @__PURE__ */ ((EVENT_NAME2) => {
|
|
415
590
|
EVENT_NAME2["完成"] = "loaded";
|
|
@@ -452,15 +627,7 @@ const usePreviewPdf = (state) => {
|
|
|
452
627
|
onPageNumChange
|
|
453
628
|
};
|
|
454
629
|
};
|
|
455
|
-
const
|
|
456
|
-
const _hoisted_2$1 = { class: "sakura-file-data__page" };
|
|
457
|
-
const _hoisted_3$1 = { class: "sakura-file-data__text" };
|
|
458
|
-
const _hoisted_4$1 = {
|
|
459
|
-
key: 1,
|
|
460
|
-
class: "sakura-file-data__scale"
|
|
461
|
-
};
|
|
462
|
-
const _hoisted_5$1 = { class: "sakura-file-data__scale-text" };
|
|
463
|
-
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
630
|
+
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
464
631
|
__name: "Tools",
|
|
465
632
|
props: /* @__PURE__ */ mergeModels({
|
|
466
633
|
showTools: { type: Boolean },
|
|
@@ -480,50 +647,80 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
|
480
647
|
}),
|
|
481
648
|
emits: /* @__PURE__ */ mergeModels([EVENT_NAME.改变, EVENT_NAME.下一页, EVENT_NAME.上一页, EVENT_NAME.放大, EVENT_NAME.缩小], ["update:modelValue"]),
|
|
482
649
|
setup(__props, { emit: __emit }) {
|
|
650
|
+
const ns = useNamespace("tools");
|
|
483
651
|
const emits = __emit;
|
|
484
652
|
const _pageNum = useModel(__props, "modelValue");
|
|
485
653
|
return (_ctx, _cache) => {
|
|
486
|
-
return openBlock(), createElementBlock("div",
|
|
654
|
+
return openBlock(), createElementBlock("div", {
|
|
655
|
+
class: normalizeClass([unref(ns).b()])
|
|
656
|
+
}, [
|
|
487
657
|
renderSlot(_ctx.$slots, "default"),
|
|
488
658
|
__props.showTools ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
489
659
|
__props.enablePagination ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
490
660
|
createElementVNode("div", {
|
|
491
|
-
class: normalizeClass(["sakura-file-data__arrow sakura-file-data__arrow-prev", [
|
|
661
|
+
class: normalizeClass(["sakura-file-data__arrow sakura-file-data__arrow-prev", [
|
|
662
|
+
unref(ns).e("arrow"),
|
|
663
|
+
unref(ns).em("arrow", "prev"),
|
|
664
|
+
unref(ns).is("disabled", __props.prevPageDisabled)
|
|
665
|
+
]]),
|
|
492
666
|
onClick: _cache[0] || (_cache[0] = ($event) => emits(unref(EVENT_NAME).上一页))
|
|
493
667
|
}, null, 2),
|
|
494
|
-
createElementVNode("div",
|
|
668
|
+
createElementVNode("div", {
|
|
669
|
+
class: normalizeClass([unref(ns).e("page")])
|
|
670
|
+
}, [
|
|
495
671
|
withDirectives(createElementVNode("input", {
|
|
496
|
-
class: "
|
|
672
|
+
class: normalizeClass([unref(ns).e("input")]),
|
|
497
673
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _pageNum.value = $event),
|
|
498
674
|
onBlur: _cache[2] || (_cache[2] = ($event) => emits(unref(EVENT_NAME).改变))
|
|
499
|
-
}, null,
|
|
500
|
-
[
|
|
675
|
+
}, null, 34), [
|
|
676
|
+
[
|
|
677
|
+
vModelText,
|
|
678
|
+
_pageNum.value,
|
|
679
|
+
void 0,
|
|
680
|
+
{ number: true }
|
|
681
|
+
]
|
|
501
682
|
]),
|
|
502
|
-
createElementVNode("span",
|
|
503
|
-
|
|
683
|
+
createElementVNode("span", {
|
|
684
|
+
class: normalizeClass([unref(ns).e("text")])
|
|
685
|
+
}, " / " + toDisplayString(__props.total), 3)
|
|
686
|
+
], 2),
|
|
504
687
|
createElementVNode("div", {
|
|
505
|
-
class: normalizeClass([
|
|
688
|
+
class: normalizeClass([
|
|
689
|
+
unref(ns).e("arrow"),
|
|
690
|
+
unref(ns).em("arrow", "next"),
|
|
691
|
+
unref(ns).is("disabled", __props.nextPageDisabled)
|
|
692
|
+
]),
|
|
506
693
|
onClick: _cache[3] || (_cache[3] = ($event) => emits(unref(EVENT_NAME).下一页))
|
|
507
694
|
}, null, 2)
|
|
508
695
|
], 64)) : createCommentVNode("", true),
|
|
509
|
-
__props.enableScale ? (openBlock(), createElementBlock("div",
|
|
696
|
+
__props.enableScale ? (openBlock(), createElementBlock("div", {
|
|
697
|
+
key: 1,
|
|
698
|
+
class: normalizeClass([unref(ns).e("scale")])
|
|
699
|
+
}, [
|
|
510
700
|
createElementVNode("div", {
|
|
511
|
-
class:
|
|
701
|
+
class: normalizeClass([
|
|
702
|
+
unref(ns).e("icon"),
|
|
703
|
+
unref(ns).e("minus")
|
|
704
|
+
]),
|
|
512
705
|
onClick: _cache[4] || (_cache[4] = ($event) => emits(unref(EVENT_NAME).缩小))
|
|
513
|
-
}),
|
|
514
|
-
createElementVNode("span",
|
|
706
|
+
}, null, 2),
|
|
707
|
+
createElementVNode("span", {
|
|
708
|
+
class: normalizeClass([unref(ns).e("scale-text")])
|
|
709
|
+
}, toDisplayString(__props.scaleText), 3),
|
|
515
710
|
createElementVNode("div", {
|
|
516
|
-
class:
|
|
711
|
+
class: normalizeClass([
|
|
712
|
+
unref(ns).e("icon"),
|
|
713
|
+
unref(ns).e("plus")
|
|
714
|
+
]),
|
|
517
715
|
onClick: _cache[5] || (_cache[5] = ($event) => emits(unref(EVENT_NAME).放大))
|
|
518
|
-
})
|
|
519
|
-
])) : createCommentVNode("", true)
|
|
716
|
+
}, null, 2)
|
|
717
|
+
], 2)) : createCommentVNode("", true)
|
|
520
718
|
], 64)) : createCommentVNode("", true)
|
|
521
|
-
]);
|
|
719
|
+
], 2);
|
|
522
720
|
};
|
|
523
721
|
}
|
|
524
722
|
});
|
|
525
|
-
const
|
|
526
|
-
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
723
|
+
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
527
724
|
__name: "Pdf",
|
|
528
725
|
props: /* @__PURE__ */ mergeModels({
|
|
529
726
|
enablePagination: { type: Boolean, default: true },
|
|
@@ -540,6 +737,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
540
737
|
}),
|
|
541
738
|
emits: /* @__PURE__ */ mergeModels([EVENT_NAME.完成], ["update:modelValue"]),
|
|
542
739
|
setup(__props, { emit: __emit }) {
|
|
740
|
+
const ns = useNamespace("file-data");
|
|
543
741
|
const props = __props;
|
|
544
742
|
const emits = __emit;
|
|
545
743
|
const pdfLoading = useModel(__props, "modelValue");
|
|
@@ -590,10 +788,15 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
590
788
|
const { fileUrl } = toRefs(props);
|
|
591
789
|
const { onWheel, clickMinusScale, clickPlusScale, isMouseDown, scaleText, onMouseStart, wrapperStyle } = usePreviewFileTools(fileUrl, pageNum);
|
|
592
790
|
return (_ctx, _cache) => {
|
|
593
|
-
return openBlock(), createElementBlock("div",
|
|
791
|
+
return openBlock(), createElementBlock("div", {
|
|
792
|
+
class: normalizeClass([
|
|
793
|
+
unref(ns).b(),
|
|
794
|
+
unref(ns).is("drag", unref(isMouseDown))
|
|
795
|
+
])
|
|
796
|
+
}, [
|
|
594
797
|
createElementVNode("div", {
|
|
595
798
|
ref: "wrapperRef",
|
|
596
|
-
class: normalizeClass([
|
|
799
|
+
class: normalizeClass([unref(ns).e("wrapper")]),
|
|
597
800
|
onMousedown: _cache[0] || (_cache[0] = ($event) => __props.enableMove && unref(onMouseStart)($event)),
|
|
598
801
|
onWheel: _cache[1] || (_cache[1] = ($event) => __props.enableScale && unref(onWheel)($event))
|
|
599
802
|
}, [
|
|
@@ -601,7 +804,6 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
601
804
|
style: normalizeStyle([unref(wrapperStyle)])
|
|
602
805
|
}, [
|
|
603
806
|
createVNode(unref(VuePdfEmbed), {
|
|
604
|
-
class: "pdf",
|
|
605
807
|
source: pdfSource.value,
|
|
606
808
|
page: __props.enablePagination ? state.pageNum : void 0,
|
|
607
809
|
scale: 1,
|
|
@@ -611,7 +813,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
611
813
|
}, null, 8, ["source", "page"])
|
|
612
814
|
], 4)
|
|
613
815
|
], 34),
|
|
614
|
-
__props.enablePagination || __props.enableScale || __props.showTools ? (openBlock(), createBlock(_sfc_main$
|
|
816
|
+
__props.enablePagination || __props.enableScale || __props.showTools ? (openBlock(), createBlock(_sfc_main$8, {
|
|
615
817
|
key: 0,
|
|
616
818
|
modelValue: unref(_pageNum),
|
|
617
819
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(_pageNum) ? _pageNum.value = $event : null),
|
|
@@ -634,12 +836,11 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
634
836
|
]),
|
|
635
837
|
_: 3
|
|
636
838
|
}, 8, ["modelValue", "total", "prev-page-disabled", "next-page-disabled", "scale-text", "show-tools", "enable-pagination", "enable-scale", "enable-move", "onChange", "onNext", "onPrev", "onZoomIn", "onZoomOut"])) : createCommentVNode("", true)
|
|
637
|
-
]);
|
|
839
|
+
], 2);
|
|
638
840
|
};
|
|
639
841
|
}
|
|
640
842
|
});
|
|
641
|
-
const
|
|
642
|
-
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
843
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
643
844
|
__name: "Word",
|
|
644
845
|
props: /* @__PURE__ */ mergeModels({
|
|
645
846
|
enablePagination: { type: Boolean },
|
|
@@ -658,6 +859,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
658
859
|
}),
|
|
659
860
|
emits: /* @__PURE__ */ mergeModels([EVENT_NAME.完成], ["update:modelValue"]),
|
|
660
861
|
setup(__props, { emit: __emit }) {
|
|
862
|
+
const ns = useNamespace("file-data");
|
|
661
863
|
const props = __props;
|
|
662
864
|
const wordLoading = useModel(__props, "modelValue");
|
|
663
865
|
const generateWordFile = async () => {
|
|
@@ -711,10 +913,16 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
711
913
|
const { fileUrl } = toRefs(props);
|
|
712
914
|
const { onWheel, clickMinusScale, clickPlusScale, isMouseDown, scaleText, onMouseStart, wrapperStyle } = usePreviewFileTools(fileUrl);
|
|
713
915
|
return (_ctx, _cache) => {
|
|
714
|
-
return openBlock(), createElementBlock("div",
|
|
916
|
+
return openBlock(), createElementBlock("div", {
|
|
917
|
+
class: normalizeClass([
|
|
918
|
+
unref(ns).b(),
|
|
919
|
+
unref(ns).is("drag", unref(isMouseDown)),
|
|
920
|
+
unref(ns).is("enable-wrapper", __props.enableWrapper)
|
|
921
|
+
])
|
|
922
|
+
}, [
|
|
715
923
|
createElementVNode("div", {
|
|
716
924
|
ref: "wrapperRef",
|
|
717
|
-
class: normalizeClass([
|
|
925
|
+
class: normalizeClass([unref(ns).e("wrapper")]),
|
|
718
926
|
onMousedown: _cache[0] || (_cache[0] = ($event) => __props.enableMove && unref(onMouseStart)($event)),
|
|
719
927
|
onWheel: _cache[1] || (_cache[1] = ($event) => __props.enableScale && unref(onWheel)($event))
|
|
720
928
|
}, [
|
|
@@ -724,7 +932,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
724
932
|
style: normalizeStyle([unref(wrapperStyle)])
|
|
725
933
|
}, null, 4)
|
|
726
934
|
], 34),
|
|
727
|
-
__props.enablePagination || __props.enableScale || __props.showTools ? (openBlock(), createBlock(_sfc_main$
|
|
935
|
+
__props.enablePagination || __props.enableScale || __props.showTools ? (openBlock(), createBlock(_sfc_main$8, {
|
|
728
936
|
key: 0,
|
|
729
937
|
"scale-text": unref(scaleText),
|
|
730
938
|
"show-tools": __props.showTools,
|
|
@@ -738,17 +946,17 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
738
946
|
]),
|
|
739
947
|
_: 3
|
|
740
948
|
}, 8, ["scale-text", "show-tools", "enable-scale", "enable-move", "onZoomIn", "onZoomOut"])) : createCommentVNode("", true)
|
|
741
|
-
]);
|
|
949
|
+
], 2);
|
|
742
950
|
};
|
|
743
951
|
}
|
|
744
952
|
});
|
|
745
|
-
const _sfc_main$
|
|
953
|
+
const _sfc_main$5 = {};
|
|
746
954
|
const _hoisted_1$3 = {
|
|
747
955
|
width: "24",
|
|
748
956
|
height: "24",
|
|
749
957
|
fill: "none"
|
|
750
958
|
};
|
|
751
|
-
function _sfc_render$
|
|
959
|
+
function _sfc_render$1(_ctx, _cache) {
|
|
752
960
|
return openBlock(), createElementBlock("svg", _hoisted_1$3, [..._cache[0] || (_cache[0] = [
|
|
753
961
|
createElementVNode("circle", {
|
|
754
962
|
cx: "10.5",
|
|
@@ -768,8 +976,8 @@ function _sfc_render$2(_ctx, _cache) {
|
|
|
768
976
|
}, null, -1)
|
|
769
977
|
])]);
|
|
770
978
|
}
|
|
771
|
-
const ZoomIn = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
772
|
-
const _sfc_main$
|
|
979
|
+
const ZoomIn = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$1]]);
|
|
980
|
+
const _sfc_main$4 = {};
|
|
773
981
|
const _hoisted_1$2 = {
|
|
774
982
|
width: "24",
|
|
775
983
|
height: "24",
|
|
@@ -777,7 +985,7 @@ const _hoisted_1$2 = {
|
|
|
777
985
|
fill: "none",
|
|
778
986
|
xmlns: "http://www.w3.org/2000/svg"
|
|
779
987
|
};
|
|
780
|
-
function _sfc_render
|
|
988
|
+
function _sfc_render(_ctx, _cache) {
|
|
781
989
|
return openBlock(), createElementBlock("svg", _hoisted_1$2, [..._cache[0] || (_cache[0] = [
|
|
782
990
|
createElementVNode("circle", {
|
|
783
991
|
cx: "10.5",
|
|
@@ -804,44 +1012,111 @@ function _sfc_render$1(_ctx, _cache) {
|
|
|
804
1012
|
}, null, -1)
|
|
805
1013
|
])]);
|
|
806
1014
|
}
|
|
807
|
-
const ZoomOut = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
808
|
-
const
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
}
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
1015
|
+
const ZoomOut = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render]]);
|
|
1016
|
+
const _hoisted_1$1 = ["src"];
|
|
1017
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
1018
|
+
__name: "Preview",
|
|
1019
|
+
props: /* @__PURE__ */ mergeModels({
|
|
1020
|
+
imageWidth: {},
|
|
1021
|
+
imageHeight: {},
|
|
1022
|
+
fileUrl: {},
|
|
1023
|
+
enableMove: { type: Boolean },
|
|
1024
|
+
enableScale: { type: Boolean }
|
|
1025
|
+
}, {
|
|
1026
|
+
"modelValue": {
|
|
1027
|
+
type: Boolean,
|
|
1028
|
+
default: false
|
|
1029
|
+
},
|
|
1030
|
+
"modelModifiers": {}
|
|
1031
|
+
}),
|
|
1032
|
+
emits: ["update:modelValue"],
|
|
1033
|
+
setup(__props) {
|
|
1034
|
+
const ns = useNamespace("preview-image");
|
|
1035
|
+
const { width, height } = useWindowSize();
|
|
1036
|
+
const showPreviewImage = useModel(__props, "modelValue");
|
|
1037
|
+
const handleShowPreviewImage = () => {
|
|
1038
|
+
showPreviewImage.value = !showPreviewImage.value;
|
|
1039
|
+
};
|
|
1040
|
+
const props = __props;
|
|
1041
|
+
const { imageHeight, imageWidth, fileUrl } = toRefs(props);
|
|
1042
|
+
const dialogImageStyle = computed(() => {
|
|
1043
|
+
if (imageWidth.value > width.value) {
|
|
1044
|
+
return {
|
|
1045
|
+
width: "auto",
|
|
1046
|
+
height: addUnit(height.value)
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
return {
|
|
1050
|
+
width: addUnit(imageWidth.value),
|
|
1051
|
+
height: addUnit(imageHeight.value)
|
|
1052
|
+
};
|
|
1053
|
+
});
|
|
1054
|
+
const {
|
|
1055
|
+
onWheel,
|
|
1056
|
+
onMouseStart,
|
|
1057
|
+
isMouseDown,
|
|
1058
|
+
clickMinusScale,
|
|
1059
|
+
clickPlusScale,
|
|
1060
|
+
wrapperStyle,
|
|
1061
|
+
resetMouseState,
|
|
1062
|
+
resetWheelState
|
|
1063
|
+
} = usePreviewFileTools(fileUrl);
|
|
1064
|
+
const resetData = () => {
|
|
1065
|
+
resetMouseState();
|
|
1066
|
+
resetWheelState();
|
|
1067
|
+
};
|
|
1068
|
+
watch(() => showPreviewImage.value, (value) => {
|
|
1069
|
+
value && resetData();
|
|
1070
|
+
});
|
|
1071
|
+
return (_ctx, _cache) => {
|
|
1072
|
+
return openBlock(), createBlock(unref(_sfc_main$d), {
|
|
1073
|
+
modelValue: showPreviewImage.value,
|
|
1074
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => showPreviewImage.value = $event),
|
|
1075
|
+
background: "transparent",
|
|
1076
|
+
"show-close": false
|
|
1077
|
+
}, {
|
|
1078
|
+
default: withCtx(() => [
|
|
1079
|
+
createElementVNode("div", {
|
|
1080
|
+
ref: "wrapperRef",
|
|
1081
|
+
class: normalizeClass([
|
|
1082
|
+
unref(ns).b(),
|
|
1083
|
+
unref(ns).is("drag", unref(isMouseDown))
|
|
1084
|
+
]),
|
|
1085
|
+
onMousedown: _cache[0] || (_cache[0] = ($event) => __props.enableMove && unref(onMouseStart)($event)),
|
|
1086
|
+
onWheel: _cache[1] || (_cache[1] = ($event) => __props.enableScale && unref(onWheel)($event))
|
|
1087
|
+
}, [
|
|
1088
|
+
createElementVNode("div", {
|
|
1089
|
+
class: normalizeClass([unref(ns).e("data")])
|
|
1090
|
+
}, [
|
|
1091
|
+
createElementVNode("img", {
|
|
1092
|
+
class: normalizeClass([unref(ns).e("dot-move")]),
|
|
1093
|
+
src: unref(fileUrl),
|
|
1094
|
+
style: normalizeStyle([dialogImageStyle.value, unref(wrapperStyle)]),
|
|
1095
|
+
alt: ""
|
|
1096
|
+
}, null, 14, _hoisted_1$1)
|
|
1097
|
+
], 2),
|
|
1098
|
+
createElementVNode("div", {
|
|
1099
|
+
class: normalizeClass([unref(ns).e("close")]),
|
|
1100
|
+
onClick: handleShowPreviewImage
|
|
1101
|
+
}, [
|
|
1102
|
+
createVNode(_sfc_main$e)
|
|
1103
|
+
], 2),
|
|
1104
|
+
__props.enableScale ? (openBlock(), createElementBlock("div", {
|
|
1105
|
+
key: 0,
|
|
1106
|
+
class: normalizeClass([unref(ns).e("tools")])
|
|
1107
|
+
}, [
|
|
1108
|
+
createVNode(ZoomOut, { onClick: unref(clickMinusScale) }, null, 8, ["onClick"]),
|
|
1109
|
+
createVNode(ZoomIn, { onClick: unref(clickPlusScale) }, null, 8, ["onClick"])
|
|
1110
|
+
], 2)) : createCommentVNode("", true)
|
|
1111
|
+
], 34)
|
|
1112
|
+
]),
|
|
1113
|
+
_: 1
|
|
1114
|
+
}, 8, ["modelValue"]);
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
const _hoisted_1 = ["src"];
|
|
1119
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
845
1120
|
__name: "Image",
|
|
846
1121
|
props: /* @__PURE__ */ mergeModels({
|
|
847
1122
|
enablePagination: { type: Boolean },
|
|
@@ -858,102 +1133,65 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
858
1133
|
}),
|
|
859
1134
|
emits: ["update:modelValue"],
|
|
860
1135
|
setup(__props) {
|
|
1136
|
+
const ns = useNamespace("file-data");
|
|
861
1137
|
const props = __props;
|
|
862
1138
|
const pdfLoading = useModel(__props, "modelValue");
|
|
863
1139
|
const onImageLoad = () => {
|
|
864
1140
|
pdfLoading.value = false;
|
|
865
1141
|
};
|
|
866
|
-
const { width, height } = useWindowSize();
|
|
867
1142
|
const imageWidth = ref(0);
|
|
868
1143
|
const imageHeight = ref(0);
|
|
869
1144
|
const loadImageSize = async () => {
|
|
870
|
-
const
|
|
1145
|
+
const fileUrl = props.fileUrl;
|
|
871
1146
|
imageWidth.value = 0;
|
|
872
1147
|
imageHeight.value = 0;
|
|
873
1148
|
const image = new Image();
|
|
874
|
-
image.src =
|
|
1149
|
+
image.src = fileUrl;
|
|
875
1150
|
image.onload = () => {
|
|
876
1151
|
imageWidth.value = image.width;
|
|
877
1152
|
imageHeight.value = image.height;
|
|
878
1153
|
};
|
|
879
1154
|
};
|
|
880
1155
|
onMounted(loadImageSize);
|
|
881
|
-
const dialogImageStyle = computed(() => {
|
|
882
|
-
if (imageWidth.value > width.value) {
|
|
883
|
-
return {
|
|
884
|
-
width: "auto",
|
|
885
|
-
height: addUnit(height.value)
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
return {
|
|
889
|
-
width: addUnit(imageWidth.value),
|
|
890
|
-
height: addUnit(imageHeight.value)
|
|
891
|
-
};
|
|
892
|
-
});
|
|
893
|
-
const { fileUrl } = toRefs(props);
|
|
894
|
-
const {
|
|
895
|
-
onWheel,
|
|
896
|
-
onMouseStart,
|
|
897
|
-
isMouseDown,
|
|
898
|
-
clickMinusScale,
|
|
899
|
-
clickPlusScale,
|
|
900
|
-
wrapperStyle
|
|
901
|
-
} = usePreviewFileTools(fileUrl);
|
|
902
1156
|
const visible = ref(false);
|
|
903
1157
|
const handleVisible = () => {
|
|
904
1158
|
visible.value = !visible.value;
|
|
905
1159
|
};
|
|
906
1160
|
return (_ctx, _cache) => {
|
|
907
1161
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
908
|
-
createElementVNode("div",
|
|
909
|
-
|
|
1162
|
+
createElementVNode("div", {
|
|
1163
|
+
class: normalizeClass([
|
|
1164
|
+
unref(ns).b(),
|
|
1165
|
+
unref(ns).is("image")
|
|
1166
|
+
])
|
|
1167
|
+
}, [
|
|
1168
|
+
createElementVNode("div", {
|
|
1169
|
+
class: normalizeClass([unref(ns).e("wrapper")])
|
|
1170
|
+
}, [
|
|
910
1171
|
createElementVNode("img", {
|
|
911
|
-
class: "
|
|
912
|
-
src:
|
|
1172
|
+
class: normalizeClass([unref(ns).e("image")]),
|
|
1173
|
+
src: __props.fileUrl,
|
|
913
1174
|
alt: "",
|
|
914
1175
|
onLoad: onImageLoad,
|
|
915
1176
|
onClick: handleVisible
|
|
916
|
-
}, null,
|
|
917
|
-
])
|
|
918
|
-
]),
|
|
919
|
-
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
920
|
-
createElementVNode("div", {
|
|
921
|
-
class: normalizeClass(["sakura-preview-dialog", [visible.value ? "is-visible" : ""]])
|
|
922
|
-
}, [
|
|
923
|
-
_cache[2] || (_cache[2] = createElementVNode("div", { class: "sakura-preview__image--mark" }, null, -1)),
|
|
924
|
-
createElementVNode("div", {
|
|
925
|
-
ref: "wrapperRef",
|
|
926
|
-
class: normalizeClass(["sakura-preview__image", [unref(isMouseDown) ? "is-drag" : ""]]),
|
|
927
|
-
onMousedown: _cache[0] || (_cache[0] = ($event) => __props.enableMove && unref(onMouseStart)($event)),
|
|
928
|
-
onWheel: _cache[1] || (_cache[1] = ($event) => __props.enableScale && unref(onWheel)($event))
|
|
929
|
-
}, [
|
|
930
|
-
createElementVNode("div", _hoisted_4, [
|
|
931
|
-
createElementVNode("img", {
|
|
932
|
-
class: "dot-move",
|
|
933
|
-
src: unref(fileUrl),
|
|
934
|
-
style: normalizeStyle([dialogImageStyle.value, unref(wrapperStyle)]),
|
|
935
|
-
alt: ""
|
|
936
|
-
}, null, 12, _hoisted_5)
|
|
937
|
-
]),
|
|
938
|
-
createElementVNode("div", {
|
|
939
|
-
class: "sakura-preview__image--close",
|
|
940
|
-
onClick: handleVisible
|
|
941
|
-
}, [
|
|
942
|
-
createVNode(Close)
|
|
943
|
-
]),
|
|
944
|
-
__props.enableScale ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
945
|
-
createVNode(ZoomIn, { onClick: unref(clickPlusScale) }, null, 8, ["onClick"]),
|
|
946
|
-
createVNode(ZoomOut, { onClick: unref(clickMinusScale) }, null, 8, ["onClick"])
|
|
947
|
-
])) : createCommentVNode("", true)
|
|
948
|
-
], 34)
|
|
1177
|
+
}, null, 42, _hoisted_1)
|
|
949
1178
|
], 2)
|
|
950
|
-
])
|
|
1179
|
+
], 2),
|
|
1180
|
+
createVNode(_sfc_main$3, {
|
|
1181
|
+
modelValue: visible.value,
|
|
1182
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
|
|
1183
|
+
"file-url": __props.fileUrl,
|
|
1184
|
+
"enable-move": __props.enableMove,
|
|
1185
|
+
"enable-scale": __props.enableScale,
|
|
1186
|
+
"image-width": imageWidth.value,
|
|
1187
|
+
"image-height": imageHeight.value
|
|
1188
|
+
}, null, 8, ["modelValue", "file-url", "enable-move", "enable-scale", "image-width", "image-height"])
|
|
951
1189
|
], 64);
|
|
952
1190
|
};
|
|
953
1191
|
}
|
|
954
1192
|
});
|
|
955
1193
|
const PreviewFileContextKey = Symbol("PreviewFile");
|
|
956
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1194
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
957
1195
|
__name: "preview-file",
|
|
958
1196
|
props: {
|
|
959
1197
|
width: { default: "100%" },
|
|
@@ -1009,7 +1247,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1009
1247
|
key: 0,
|
|
1010
1248
|
class: normalizeClass([unref(ns).e("wrapper")])
|
|
1011
1249
|
}, [
|
|
1012
|
-
unref(isPdfFile)(unref(fileType)) ? (openBlock(), createBlock(_sfc_main$
|
|
1250
|
+
unref(isPdfFile)(unref(fileType)) ? (openBlock(), createBlock(_sfc_main$7, {
|
|
1013
1251
|
key: 0,
|
|
1014
1252
|
modelValue: loading.value,
|
|
1015
1253
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => loading.value = $event),
|
|
@@ -1027,7 +1265,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1027
1265
|
]),
|
|
1028
1266
|
_: 3
|
|
1029
1267
|
}, 8, ["modelValue", "file-url", "show-tools", "enable-pagination", "enable-scale", "enable-move"])) : createCommentVNode("", true),
|
|
1030
|
-
unref(isWordFile)(unref(fileType)) ? (openBlock(), createBlock(_sfc_main$
|
|
1268
|
+
unref(isWordFile)(unref(fileType)) ? (openBlock(), createBlock(_sfc_main$6, {
|
|
1031
1269
|
key: 1,
|
|
1032
1270
|
modelValue: loading.value,
|
|
1033
1271
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => loading.value = $event),
|
|
@@ -1037,7 +1275,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1037
1275
|
"enable-scale": __props.enableScale,
|
|
1038
1276
|
"enable-move": __props.enableMove,
|
|
1039
1277
|
"is-local-file": __props.convertToLocalFileUrl
|
|
1040
|
-
}, null, 8, ["modelValue", "file-url", "show-tools", "enable-pagination", "enable-scale", "enable-move", "is-local-file"])) : unref(isImageFile)(unref(fileType)) ? (openBlock(), createBlock(_sfc_main$
|
|
1278
|
+
}, null, 8, ["modelValue", "file-url", "show-tools", "enable-pagination", "enable-scale", "enable-move", "is-local-file"])) : unref(isImageFile)(unref(fileType)) ? (openBlock(), createBlock(_sfc_main$2, {
|
|
1041
1279
|
key: 2,
|
|
1042
1280
|
modelValue: loading.value,
|
|
1043
1281
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => loading.value = $event),
|
|
@@ -1065,11 +1303,101 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1065
1303
|
};
|
|
1066
1304
|
}
|
|
1067
1305
|
});
|
|
1068
|
-
_sfc_main
|
|
1069
|
-
|
|
1070
|
-
|
|
1306
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1307
|
+
__name: "preview-file-dialog",
|
|
1308
|
+
setup(__props, { expose: __expose }) {
|
|
1309
|
+
const getState = () => {
|
|
1310
|
+
return {
|
|
1311
|
+
width: 749,
|
|
1312
|
+
height: "80vh",
|
|
1313
|
+
src: "",
|
|
1314
|
+
convertToLocalFileUrl: false,
|
|
1315
|
+
enablePagination: true,
|
|
1316
|
+
enableMove: true,
|
|
1317
|
+
enableScale: true,
|
|
1318
|
+
loadingType: "progress",
|
|
1319
|
+
themeColor: "#245EFF",
|
|
1320
|
+
top: "5vh"
|
|
1321
|
+
};
|
|
1322
|
+
};
|
|
1323
|
+
const state = reactive(getState());
|
|
1324
|
+
const { fileUrl, fileType } = useFileState(state);
|
|
1325
|
+
const previewFileTitle = computed(() => {
|
|
1326
|
+
const { title } = state;
|
|
1327
|
+
if (!isEmpty(title)) {
|
|
1328
|
+
return title;
|
|
1329
|
+
}
|
|
1330
|
+
if (isPdfFile(fileType.value)) {
|
|
1331
|
+
return "pdf";
|
|
1332
|
+
}
|
|
1333
|
+
if (isWordFile(fileType.value)) {
|
|
1334
|
+
return "word";
|
|
1335
|
+
}
|
|
1336
|
+
return "image";
|
|
1337
|
+
});
|
|
1338
|
+
const visible = ref(false);
|
|
1339
|
+
const previewFile = (_fileUrl, title, params = {}) => {
|
|
1340
|
+
extend(state, getState(), {
|
|
1341
|
+
...params,
|
|
1342
|
+
title,
|
|
1343
|
+
src: _fileUrl
|
|
1344
|
+
});
|
|
1345
|
+
visible.value = true;
|
|
1346
|
+
};
|
|
1347
|
+
__expose({
|
|
1348
|
+
previewFile
|
|
1349
|
+
});
|
|
1350
|
+
return (_ctx, _cache) => {
|
|
1351
|
+
return openBlock(), createBlock(unref(_sfc_main$d), {
|
|
1352
|
+
modelValue: visible.value,
|
|
1353
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => visible.value = $event),
|
|
1354
|
+
top: state.top,
|
|
1355
|
+
title: previewFileTitle.value,
|
|
1356
|
+
width: state.width
|
|
1357
|
+
}, {
|
|
1358
|
+
default: withCtx(() => [
|
|
1359
|
+
visible.value ? (openBlock(), createBlock(_sfc_main$1, mergeProps({ key: 0 }, state, {
|
|
1360
|
+
src: unref(fileUrl),
|
|
1361
|
+
width: "100%"
|
|
1362
|
+
}), null, 16, ["src"])) : createCommentVNode("", true)
|
|
1363
|
+
]),
|
|
1364
|
+
_: 1
|
|
1365
|
+
}, 8, ["modelValue", "top", "title", "width"]);
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
const checkElementIsExist = (id, container = "body") => {
|
|
1370
|
+
if (document.querySelector(`#${id}`)) {
|
|
1371
|
+
return true;
|
|
1372
|
+
}
|
|
1373
|
+
try {
|
|
1374
|
+
const div = document.createElement("div");
|
|
1375
|
+
div.id = id;
|
|
1376
|
+
const containerEl = document.querySelector(container);
|
|
1377
|
+
containerEl.append(div);
|
|
1378
|
+
return true;
|
|
1379
|
+
} catch {
|
|
1380
|
+
return false;
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
function install(vm) {
|
|
1384
|
+
const vnode = createVNode(_sfc_main);
|
|
1385
|
+
checkElementIsExist("sakura-preview-file");
|
|
1386
|
+
render(vnode, document.querySelector("#sakura-preview-file"));
|
|
1387
|
+
vm.config.globalProperties.$previewFile = (fileUrl, title = "", params) => {
|
|
1388
|
+
var _a, _b;
|
|
1389
|
+
return ((_a = vnode.component) == null ? void 0 : _a.exposed) && ((_b = vnode.component) == null ? void 0 : _b.exposed.previewFile(fileUrl, title, params));
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
const index$1 = "";
|
|
1393
|
+
const index = {
|
|
1394
|
+
install
|
|
1071
1395
|
};
|
|
1072
1396
|
export {
|
|
1397
|
+
_sfc_main$d as Dialog,
|
|
1073
1398
|
Loading,
|
|
1074
|
-
_sfc_main as
|
|
1399
|
+
_sfc_main$1 as PreviewFile,
|
|
1400
|
+
_sfc_main as PreviewFileDialog,
|
|
1401
|
+
index as default,
|
|
1402
|
+
usePreviewFile
|
|
1075
1403
|
};
|