@ibiz-template-plugin/ibiz-file-previewer 0.0.3 → 0.0.5

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 +97 -25
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.es.js +925 -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,39 @@ 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);
17095
17300
  });
17096
17301
  return {
17097
- widthStyle,
17302
+ imgRef,
17303
+ imgStyle,
17304
+ isLoading,
17098
17305
  handleImageLoad,
17099
17306
  handleImageError
17100
17307
  };
17101
17308
  },
17102
17309
  render() {
17103
17310
  return createVNode("div", {
17311
+ "ref": "imgRef",
17104
17312
  "class": "image-page",
17105
- "data-page-index": this.index,
17106
- "style": this.widthStyle
17313
+ "style": this.imgStyle,
17314
+ "data-page-index": this.index
17107
17315
  }, [createVNode("img", {
17108
- "src": `http://172.16.86.77:30450${this.page.image_url}`,
17109
- "alt": this.page.description,
17110
17316
  "class": "image-content",
17317
+ "src": `${imgBasePath}${this.page.image_url}`,
17318
+ "alt": this.page.description,
17111
17319
  "onLoad": () => {
17112
17320
  this.handleImageLoad();
17113
17321
  },
@@ -17115,7 +17323,7 @@ const ImagePage = /* @__PURE__ */ defineComponent({
17115
17323
  this.handleImageError(error2);
17116
17324
  },
17117
17325
  "loading": "lazy"
17118
- }, null)]);
17326
+ }, null), this.isLoading && createVNode(Loading, null, null)]);
17119
17327
  }
17120
17328
  });
17121
17329
  const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
@@ -17125,7 +17333,12 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17125
17333
  required: true
17126
17334
  }
17127
17335
  },
17128
- setup(props) {
17336
+ emits: {
17337
+ initialization: () => true
17338
+ },
17339
+ setup(props, {
17340
+ emit
17341
+ }) {
17129
17342
  const controller = props.controller;
17130
17343
  const state = controller.state;
17131
17344
  const contentRef = ref(null);
@@ -17170,7 +17383,7 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17170
17383
  visiblePages.forEach((page) => {
17171
17384
  if (page) {
17172
17385
  const img = new Image();
17173
- img.src = `http://172.16.86.77:30450${page.image_url}`;
17386
+ img.src = `${imgBasePath}${page.image_url}`;
17174
17387
  }
17175
17388
  });
17176
17389
  };
@@ -17205,11 +17418,16 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17205
17418
  }
17206
17419
  }
17207
17420
  };
17421
+ const handleModeChange = (payload) => {
17422
+ const value = payload.target.value;
17423
+ controller.switchMode(value);
17424
+ };
17208
17425
  onMounted(() => {
17209
17426
  if (contentRef.value) {
17210
17427
  contentRef.value.addEventListener("scroll", handleScroll);
17211
17428
  }
17212
17429
  preloadImages();
17430
+ emit("initialization");
17213
17431
  });
17214
17432
  onUnmounted(() => {
17215
17433
  if (contentRef.value) {
@@ -17220,9 +17438,10 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17220
17438
  state,
17221
17439
  contentRef,
17222
17440
  shouldRender,
17223
- handlePageClick,
17224
- handleScroll,
17225
17441
  handleInput,
17442
+ handleScroll,
17443
+ handlePageClick,
17444
+ handleModeChange,
17226
17445
  updatePageChange
17227
17446
  };
17228
17447
  },
@@ -17241,8 +17460,8 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17241
17460
  this.handlePageClick(index);
17242
17461
  }
