@ibiz-template-plugin/ibiz-file-previewer 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +123 -25
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.es.js +928 -488
  4. package/dist/index.umd.js +1 -1
  5. package/dist/style.css +2 -2
  6. package/dist/types/component/file-preview-item/file-preview-html/file-preview-html.d.ts +20 -0
  7. package/dist/types/component/file-preview-item/file-preview-image/file-preview-image.d.ts +22 -0
  8. package/dist/types/component/file-preview-item/file-preview-image-group/file-preview-image-group.d.ts +17 -5
  9. package/dist/types/component/file-preview-item/file-preview-image-group/image-page/image-page.d.ts +21 -4
  10. package/dist/types/component/file-preview-item/file-preview-md/file-preview-md.d.ts +10 -6
  11. package/dist/types/component/file-preview-item/file-preview-text/file-preview-text.d.ts +6 -2
  12. package/dist/types/component/file-preview-item/file-preview-unknown/file-preview-unkown.d.ts +7 -3
  13. package/dist/types/component/file-preview-item/index.d.ts +6 -0
  14. package/dist/types/component/file-preview-shell/file-preview-shell.d.ts +6 -3
  15. package/dist/types/component/index.d.ts +3 -0
  16. package/dist/types/component/loading/loading.d.ts +14 -0
  17. package/dist/types/const/constant.d.ts +6 -5
  18. package/dist/types/const/index.d.ts +2 -0
  19. package/dist/types/const/{file-type.d.ts → type.d.ts} +30 -2
  20. package/dist/types/controller/file-preview-item/file-preview-image-controller.d.ts +42 -0
  21. package/dist/types/controller/{file-preview-image-group-controller.d.ts → file-preview-item/file-preview-image-group-controller.d.ts} +12 -3
  22. package/dist/types/controller/{file-preview-item-controller.d.ts → file-preview-item/file-preview-item-controller.d.ts} +2 -11
  23. package/dist/types/controller/{file-preview-md-controller.d.ts → file-preview-item/file-preview-md-controller.d.ts} +1 -1
  24. package/dist/types/controller/{file-preview-text-controller.d.ts → file-preview-item/file-preview-text-controller.d.ts} +1 -1
  25. package/dist/types/controller/file-preview-item/file-prview-html-controller.d.ts +7 -0
  26. package/dist/types/controller/file-preview-item/index.d.ts +6 -0
  27. package/dist/types/controller/file-preview-item-dispatcher.d.ts +4 -3
  28. package/dist/types/controller/file-preview-shell-controller.d.ts +16 -2
  29. package/dist/types/controller/index.d.ts +5 -3
  30. package/dist/types/icon/index.d.ts +8 -0
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/interface/i-file-preview-item-controller.d.ts +27 -20
  33. package/dist/types/interface/i-file-preview-shell-controller.d.ts +14 -12
  34. package/dist/types/interface/i-file-previewer-option.d.ts +8 -4
  35. package/dist/types/interface/index.d.ts +1 -1
  36. package/dist/types/util/util.d.ts +2 -1
  37. package/package.json +1 -1
  38. package/dist/types/component/file-preview-item/file-preview-img/file-preview-img.d.ts +0 -19
  39. package/dist/types/component/file-preview-item/file-preview-json/file-preview-json.d.ts +0 -18
  40. package/dist/types/component/file-preview-item/file-preview-xml/file-preview-xml.d.ts +0 -18
  41. package/dist/types/const/action-type.d.ts +0 -6
  42. package/dist/types/controller/file-preview-image-controller.d.ts +0 -18