17243
17462
  }, null)]), createVNode("div", {
17244
- "class": "image-group-main-container",
17245
17463
  "ref": "contentRef",
17464
+ "class": "image-group-main-container",
17246
17465
  "onScroll": () => {
17247
17466
  this.handleScroll();
17248
17467
  }
@@ -17250,13 +17469,15 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17250
17469
  return createVNode(ImagePage, {
17251
17470
  "page": page,
17252
17471
  "index": index,
17253
- "scale": this.state.scale
17472
+ "mode": this.state.mode,
17473
+ "scale": this.state.scale,
17474
+ "rotate": this.state.rotateMap[index] || 0
17254
17475
  }, null);
17255
17476
  })]), this.shouldRender && createVNode(Teleport, {
17256
17477
  "to": "#custom-controls"
17257
17478
  }, {
17258
17479
  default: () => [createVNode("div", {
17259
- "class": "image-group-toolbar-container"
17480
+ "class": "image-toolbar-container"
17260
17481
  }, [createVNode("button", {
17261
17482
  "class": "control-btn",
17262
17483
  "title": "缩略图",
@@ -17264,6 +17485,18 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17264
17485
  this.controller.switchThumbnailPanel();
17265
17486
  }
17266
17487
  }, [createVNode(ThumbnailSvg, null, null)]), createVNode("button", {
17488
+ "title": "逆时针",
17489
+ "class": "control-btn",
17490
+ "onClick": () => this.controller.handleRotateChange(-90)
17491
+ }, [createVNode("span", {
17492
+ "class": "icon"
17493
+ }, [createVNode(CounterClockwiseSvg, null, null)])]), createVNode("button", {
17494
+ "title": "顺时针",
17495
+ "class": "control-btn",
17496
+ "onClick": () => this.controller.handleRotateChange(90)
17497
+ }, [createVNode("span", {
17498
+ "class": "icon"
17499
+ }, [createVNode(ClockwiseSvg, null, null)])]), createVNode("button", {
17267
17500
  "class": "control-btn",
17268
17501
  "title": "上一页",
17269
17502
  "onClick": () => {
@@ -17275,7 +17508,9 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17275
17508
  "onClick": () => {
17276
17509
  this.updatePageChange("UP");
17277
17510
  }
17278
- }, [createVNode(DownPageSvg, null, null)]), createVNode("input", {
17511
+ }, [createVNode(DownPageSvg, null, null)]), createVNode("div", {
17512
+ "class": "pagination"
17513
+ }, [createVNode("input", {
17279
17514
  "type": "number",
17280
17515
  "class": "page-input",
17281
17516
  "value": this.state.currentPage + 1,
@@ -17284,9 +17519,20 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17284
17519
  "onInput": (event) => {
17285
17520
  this.handleInput(event);
17286
17521
  }
17287
- }, null), createVNode("div", null, [createTextVNode("/")]), createVNode("div", null, [this.state.total]), createVNode("button", {
17288
- "class": "control-btn",
17522
+ }, null), createVNode("div", null, [createTextVNode("/")]), createVNode("div", null, [this.state.total])]), createVNode("select", {
17523
+ "class": "img-mode",
17524
+ "value": this.state.mode,
17525
+ "onChange": this.handleModeChange
17526
+ }, [imgModes.map((mode) => {
17527
+ return createVNode("option", {
17528
+ "label": mode.lable,
17529
+ "value": mode.value
17530
+ }, null);
17531
+ })]), createVNode("div", {
17532
+ "class": "zoom"
17533
+ }, [createVNode("button", {
17289
17534
  "title": "缩小",
17535
+ "class": "control-btn",
17290
17536
  "onClick": (event) => {
17291
17537
  this.controller.zoomOutPreview(event);
17292
17538
  }
@@ -17295,17 +17541,182 @@ const FilePreviewImageGroup = /* @__PURE__ */ defineComponent({
17295
17541
  }, [createVNode(ZoomOutSvg, null, null)])]), createVNode("span", {
17296
17542
  "class": "zoom-level"
17297
17543
  }, [Math.round(this.state.scale * 100), createTextVNode("%")]), createVNode("button", {
17298
- "class": "control-btn",
17299
17544
  "title": "放大",
17545
+ "class": "control-btn",
17300
17546
  "onClick": (event) => {
17301
17547
  this.controller.zoomInPreview(event);
17302
17548
  }
17303
17549
  }, [createVNode("span", {
17304
17550
  "class": "icon"
17305
- }, [createVNode(ZoomInSvg, null, null)])])])]
17551
+ }, [createVNode(ZoomInSvg, null, null)])])]), createVNode("button", {
17552
+ "title": "重置",
17553
+ "class": "control-btn",
17554
+ "onClick": () => {
17555
+ this.controller.reSet();
17556
+ }
17557
+ }, [createVNode("span", {
17558
+ "class": "icon"
17559
+ }, [createVNode(ResetSvg, null, null)])])])]
17306
17560
  })]);