package/dist/index.es.js CHANGED
@@ -1,4 +1,17 @@
1
- import { createVNode, defineComponent, createTextVNode, h, ref, onMounted, onUnmounted, nextTick, Teleport, computed, watch, reactive, createApp } from "vue";
1
+ import { defineComponent, createVNode, onMounted, ref, nextTick, Teleport, createTextVNode, computed, watch, reactive, onUnmounted, h, createApp } from "vue";
2
+ var ActionType = /* @__PURE__ */ ((ActionType2) => {
3
+ ActionType2["DOWNORIGINAL"] = "DOWNORIGINAL";
4
+ ActionType2["COPYTEXTCONTENT"] = "COPYTEXTCONTENT";
5
+ ActionType2["DOWNPDF"] = "DOWNPDF";
6
+ ActionType2["DOWNMD"] = "DOWNMD";
7
+ return ActionType2;
8
+ })(ActionType || {});
9
+ var ImageMode = /* @__PURE__ */ ((ImageMode2) => {
10
+ ImageMode2["AUTO"] = "auto";
11
+ ImageMode2["WIDTH"] = "width";
12
+ ImageMode2["PAGE"] = "page";
13
+ return ImageMode2;
14
+ })(ImageMode || {});
2
15
  var FileType = /* @__PURE__ */ ((FileType2) => {
3
16
  FileType2["HTML"] = "html";
4
17
  FileType2["MD"] = "md";
@@ -20,7 +33,11 @@ var FileType = /* @__PURE__ */ ((FileType2) => {
20
33
  FileType2["PNG"] = "png";
21
34
  FileType2["GIF"] = "gif";
22
35
  FileType2["SVG"] = "svg";
23
- FileType2["UNKNOWN"] = "unknown";
36
+ FileType2["BMP"] = "bmp";
37
+ FileType2["WEBP"] = "webp";
38
+ FileType2["JPEG"] = "jpeg";
39
+ FileType2["ICO"] = "ico";
40
+ FileType2["UNKNOWN"] = "UNKNOWN";
24
41
  return FileType2;
25
42
  })(FileType || {});
26
43
  var EngineType = /* @__PURE__ */ ((EngineType2) => {
@@ -32,6 +49,137 @@ var EngineType = /* @__PURE__ */ ((EngineType2) => {
32
49
  EngineType2["UNKNOWN"] = "UNKNOWN";
33
50
  return EngineType2;
34
51
  })(EngineType || {});
52
+ const FileTypeEngineMap = /* @__PURE__ */ new Map([
53
+ ["html", [
54
+ "MD"
55
+ /* MD */
56
+ ]],
57
+ // HTML类型文件
58
+ ["md", [
59
+ "MD"
60
+ /* MD */
61
+ ]],
62
+ // MD类型文件
63
+ ["xls", [
64
+ "HTML"
65
+ /* HTML */
66
+ ]],
67
+ // XLS类型文件
68
+ ["xlsx", [
69
+ "HTML"
70
+ /* HTML */
71
+ ]],
72
+ // XLSX类型文件
73
+ ["et", [
74
+ "HTML"
75
+ /* HTML */
76
+ ]],
77
+ // ET类型文件
78
+ ["txt", [
79
+ "TXT"
80
+ /* TXT */
81
+ ]],
82
+ // TXT类型文件
83
+ ["json", [
84
+ "TXT"
85
+ /* TXT */
86
+ ]],
87
+ // JSON类型文件
88
+ ["xml", [
89
+ "TXT"
90
+ /* TXT */
91
+ ]],
92
+ // XML类型文件
93
+ ["pdf", [
94
+ "PDF"
95
+ /* PDF */
96
+ ]],
97
+ // PDF类型文件
98
+ ["doc", [
99
+ "PDF",
100
+ "HTML"
101
+ /* HTML */
102
+ ]],
103
+ // DOC类型文件
104
+ ["docx", [
105
+ "PDF",
106
+ "HTML"
107
+ /* HTML */
108
+ ]],
109
+ // DOCX类型文件
110
+ ["wps", [
111
+ "PDF",
112
+ "HTML"
113
+ /* HTML */
114
+ ]],
115
+ // WPS类型文件
116
+ ["ppt", [
117
+ "PDF"
118
+ /* PDF */
119
+ ]],
120
+ // PPT类型文件
121
+ ["pptx", [
122
+ "PDF"
123
+ /* PDF */
124
+ ]],
125
+ // PPTX类型文件
126
+ ["jpg", [
127
+ "IMG"
128
+ /* IMG */
129
+ ]],
130
+ // JPG类型文件
131
+ ["png", [
132
+ "IMG"
133
+ /* IMG */
134
+ ]],
135
+ // PNG类型文件
136
+ ["gif", [
137
+ "IMG"
138
+ /* IMG */
139
+ ]],
140
+ // GIF类型文件
141
+ ["svg", [
142
+ "IMG"
143
+ /* IMG */
144
+ ]],
145
+ // SVG类型文件
146
+ ["bmp", [
147
+ "IMG"
148
+ /* IMG */
149
+ ]],
150
+ // BMP类型文件
151
+ ["jpeg", [
152
+ "IMG"
153
+ /* IMG */
154
+ ]],
155
+ // JPEG类型文件
156
+ ["webp", [
157
+ "IMG"
158
+ /* IMG */
159
+ ]],
160
+ // WEBP类型文件
161
+ ["ico", [
162
+ "IMG"
163
+ /* IMG */
164
+ ]]
165
+ // ICO类型文件
166
+ ]);
167
+ const contentWidth = 800;
168
+ const imgModes = [
169
+ {
170
+ lable: "自动缩放",
171
+ value: ImageMode.AUTO
172
+ },
173
+ {
174
+ lable: "适合页宽",
175
+ value: ImageMode.WIDTH
176
+ },
177
+ {
178
+ lable: "适合页面",
179
+ value: ImageMode.PAGE
180
+ }
181
+ ];
182
+ const imgBasePath = "";
35
183
  const fileNameToFileType = (fileName) => {
36
184
  var _a;
37
185
  const extension = (_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase();
@@ -97,6 +245,18 @@ const fileNameToFileType = (fileName) => {
97
245
  case "svg":
98
246
  fileType = FileType.SVG;
99
247
  break;
248
+ case "bmp":
249
+ fileType = FileType.BMP;
250
+ break;
251
+ case "jpeg":
252
+ fileType = FileType.JPEG;
253
+ break;
254
+ case "webp":
255
+ fileType = FileType.WEBP;
256
+ break;
257
+ case "ico":
258
+ fileType = FileType.ICO;
259
+ break;
100
260
  default:
101
261
  fileType = FileType.UNKNOWN;
102
262
  }
@@ -113,6 +273,36 @@ const throttle = (func, wait) => {
113
273
  }
114
274
  };
115
275
  };
276
+ const FilePreviewHtml = /* @__PURE__ */ defineComponent({
277
+ props: {
278
+ controller: {
279
+ type: Object,
280
+ required: true
281
+ }
282
+ },
283
+ emits: {
284
+ initialization: () => true
285
+ },
286
+ setup(props, {
287
+ emit
288
+ }) {
289
+ const c = props.controller;
290
+ onMounted(() => {
291
+ emit("initialization");
292
+ });
293
+ return {
294
+ c
295
+ };
296
+ },
297
+ render() {
298
+ return createVNode("div", {
299
+ "class": ["file-preview-html", this.c.state.theme]
300
+ }, [createVNode("div", {
301
+ "class": "container",
302
+ "innerHTML": this.c.state.content
303
+ }, null)]);
304
+ }
305
+ });
116
306
  const ZoomOutSvg = () => {
117
307
  return createVNode("svg", {
118
308
  "class": "icon",
@@ -177,150 +367,273 @@ const CounterClockwiseSvg = () => createVNode("svg", {
177
367
  "d": "M621.691007 930.837137l0 93.162863C896.942803 1015.340184 1117.395653 789.486587 1117.395653 512.139674c0-282.840775-229.2989-512.139674-512.139674-512.139674C346.113304 0 131.899245 192.517959 97.818678 442.302446L0 442.302446 139.674457 605.255979l139.674457-162.953533L192.00582 442.302446C225.294899 244.104392 397.60662 93.116304 605.255979 93.116304c231.440575 0 419.02337 187.582795 419.02337 419.02337C1024.279349 738.039829 845.496044 922.223879 621.691007 930.837137z",
178
368
  "fill": "currentColor"
179
369
  }, null)]);
180
- const ThumbnailSvg = () => {
370
+ const ThumbnailSvg = () => createVNode("svg", {
371
+ "class": "icon",
372
+ "viewBox": "0 0 1024 1024",
373
+ "version": "1.1",
374
+ "xmlns": "http://www.w3.org/2000/svg",
375
+ "width": "16",
376
+ "height": "16"
377
+ }, [createVNode("path", {
378
+ "d": "M112 912h368V544H112v368z m80-288h208v208H192V624zM544 112v368h368V112H544z m288 288H624V192h208v208zM112 480h368V112H112v368z m80-288h208v208H192V192z m352 720h368V544H544v368z m80-288h208v208H624V624z",
379
+ "fill": "currentColor"
380
+ }, null)]);
381
+ const UpPageSvg = () => createVNode("svg", {
382
+ "class": "icon",
383
+ "viewBox": "0 0 1025 1024",
384
+ "version": "1.1",
385
+ "xmlns": "http://www.w3.org/2000/svg",
386
+ "width": "16.015625",
387
+ "height": "16"
388
+ }, [createVNode("path", {
389
+ "d": "M131.339914 423.017198c-9.52111 9.670597-9.400291 25.229558 0.270306 34.750668 9.670597 9.522134 25.229558 9.401315 34.750668-0.269282l320.722863-325.740925 0 798.397108c0 13.5716 11.001648 24.573248 24.573248 24.573248 13.5716 0 24.573248-11.001648 24.573248-24.573248L536.230246 135.522485l315.80719 320.551874c9.523157 9.667525 25.084167 9.783224 34.750668 0.259043 9.667525-9.524181 9.784248-25.083143 0.259043-34.750668L552.305246 81.813557c-11.058985-11.331339-25.865391-17.688643-41.702849-17.905707-0.277473-0.004096-0.554946-0.005119-0.832419-0.005119-15.559985 0-30.237381 5.957989-41.412066 16.831651-0.124914 0.121842-0.249828 0.245732-0.372694 0.370646L131.339914 423.017198z",
390
+ "fill": "currentColor"
391
+ }, null)]);
392
+ const DownPageSvg = () => createVNode("svg", {
393
+ "class": "icon",
394
+ "viewBox": "0 0 1025 1024",
395
+ "version": "1.1",
396
+ "xmlns": "http://www.w3.org/2000/svg",
397
+ "width": "16.015625",
398
+ "height": "16"
399
+ }, [createVNode("path", {
400
+ "d": "M467.985218 937.525717c0.122866 0.124914 0.24778 0.248804 0.372694 0.370646 11.174684 10.873662 25.852081 16.831651 41.412066 16.831651 0.277473 0 0.554946-0.001024 0.832419-0.005119 15.837458-0.217064 30.643864-6.574368 41.702849-17.905707l334.741901-339.769178c9.525205-9.667525 9.408482-25.226487-0.259043-34.750668-9.666501-9.524181-25.227511-9.408482-34.750668 0.259043l-315.80719 320.551874L536.230246 88.475979c0-13.5716-11.001648-24.573248-24.573248-24.573248-13.5716 0-24.573248 11.001648-24.573248 24.573248l0 798.397108L166.360888 561.132161c-9.52111-9.670597-25.080071-9.791415-34.750668-0.269282-9.670597 9.52111-9.791415 25.080071-0.270306 34.750668L467.985218 937.525717z",
401
+ "fill": "currentColor"
402
+ }, null)]);
403
+ const DownSvg = () => {
181
404
  return createVNode("svg", {
182
405
  "class": "icon",
183
406
  "viewBox": "0 0 1024 1024",
184
407
  "version": "1.1",
185
408
  "xmlns": "http://www.w3.org/2000/svg",
186
- "width": "16",
187
- "height": "16"
409
+ "width": "24",
410
+ "height": "24"
188
411
  }, [createVNode("path", {
189
- "d": "M112 912h368V544H112v368z m80-288h208v208H192V624zM544 112v368h368V112H544z m288 288H624V192h208v208zM112 480h368V112H112v368z m80-288h208v208H192V192z m352 720h368V544H544v368z m80-288h208v208H624V624z",
412
+ "d": "M512 608c-6.4 0-19.2 0-25.6-6.4l-128-128c-12.8-12.8-12.8-32 0-44.8s32-12.8 44.8 0L512 531.2l102.4-102.4c12.8-12.8 32-12.8 44.8 0s12.8 32 0 44.8l-128 128C531.2 608 518.4 608 512 608z",
190
413
  "fill": "currentColor"
191
414
  }, null)]);
192
415
  };
193
- const UpPageSvg = () => {
416
+ const ResetSvg = () => {
194
417
  return createVNode("svg", {
195
418
  "class": "icon",
196
- "viewBox": "0 0 1025 1024",
419
+ "viewBox": "0 0 1024 1024",
197
420
  "version": "1.1",
198
421
  "xmlns": "http://www.w3.org/2000/svg",
199
- "width": "16.015625",
422
+ "width": "16",
200
423
  "height": "16"
201
424
  }, [createVNode("path", {
202
- "d": "M131.339914 423.017198c-9.52111 9.670597-9.400291 25.229558 0.270306 34.750668 9.670597 9.522134 25.229558 9.401315 34.750668-0.269282l320.722863-325.740925 0 798.397108c0 13.5716 11.001648 24.573248 24.573248 24.573248 13.5716 0 24.573248-11.001648 24.573248-24.573248L536.230246 135.522485l315.80719 320.551874c9.523157 9.667525 25.084167 9.783224 34.750668 0.259043 9.667525-9.524181 9.784248-25.083143 0.259043-34.750668L552.305246 81.813557c-11.058985-11.331339-25.865391-17.688643-41.702849-17.905707-0.277473-0.004096-0.554946-0.005119-0.832419-0.005119-15.559985 0-30.237381 5.957989-41.412066 16.831651-0.124914 0.121842-0.249828 0.245732-0.372694 0.370646L131.339914 423.017198z",
425
+ "d": "M512 950.86c-210.65 0-386.92-149.21-429.35-347.43H190.9L74.61 486.4 8.78 420.57C2.92 449.83 0 480.55 0 512s2.92 62.17 8.78 91.43C51.2 842.6 260.39 1024 512 1024c208.46 0 386.92-123.61 466.65-302.08l-55.59-55.59C860.16 832.37 699.98 950.86 512 950.86zM1015.22 420.57C972.8 181.39 763.61 0 512 0 303.54 0 125.08 123.61 45.35 302.08l55.59 56.32C163.11 192.37 324.02 73.14 512 73.14c210.65 0 386.92 149.21 429.35 347.43H833.1l116.29 116.29 65.83 65.83c5.85-29.26 8.78-59.25 8.78-90.7s-2.92-62.16-8.78-91.42z",
203
426
  "fill": "currentColor"
204
427
  }, null)]);
205
428
  };
206
- const DownPageSvg = () => {
429
+ const LoaddingSvg = (props) => {
207
430
  return createVNode("svg", {
208
431
  "class": "icon",
209
- "viewBox": "0 0 1025 1024",
432
+ "viewBox": "0 0 1024 1024",
210
433
  "version": "1.1",
211
434
  "xmlns": "http://www.w3.org/2000/svg",
212
- "width": "16.015625",
213
- "height": "16"
435
+ "width": props.size,
436
+ "height": props.size
214
437
  }, [createVNode("path", {
215
- "d": "M467.985218 937.525717c0.122866 0.124914 0.24778 0.248804 0.372694 0.370646 11.174684 10.873662 25.852081 16.831651 41.412066 16.831651 0.277473 0 0.554946-0.001024 0.832419-0.005119 15.837458-0.217064 30.643864-6.574368 41.702849-17.905707l334.741901-339.769178c9.525205-9.667525 9.408482-25.226487-0.259043-34.750668-9.666501-9.524181-25.227511-9.408482-34.750668 0.259043l-315.80719 320.551874L536.230246 88.475979c0-13.5716-11.001648-24.573248-24.573248-24.573248-13.5716 0-24.573248 11.001648-24.573248 24.573248l0 798.397108L166.360888 561.132161c-9.52111-9.670597-25.080071-9.791415-34.750668-0.269282-9.670597 9.52111-9.791415 25.080071-0.270306 34.750668L467.985218 937.525717z",
216
- "fill": "currentColor"
438
+ "d": "M512 61.44a40.96 40.96 0 0 1 40.96 40.96v122.88a40.96 40.96 0 1 1-81.92 0V102.4A40.96 40.96 0 0 1 512 61.44z",
439
+ "fill": "currentColor",
440
+ "opacity": ".9"
441
+ }, null), createVNode("path", {
442
+ "d": "M737.28 121.792a40.96 40.96 0 0 1 14.992 55.952l-61.44 106.432a40.96 40.96 0 1 1-70.944-40.96l61.44-106.432a40.96 40.96 0 0 1 55.952-14.992z",
443
+ "fill": "currentColor",
444
+ "opacity": ".8"
445
+ }, null), createVNode("path", {
446
+ "d": "M902.208 286.72a40.96 40.96 0 0 1-14.992 55.952l-106.432 61.44a40.96 40.96 0 0 1-40.96-70.944l106.432-61.44a40.96 40.96 0 0 1 55.952 14.992z",
447
+ "fill": "currentColor",
448
+ "opacity": ".76"
449
+ }, null), createVNode("path", {
450
+ "d": "M962.56 512a40.96 40.96 0 0 1-40.96 40.96h-122.88a40.96 40.96 0 1 1 0-81.92h122.88A40.96 40.96 0 0 1 962.56 512z",
451
+ "fill": "currentColor",
452
+ "opacity": ".7"
453
+ }, null), createVNode("path", {
454
+ "d": "M902.208 737.28a40.96 40.96 0 0 1-55.952 14.992l-106.432-61.44a40.96 40.96 0 1 1 40.96-70.944l106.432 61.44a40.96 40.96 0 0 1 14.992 55.952z",
455
+ "fill": "currentColor",
456
+ "opacity": ".6",
457
+ "p-id": "4720"
458
+ }, null), createVNode("path", {
459
+ "d": "M737.28 902.208a40.96 40.96 0 0 1-55.952-14.992l-61.44-106.432a40.96 40.96 0 0 1 70.944-40.96l61.44 106.432a40.96 40.96 0 0 1-14.992 55.952z",
460
+ "fill": "currentColor",
461
+ "opacity": ".5",
462
+ "p-id": "4721"
463
+ }, null), createVNode("path", {
464
+ "d": "M512 962.56a40.96 40.96 0 0 1-40.96-40.96v-122.88a40.96 40.96 0 1 1 81.92 0v122.88A40.96 40.96 0 0 1 512 962.56z",
465
+ "fill": "currentColor",
466
+ "opacity": ".4",
467
+ "p-id": "4722"
468
+ }, null), createVNode("path", {
469
+ "d": "M286.72 902.208a40.96 40.96 0 0 1-14.992-55.952l61.44-106.432a40.96 40.96 0 1 1 70.944 40.96l-61.44 106.432a40.96 40.96 0 0 1-55.952 14.992z",
470
+ "fill": "currentColor",
471
+ "opacity": ".3",
472
+ "p-id": "4723"
473
+ }, null), createVNode("path", {
474
+ "d": "M121.792 737.28a40.96 40.96 0 0 1 14.992-55.952l106.432-61.44a40.96 40.96 0 0 1 40.96 70.944l-106.432 61.44a40.96 40.96 0 0 1-55.952-14.992z",
475
+ "fill": "currentColor",
476
+ "opacity": ".2",
477
+ "p-id": "4724"
478
+ }, null), createVNode("path", {
479
+ "d": "M61.44 512a40.96 40.96 0 0 1 40.96-40.96h122.88a40.96 40.96 0 1 1 0 81.92H102.4A40.96 40.96 0 0 1 61.44 512z",
480
+ "fill": "currentColor",
481
+ "opacity": ".1",
482
+ "p-id": "4725"
483
+ }, null), createVNode("path", {
484
+ "d": "M121.792 286.72a40.96 40.96 0 0 1 55.952-14.992l106.432 61.44a40.96 40.96 0 1 1-40.96 70.944l-106.432-61.44a40.96 40.96 0 0 1-14.992-55.952z",
485
+ "fill": "currentColor",
486
+ "opacity": ".04",
487
+ "p-id": "4726"
488
+ }, null), createVNode("path", {
489
+ "d": "M286.72 121.792a40.96 40.96 0 0 1 55.952 14.992l61.44 106.432a40.96 40.96 0 0 1-70.944 40.96l-61.44-106.432a40.96 40.96 0 0 1 14.992-55.952z",
490
+ "fill": "currentColor",
491
+ "p-id": "4727"
217
492
  }, null)]);
218
493
  };
219
- var ActionType = /* @__PURE__ */ ((ActionType2) => {
220
- ActionType2["DOWNORIGINAL"] = "DOWNORIGINAL";
221
- ActionType2["COPYTEXTCONTENT"] = "COPYTEXTCONTENT";
222
- ActionType2["DOWNPDF"] = "DOWNPDF";
223
- ActionType2["DOWNMD"] = "DOWNMD";
224
- return ActionType2;
225
- })(ActionType || {});
226
- const FilePreviewShell = /* @__PURE__ */ defineComponent({
494
+ const useTeleportWithDelay = () => {
495
+ const shouldRender = ref(false);
496
+ onMounted(() => {
497
+ nextTick(() => {
498
+ shouldRender.value = true;
499
+ });
500
+ });
501
+ return {
502
+ shouldRender
503
+ };
504
+ };
505
+ const FilePreviewImage = /* @__PURE__ */ defineComponent({
227
506
  props: {
228
507
  controller: {
229
508
  type: Object,
230
509
  required: true
231
510
  }
232
511
  },
233
- setup(props) {
512
+ emits: {
513
+ initialization: () => true
514
+ },
515
+ setup(props, {
516
+ emit
517
+ }) {
234
518
  const controller = props.controller;
235
- const state = controller.state;
236
- const showDownloadMenu = ref(false);
237
- const showDownloadOptions = () => {
238
- showDownloadMenu.value = !showDownloadMenu.value;
239
- };
240
- const handleClickOutside = (event) => {
241
- const downloadBtn = document.querySelector(".download-btn");
242
- const downloadOptions = document.querySelector(".download-options");
243
- if (downloadBtn && !downloadBtn.contains(event.target) && downloadOptions && !downloadOptions.contains(event.target)) {
244
- showDownloadMenu.value = false;
245
- }
246
- };
247
- const handDownLoad = (actionType, event) => {
248
- showDownloadMenu.value = false;
249
- switch (actionType) {
250
- case ActionType.DOWNORIGINAL:
251
- controller.downloadOriginal(event);
252
- break;
253
- case ActionType.COPYTEXTCONTENT:
254
- controller.copyTextContent(event);
255
- break;
256
- case ActionType.DOWNPDF:
257
- controller.exportToPdf(event);
519
+ const {
520
+ shouldRender
521
+ } = useTeleportWithDelay();
522
+ const imgStyle = computed(() => {
523
+ const {
524
+ scale,
525
+ rotate,
526
+ offsetX,
527
+ offsetY,
528
+ enableTransition
529
+ } = controller.state;
530
+ let translateX = offsetX / scale;
531
+ let translateY = offsetY / scale;
532
+ switch (rotate % 360) {
533
+ case 90:
534
+ case -270:
535
+ [translateX, translateY] = [translateY, -translateX];
258
536
  break;
259
- case ActionType.DOWNMD:
260
- controller.exportToMd(event);
537
+ case 180:
538
+ case -180:
539
+ [translateX, translateY] = [-translateX, -translateY];
261
540
  break;
262
- default:
263
- console.error("Invalid action type:", actionType);
541
+ case 270:
542
+ case -90:
543
+ [translateX, translateY] = [-translateY, translateX];
264
544
  break;
265
545
  }
546
+ const style = {
547
+ transform: `scale(${scale}) rotate(${rotate}deg) translate(${translateX}px, ${translateY}px)`,
548
+ transition: enableTransition ? "transform .3s" : ""
549
+ };
550
+ if (controller.state.mode === ImageMode.WIDTH) style.width = "100%";
551
+ if (controller.state.mode === ImageMode.PAGE) style.height = "100%";
552
+ return style;
553
+ });
554
+ const handleModeChange = (payload) => {
555
+ const value = payload.target.value;
556
+ controller.switchMode(value);
266
557
  };
267
558
  onMounted(() => {
268
- document.addEventListener("click", handleClickOutside);
269
- });
270
- onUnmounted(() => {
271
- document.removeEventListener("click", handleClickOutside);
559
+ if (controller.state.fileType === FileType.SVG) emit("initialization");
272
560
  });
273
561
  return {
274
- controller,
275
- state,
276
- showDownloadMenu,
277
- showDownloadOptions,
278
- handDownLoad
562
+ imgStyle,
563
+ shouldRender,
564
+ handleModeChange
279
565
  };
280
566
  },
281
567
  render() {
282
568
  return createVNode("div", {
283
- "class": ["file-preview-shell", this.state.theme]
284
- }, [createVNode("div", {
285
- "class": "preview-header"
286
- }, [createVNode("div", {
287
- "class": "file-info"
288
- }, [createVNode("h3", {
289
- "class": "file-name"
290
- }, [this.state.fileName]), createVNode("span", {
291
- "class": "file-type"
292
- }, [this.state.engineType])]), createVNode("div", {
293
- "class": "preview-controls"
294
- }, [createVNode("div", {
295
- "class": "custom-controls",
296
- "id": "custom-controls"
297
- }, null), createVNode("button", {
298
- "class": "control-btn download-btn",
299
- "title": "下载选项",
300
- "onClick": () => {
301
- this.showDownloadOptions();
302
- }
303
- }, [createVNode("span", {
304
- "class": "icon"
305
- }, [createVNode(DownLoadSvg, null, null)])])])]), this.showDownloadMenu && createVNode("div", {
306
- "class": "download-options"
307
- }, [createVNode("button", {
308
- "class": "download-option",
309
- "onClick": (event) => {
310
- this.handDownLoad(ActionType.DOWNORIGINAL, event);
311
- }
312
- }, [createTextVNode("下载原文件")]), this.state.engineType !== EngineType.PDF && this.state.engineType !== EngineType.UNKNOWN && createVNode("button", {
313
- "class": "download-option",
314
- "onClick": (event) => {
315
- this.handDownLoad(ActionType.COPYTEXTCONTENT, event);
316
- }
317
- }, [createTextVNode("复制文本内容")])]), createVNode("div", {
318
- "class": "preview-content"
319
- }, [createVNode("div", {
320
- "class": "preview-inner"
321
- }, [this.state.preViewComp && this.state.preViewController ? h(this.state.preViewComp, {
322
- controller: this.state.preViewController
323
- }) : null])])]);
569
+ "class": ["file-preview-image", this.controller.state.theme]
570
+ }, [this.controller.state.fileType === FileType.SVG ? createVNode("div", {
571
+ "class": "svg-container",
572
+ "style": this.imgStyle,
573
+ "innerHTML": this.controller.state.content,
574
+ "onMousedown": (evt) => this.controller.handleMouseDown(evt)
575
+ }, null) : createVNode("img", {
576
+ "style": this.imgStyle,
577
+ "src": this.controller.state.content,
578
+ "onLoad": () => this.$emit("initialization"),
579
+ "onError": () => this.$emit("initialization"),
580
+ "onMousedown": (evt) => this.controller.handleMouseDown(evt)
581
+ }, null), this.shouldRender && createVNode(Teleport, {
582
+ "to": "#custom-controls"
583
+ }, {
584
+ default: () => [createVNode("div", {
585
+ "class": "image-toolbar-container"
586
+ }, [createVNode("button", {
587
+ "title": "逆时针",
588
+ "class": "control-btn",
589
+ "onClick": () => this.controller.handleRotateChange(-90)
590
+ }, [createVNode("span", {
591
+ "class": "icon"
592
+ }, [createVNode(CounterClockwiseSvg, null, null)])]), createVNode("button", {
593
+ "title": "顺时针",
594
+ "class": "control-btn",
595
+ "onClick": () => this.controller.handleRotateChange(90)
596
+ }, [createVNode("span", {
597
+ "class": "icon"
598
+ }, [createVNode(ClockwiseSvg, null, null)])]), createVNode("select", {
599
+ "class": "img-mode",
600
+ "value": this.controller.state.mode,
601
+ "onChange": this.handleModeChange
602
+ }, [imgModes.map((mode) => {
603
+ return createVNode("option", {
604
+ "label": mode.lable,
605
+ "value": mode.value
606
+ }, null);
607
+ })]), createVNode("div", {
608
+ "class": "zoom"
609
+ }, [createVNode("button", {
610
+ "title": "缩小",
611
+ "class": "control-btn",
612
+ "onClick": (event) => {
613
+ this.controller.zoomOutPreview(event);
614
+ }
615
+ }, [createVNode("span", {
616
+ "class": "icon"
617
+ }, [createVNode(ZoomOutSvg, null, null)])]), createVNode("span", {
618
+ "class": "zoom-level"
619
+ }, [Math.round(this.controller.state.scale * 100), createTextVNode("%")]), createVNode("button", {
620
+ "title": "放大",
621
+ "class": "control-btn",
622
+ "onClick": (event) => {
623
+ this.controller.zoomInPreview(event);
624
+ }
625
+ }, [createVNode("span", {
626
+ "class": "icon"
627
+ }, [createVNode(ZoomInSvg, null, null)])])]), createVNode("button", {
628
+ "title": "重置",
629
+ "class": "control-btn",
630
+ "onClick": () => {
631
+ this.controller.reSet();
632
+ }
633
+ }, [createVNode("span", {
634
+ "class": "icon"
635
+ }, [createVNode(ResetSvg, null, null)])])])]
636
+ })]);
324
637
  }
325
638
  });
326
639
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -14878,17 +15191,6 @@ window.addEventListener("message", (e) => {
14878
15191
  })(dist);
14879
15192
  var distExports = dist.exports;
14880
15193
  const Vditor = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
14881
- const useTeleportWithDelay = () => {
14882
- const shouldRender = ref(false);
14883
- onMounted(() => {
14884
- nextTick(() => {
14885
- shouldRender.value = true;
14886
- });
14887
- });
14888
- return {
14889
- shouldRender
14890
- };
14891
- };
14892
15194
  const FilePreviewMD = /* @__PURE__ */ defineComponent({
14893
15195
  props: {
14894
15196
  controller: {
@@ -14896,7 +15198,12 @@ const FilePreviewMD = /* @__PURE__ */ defineComponent({
14896
15198
  required: true
14897
15199
  }
14898
15200
  },
14899
- setup(props) {
15201
+ emits: {
15202
+ initialization: () => true
15203
+ },
15204
+ setup(props, {
15205
+ emit
15206
+ }) {
14900
15207
  const c = props.controller;
14901
15208
  let vditorEditor;
14902
15209
  const {
@@ -14938,7 +15245,7 @@ const FilePreviewMD = /* @__PURE__ */ defineComponent({
14938
15245
  actions: []
14939
15246
  },
14940
15247
  outline: {
14941
- enable: true,
15248
+ enable: false,
14942
15249
  position: "left"
14943
15250
  },
14944
15251
  toolbarConfig: {
@@ -14947,6 +15254,7 @@ const FilePreviewMD = /* @__PURE__ */ defineComponent({
14947
15254
  value: c.state.content,
14948
15255
  after: () => {
14949
15256
  onPreview();
15257
+ emit("initialization");
14950
15258
  }
14951
15259
  });
14952
15260
  });
@@ -14975,54 +15283,6 @@ const FilePreviewMD = /* @__PURE__ */ defineComponent({
14975
15283
  })]);
14976
15284
  }
14977
15285
  });
14978
- const FilePreviewUnkown = /* @__PURE__ */ defineComponent({
14979
- props: {
14980
- controller: {
14981
- type: Object,
14982
- required: true
14983
- }
14984
- },
14985
- setup(props) {
14986
- const c = props.controller;
14987
- const fileType = c.filePreviewShell.getState().fileType;
14988
- return {
14989
- c,
14990
- fileType
14991
- };
14992
- },
14993
- render() {
14994
- return createVNode("div", {
14995
- "class": ["file-preview-unkown", this.c.state.theme]
14996
- }, [createVNode("div", null, [createTextVNode("暂未支持"), this.fileType, createTextVNode("类型预览")])]);
14997
- }
14998
- });
14999
- const FilePreviewText = /* @__PURE__ */ defineComponent({
15000
- props: {
15001
- controller: {
15002
- type: Object,
15003
- required: true
15004
- }
15005
- },
15006
- setup(props) {
15007
- const c = props.controller;
15008
- const previewRef = ref();
15009
- const {
15010
- shouldRender
15011
- } = useTeleportWithDelay();
15012
- return {
15013
- c,
15014
- previewRef,
15015
- shouldRender
15016
- };
15017
- },
15018
- render() {
15019
- return createVNode("div", {
15020
- "class": ["file-preview-text", this.c.state.theme]
15021
- }, [createVNode("div", {
15022
- "ref": "previewRef"
15023
- }, [this.c.state.content])]);
15024
- }
15025
- });
15026
15286
  function deepFreeze(obj) {
15027
15287
  if (obj instanceof Map) {
15028
15288
  obj.clear = obj.delete = obj.set = function() {
@@ -16594,44 +16854,6 @@ function json(hljs) {
16594
16854
  illegal: "\\S"
16595
16855
  };
16596
16856
  }
16597
- HighlightJS.registerLanguage("json", json);
16598
- const FilePreviewJson = /* @__PURE__ */ defineComponent({
16599
- props: {
16600
- controller: {
16601
- type: Object,
16602
- required: true
16603
- }
16604
- },
16605
- setup(props) {
16606
- const c = props.controller;
16607
- const {
16608
- shouldRender
16609
- } = useTeleportWithDelay();
16610
- const previewRef = ref();
16611
- onMounted(() => {
16612
- try {
16613
- const obj = JSON.parse(c.state.content);
16614
- previewRef.value.textContent = JSON.stringify(obj, null, 2);
16615
- HighlightJS.highlightElement(previewRef.value);
16616
- } catch (error2) {
16617
- console.error(error2);
16618
- }
16619
- });
16620
- return {
16621
- c,
16622
- previewRef,
16623
- shouldRender
16624
- };
16625
- },
16626
- render() {
16627
- return createVNode("pre", {
16628
- "class": ["file-preview-json", this.c.state.theme]
16629
- }, [createVNode("code", {
16630
- "ref": "previewRef",
16631
- "class": "language-json"
16632
- }, null)]);
16633
- }
16634
- });
16635
16857
  function xml(hljs) {
16636
16858
  const regex = hljs.regex;
16637
16859
  const TAG_NAME_RE = regex.concat(/[\p{L}_]/u, regex.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u);
@@ -16857,25 +17079,33 @@ function xml(hljs) {
16857
17079
  };
16858
17080
  }
16859
17081
  HighlightJS.registerLanguage("xml", xml);
16860
- const FilePreviewXml = /* @__PURE__ */ defineComponent({
17082
+ HighlightJS.registerLanguage("json", json);
17083
+ const FilePreviewText = /* @__PURE__ */ defineComponent({
16861
17084
  props: {
16862
17085
  controller: {
16863
17086
  type: Object,
16864
17087
  required: true
16865
17088
  }
16866
17089
  },
16867
- setup(props) {
17090
+ emits: {
17091
+ initialization: () => true
17092
+ },
17093
+ setup(props, {
17094
+ emit
17095
+ }) {
16868
17096
  const c = props.controller;
17097
+ const previewRef = ref();
16869
17098
  const {
16870
17099
  shouldRender
16871
17100
  } = useTeleportWithDelay();
16872
- const previewRef = ref();
16873
17101
  onMounted(() => {
16874
17102
  try {
16875
17103
  previewRef.value.textContent = c.state.content;
16876
17104
  HighlightJS.highlightElement(previewRef.value);
16877
17105
  } catch (error2) {
16878
17106
  console.error(error2);
17107
+ } finally {
17108
+ emit("initialization");
16879
17109
  }
16880
17110
  });
16881
17111
  return {
@@ -16886,82 +17116,40 @@ const FilePreviewXml = /* @__PURE__ */ defineComponent({
16886
17116
  },
16887
17117
  render() {
16888
17118
  return createVNode("pre", {
16889
- "class": ["file-preview-xml", this.c.state.theme]
17119
+ "class": ["file-preview-text", this.c.state.theme]
16890
17120
  }, [createVNode("code", {
16891
17121
  "ref": "previewRef",
16892
- "class": "language-xml"
17122
+ "class": `language-${this.c.state.fileType}`
16893
17123
  }, null)]);
16894
17124
  }
16895
17125
  });
16896
- const FilePreviewImg = /* @__PURE__ */ defineComponent({
17126
+ const FilePreviewUnkown = /* @__PURE__ */ defineComponent({
16897
17127
  props: {
16898
17128
  controller: {
16899
17129
  type: Object,
16900
17130
  required: true
16901
17131
  }
16902
17132
  },
16903
- setup(props) {
17133
+ emits: {
17134
+ initialization: () => true
17135
+ },
17136
+ setup(props, {
17137
+ emit
17138
+ }) {
16904
17139
  const c = props.controller;
16905
- const {
16906
- shouldRender
16907
- } = useTeleportWithDelay();
16908
- const previewRef = ref();
16909
- const style = computed(() => {
16910
- return {
16911
- transform: `scale(${c.state.scale}) rotate(${c.state.rotate}deg) translate(0px, 0px)`
16912
- };
17140
+ const fileType = c.filePreviewShell.getState().fileType;
17141
+ onMounted(() => {
17142
+ emit("initialization");
16913
17143
  });
16914
17144
  return {
16915
17145
  c,
16916
- style,
16917
- previewRef,
16918
- shouldRender
17146
+ fileType
16919
17147
  };
16920
17148
  },
16921
17149
  render() {
16922
17150
  return createVNode("div", {
16923
- "class": ["file-preview-img", this.c.state.theme]
16924
- }, [createVNode("img", {
16925
- "style": this.style,
16926
- "src": this.c.state.content
16927
- }, null), this.shouldRender && createVNode(Teleport, {
16928
- "to": "#custom-controls"
16929
- }, {
16930
- default: () => [createVNode("div", {
16931
- "class": "file-preview-img__toolbar"
16932
- }, [createVNode("button", {
16933
- "title": "逆时针",
16934
- "class": "control-btn",
16935
- "onClick": () => this.c.onRotateChange(-90)
16936
- }, [createVNode("span", {
16937
- "class": "icon"
16938
- }, [createVNode(CounterClockwiseSvg, null, null)])]), createVNode("button", {
16939
- "title": "顺时针",
16940
- "class": "control-btn",
16941
- "onClick": () => this.c.onRotateChange(90)
16942
- }, [createVNode("span", {
16943
- "class": "icon"
16944
- }, [createVNode(ClockwiseSvg, null, null)])]), createVNode("button", {
16945
- "class": "control-btn",
16946
- "title": "缩小",
16947
- "onClick": (event) => {
16948
- console.log("缩小");
16949
- this.controller.zoomOutPreview(event);
16950
- }
16951
- }, [createVNode("span", {
16952
- "class": "icon"
16953
- }, [createVNode(ZoomOutSvg, null, null)])]), createVNode("span", {
16954
- "class": "zoom-level"
16955
- }, [Math.round(this.c.state.scale * 100), createTextVNode("%")]), createVNode("button", {
16956
- "class": "control-btn",
16957
- "title": "放大",
16958
- "onClick": (event) => {
16959
- this.controller.zoomInPreview(event);
16960
- }
16961
- }, [createVNode("span", {
16962
- "class": "icon"
16963
- }, [createVNode(ZoomInSvg, null, null)])])])]
16964
- })]);
17151
+ "class": ["file-preview-unkown", this.c.state.theme]
17152
+ }, [createVNode("div", null, [createTextVNode("暂未支持"), this.fileType, createTextVNode("类型预览")])]);
16965
17153
  }
16966
17154
  });
16967
17155
  const ThumbnailPanel = /* @__PURE__ */ defineComponent({
@@ -17027,7 +17215,7 @@ const ThumbnailPanel = /* @__PURE__ */ defineComponent({
17027
17215
  this.handleClick(index, event);
17028
17216
  }
17029
17217
  }, [createVNode("img", {
17030
- "src": `http://172.16.86.77:30450${page.image_url}`,
17218
+ "src": `${imgBasePath}${page.image_url}`,
17031
17219
  "alt": page.description,
17032
17220
  "class": "thumbnail-image",
17033
17221
  "loading": "lazy"
@@ -17037,33 +17225,6 @@ const ThumbnailPanel = /* @__PURE__ */ defineComponent({
17037
17225
  })])]);
17038
17226
  }
17039
17227
  });
17040
- const contentWidth = 800;
17041
- const mdEngineTypes = [FileType.HTML, FileType.MD];
17042
- const htmlEngineTypes = [
17043
- FileType.XLS,
17044
- FileType.XLSX,
17045
- FileType.ET
17046
- ];
17047
- const txtEngineTypes = [
17048
- FileType.TXT,
17049
- FileType.JSON,
17050
- FileType.XML,
17051
- FileType.UNKNOWN
17052
- ];
17053
- const pdfEngineTypes = [
17054
- FileType.PDF,
17055
- FileType.DOC,
17056
- FileType.DOCX,
17057
- FileType.WPS,
17058
- FileType.PPT,
17059
- FileType.PPTX
17060
- ];
17061
- const imgEngineTypes = [
17062
- FileType.JPG,
17063
- FileType.PNG,
17064
- FileType.GIF,
17065
- FileType.SVG
17066
- ];
17067
17228
  const ImagePage = /* @__PURE__ */ defineComponent({
17068
17229
  props: {
17069
17230
  index: {
@@ -17074,13 +17235,47 @@ const ImagePage = /* @__PURE__ */ defineComponent({
17074
17235
  type: Object,
17075
17236
  required: true
17076
17237
  },
17238
+ mode: {
17239
+ type: String,
17240
+ required: true
17241
+ },
17077
17242
  scale: {
17078
17243
  type: Number,
17079
17244
  required: true
17245
+ },
17246
+ rotate: {
17247
+ type: Number,
17248
+ required: true
17080
17249
  }
17081
17250
  },
17082
17251
  setup(props) {
17083
17252
  const isLoading = ref(true);
17253
+ let observer;
17254
+ const imgRef = ref();
17255
+ const parentStyle = reactive({
17256
+ width: 0,
17257
+ height: 0
17258
+ });
17259
+ const imgStyle = computed(() => {
17260
+ const result = {
17261
+ transform: `rotate(${props.rotate}deg)`,
17262
+ transition: "transform .3s"
17263
+ };
17264
+ if (props.mode === ImageMode.WIDTH) {
17265
+ Object.assign(result, {
17266
+ width: `${parentStyle.width * props.scale}px`
17267
+ });
17268
+ } else if (props.mode === ImageMode.PAGE) {
17269
+ Object.assign(result, {
17270
+ height: `${parentStyle.height * props.scale}px`
17271
+ });
17272
+ } else {
17273
+ Object.assign(result, {
17274
+ width: `${contentWidth * props.scale}px`
17275
+ });
17276
+ }
17277
+ return result;
17278
+ });
17084
17279
  const handleImageLoad = () => {
17085
17280
  isLoading.value = false;
17086
17281
  };
@@ -17088,26 +17283,42 @@ const ImagePage = /* @__PURE__ */ defineComponent({
17088
17283
  console.error("图片加载失败:", error2);
17089
17284
  isLoading.value = false;
17090
17285
  };
17091
- const widthStyle = computed(() => {
17092
- return {
17093
- width: `${contentWidth * props.scale}px`
17094
- };
17286
+ const updateParentStyle = () => {
17287
+ var _a, _b;
17288
+ const rect = (_b = (_a = imgRef.value) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.getBoundingClientRect();
17289
+ if (!rect) return;
17290
+ Object.assign(parentStyle, {
17291
+ height: rect.height,
17292
+ width: rect.width
17293
+ });
17294
+ };
17295
+ onMounted(() => {
17296
+ var _a;
17297
+ updateParentStyle();
17298
+ observer = new ResizeObserver(updateParentStyle);
17299
+ if ((_a = imgRef.value) == null ? void 0 : _a.parentElement) observer.observe(imgRef.value.parentElement);
17300
+ });
17301
+ onUnmounted(() => {
17302
+ observer == null ? void 0 : observer.disconnect();
17095
17303
  });
17096
17304
  return {
17097
- widthStyle,
17305
+ imgRef,
17306
+ imgStyle,
17307
+ isLoading,
17098
17308
  handleImageLoad,
17099
17309
  handleImageError
17100
17310
  };
17101
17311
  },
17102
17312
  render() {
17103
17313
  return createVNode("div", {
17314
+ "ref": "imgRef",
17104
17315
  "class": "image-page",
17105
- "data-page-index": this.index,
17106
- "style": this.widthStyle
17316
+ "style": this.imgStyle,
17317
+ "data-page-index": this.index
17107
17318
  }, [createVNode("img", {
17108
- "src": `http://172.16.86.77:30450${this.page.image_url}`,
17109
- "alt": this.page.description,
17110
17319
  "class": "image-content",
17320
+ "src": `${imgBasePath}${this.page.image_url}`,
17321
+ "alt": this.page.description,
17111
17322
  "onLoad": () => {
17112
17323
  this.handleImageLoad();
17113
17324
  },
@@ -17115,7 +17326,7 @@ const ImagePage = /* @__PURE__ */ defineComponent({
17115
17326
  this.handleImageError(error2);
17116
17327
  },
17117
17328
  "loading": "lazy"
17118
- }, null)]);
17329
+ }, null), this.isLoading && createVNode(Loading, null, null)]);
17119
17330
  }
17120
17331
  });
17121
17332
  const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
@@ -17125,7 +17336,12 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17125
17336
  required: true
17126
17337
  }
17127
17338
  },
17128
- setup(props) {
17339
+ emits: {
17340
+ initialization: () => true
17341
+ },
17342
+ setup(props, {
17343
+ emit
17344
+ }) {
17129
17345
  const controller = props.controller;
17130
17346
  const state = controller.state;
17131
17347
  const contentRef = ref(null);
@@ -17170,7 +17386,7 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17170
17386
  visiblePages.forEach((page) => {
17171
17387
  if (page) {
17172
17388
  const img = new Image();
17173
- img.src = `http://172.16.86.77:30450${page.image_url}`;
17389
+ img.src = `${imgBasePath}${page.image_url}`;
17174
17390
  }
17175
17391
  });
17176
17392
  };
@@ -17205,11 +17421,16 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17205
17421
  }
17206
17422
  }
17207
17423
  };
17424
+ const handleModeChange = (payload) => {
17425
+ const value = payload.target.value;
17426
+ controller.switchMode(value);
17427
+ };
17208
17428
  onMounted(() => {
17209
17429
  if (contentRef.value) {
17210
17430
  contentRef.value.addEventListener("scroll", handleScroll);
17211
17431
  }
17212
17432
  preloadImages();
17433
+ emit("initialization");
17213
17434
  });
17214
17435
  onUnmounted(() => {
17215
17436
  if (contentRef.value) {
@@ -17220,9 +17441,10 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17220
17441
  state,
17221
17442
  contentRef,
17222
17443
  shouldRender,
17223
- handlePageClick,
17224
- handleScroll,
17225
17444
  handleInput,
17445
+ handleScroll,
17446
+ handlePageClick,
17447
+ handleModeChange,
17226
17448
  updatePageChange
17227
17449
  };
17228
17450
  },
@@ -17241,8 +17463,8 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17241
17463
  this.handlePageClick(index);
17242
17464
  }
17243
17465
  }, null)]), createVNode("div", {
17244
- "class": "image-group-main-container",
17245
17466
  "ref": "contentRef",
17467
+ "class": "image-group-main-container",
17246
17468
  "onScroll": () => {
17247
17469
  this.handleScroll();
17248
17470
  }
@@ -17250,13 +17472,15 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17250
17472
  return createVNode(ImagePage, {
17251
17473
  "page": page,
17252
17474
  "index": index,
17253
- "scale": this.state.scale
17475
+ "mode": this.state.mode,
17476
+ "scale": this.state.scale,
17477
+ "rotate": this.state.rotateMap[index] || 0
17254
17478
  }, null);
17255
17479
  })]), this.shouldRender && createVNode(Teleport, {
17256
17480
  "to": "#custom-controls"
17257
17481
  }, {
17258
17482
  default: () => [createVNode("div", {
17259
- "class": "image-group-toolbar-container"
17483
+ "class": "image-toolbar-container"
17260
17484
  }, [createVNode("button", {
17261
17485
  "class": "control-btn",
17262
17486
  "title": "缩略图",
@@ -17264,6 +17488,18 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17264
17488
  this.controller.switchThumbnailPanel();
17265
17489
  }
17266
17490
  }, [createVNode(ThumbnailSvg, null, null)]), createVNode("button", {
17491
+ "title": "逆时针",
17492
+ "class": "control-btn",
17493
+ "onClick": () => this.controller.handleRotateChange(-90)
17494
+ }, [createVNode("span", {
17495
+ "class": "icon"
17496
+ }, [createVNode(CounterClockwiseSvg, null, null)])]), createVNode("button", {
17497
+ "title": "顺时针",
17498
+ "class": "control-btn",
17499
+ "onClick": () => this.controller.handleRotateChange(90)
17500
+ }, [createVNode("span", {
17501
+ "class": "icon"
17502
+ }, [createVNode(ClockwiseSvg, null, null)])]), createVNode("button", {
17267
17503
  "class": "control-btn",
17268
17504
  "title": "上一页",
17269
17505
  "onClick": () => {
@@ -17275,7 +17511,9 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17275
17511
  "onClick": () => {
17276
17512
  this.updatePageChange("UP");
17277
17513
  }
17278
- }, [createVNode(DownPageSvg, null, null)]), createVNode("input", {
17514
+ }, [createVNode(DownPageSvg, null, null)]), createVNode("div", {
17515
+ "class": "pagination"
17516
+ }, [createVNode("input", {
17279
17517
  "type": "number",
17280
17518
  "class": "page-input",
17281
17519
  "value": this.state.currentPage + 1,
@@ -17284,9 +17522,20 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17284
17522
  "onInput": (event) => {
17285
17523
  this.handleInput(event);
17286
17524
  }
17287
- }, null), createVNode("div", null, [createTextVNode("/")]), createVNode("div", null, [this.state.total]), createVNode("button", {
17288
- "class": "control-btn",
17525
+ }, null), createVNode("div", null, [createTextVNode("/")]), createVNode("div", null, [this.state.total])]), createVNode("select", {
17526
+ "class": "img-mode",
17527
+ "value": this.state.mode,
17528
+ "onChange": this.handleModeChange
17529
+ }, [imgModes.map((mode) => {
17530
+ return createVNode("option", {
17531
+ "label": mode.lable,
17532
+ "value": mode.value
17533
+ }, null);
17534
+ })]), createVNode("div", {
17535
+ "class": "zoom"
17536
+ }, [createVNode("button", {
17289
17537
  "title": "缩小",
17538
+ "class": "control-btn",
17290
17539
  "onClick": (event) => {
17291
17540
  this.controller.zoomOutPreview(event);
17292
17541
  }
@@ -17295,17 +17544,182 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17295
17544
  }, [createVNode(ZoomOutSvg, null, null)])]), createVNode("span", {
17296
17545
  "class": "zoom-level"
17297
17546
  }, [Math.round(this.state.scale * 100), createTextVNode("%")]), createVNode("button", {
17298
- "class": "control-btn",
17299
17547
  "title": "放大",
17548
+ "class": "control-btn",
17300
17549
  "onClick": (event) => {
17301
17550
  this.controller.zoomInPreview(event);
17302
17551
  }
17303
17552
  }, [createVNode("span", {
17304
17553
  "class": "icon"
17305
- }, [createVNode(ZoomInSvg, null, null)])])])]
17554
+ }, [createVNode(ZoomInSvg, null, null)])])]), createVNode("button", {
17555
+ "title": "重置",
17556
+ "class": "control-btn",
17557
+ "onClick": () => {
17558
+ this.controller.reSet();
17559
+ }
17560
+ }, [createVNode("span", {
17561
+ "class": "icon"
17562
+ }, [createVNode(ResetSvg, null, null)])])])]
17306
17563
  })]);
17307
17564
  }
17308
17565
  });
17566
+ const Loading = /* @__PURE__ */ defineComponent({
17567
+ props: {
17568
+ size: {
17569
+ type: Number,
17570
+ default: 24
17571
+ }
17572
+ },
17573
+ setup() {
17574
+ return {};
17575
+ },
17576
+ render() {
17577
+ return createVNode("div", {
17578
+ "class": "loading-mask"
17579
+ }, [createVNode("div", {
17580
+ "class": "loading-spinner"
17581
+ }, [createVNode(LoaddingSvg, {
17582
+ "size": this.size
17583
+ }, null)])]);
17584
+ }
17585
+ });
17586
+ const FilePreviewShell = /* @__PURE__ */ defineComponent({
17587
+ props: {
17588
+ controller: {
17589
+ type: Object,
17590
+ required: true
17591
+ }
17592
+ },
17593
+ setup(props) {
17594
+ const controller = props.controller;
17595
+ const state = controller.state;
17596
+ const showDownloadMenu = ref(false);
17597
+ const showEngineMenu = ref(false);
17598
+ const showDownloadOptions = () => {
17599
+ showDownloadMenu.value = !showDownloadMenu.value;
17600
+ };
17601
+ const showwEngineOptions = () => {
17602
+ if (state.value.engineOptions && state.value.engineOptions.length > 1) {
17603
+ showEngineMenu.value = !showEngineMenu.value;
17604
+ }
17605
+ };
17606
+ const handleClickOutside = () => {
17607
+ showEngineMenu.value = false;
17608
+ showDownloadMenu.value = false;
17609
+ };
17610
+ const handleEngineOptionSelect = (value) => {
17611
+ controller.switchEngineType(value);
17612
+ showEngineMenu.value = false;
17613
+ };
17614
+ const handDownLoad = (actionType, event) => {
17615
+ showDownloadMenu.value = false;
17616
+ switch (actionType) {
17617
+ case ActionType.DOWNORIGINAL:
17618
+ controller.downloadOriginal(event);
17619
+ break;
17620
+ case ActionType.COPYTEXTCONTENT:
17621
+ controller.copyTextContent(event);
17622
+ break;
17623
+ case ActionType.DOWNPDF:
17624
+ controller.exportToPdf(event);
17625
+ break;
17626
+ case ActionType.DOWNMD:
17627
+ controller.exportToMd(event);
17628
+ break;
17629
+ default:
17630
+ console.error("Invalid action type:", actionType);
17631
+ break;
17632
+ }
17633
+ };
17634
+ onMounted(() => {
17635
+ document.addEventListener("click", handleClickOutside, true);
17636
+ });
17637
+ onUnmounted(() => {
17638
+ document.removeEventListener("click", handleClickOutside, true);
17639
+ });
17640
+ return {
17641
+ state,
17642
+ controller,
17643
+ showEngineMenu,
17644
+ showDownloadMenu,
17645
+ handDownLoad,
17646
+ showwEngineOptions,
17647
+ showDownloadOptions,
17648
+ handleEngineOptionSelect
17649
+ };
17650
+ },
17651
+ render() {
17652
+ return createVNode("div", {
17653
+ "class": ["file-preview-shell", this.state.theme]
17654
+ }, [createVNode("div", {
17655
+ "class": "preview-header"
17656
+ }, [createVNode("div", {
17657
+ "class": "file-info"
17658
+ }, [createVNode("h3", {
17659
+ "class": "file-name"
17660
+ }, [this.state.fileName]), createVNode("div", {
17661
+ "class": "engine-container"
17662
+ }, [createVNode("div", {
17663
+ "class": "engine-content"
17664
+ }, [createVNode("div", {
17665
+ "class": {
17666
+ "engine-type": true,
17667
+ "is-multiple": this.state.engineOptions.length > 1
17668
+ }
17669
+ }, [this.state.engineType]), this.state.engineOptions.length > 1 && createVNode("div", {
17670
+ "class": "engine-icon",
17671
+ "onClick": () => {
17672
+ this.showwEngineOptions();
17673
+ }
17674
+ }, [createVNode(DownSvg, null, null)])]), this.showEngineMenu && this.state.engineOptions.length > 1 && createVNode("ul", {
17675
+ "class": "engine-options"
17676
+ }, [this.state.engineOptions.map((type) => createVNode("li", {
17677
+ "class": {
17678
+ "engine-option-item": true,
17679
+ "is-active": type === this.state.engineType
17680
+ },
17681
+ "onClick": () => {
17682
+ this.handleEngineOptionSelect(type);
17683
+ }
17684
+ }, [type]))])])]), createVNode("div", {
17685
+ "class": "preview-controls"
17686
+ }, [createVNode("div", {
17687
+ "class": "custom-controls",
17688
+ "id": "custom-controls"
17689
+ }, null), createVNode("button", {
17690
+ "class": "control-btn download-btn",
17691
+ "title": "下载选项",
17692
+ "onClick": () => {
17693
+ this.showDownloadOptions();
17694
+ }
17695
+ }, [createVNode("span", {
17696
+ "class": "icon"
17697
+ }, [createVNode(DownLoadSvg, null, null)])])])]), this.showDownloadMenu && createVNode("div", {
17698
+ "class": "download-options"
17699
+ }, [createVNode("button", {
17700
+ "class": "download-option",
17701
+ "onClick": (event) => {
17702
+ this.handDownLoad(ActionType.DOWNORIGINAL, event);
17703
+ }
17704
+ }, [createTextVNode("下载原文件")]), this.state.engineType !== EngineType.PDF && this.state.engineType !== EngineType.UNKNOWN && createVNode("button", {
17705
+ "class": "download-option",
17706
+ "onClick": (event) => {
17707
+ this.handDownLoad(ActionType.COPYTEXTCONTENT, event);
17708
+ }
17709
+ }, [createTextVNode("复制文本内容")])]), createVNode("div", {
17710
+ "class": "preview-content"
17711
+ }, [createVNode("div", {
17712
+ "class": "preview-inner"
17713
+ }, [this.state.isCreated && this.controller.preViewComp && this.controller.preViewController ? h(this.controller.preViewComp, {
17714
+ controller: this.controller.preViewController,
17715
+ onInitialization: () => {
17716
+ this.state.isLoading = false;
17717
+ }
17718
+ }) : null]), this.state.isLoading && createVNode(Loading, {
17719
+ "size": 48
17720
+ }, null)])]);
17721
+ }
17722
+ });
17309
17723
  class FilePreviewItemController {
17310
17724
  /**
17311
17725
  * 构造函数
@@ -17320,17 +17734,15 @@ class FilePreviewItemController {
17320
17734
  * 初始化状态
17321
17735
  */
17322
17736
  initState() {
17737
+ const { fileType, theme } = this.filePreviewShell.getState();
17323
17738
  this.state.content = "";
17324
- this.state.scale = 1;
17325
- this.state.theme = "dark";
17739
+ this.state.theme = theme;
17740
+ this.state.fileType = fileType;
17326
17741
  }
17327
17742
  /**
17328
17743
  * 初始化
17329
- * @param param 初始化参数
17330
17744
  */
17331
- async initialize(param) {
17332
- const { theme } = param;
17333
- this.state.theme = theme;
17745
+ async initialize() {
17334
17746
  this.state.content = await this.getContent();
17335
17747
  }
17336
17748
  /**
@@ -17339,29 +17751,146 @@ class FilePreviewItemController {
17339
17751
  async getContent() {
17340
17752
  return "";
17341
17753
  }
17754
+ }
17755
+ class FilePreviewImageController extends FilePreviewItemController {
17756
+ initState() {
17757
+ super.initState();
17758
+ this.state.rotate = 0;
17759
+ this.state.offsetX = 0;
17760
+ this.state.offsetY = 0;
17761
+ this.state.scale = 1;
17762
+ this.state.mode = ImageMode.PAGE;
17763
+ this.state.enableTransition = true;
17764
+ }
17765
+ /**
17766
+ * 获取内容
17767
+ */
17768
+ async getContent() {
17769
+ const options = this.filePreviewShell.getOptions();
17770
+ const { fileId, fileCat, fileType } = this.filePreviewShell.getState();
17771
+ try {
17772
+ const content = await options.getImgContent(fileId, fileType, fileCat);
17773
+ return content;
17774
+ } catch (error2) {
17775
+ return "";
17776
+ }
17777
+ }
17778
+ /**
17779
+ * 处理旋转角度改变
17780
+ *
17781
+ * @param value
17782
+ */
17783
+ handleRotateChange(value) {
17784
+ this.state.rotate += value;
17785
+ }
17786
+ /**
17787
+ * 处理鼠标按下
17788
+ * @param e
17789
+ * @returns
17790
+ */
17791
+ handleMouseDown(e) {
17792
+ const { offsetX, offsetY } = this.state;
17793
+ e.preventDefault();
17794
+ this.state.enableTransition = false;
17795
+ const startX = e.pageX;
17796
+ const startY = e.pageY;
17797
+ const dragHandler = (ev) => {
17798
+ this.state.offsetX = offsetX + ev.pageX - startX;
17799
+ this.state.offsetY = offsetY + ev.pageY - startY;
17800
+ };
17801
+ document.addEventListener("mousemove", dragHandler);
17802
+ const removeListeners = () => {
17803
+ document.removeEventListener("mousemove", dragHandler);
17804
+ this.state.enableTransition = true;
17805
+ };
17806
+ document.addEventListener("mouseup", removeListeners, {
17807
+ once: true
17808
+ });
17809
+ }
17342
17810
  /**
17343
17811
  * 缩小预览
17344
17812
  */
17345
- zoomOutPreview(event) {
17813
+ zoomOutPreview(_event) {
17346
17814
  this.state.scale = Math.max(this.state.scale - 0.1, 0.1);
17347
17815
  }
17348
17816
  /**
17349
17817
  * 放大预览
17350
17818
  */
17351
- zoomInPreview(event) {
17819
+ zoomInPreview(_event) {
17352
17820
  this.state.scale = Math.min(this.state.scale + 0.1, 2);
17353
17821
  }
17822
+ /**
17823
+ * 重置
17824
+ */
17825
+ reSet() {
17826
+ this.state.rotate = 0;
17827
+ this.state.offsetX = 0;
17828
+ this.state.offsetY = 0;
17829
+ this.state.scale = 1;
17830
+ this.state.mode = ImageMode.PAGE;
17831
+ this.state.enableTransition = true;
17832
+ }
17833
+ /**
17834
+ * 切换模式
17835
+ * @param mode 模式
17836
+ */
17837
+ switchMode(mode) {
17838
+ this.state.scale = 1;
17839
+ this.state.rotate = 0;
17840
+ this.state.offsetX = 0;
17841
+ this.state.offsetY = 0;
17842
+ this.state.mode = mode;
17843
+ }
17354
17844
  }
17355
- class FilePreviewTextController extends FilePreviewItemController {
17845
+ class FilePreviewImageGroupController extends FilePreviewImageController {
17846
+ initState() {
17847
+ super.initState();
17848
+ this.state.items = [];
17849
+ this.state.currentPage = 0;
17850
+ this.state.total = 0;
17851
+ this.state.showThumbnailPanel = false;
17852
+ this.state.rotateMap = {};
17853
+ }
17356
17854
  /**
17357
17855
  * 获取内容
17358
17856
  */
17359
17857
  async getContent() {
17360
- if (!this.filePreviewShell) return "";
17361
17858
  const options = this.filePreviewShell.getOptions();
17362
- const { fileId, fileType, fileCat } = this.filePreviewShell.getState();
17363
- const content = await options.getContent(fileId, fileType, fileCat);
17364
- return content || "";
17859
+ const { fileId, fileCat } = this.filePreviewShell.getState();
17860
+ try {
17861
+ const content = await options.getContent(fileId, "pageindex", fileCat);
17862
+ if (content && content.pages && content.pages.length > 0) {
17863
+ this.state.items = content.pages;
17864
+ }
17865
+ this.state.total = this.state.items.length;
17866
+ return content || {};
17867
+ } catch (error2) {
17868
+ return {};
17869
+ }
17870
+ }
17871
+ /**
17872
+ * 切换缩略图面板
17873
+ */
17874
+ switchThumbnailPanel() {
17875
+ this.state.showThumbnailPanel = !this.state.showThumbnailPanel;
17876
+ }
17877
+ /**
17878
+ * 处理旋转角度改变
17879
+ * @param value
17880
+ */
17881
+ handleRotateChange(value) {
17882
+ const indexStr = this.state.currentPage.toString();
17883
+ if (!this.state.rotateMap[indexStr]) {
17884
+ this.state.rotateMap[indexStr] = 0;
17885
+ }
17886
+ this.state.rotateMap[indexStr] += value;
17887
+ }
17888
+ /**
17889
+ * 重置
17890
+ */
17891
+ reSet() {
17892
+ super.reSet();
17893
+ this.state.rotateMap = {};
17365
17894
  }
17366
17895
  }
17367
17896
  function extend(destination) {
@@ -18104,81 +18633,50 @@ function join(output, replacement) {
18104
18633
  function canConvert(input) {
18105
18634
  return input != null && (typeof input === "string" || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));
18106
18635
  }
18107
- class FilePreviewMDController extends FilePreviewTextController {
18108
- /**
18109
- * 获取内容
18110
- */
18111
- async getContent() {
18112
- if (!this.filePreviewShell) return "";
18113
- const html = await super.getContent();
18114
- const parser = new DOMParser();
18115
- const doc = parser.parseFromString(html, "text/html");
18116
- const scripts = doc.body.querySelectorAll("script");
18117
- scripts.forEach((script) => script.remove());
18118
- const styles = doc.body.querySelectorAll("style");
18119
- styles.forEach((style) => style.remove());
18120
- const cleanBodyHTML = doc.body.innerHTML;
18121
- const turndown = new TurndownService({
18122
- headingStyle: "atx",
18123
- codeBlockStyle: "fenced"
18124
- });
18125
- const content = turndown.turndown(cleanBodyHTML);
18126
- return content;
18127
- }
18128
- }
18129
- class FilePreviewImageController extends FilePreviewItemController {
18130
- initState() {
18131
- super.initState();
18132
- this.state.rotate = 0;
18133
- }
18636
+ class FilePreviewTextController extends FilePreviewItemController {
18134
18637
  /**
18135
18638
  * 获取内容
18136
18639
  */
18137
18640
  async getContent() {
18138
- if (!this.filePreviewShell) return "";
18139
18641
  const options = this.filePreviewShell.getOptions();
18140
- const { fileId, fileCat } = this.filePreviewShell.getState();
18141
- const content = await options.getUrl(fileId, fileCat);
18142
- return content || "";
18143
- }
18144
- /**
18145
- * 改变旋转角度
18146
- *
18147
- * @param value
18148
- */
18149
- onRotateChange(value) {
18150
- this.state.rotate += value;
18642
+ const { fileId, fileType, fileCat } = this.filePreviewShell.getState();
18643
+ try {
18644
+ const content = await options.getContent(fileId, fileType, fileCat);
18645
+ return content || "";
18646
+ } catch (error2) {
18647
+ return error2.message || "";
18648
+ }
18151
18649
  }
18152
18650
  }
18153
- class FilePreviewImageGroupController extends FilePreviewItemController {
18154
- initState() {
18155
- super.initState();
18156
- this.state.items = [];
18157
- this.state.currentPage = 0;
18158
- this.state.total = 0;
18159
- this.state.showThumbnailPanel = false;
18160
- }
18651
+ class FilePreviewMDController extends FilePreviewTextController {
18161
18652
  /**
18162
18653
  * 获取内容
18163
18654
  */
18164
18655
  async getContent() {
18165
- if (!this.filePreviewShell) return "";
18166
- const options = this.filePreviewShell.getOptions();
18167
- const { fileId, fileCat } = this.filePreviewShell.getState();
18168
- const content = await options.getContent(fileId, "pageindex", fileCat);
18169
- if (content && content.pages && content.pages.length > 0) {
18170
- this.state.items = content.pages;
18656
+ try {
18657
+ let content = await super.getContent();
18658
+ if (this.state.fileType === FileType.HTML) {
18659
+ const parser = new DOMParser();
18660
+ const doc = parser.parseFromString(content, "text/html");
18661
+ const scripts = doc.body.querySelectorAll("script");
18662
+ scripts.forEach((script) => script.remove());
18663
+ const styles = doc.body.querySelectorAll("style");
18664
+ styles.forEach((style) => style.remove());
18665
+ const cleanBodyHTML = doc.body.innerHTML;
18666
+ const turndown = new TurndownService({
18667
+ headingStyle: "atx",
18668
+ codeBlockStyle: "fenced"
18669
+ });
18670
+ content = turndown.turndown(cleanBodyHTML);
18671
+ }
18672
+ return content;
18673
+ } catch (error2) {
18674
+ return error2.message || "";
18171
18675
  }
18172
- this.state.total = this.state.items.length;
18173
- return content || {};
18174
- }
18175
- /**
18176
- * 切换缩略图面板
18177
- */
18178
- switchThumbnailPanel() {
18179
- this.state.showThumbnailPanel = !this.state.showThumbnailPanel;
18180
18676
  }
18181
18677
  }
18678
+ class FilePreviewHtmlController extends FilePreviewTextController {
18679
+ }
18182
18680
  const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18183
18681
  /**
18184
18682
  * 注册文件预览项
@@ -18187,7 +18685,7 @@ const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18187
18685
  * @param controller 控制器
18188
18686
  */
18189
18687
  static registerItem(type, component, controller) {
18190
- this.filePreviewMap.set(type, {
18688
+ this.enginePreviewMap.set(type, {
18191
18689
  component,
18192
18690
  controller
18193
18691
  });
@@ -18197,112 +18695,42 @@ const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18197
18695
  */
18198
18696
  static initialize() {
18199
18697
  this.registerItem(
18200
- "html",
18201
- FilePreviewMD,
18698
+ EngineType.HTML,
18699
+ FilePreviewHtml,
18202
18700
  (filePreviewShell) => {
18203
- return new FilePreviewMDController(filePreviewShell);
18701
+ return new FilePreviewHtmlController(filePreviewShell);
18204
18702
  }
18205
18703
  );
18206
18704
  this.registerItem(
18207
- "md",
18705
+ EngineType.MD,
18208
18706
  FilePreviewMD,
18209
18707
  (filePreviewShell) => {
18210
- return new FilePreviewTextController(filePreviewShell);
18211
- }
18212
- );
18213
- this.registerItem(
18214
- "json",
18215
- FilePreviewJson,
18216
- (filePreviewShell) => {
18217
- return new FilePreviewTextController(filePreviewShell);
18218
- }
18219
- );
18220
- this.registerItem(
18221
- "xml",
18222
- FilePreviewXml,
18223
- (filePreviewShell) => {
18224
- return new FilePreviewTextController(filePreviewShell);
18708
+ return new FilePreviewMDController(filePreviewShell);
18225
18709
  }
18226
18710
  );
18227
18711
  this.registerItem(
18228
- "txt",
18712
+ EngineType.TXT,
18229
18713
  FilePreviewText,
18230
18714
  (filePreviewShell) => {
18231
18715
  return new FilePreviewTextController(filePreviewShell);
18232
18716
  }
18233
18717
  );
18234
18718
  this.registerItem(
18235
- "pdf",
18236
- FilePreviewImageGroup,
18237
- (filePreviewShell) => {
18238
- return new FilePreviewImageGroupController(filePreviewShell);
18239
- }
18240
- );
18241
- this.registerItem(
18242
- "doc",
18719
+ EngineType.PDF,
18243
18720
  FilePreviewImageGroup,
18244
18721
  (filePreviewShell) => {
18245
18722
  return new FilePreviewImageGroupController(filePreviewShell);
18246
18723
  }
18247
18724
  );
18248
18725
  this.registerItem(
18249
- "docx",
18250
- FilePreviewImageGroup,
18251
- (filePreviewShell) => {
18252
- return new FilePreviewImageGroupController(filePreviewShell);
18253
- }
18254
- );
18255
- this.registerItem(
18256
- "wps",
18257
- FilePreviewImageGroup,
18258
- (filePreviewShell) => {
18259
- return new FilePreviewImageGroupController(filePreviewShell);
18260
- }
18261
- );
18262
- this.registerItem(
18263
- "ppt",
18264
- FilePreviewImageGroup,
18265
- (filePreviewShell) => {
18266
- return new FilePreviewImageGroupController(filePreviewShell);
18267
- }
18268
- );
18269
- this.registerItem(
18270
- "pptx",
18271
- FilePreviewImageGroup,
18272
- (filePreviewShell) => {
18273
- return new FilePreviewImageGroupController(filePreviewShell);
18274
- }
18275
- );
18276
- this.registerItem(
18277
- "jpg",
18278
- FilePreviewImg,
18726
+ EngineType.IMG,
18727
+ FilePreviewImage,
18279
18728
  (filePreviewShell) => {
18280
18729
  return new FilePreviewImageController(filePreviewShell);
18281
18730
  }
18282
18731
  );
18283
18732
  this.registerItem(
18284
- "png",
18285
- FilePreviewImg,
18286
- (filePreviewShell) => {
18287
- return new FilePreviewImageController(filePreviewShell);
18288
- }
18289
- );
18290
- this.registerItem(
18291
- "gif",
18292
- FilePreviewImg,
18293
- (filePreviewShell) => {
18294
- return new FilePreviewImageController(filePreviewShell);
18295
- }
18296
- );
18297
- this.registerItem(
18298
- "svg",
18299
- FilePreviewImg,
18300
- (filePreviewShell) => {
18301
- return new FilePreviewImageController(filePreviewShell);
18302
- }
18303
- );
18304
- this.registerItem(
18305
- "unknown",
18733
+ EngineType.UNKNOWN,
18306
18734
  FilePreviewUnkown,
18307
18735
  (filePreviewShell) => {
18308
18736
  return new FilePreviewItemController(filePreviewShell);
@@ -18315,10 +18743,10 @@ const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18315
18743
  * @returns
18316
18744
  */
18317
18745
  static getItem(type) {
18318
- return this.filePreviewMap.get(type) || null;
18746
+ return this.enginePreviewMap.get(type) || null;
18319
18747
  }
18320
18748
  };
18321
- _FilePreviewItemDispatcher.filePreviewMap = /* @__PURE__ */ new Map();
18749
+ _FilePreviewItemDispatcher.enginePreviewMap = /* @__PURE__ */ new Map();
18322
18750
  let FilePreviewItemDispatcher = _FilePreviewItemDispatcher;
18323
18751
  class FilePreviewShellController {
18324
18752
  /**
@@ -18328,15 +18756,17 @@ class FilePreviewShellController {
18328
18756
  constructor(options) {
18329
18757
  this.options = options;
18330
18758
  this.currentApp = null;
18759
+ this.preViewComp = void 0;
18331
18760
  this.state = ref({
18332
18761
  fileName: "",
18333
18762
  fileId: "",
18334
18763
  fileCat: "",
18335
18764
  theme: "dark",
18765
+ isLoading: false,
18766
+ isCreated: false,
18336
18767
  fileType: FileType.UNKNOWN,
18337
- preViewComp: void 0,
18338
- preViewController: void 0,
18339
- engineType: EngineType.UNKNOWN
18768
+ engineType: EngineType.UNKNOWN,
18769
+ engineOptions: []
18340
18770
  });
18341
18771
  if (options.theme) {
18342
18772
  this.state.value.theme = options.theme;
@@ -18374,19 +18804,13 @@ class FilePreviewShellController {
18374
18804
  * 解析引擎类型
18375
18805
  */
18376
18806
  async parseEngineType() {
18377
- if (htmlEngineTypes.includes(this.state.value.fileType)) {
18378
- this.state.value.engineType = EngineType.HTML;
18379
- } else if (mdEngineTypes.includes(this.state.value.fileType)) {
18380
- this.state.value.engineType = EngineType.MD;
18381
- } else if (txtEngineTypes.includes(this.state.value.fileType)) {
18382
- this.state.value.engineType = EngineType.TXT;
18383
- } else if (pdfEngineTypes.includes(this.state.value.fileType)) {
18384
- this.state.value.engineType = EngineType.PDF;
18385
- } else if (imgEngineTypes.includes(this.state.value.fileType)) {
18386
- this.state.value.engineType = EngineType.IMG;
18807
+ const engineOptions = FileTypeEngineMap.get(this.state.value.fileType);
18808
+ if (engineOptions && engineOptions.length > 0) {
18809
+ this.state.value.engineOptions = engineOptions;
18387
18810
  } else {
18388
- this.state.value.engineType = EngineType.UNKNOWN;
18811
+ this.state.value.engineOptions = [EngineType.UNKNOWN];
18389
18812
  }
18813
+ this.state.value.engineType = this.state.value.engineOptions[0];
18390
18814
  }
18391
18815
  /**
18392
18816
  * 解析预览项
@@ -18394,15 +18818,15 @@ class FilePreviewShellController {
18394
18818
  */
18395
18819
  async parsePreviewItem() {
18396
18820
  let previewItem = FilePreviewItemDispatcher.getItem(
18397
- this.state.value.fileType
18821
+ this.state.value.engineType
18398
18822
  );
18399
18823
  if (!previewItem) {
18400
- previewItem = FilePreviewItemDispatcher.getItem("unknown");
18824
+ previewItem = FilePreviewItemDispatcher.getItem(EngineType.UNKNOWN);
18401
18825
  }
18402
- this.state.value.preViewComp = previewItem.component;
18826
+ this.preViewComp = previewItem.component;
18403
18827
  const preViewController = previewItem.controller(this);
18404
- await preViewController.initialize({ theme: this.state.value.theme });
18405
- this.state.value.preViewController = preViewController;
18828
+ await preViewController.initialize();
18829
+ this.preViewController = preViewController;
18406
18830
  }
18407
18831
  /**
18408
18832
  * 挂载组件实例
@@ -18434,9 +18858,12 @@ class FilePreviewShellController {
18434
18858
  * @param data
18435
18859
  */
18436
18860
  async updateView(data) {
18861
+ this.state.value.isCreated = false;
18862
+ this.state.value.isLoading = true;
18437
18863
  await this.parseParams(data);
18438
18864
  await this.parsePreviewItem();
18439
18865
  this.mountComponent();
18866
+ this.state.value.isCreated = true;
18440
18867
  }
18441
18868
  /**
18442
18869
  * 获取内容
@@ -18473,6 +18900,7 @@ class FilePreviewShellController {
18473
18900
  */
18474
18901
  async copyTextContent(event) {
18475
18902
  if (!this.options.getContent) return;
18903
+ await navigator.clipboard.writeText("");
18476
18904
  const content = await this.options.getContent(
18477
18905
  this.state.value.fileId,
18478
18906
  this.state.value.fileType,
@@ -18503,8 +18931,20 @@ class FilePreviewShellController {
18503
18931
  await this.options.actionSuccessCallBack(ActionType.DOWNMD);
18504
18932
  }
18505
18933
  }
18934
+ /**
18935
+ * 切换引擎类型
18936
+ * @param engineType
18937
+ */
18938
+ async switchEngineType(engineType) {
18939
+ this.state.value.isCreated = false;
18940
+ this.state.value.engineType = engineType;
18941
+ await this.parsePreviewItem();
18942
+ this.mountComponent();
18943
+ this.state.value.isCreated = true;
18944
+ }
18506
18945
  }
18507
18946
  export {
18508
18947
  ActionType,
18509
- FilePreviewShellController
18948
+ FilePreviewShellController,
18949
+ FileType
18510
18950
  };