17307
17561
  }
17308
17562
  });
17563
+ const Loading = /* @__PURE__ */ defineComponent({
17564
+ props: {
17565
+ size: {
17566
+ type: Number,
17567
+ default: 24
17568
+ }
17569
+ },
17570
+ setup() {
17571
+ return {};
17572
+ },
17573
+ render() {
17574
+ return createVNode("div", {
17575
+ "class": "loading-mask"
17576
+ }, [createVNode("div", {
17577
+ "class": "loading-spinner"
17578
+ }, [createVNode(LoaddingSvg, {
17579
+ "size": this.size
17580
+ }, null)])]);
17581
+ }
17582
+ });
17583
+ const FilePreviewShell = /* @__PURE__ */ defineComponent({
17584
+ props: {
17585
+ controller: {
17586
+ type: Object,
17587
+ required: true
17588
+ }
17589
+ },
17590
+ setup(props) {
17591
+ const controller = props.controller;
17592
+ const state = controller.state;
17593
+ const showDownloadMenu = ref(false);
17594
+ const showEngineMenu = ref(false);
17595
+ const showDownloadOptions = () => {
17596
+ showDownloadMenu.value = !showDownloadMenu.value;
17597
+ };
17598
+ const showwEngineOptions = () => {
17599
+ if (state.value.engineOptions && state.value.engineOptions.length > 1) {
17600
+ showEngineMenu.value = !showEngineMenu.value;
17601
+ }
17602
+ };
17603
+ const handleClickOutside = () => {
17604
+ showEngineMenu.value = false;
17605
+ showDownloadMenu.value = false;
17606
+ };
17607
+ const handleEngineOptionSelect = (value) => {
17608
+ controller.switchEngineType(value);
17609
+ showEngineMenu.value = false;
17610
+ };
17611
+ const handDownLoad = (actionType, event) => {
17612
+ showDownloadMenu.value = false;
17613
+ switch (actionType) {
17614
+ case ActionType.DOWNORIGINAL:
17615
+ controller.downloadOriginal(event);
17616
+ break;
17617
+ case ActionType.COPYTEXTCONTENT:
17618
+ controller.copyTextContent(event);
17619
+ break;
17620
+ case ActionType.DOWNPDF:
17621
+ controller.exportToPdf(event);
17622
+ break;
17623
+ case ActionType.DOWNMD:
17624
+ controller.exportToMd(event);
17625
+ break;
17626
+ default:
17627
+ console.error("Invalid action type:", actionType);
17628
+ break;
17629
+ }
17630
+ };
17631
+ onMounted(() => {
17632
+ document.addEventListener("click", handleClickOutside, true);
17633
+ });
17634
+ onUnmounted(() => {
17635
+ document.removeEventListener("click", handleClickOutside, true);
17636
+ });
17637
+ return {
17638
+ state,
17639
+ controller,
17640
+ showEngineMenu,
17641
+ showDownloadMenu,
17642
+ handDownLoad,
17643
+ showwEngineOptions,
17644
+ showDownloadOptions,
17645
+ handleEngineOptionSelect
17646
+ };
17647
+ },
17648
+ render() {
17649
+ return createVNode("div", {
17650
+ "class": ["file-preview-shell", this.state.theme]
17651
+ }, [createVNode("div", {
17652
+ "class": "preview-header"
17653
+ }, [createVNode("div", {
17654
+ "class": "file-info"
17655
+ }, [createVNode("h3", {
17656
+ "class": "file-name"
17657
+ }, [this.state.fileName]), createVNode("div", {
17658
+ "class": "engine-container"
17659
+ }, [createVNode("div", {
17660
+ "class": "engine-content"
17661
+ }, [createVNode("div", {
17662
+ "class": {
17663
+ "engine-type": true,
17664
+ "is-multiple": this.state.engineOptions.length > 1
17665
+ }
17666
+ }, [this.state.engineType]), this.state.engineOptions.length > 1 && createVNode("div", {
17667
+ "class": "engine-icon",
17668
+ "onClick": () => {
17669
+ this.showwEngineOptions();
17670
+ }
17671
+ }, [createVNode(DownSvg, null, null)])]), this.showEngineMenu && this.state.engineOptions.length > 1 && createVNode("ul", {
17672
+ "class": "engine-options"
17673
+ }, [this.state.engineOptions.map((type) => createVNode("li", {
17674
+ "class": {
17675
+ "engine-option-item": true,
17676
+ "is-active": type === this.state.engineType
17677
+ },
17678
+ "onClick": () => {
17679
+ this.handleEngineOptionSelect(type);
17680
+ }
17681
+ }, [type]))])])]), createVNode("div", {
17682
+ "class": "preview-controls"
17683
+ }, [createVNode("div", {
17684
+ "class": "custom-controls",
17685
+ "id": "custom-controls"
17686
+ }, null), createVNode("button", {
17687
+ "class": "control-btn download-btn",
17688
+ "title": "下载选项",
17689
+ "onClick": () => {
17690
+ this.showDownloadOptions();
17691
+ }
17692
+ }, [createVNode("span", {
17693
+ "class": "icon"
17694
+ }, [createVNode(DownLoadSvg, null, null)])])])]), this.showDownloadMenu && createVNode("div", {
17695
+ "class": "download-options"
17696
+ }, [createVNode("button", {
17697
+ "class": "download-option",
17698
+ "onClick": (event) => {
17699
+ this.handDownLoad(ActionType.DOWNORIGINAL, event);
17700
+ }
17701
+ }, [createTextVNode("下载原文件")]), this.state.engineType !== EngineType.PDF && this.state.engineType !== EngineType.UNKNOWN && createVNode("button", {
17702
+ "class": "download-option",
17703
+ "onClick": (event) => {
17704
+ this.handDownLoad(ActionType.COPYTEXTCONTENT, event);
17705
+ }
17706
+ }, [createTextVNode("复制文本内容")])]), createVNode("div", {
17707
+ "class": "preview-content"
17708
+ }, [createVNode("div", {
17709
+ "class": "preview-inner"
17710
+ }, [this.state.isCreated && this.controller.preViewComp && this.controller.preViewController ? h(this.controller.preViewComp, {
17711
+ controller: this.controller.preViewController,
17712
+ onInitialization: () => {
17713
+ this.state.isLoading = false;
17714
+ }
17715
+ }) : null]), this.state.isLoading && createVNode(Loading, {
17716
+ "size": 48
17717
+ }, null)])]);
17718
+ }
17719
+ });
17309
17720
  class FilePreviewItemController {
17310
17721
  /**
17311
17722
  * 构造函数
@@ -17320,17 +17731,15 @@ class FilePreviewItemController {
17320
17731
  * 初始化状态
17321
17732
  */
17322
17733
  initState() {
17734
+ const { fileType, theme } = this.filePreviewShell.getState();
17323
17735
  this.state.content = "";
17324
- this.state.scale = 1;
17325
- this.state.theme = "dark";
17736
+ this.state.theme = theme;
17737
+ this.state.fileType = fileType;
17326
17738
  }
17327
17739
  /**
17328
17740
  * 初始化
17329
- * @param param 初始化参数
17330
17741
  */
17331
- async initialize(param) {
17332
- const { theme } = param;
17333
- this.state.theme = theme;
17742
+ async initialize() {
17334
17743
  this.state.content = await this.getContent();
17335
17744
  }
17336
17745
  /**
@@ -17339,29 +17748,146 @@ class FilePreviewItemController {
17339
17748
  async getContent() {
17340
17749
  return "";
17341
17750
  }
17751
+ }
17752
+ class FilePreviewImageController extends FilePreviewItemController {
17753
+ initState() {
17754
+ super.initState();
17755
+ this.state.rotate = 0;
17756
+ this.state.offsetX = 0;
17757
+ this.state.offsetY = 0;
17758
+ this.state.scale = 1;
17759
+ this.state.mode = ImageMode.PAGE;
17760
+ this.state.enableTransition = true;
17761
+ }
17762
+ /**
17763
+ * 获取内容
17764
+ */
17765
+ async getContent() {
17766
+ const options = this.filePreviewShell.getOptions();
17767
+ const { fileId, fileCat, fileType } = this.filePreviewShell.getState();
17768
+ try {
17769
+ const content = await options.getImgContent(fileId, fileType, fileCat);
17770
+ return content;
17771
+ } catch (error2) {
17772
+ return "";
17773
+ }
17774
+ }
17775
+ /**
17776
+ * 处理旋转角度改变
17777
+ *
17778
+ * @param value
17779
+ */
17780
+ handleRotateChange(value) {
17781
+ this.state.rotate += value;
17782
+ }
17783
+ /**
17784
+ * 处理鼠标按下
17785
+ * @param e
17786
+ * @returns
17787
+ */
17788
+ handleMouseDown(e) {
17789
+ const { offsetX, offsetY } = this.state;
17790
+ e.preventDefault();
17791
+ this.state.enableTransition = false;
17792
+ const startX = e.pageX;
17793
+ const startY = e.pageY;
17794
+ const dragHandler = (ev) => {
17795
+ this.state.offsetX = offsetX + ev.pageX - startX;
17796
+ this.state.offsetY = offsetY + ev.pageY - startY;
17797
+ };
17798
+ document.addEventListener("mousemove", dragHandler);
17799
+ const removeListeners = () => {
17800
+ document.removeEventListener("mousemove", dragHandler);
17801
+ this.state.enableTransition = true;
17802
+ };
17803
+ document.addEventListener("mouseup", removeListeners, {
17804
+ once: true
17805
+ });
17806
+ }
17342
17807
  /**
17343
17808
  * 缩小预览
17344
17809
  */
17345
- zoomOutPreview(event) {
17810
+ zoomOutPreview(_event) {
17346
17811
  this.state.scale = Math.max(this.state.scale - 0.1, 0.1);
17347
17812
  }
17348
17813
  /**
17349
17814
  * 放大预览
17350
17815
  */
17351
- zoomInPreview(event) {
17816
+ zoomInPreview(_event) {
17352
17817
  this.state.scale = Math.min(this.state.scale + 0.1, 2);
17353
17818
  }
17819
+ /**
17820
+ * 重置
17821
+ */
17822
+ reSet() {
17823
+ this.state.rotate = 0;
17824
+ this.state.offsetX = 0;
17825
+ this.state.offsetY = 0;
17826
+ this.state.scale = 1;
17827
+ this.state.mode = ImageMode.PAGE;
17828
+ this.state.enableTransition = true;
17829
+ }
17830
+ /**
17831
+ * 切换模式
17832
+ * @param mode 模式
17833
+ */
17834
+ switchMode(mode) {
17835
+ this.state.scale = 1;
17836
+ this.state.rotate = 0;
17837
+ this.state.offsetX = 0;
17838
+ this.state.offsetY = 0;
17839
+ this.state.mode = mode;
17840
+ }
17354
17841
  }
17355
- class FilePreviewTextController extends FilePreviewItemController {
17842
+ class FilePreviewImageGroupController extends FilePreviewImageController {
17843
+ initState() {
17844
+ super.initState();
17845
+ this.state.items = [];
17846
+ this.state.currentPage = 0;
17847
+ this.state.total = 0;
17848
+ this.state.showThumbnailPanel = false;
17849
+ this.state.rotateMap = {};
17850
+ }
17356
17851
  /**
17357
17852
  * 获取内容
17358
17853
  */
17359
17854
  async getContent() {
17360
- if (!this.filePreviewShell) return "";
17361
17855
  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 || "";
17856
+ const { fileId, fileCat } = this.filePreviewShell.getState();
17857
+ try {
17858
+ const content = await options.getContent(fileId, "pageindex", fileCat);
17859
+ if (content && content.pages && content.pages.length > 0) {
17860
+ this.state.items = content.pages;
17861
+ }
17862
+ this.state.total = this.state.items.length;
17863
+ return content || {};
17864
+ } catch (error2) {
17865
+ return {};
17866
+ }
17867
+ }
17868
+ /**
17869
+ * 切换缩略图面板
17870
+ */
17871
+ switchThumbnailPanel() {
17872
+ this.state.showThumbnailPanel = !this.state.showThumbnailPanel;
17873
+ }
17874
+ /**
17875
+ * 处理旋转角度改变
17876
+ * @param value
17877
+ */
17878
+ handleRotateChange(value) {
17879
+ const indexStr = this.state.currentPage.toString();
17880
+ if (!this.state.rotateMap[indexStr]) {
17881
+ this.state.rotateMap[indexStr] = 0;
17882
+ }
17883
+ this.state.rotateMap[indexStr] += value;
17884
+ }
17885
+ /**
17886
+ * 重置
17887
+ */
17888
+ reSet() {
17889
+ super.reSet();
17890
+ this.state.rotateMap = {};
17365
17891
  }
17366
17892
  }
17367
17893
  function extend(destination) {
@@ -18104,81 +18630,50 @@ function join(output, replacement) {
18104
18630
  function canConvert(input) {
18105
18631
  return input != null && (typeof input === "string" || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));
18106
18632
  }
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
- }
18633
+ class FilePreviewTextController extends FilePreviewItemController {
18134
18634
  /**
18135
18635
  * 获取内容
18136
18636
  */
18137
18637
  async getContent() {
18138
- if (!this.filePreviewShell) return "";
18139
18638
  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;
18639
+ const { fileId, fileType, fileCat } = this.filePreviewShell.getState();
18640
+ try {
18641
+ const content = await options.getContent(fileId, fileType, fileCat);
18642
+ return content || "";
18643
+ } catch (error2) {
18644
+ return error2.message || "";
18645
+ }
18151
18646
  }
18152
18647
  }
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
- }
18648
+ class FilePreviewMDController extends FilePreviewTextController {
18161
18649
  /**
18162
18650
  * 获取内容
18163
18651
  */
18164
18652
  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;
18653
+ try {
18654
+ let content = await super.getContent();
18655
+ if (this.state.fileType === FileType.HTML) {
18656
+ const parser = new DOMParser();
18657
+ const doc = parser.parseFromString(content, "text/html");
18658
+ const scripts = doc.body.querySelectorAll("script");
18659
+ scripts.forEach((script) => script.remove());
18660
+ const styles = doc.body.querySelectorAll("style");
18661
+ styles.forEach((style) => style.remove());
18662
+ const cleanBodyHTML = doc.body.innerHTML;
18663
+ const turndown = new TurndownService({
18664
+ headingStyle: "atx",
18665
+ codeBlockStyle: "fenced"
18666
+ });
18667
+ content = turndown.turndown(cleanBodyHTML);
18668
+ }
18669
+ return content;
18670
+ } catch (error2) {
18671
+ return error2.message || "";
18171
18672
  }
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
18673
  }
18181
18674
  }
18675
+ class FilePreviewHtmlController extends FilePreviewTextController {
18676
+ }
18182
18677
  const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18183
18678
  /**
18184
18679
  * 注册文件预览项
@@ -18187,7 +18682,7 @@ const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18187
18682
  * @param controller 控制器
18188
18683
  */
18189
18684
  static registerItem(type, component, controller) {
18190
- this.filePreviewMap.set(type, {
18685
+ this.enginePreviewMap.set(type, {
18191
18686
  component,
18192
18687
  controller
18193
18688
  });
@@ -18197,112 +18692,42 @@ const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18197
18692
  */
18198
18693
  static initialize() {
18199
18694
  this.registerItem(
18200
- "html",
18201
- FilePreviewMD,
18695
+ EngineType.HTML,
18696
+ FilePreviewHtml,
18202
18697
  (filePreviewShell) => {
18203
- return new FilePreviewMDController(filePreviewShell);
18698
+ return new FilePreviewHtmlController(filePreviewShell);
18204
18699
  }
18205
18700
  );
18206
18701
  this.registerItem(
18207
- "md",
18702
+ EngineType.MD,
18208
18703
  FilePreviewMD,
18209
18704
  (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);
18705
+ return new FilePreviewMDController(filePreviewShell);
18225
18706
  }
18226
18707
  );
18227
18708
  this.registerItem(
18228
- "txt",
18709
+ EngineType.TXT,
18229
18710
  FilePreviewText,
18230
18711
  (filePreviewShell) => {
18231
18712
  return new FilePreviewTextController(filePreviewShell);
18232
18713
  }
18233
18714
  );
18234
18715
  this.registerItem(
18235
- "pdf",
18236
- FilePreviewImageGroup,
18237
- (filePreviewShell) => {
18238
- return new FilePreviewImageGroupController(filePreviewShell);
18239
- }
18240
- );
18241
- this.registerItem(
18242
- "doc",
18716
+ EngineType.PDF,
18243
18717
  FilePreviewImageGroup,
18244
18718
  (filePreviewShell) => {
18245
18719
  return new FilePreviewImageGroupController(filePreviewShell);
18246
18720
  }
18247
18721
  );
18248
18722
  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,
18723
+ EngineType.IMG,
18724
+ FilePreviewImage,
18279
18725
  (filePreviewShell) => {
18280
18726
  return new FilePreviewImageController(filePreviewShell);
18281
18727
  }
18282
18728
  );
18283
18729
  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",
18730
+ EngineType.UNKNOWN,
18306
18731
  FilePreviewUnkown,
18307
18732
  (filePreviewShell) => {
18308
18733
  return new FilePreviewItemController(filePreviewShell);
@@ -18315,10 +18740,10 @@ const _FilePreviewItemDispatcher = class _FilePreviewItemDispatcher {
18315
18740
  * @returns
18316
18741
  */
18317
18742
  static getItem(type) {
18318
- return this.filePreviewMap.get(type) || null;
18743
+ return this.enginePreviewMap.get(type) || null;
18319
18744
  }
18320
18745
  };
18321
- _FilePreviewItemDispatcher.filePreviewMap = /* @__PURE__ */ new Map();
18746
+ _FilePreviewItemDispatcher.enginePreviewMap = /* @__PURE__ */ new Map();
18322
18747
  let FilePreviewItemDispatcher = _FilePreviewItemDispatcher;
18323
18748
  class FilePreviewShellController {
18324
18749
  /**
@@ -18328,15 +18753,17 @@ class FilePreviewShellController {
18328
18753
  constructor(options) {
18329
18754
  this.options = options;
18330
18755
  this.currentApp = null;
18756
+ this.preViewComp = void 0;
18331
18757
  this.state = ref({
18332
18758
  fileName: "",
18333
18759
  fileId: "",
18334
18760
  fileCat: "",
18335
18761
  theme: "dark",
18762
+ isLoading: false,
18763
+ isCreated: false,
18336
18764
  fileType: FileType.UNKNOWN,
18337
- preViewComp: void 0,
18338
- preViewController: void 0,
18339
- engineType: EngineType.UNKNOWN
18765
+ engineType: EngineType.UNKNOWN,
18766
+ engineOptions: []
18340
18767
  });
18341
18768
  if (options.theme) {
18342
18769
  this.state.value.theme = options.theme;
@@ -18374,19 +18801,13 @@ class FilePreviewShellController {
18374
18801
  * 解析引擎类型
18375
18802
  */
18376
18803
  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;
18804
+ const engineOptions = FileTypeEngineMap.get(this.state.value.fileType);
18805
+ if (engineOptions && engineOptions.length > 0) {
18806
+ this.state.value.engineOptions = engineOptions;
18387
18807
  } else {
18388
- this.state.value.engineType = EngineType.UNKNOWN;
18808
+ this.state.value.engineOptions = [EngineType.UNKNOWN];
18389
18809
  }
18810
+ this.state.value.engineType = this.state.value.engineOptions[0];
18390
18811
  }
18391
18812
  /**
18392
18813
  * 解析预览项
@@ -18394,15 +18815,15 @@ class FilePreviewShellController {
18394
18815
  */
18395
18816
  async parsePreviewItem() {
18396
18817
  let previewItem = FilePreviewItemDispatcher.getItem(
18397
- this.state.value.fileType
18818
+ this.state.value.engineType
18398
18819
  );
18399
18820
  if (!previewItem) {
18400
- previewItem = FilePreviewItemDispatcher.getItem("unknown");
18821
+ previewItem = FilePreviewItemDispatcher.getItem(EngineType.UNKNOWN);
18401
18822
  }
18402
- this.state.value.preViewComp = previewItem.component;
18823
+ this.preViewComp = previewItem.component;
18403
18824
  const preViewController = previewItem.controller(this);
18404
- await preViewController.initialize({ theme: this.state.value.theme });
18405
- this.state.value.preViewController = preViewController;
18825
+ await preViewController.initialize();
18826
+ this.preViewController = preViewController;
18406
18827
  }
18407
18828
  /**
18408
18829
  * 挂载组件实例
@@ -18434,9 +18855,12 @@ class FilePreviewShellController {
18434
18855
  * @param data
18435
18856
  */
18436
18857
  async updateView(data) {
18858
+ this.state.value.isCreated = false;
18859
+ this.state.value.isLoading = true;
18437
18860
  await this.parseParams(data);
18438
18861
  await this.parsePreviewItem();
18439
18862
  this.mountComponent();
18863
+ this.state.value.isCreated = true;
18440
18864
  }
18441
18865
  /**
18442
18866
  * 获取内容
@@ -18473,6 +18897,7 @@ class FilePreviewShellController {
18473
18897
  */
18474
18898
  async copyTextContent(event) {
18475
18899
  if (!this.options.getContent) return;
18900
+ await navigator.clipboard.writeText("");
18476
18901
  const content = await this.options.getContent(
18477
18902
  this.state.value.fileId,
18478
18903
  this.state.value.fileType,
@@ -18503,8 +18928,20 @@ class FilePreviewShellController {
18503
18928
  await this.options.actionSuccessCallBack(ActionType.DOWNMD);
18504
18929
  }
18505
18930
  }
18931
+ /**
18932
+ * 切换引擎类型
18933
+ * @param engineType
18934
+ */
18935
+ async switchEngineType(engineType) {
18936
+ this.state.value.isCreated = false;
18937
+ this.state.value.engineType = engineType;
18938
+ await this.parsePreviewItem();
18939
+ this.mountComponent();
18940
+ this.state.value.isCreated = true;
18941
+ }
18506
18942
  }
18507
18943
  export {
18508
18944
  ActionType,
18509
- FilePreviewShellController
18945
+ FilePreviewShellController,
18946
+ FileType
18510
18947
  };