@cecee/document-flip-book 1.0.8

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 (59) hide show
  1. package/dist/cjs/ArchiveCover.d.ts +9 -0
  2. package/dist/cjs/ArchiveCover.js +142 -0
  3. package/dist/cjs/DocumentFlipBook.d.ts +32 -0
  4. package/dist/cjs/DocumentFlipBook.js +644 -0
  5. package/dist/cjs/ExportModal.d.ts +10 -0
  6. package/dist/cjs/ExportModal.js +96 -0
  7. package/dist/cjs/HeaderBar.d.ts +25 -0
  8. package/dist/cjs/HeaderBar.js +220 -0
  9. package/dist/cjs/PdfPage.d.ts +9 -0
  10. package/dist/cjs/PdfPage.js +143 -0
  11. package/dist/cjs/ProjectCover.d.ts +8 -0
  12. package/dist/cjs/ProjectCover.js +201 -0
  13. package/dist/cjs/SideTabs.d.ts +8 -0
  14. package/dist/cjs/SideTabs.js +34 -0
  15. package/dist/cjs/exportHtml.d.ts +19 -0
  16. package/dist/cjs/exportHtml.js +189 -0
  17. package/dist/cjs/exportPdf.d.ts +27 -0
  18. package/dist/cjs/exportPdf.js +232 -0
  19. package/dist/cjs/globalCache.d.ts +5 -0
  20. package/dist/cjs/globalCache.js +20 -0
  21. package/dist/cjs/index.d.ts +3 -0
  22. package/dist/cjs/index.js +36 -0
  23. package/dist/cjs/index.less +637 -0
  24. package/dist/cjs/printPdf.d.ts +6 -0
  25. package/dist/cjs/printPdf.js +51 -0
  26. package/dist/cjs/types.d.ts +31 -0
  27. package/dist/cjs/types.js +5 -0
  28. package/dist/cjs/utils.d.ts +17 -0
  29. package/dist/cjs/utils.js +220 -0
  30. package/dist/esm/ArchiveCover.d.ts +9 -0
  31. package/dist/esm/ArchiveCover.js +136 -0
  32. package/dist/esm/DocumentFlipBook.d.ts +32 -0
  33. package/dist/esm/DocumentFlipBook.js +630 -0
  34. package/dist/esm/ExportModal.d.ts +10 -0
  35. package/dist/esm/ExportModal.js +88 -0
  36. package/dist/esm/HeaderBar.d.ts +25 -0
  37. package/dist/esm/HeaderBar.js +211 -0
  38. package/dist/esm/PdfPage.d.ts +9 -0
  39. package/dist/esm/PdfPage.js +136 -0
  40. package/dist/esm/ProjectCover.d.ts +8 -0
  41. package/dist/esm/ProjectCover.js +195 -0
  42. package/dist/esm/SideTabs.d.ts +8 -0
  43. package/dist/esm/SideTabs.js +27 -0
  44. package/dist/esm/exportHtml.d.ts +19 -0
  45. package/dist/esm/exportHtml.js +178 -0
  46. package/dist/esm/exportPdf.d.ts +27 -0
  47. package/dist/esm/exportPdf.js +223 -0
  48. package/dist/esm/globalCache.d.ts +5 -0
  49. package/dist/esm/globalCache.js +15 -0
  50. package/dist/esm/index.d.ts +3 -0
  51. package/dist/esm/index.js +3 -0
  52. package/dist/esm/index.less +637 -0
  53. package/dist/esm/printPdf.d.ts +6 -0
  54. package/dist/esm/printPdf.js +45 -0
  55. package/dist/esm/types.d.ts +31 -0
  56. package/dist/esm/types.js +1 -0
  57. package/dist/esm/utils.d.ts +17 -0
  58. package/dist/esm/utils.js +214 -0
  59. package/package.json +57 -0
@@ -0,0 +1,195 @@
1
+ import React from 'react';
2
+ import "./index.less";
3
+ import dayjs from 'dayjs';
4
+ import { Checkbox, ConfigProvider } from 'antd';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ var ProjectCover = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
8
+ var _user$company, _info$dt, _user$info;
9
+ var documentInfo = _ref.documentInfo,
10
+ _ref$themeColor = _ref.themeColor,
11
+ themeColor = _ref$themeColor === void 0 ? '#4baae3' : _ref$themeColor;
12
+ var info = documentInfo || {};
13
+ var user = info === null || info === void 0 ? void 0 : info.user;
14
+ var companyName = (info === null || info === void 0 ? void 0 : info.companyName) || (user === null || user === void 0 || (_user$company = user.company) === null || _user$company === void 0 ? void 0 : _user$company.fd) || '-';
15
+ var checkboxTheme = {
16
+ token: {
17
+ colorBgContainerDisabled: 'transparent',
18
+ colorBorder: '#000',
19
+ colorTextDisabled: '#000',
20
+ controlInteractiveSize: 18,
21
+ lineWidth: 2
22
+ }
23
+ };
24
+ return /*#__PURE__*/_jsx("div", {
25
+ className: "project-cover-container",
26
+ style: {
27
+ backgroundColor: themeColor
28
+ },
29
+ ref: ref,
30
+ children: /*#__PURE__*/_jsx("div", {
31
+ className: "project-cover-border-outer",
32
+ children: /*#__PURE__*/_jsxs("div", {
33
+ className: "project-cover-border-inner",
34
+ children: [/*#__PURE__*/_jsx("div", {
35
+ className: "project-cover-header",
36
+ children: /*#__PURE__*/_jsx("h1", {
37
+ className: "project-cover-title",
38
+ children: (info === null || info === void 0 ? void 0 : info.title) || '高企研发'
39
+ })
40
+ }), /*#__PURE__*/_jsxs("div", {
41
+ className: "project-cover-stats-row",
42
+ children: [/*#__PURE__*/_jsx("div", {
43
+ className: "stat-cell-label",
44
+ children: /*#__PURE__*/_jsxs(ConfigProvider, {
45
+ theme: checkboxTheme,
46
+ children: [/*#__PURE__*/_jsx(Checkbox, {
47
+ checked: !!(info !== null && info !== void 0 && info.edr04bs && info.edr04bs.length > 0),
48
+ disabled: true
49
+ }), " \u7EAA\u8981"]
50
+ })
51
+ }), /*#__PURE__*/_jsx("div", {
52
+ className: "stat-cell-value",
53
+ children: info !== null && info !== void 0 && info.edr04bs && info.edr04bs.length > 0 ? info.edr04bs.length : '-'
54
+ }), /*#__PURE__*/_jsx("div", {
55
+ className: "stat-cell-label",
56
+ children: /*#__PURE__*/_jsxs(ConfigProvider, {
57
+ theme: checkboxTheme,
58
+ children: [/*#__PURE__*/_jsx(Checkbox, {
59
+ checked: false,
60
+ disabled: true
61
+ }), " \u4EBA\u5458"]
62
+ })
63
+ }), /*#__PURE__*/_jsx("div", {
64
+ className: "stat-cell-value",
65
+ children: "1"
66
+ })]
67
+ }), /*#__PURE__*/_jsxs("div", {
68
+ className: "project-cover-stats-row",
69
+ style: {
70
+ borderTop: 'none'
71
+ },
72
+ children: [/*#__PURE__*/_jsx("div", {
73
+ className: "stat-cell-label",
74
+ children: /*#__PURE__*/_jsxs(ConfigProvider, {
75
+ theme: checkboxTheme,
76
+ children: [/*#__PURE__*/_jsx(Checkbox, {
77
+ checked: false,
78
+ disabled: true
79
+ }), " \u8D39\u7528"]
80
+ })
81
+ }), /*#__PURE__*/_jsx("div", {
82
+ className: "stat-cell-value",
83
+ children: "3"
84
+ }), /*#__PURE__*/_jsx("div", {
85
+ className: "stat-cell-label",
86
+ children: /*#__PURE__*/_jsxs(ConfigProvider, {
87
+ theme: checkboxTheme,
88
+ children: [/*#__PURE__*/_jsx(Checkbox, {
89
+ checked: false,
90
+ disabled: true
91
+ }), " \u8BF4\u660E\u4E66"]
92
+ })
93
+ }), /*#__PURE__*/_jsx("div", {
94
+ className: "stat-cell-value",
95
+ children: "1"
96
+ })]
97
+ }), /*#__PURE__*/_jsxs("div", {
98
+ className: "project-cover-details",
99
+ children: [/*#__PURE__*/_jsxs("div", {
100
+ className: "detail-row",
101
+ children: [/*#__PURE__*/_jsx("div", {
102
+ className: "detail-label",
103
+ children: "\u5E74\u5EA6"
104
+ }), /*#__PURE__*/_jsx("div", {
105
+ className: "detail-value",
106
+ children: (info === null || info === void 0 || (_info$dt = info.dt) === null || _info$dt === void 0 ? void 0 : _info$dt.slice(0, 4)) || ''
107
+ })]
108
+ }), /*#__PURE__*/_jsxs("div", {
109
+ className: "detail-row",
110
+ children: [/*#__PURE__*/_jsx("div", {
111
+ className: "detail-label",
112
+ children: "\u6863\u6848\u53F7"
113
+ }), /*#__PURE__*/_jsx("div", {
114
+ className: "detail-value",
115
+ children: (info === null || info === void 0 ? void 0 : info.code) || ''
116
+ })]
117
+ }), /*#__PURE__*/_jsxs("div", {
118
+ className: "detail-row",
119
+ children: [/*#__PURE__*/_jsx("div", {
120
+ className: "detail-label",
121
+ children: "\u9879\u76EE\u540D\u79F0"
122
+ }), /*#__PURE__*/_jsx("div", {
123
+ className: "detail-value",
124
+ children: (info === null || info === void 0 ? void 0 : info.acc56c_fd) || ''
125
+ })]
126
+ }), /*#__PURE__*/_jsxs("div", {
127
+ className: "detail-row",
128
+ children: [/*#__PURE__*/_jsx("div", {
129
+ className: "detail-label",
130
+ children: "\u9879\u76EE\u7F16\u53F7"
131
+ }), /*#__PURE__*/_jsx("div", {
132
+ className: "detail-value",
133
+ children: (info === null || info === void 0 ? void 0 : info.code) || ''
134
+ })]
135
+ }), /*#__PURE__*/_jsxs("div", {
136
+ className: "detail-row",
137
+ children: [/*#__PURE__*/_jsx("div", {
138
+ className: "detail-label",
139
+ children: "\u7F16\u5236\u5355\u4F4D"
140
+ }), /*#__PURE__*/_jsx("div", {
141
+ className: "detail-value",
142
+ children: companyName || ''
143
+ })]
144
+ }), /*#__PURE__*/_jsxs("div", {
145
+ className: "detail-row",
146
+ children: [/*#__PURE__*/_jsx("div", {
147
+ className: "detail-label",
148
+ children: "\u7F16\u5236\u65E5\u671F"
149
+ }), /*#__PURE__*/_jsx("div", {
150
+ className: "detail-value",
151
+ children: info !== null && info !== void 0 && info.updated_at ? dayjs(info.updated_at).format('YYYY-MM-DD HH:mm:ss') : ''
152
+ })]
153
+ }), /*#__PURE__*/_jsxs("div", {
154
+ className: "detail-row",
155
+ children: [/*#__PURE__*/_jsx("div", {
156
+ className: "detail-label",
157
+ children: "\u7F16\u5236\u4EBA"
158
+ }), /*#__PURE__*/_jsx("div", {
159
+ className: "detail-value",
160
+ children: (info === null || info === void 0 ? void 0 : info.full_name) || (user === null || user === void 0 || (_user$info = user.info) === null || _user$info === void 0 ? void 0 : _user$info.name) || ''
161
+ })]
162
+ })]
163
+ }), /*#__PURE__*/_jsxs("div", {
164
+ className: "project-cover-footer",
165
+ children: [/*#__PURE__*/_jsxs("div", {
166
+ className: "footer-row",
167
+ children: [/*#__PURE__*/_jsx("div", {
168
+ className: "footer-cell",
169
+ children: "\u51ED\u8BC1"
170
+ }), /*#__PURE__*/_jsx("div", {
171
+ className: "footer-cell",
172
+ children: "\u5F20\u9644\u4EF6"
173
+ }), /*#__PURE__*/_jsx("div", {
174
+ className: "footer-cell",
175
+ children: "\u5F20"
176
+ })]
177
+ }), /*#__PURE__*/_jsxs("div", {
178
+ className: "footer-row ",
179
+ children: [/*#__PURE__*/_jsx("div", {
180
+ className: "footer-cell",
181
+ children: "\u5171"
182
+ }), /*#__PURE__*/_jsxs("div", {
183
+ className: "footer-cell",
184
+ children: [(info === null || info === void 0 ? void 0 : info.totalVolumes) || '', "\u518C\u7B2C"]
185
+ }), /*#__PURE__*/_jsxs("div", {
186
+ className: "footer-cell",
187
+ children: [(info === null || info === void 0 ? void 0 : info.volumeNumber) || '', "\u518C"]
188
+ })]
189
+ })]
190
+ })]
191
+ })
192
+ })
193
+ });
194
+ });
195
+ export default /*#__PURE__*/React.memo(ProjectCover);
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import type { SideTabItem } from './types';
3
+ export default function SideTabs(props: {
4
+ items: SideTabItem[];
5
+ activeKey?: string;
6
+ className?: string;
7
+ onSelect: (item: SideTabItem) => void;
8
+ }): React.JSX.Element;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export default function SideTabs(props) {
4
+ var items = props.items,
5
+ activeKey = props.activeKey,
6
+ className = props.className,
7
+ onSelect = props.onSelect;
8
+ return /*#__PURE__*/_jsx("div", {
9
+ className: ['dfb-sideTabs', className].filter(Boolean).join(' '),
10
+ children: items.map(function (it) {
11
+ return /*#__PURE__*/_jsx("button", {
12
+ type: "button",
13
+ className: ['dfb-sideTab', activeKey === it.key ? 'is-active' : ''].join(' '),
14
+ style: {
15
+ background: it.color
16
+ },
17
+ onClick: function onClick() {
18
+ return onSelect(it);
19
+ },
20
+ children: /*#__PURE__*/_jsx("span", {
21
+ className: "dfb-sideTabText",
22
+ children: it.label
23
+ })
24
+ }, it.key);
25
+ })
26
+ });
27
+ }
@@ -0,0 +1,19 @@
1
+ import { BuiltPage, PdfDocumentLike } from './types';
2
+ interface ExportHtmlOptions {
3
+ pages: BuiltPage[];
4
+ filename: string;
5
+ title?: string;
6
+ getDocument: (path: string) => Promise<PdfDocumentLike>;
7
+ coverInfo: {
8
+ data: any;
9
+ archiveInfo?: any;
10
+ themeColor?: string;
11
+ companyName?: string;
12
+ isProjectMode?: boolean;
13
+ };
14
+ }
15
+ /**
16
+ * 导出 HTML 翻书功能
17
+ */
18
+ export declare const exportArchivePagesToHtml: (options: ExportHtmlOptions) => Promise<void>;
19
+ export {};
@@ -0,0 +1,178 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ import { message } from 'antd';
6
+ import dayjs from 'dayjs';
7
+ import { renderPdfPageToDataUrl, renderImageToDataUrl } from "./exportPdf";
8
+ /**
9
+ * 渲染封面为图片
10
+ */
11
+ var renderCoverToImage = /*#__PURE__*/function () {
12
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
13
+ var data, archiveInfo, _options$themeColor, themeColor, _options$companyName, companyName, _options$isProjectMod, isProjectMode, acc51c, div, html, _info$user, info, coverData, _archiveInfo$nsp24c, _coverData, canvas;
14
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
15
+ while (1) switch (_context.prev = _context.next) {
16
+ case 0:
17
+ data = options.data, archiveInfo = options.archiveInfo, _options$themeColor = options.themeColor, themeColor = _options$themeColor === void 0 ? '#9F7D4E' : _options$themeColor, _options$companyName = options.companyName, companyName = _options$companyName === void 0 ? '-' : _options$companyName, _options$isProjectMod = options.isProjectMode, isProjectMode = _options$isProjectMod === void 0 ? false : _options$isProjectMod;
18
+ acc51c = data || {}; // 创建一个隐藏的 DOM 节点来渲染封面
19
+ div = document.createElement('div');
20
+ div.style.position = 'absolute';
21
+ div.style.left = '-9999px';
22
+ div.style.width = '600px';
23
+ div.style.height = '800px';
24
+ div.style.backgroundColor = themeColor;
25
+ document.body.appendChild(div);
26
+ html = '';
27
+ if (isProjectMode) {
28
+ info = archiveInfo || {};
29
+ coverData = {
30
+ year: info !== null && info !== void 0 && info.dt ? info.dt.slice(0, 4) : dayjs().format('YYYY'),
31
+ archiveNo: (info === null || info === void 0 ? void 0 : info.code) || '-',
32
+ projectName: (info === null || info === void 0 ? void 0 : info.acc56c_fd) || '-',
33
+ projectNo: (info === null || info === void 0 ? void 0 : info.code) || '-',
34
+ company: companyName,
35
+ date: info !== null && info !== void 0 && info.updated_at ? dayjs(info.updated_at).format('YYYY-MM-DD HH:mm:ss') : '-',
36
+ creator: (info === null || info === void 0 ? void 0 : info.full_name) || (info === null || info === void 0 || (_info$user = info.user) === null || _info$user === void 0 || (_info$user = _info$user.info) === null || _info$user === void 0 ? void 0 : _info$user.name) || '管理员',
37
+ totalVolumes: (info === null || info === void 0 ? void 0 : info.totalVolumes) || '',
38
+ volumeNumber: (info === null || info === void 0 ? void 0 : info.volumeNumber) || '',
39
+ edr04bs: (info === null || info === void 0 ? void 0 : info.edr04bs) || [],
40
+ title: (info === null || info === void 0 ? void 0 : info.title) || '高企研发'
41
+ };
42
+ html = "\n <div style=\"width: 600px; height: 800px; background-color: ".concat(themeColor, "; display: flex; flex-direction: column; padding: 30px; box-sizing: border-box; font-family: SimSun, STSong, serif;\">\n <div style=\"border: 5px solid #000; padding: 5px; height: 100%; box-sizing: border-box;\">\n <div style=\"border: 2px solid #000; height: 100%; display: flex; flex-direction: column; box-sizing: border-box;\">\n <div style=\"text-align: center; color: #000; padding: 8px 0;\">\n <h1 style=\"font-size: 54px; margin: 0; font-weight: 900; letter-spacing: 8px;\">").concat(coverData.title, "</h1>\n </div>\n\n <div style=\"display: flex; border-top: 1px solid #000; border-bottom: 1px solid #000;\">\n <div style=\"flex: 1; text-align: center; padding: 8px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 8px;\">").concat(coverData.edr04bs.length > 0 ? '☑' : '☐', " \u7EAA\u8981</div>\n <div style=\"flex: 1; text-align: center; padding: 8px; border-right: 1px solid #000; font-family: 'Times New Roman'; font-size: 18px; font-weight: bold;\">").concat(coverData.edr04bs.length > 0 ? coverData.edr04bs.length : '-', "</div>\n <div style=\"flex: 1; text-align: center; padding: 8px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 8px;\">\u2610 \u4EBA\u5458</div>\n <div style=\"flex: 1; text-align: center; padding: 8px; font-family: 'Times New Roman'; font-size: 18px; font-weight: bold;\">1</div>\n </div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\">\n <div style=\"flex: 1; text-align: center; padding: 8px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 8px;\">\u2610 \u8D39\u7528</div>\n <div style=\"flex: 1; text-align: center; padding: 8px; border-right: 1px solid #000; font-family: 'Times New Roman'; font-size: 18px; font-weight: bold;\">3</div>\n <div style=\"flex: 1; text-align: center; padding: 8px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 8px;\">\u2610 \u8BF4\u660E\u4E66</div>\n <div style=\"flex: 1; text-align: center; padding: 8px; font-family: 'Times New Roman'; font-size: 18px; font-weight: bold;\">1</div>\n </div>\n\n <div style=\" display: flex; flex-direction: column;\">\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u5E74\u5EA6</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.year, "</div></div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u6863\u6848\u53F7</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.archiveNo, "</div></div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u9879\u76EE\u540D\u79F0</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.projectName, "</div></div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u9879\u76EE\u7F16\u53F7</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.projectNo, "</div></div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u7F16\u5236\u5355\u4F4D</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.company, "</div></div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u7F16\u5236\u65E5\u671F</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.date, "</div></div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\"><div style=\"width: 100px; padding: 8px; font-weight: bold; border-right: 1px solid #000;\">\u7F16\u5236\u4EBA</div><div style=\"flex: 1; padding: 8px; font-weight: 600;\">").concat(coverData.creator, "</div></div>\n </div>\n\n <div style=\"display: flex; border-bottom: 1px solid #000;\">\n <div style=\"flex: 1; text-align: center; padding: 10px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; font-size: 16px;\">\u51ED\u8BC1</div>\n <div style=\"flex: 1; text-align: center; padding: 10px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; font-size: 16px;\">\u5F20\u9644\u4EF6</div>\n <div style=\"flex: 1; text-align: center; padding: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center; font-size: 16px;\">\u5F20</div>\n </div>\n <div style=\"display: flex; border-bottom: 1px solid #000;\">\n <div style=\"flex: 1; text-align: center; padding: 10px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; font-size: 16px;\">\u5171</div>\n <div style=\"flex: 1; text-align: center; padding: 10px; border-right: 1px solid #000; font-weight: bold; display: flex; align-items: center; justify-content: center; font-size: 16px;\">").concat(coverData.totalVolumes, "\u518C\u7B2C</div>\n <div style=\"flex: 1; text-align: center; padding: 10px; font-weight: bold; display: flex; align-items: center; justify-content: center; font-size: 16px;\">").concat(coverData.volumeNumber, "\u518C</div>\n </div>\n </div>\n </div>\n </div>\n ");
43
+ } else {
44
+ _coverData = {
45
+ company: companyName,
46
+ title: (archiveInfo === null || archiveInfo === void 0 ? void 0 : archiveInfo.fd) || '项目档案',
47
+ archiveNo: (archiveInfo === null || archiveInfo === void 0 ? void 0 : archiveInfo.fd_dam) || '-',
48
+ projectNo: acc51c.fd_dam || '-',
49
+ projectName: acc51c.fd || '-',
50
+ bindPeriod: "".concat((archiveInfo === null || archiveInfo === void 0 ? void 0 : archiveInfo.fd_start) || '-', " \u81F3 ").concat((archiveInfo === null || archiveInfo === void 0 ? void 0 : archiveInfo.fd_beover) || '-'),
51
+ projectPeriod: "".concat(acc51c.fd_06 || '-', " \u81F3 ").concat(acc51c.fd_07 || '-'),
52
+ compileDate: archiveInfo !== null && archiveInfo !== void 0 && archiveInfo.created_at ? dayjs(archiveInfo.created_at).format('YYYY-MM-DD HH:mm') : '-',
53
+ manager: acc51c.fd_04 || '-',
54
+ totalFiles: (archiveInfo === null || archiveInfo === void 0 ? void 0 : archiveInfo.fd_su) || 0,
55
+ nsp24cFd: (archiveInfo === null || archiveInfo === void 0 || (_archiveInfo$nsp24c = archiveInfo.nsp24c) === null || _archiveInfo$nsp24c === void 0 ? void 0 : _archiveInfo$nsp24c.fd) || '-'
56
+ };
57
+ html = "\n <div style=\"width: 600px; height: 800px; background-color: ".concat(themeColor, "; display: flex; align-items: center; justify-content: center; color: #000; font-family: SimSun, STSong, serif; padding: 40px; box-sizing: border-box; border: 1px solid rgba(0,0,0,0.1);\">\n <div style=\"border: 5px solid #000; width: 100%; height: 100%; padding: 4px; box-sizing: border-box; display: flex;\">\n <div style=\"border: 1px solid #000; width: 100%; height: 100%; padding: 20px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; background: transparent; position: relative;\">\n <!-- \u6A21\u62DF\u62DF\u7269\u611F -->\n <div style=\"position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-image: radial-gradient(circle, rgba(255, 255, 255, 0.05) 1px, transparent 1px); background-size: 4px 4px; opacity: 0.3; pointer-events: none;\"></div>\n \n <div style=\"font-size: 26px; font-weight: bold; margin-top: 10px; margin-bottom: 30px; letter-spacing: 4px; text-align: center; position: relative; z-index: 1;\">").concat(_coverData.company, "</div>\n <div style=\"font-size: 42px; font-weight: 900; margin-bottom: 22px; letter-spacing: 16px; text-align: center; line-height: 1; position: relative; z-index: 1;\">").concat(_coverData.title, "</div>\n <table style=\"width: 100%; border-collapse: collapse; border: 2px solid #000; margin-bottom: 10px; position: relative; z-index: 1;\">\n <tbody>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; width: 120px; background: rgba(0, 0, 0, 0.04);\">\u6863\u6848\u7F16\u53F7</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.archiveNo, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u9879\u76EE\u7F16\u53F7</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.projectNo, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 100px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u9879\u76EE\u540D\u79F0</td><td style=\"border: 1.5px solid #000; padding: 10px 15px;\">").concat(_coverData.projectName, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u9879\u76EE\u8D1F\u8D23\u4EBA</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.manager, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u88C5\u8BA2\u671F\u95F4</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.bindPeriod, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u9879\u76EE\u671F\u95F4</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.projectPeriod, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u88C5\u8BA2\u65E5\u671F</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.compileDate, "</td></tr>\n <tr><td style=\"border: 1.5px solid #000; height: 30px; padding: 4px 12px; font-weight: 900; background: rgba(0, 0, 0, 0.04);\">\u88C5\u8BA2\u4EBA</td><td style=\"border: 1.5px solid #000; padding: 4px 12px;\">").concat(_coverData.nsp24cFd, "</td></tr>\n <tr><td colspan=\"2\" style=\"border: 1.5px solid #000; height: 54px; text-align: center;\"><div style=\"display: flex; justify-content: center; align-items: center; gap: 30px; font-size: 20px; font-weight: 700;\"><span>\u5171</span><span style=\"font-size: 24px; margin: 0 5px;\">").concat(_coverData.totalFiles, "</span><span>\u4EFD\u6587\u4EF6</span></div></td></tr>\n </tbody>\n </table>\n </div>\n </div>\n </div>\n ");
58
+ }
59
+ div.innerHTML = html;
60
+ _context.next = 14;
61
+ return import('html2canvas');
62
+ case 14:
63
+ _context.next = 16;
64
+ return _context.sent.default(div, {
65
+ scale: 2
66
+ });
67
+ case 16:
68
+ canvas = _context.sent;
69
+ document.body.removeChild(div);
70
+ return _context.abrupt("return", canvas.toDataURL('image/jpeg', 0.9));
71
+ case 19:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }, _callee);
76
+ }));
77
+ return function renderCoverToImage(_x) {
78
+ return _ref.apply(this, arguments);
79
+ };
80
+ }();
81
+
82
+ /**
83
+ * 导出 HTML 翻书功能
84
+ */
85
+ export var exportArchivePagesToHtml = /*#__PURE__*/function () {
86
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
87
+ var pages, filename, _options$title, title, getDocument, coverInfo, hide, coverImg, pagesData, i, page, img, _img, htmlContent, blob, url, link;
88
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
+ while (1) switch (_context2.prev = _context2.next) {
90
+ case 0:
91
+ pages = options.pages, filename = options.filename, _options$title = options.title, title = _options$title === void 0 ? '档案翻书' : _options$title, getDocument = options.getDocument, coverInfo = options.coverInfo;
92
+ hide = message.loading('正在导出 HTML 翻书,请稍候…', 0);
93
+ _context2.prev = 2;
94
+ _context2.next = 5;
95
+ return renderCoverToImage(coverInfo);
96
+ case 5:
97
+ coverImg = _context2.sent;
98
+ pagesData = [coverImg];
99
+ i = 0;
100
+ case 8:
101
+ if (!(i < pages.length)) {
102
+ _context2.next = 31;
103
+ break;
104
+ }
105
+ page = pages[i];
106
+ _context2.prev = 10;
107
+ if (!(page.type === 'image')) {
108
+ _context2.next = 18;
109
+ break;
110
+ }
111
+ _context2.next = 14;
112
+ return renderImageToDataUrl(page.file);
113
+ case 14:
114
+ img = _context2.sent;
115
+ pagesData.push(img.dataUrl);
116
+ _context2.next = 23;
117
+ break;
118
+ case 18:
119
+ if (!(page.type === 'pdf')) {
120
+ _context2.next = 23;
121
+ break;
122
+ }
123
+ _context2.next = 21;
124
+ return renderPdfPageToDataUrl({
125
+ getDocument: getDocument,
126
+ file: page.file,
127
+ pageNum: page.pageNum,
128
+ scale: 2
129
+ });
130
+ case 21:
131
+ _img = _context2.sent;
132
+ pagesData.push(_img.dataUrl);
133
+ case 23:
134
+ _context2.next = 28;
135
+ break;
136
+ case 25:
137
+ _context2.prev = 25;
138
+ _context2.t0 = _context2["catch"](10);
139
+ console.error("\u6E32\u67D3\u7B2C ".concat(i + 1, " \u9875\u5931\u8D25:"), _context2.t0);
140
+ case 28:
141
+ i++;
142
+ _context2.next = 8;
143
+ break;
144
+ case 31:
145
+ htmlContent = "\n<!DOCTYPE html>\n<html>\n<head>\n <meta charset=\"UTF-8\">\n <title>".concat(title, "</title>\n <style>\n body { margin: 0; background: #333; display: flex; flex-direction: column; align-items: center; min-height: 100vh; font-family: sans-serif; overflow: hidden; }\n .viewport { flex: 1; display: flex; justify-content: center; align-items: center; width: 100%; height: calc(100vh - 60px); }\n .book-container { position: relative; width: 1200px; height: 800px; display: flex; justify-content: center; align-items: center; transition: all 0.5s ease; }\n .page-wrapper { position: relative; width: 50%; height: 100%; background: #fff; box-shadow: 0 0 20px rgba(0,0,0,0.5); overflow: hidden; display: flex; justify-content: center; align-items: center; }\n .page-left { border-radius: 10px 0 0 10px; border-right: 1px solid #eee; }\n .page-right { border-radius: 0 10px 10px 0; }\n .page-img { max-width: 100%; max-height: 100%; object-fit: contain; }\n .controls { height: 60px; width: 100%; background: #222; color: #fff; display: flex; justify-content: center; align-items: center; gap: 25px; z-index: 100; border-top: 1px solid #444; position: fixed; bottom: 0; left: 0; }\n button { background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.2); color: #fff; padding: 6px 20px; border-radius: 4px; cursor: pointer; font-size: 14px; transition: all 0.2s; }\n button:hover { background: rgba(255, 255, 255, 0.25); }\n button#btnNext { background: ").concat(options.coverInfo.themeColor || '#9F7D4E', "; border: none; font-weight: bold; }\n button:disabled { background: #333 !important; color: #666; cursor: not-allowed; border-color: #444; }\n .page-info { font-size: 14px; display: flex; align-items: center; gap: 12px; color: #ccc; }\n select { background: #333; color: #fff; border: 1px solid #555; padding: 5px 10px; border-radius: 4px; outline: none; cursor: pointer; font-size: 14px; min-width: 120px; }\n .spine { position: absolute; left: 50%; top: 20px; bottom: 20px; width: 2px; background: rgba(0,0,0,0.15); transform: translateX(-50%); z-index: 10; box-shadow: 0 0 15px rgba(0,0,0,0.3); }\n \n /* \u5C01\u9762\u5355\u9875\u5C45\u4E2D\u6837\u5F0F */\n .is-cover .page-left { display: none; }\n .is-cover .page-right { border-radius: 10px; width: 600px; }\n .is-cover .spine { display: none; }\n </style>\n</head>\n<body>\n <div class=\"viewport\">\n <div id=\"book\" class=\"book-container is-cover\">\n <div class=\"page-wrapper page-left\">\n <img id=\"leftPage\" class=\"page-img\" src=\"\">\n </div>\n <div class=\"spine\"></div>\n <div class=\"page-wrapper page-right\">\n <img id=\"rightPage\" class=\"page-img\" src=\"\">\n </div>\n </div>\n </div>\n <div class=\"controls\">\n <button id=\"btnPrev\" onclick=\"prev()\">\u4E0A\u4E00\u9875</button>\n <div class=\"page-info\">\n \u8DF3\u8F6C\u81F3\uFF1A<select id=\"pageSelect\" onchange=\"jump(this.value)\"></select>\n <span id=\"totalInfo\" style=\"margin-left: 15px; color: #aaa; font-size: 13px;\"></span>\n </div>\n <button id=\"btnNext\" onclick=\"next()\">\u4E0B\u4E00\u9875</button>\n </div>\n <script>\n const pages = ").concat(JSON.stringify(pagesData), ";\n let currentSpread = 0; \n \n const book = document.getElementById('book');\n const leftPage = document.getElementById('leftPage');\n const rightPage = document.getElementById('rightPage');\n const pageSelect = document.getElementById('pageSelect');\n const totalInfo = document.getElementById('totalInfo');\n const btnPrev = document.getElementById('btnPrev');\n const btnNext = document.getElementById('btnNext');\n\n const totalSpreads = Math.ceil((pages.length - 1) / 2) + 1;\n\n function init() {\n for(let i = 0; i < totalSpreads; i++) {\n const opt = document.createElement('option');\n opt.value = i;\n opt.innerText = i === 0 ? '\u5C01\u9762' : '\u7B2C ' + i + ' \u7EC4 (' + ((i-1)*2+1) + '-' + Math.min((i-1)*2+2, pages.length-1) + ')';\n pageSelect.appendChild(opt);\n }\n totalInfo.innerText = '\u5171 ' + totalSpreads + ' \u7EC4\u9875\u9762';\n update();\n }\n\n function update() {\n if (currentSpread === 0) {\n book.classList.add('is-cover');\n rightPage.src = pages[0];\n } else {\n book.classList.remove('is-cover');\n const leftIdx = (currentSpread - 1) * 2 + 1;\n const rightIdx = leftIdx + 1;\n \n leftPage.src = pages[leftIdx] || '';\n rightPage.src = pages[rightIdx] || '';\n \n if (!pages[rightIdx]) {\n rightPage.parentNode.style.visibility = 'hidden';\n } else {\n rightPage.parentNode.style.visibility = 'visible';\n }\n }\n \n pageSelect.value = currentSpread;\n btnPrev.disabled = currentSpread === 0;\n btnNext.disabled = currentSpread === totalSpreads - 1;\n }\n\n function prev() { if(currentSpread > 0) { currentSpread--; update(); } }\n function next() { if(currentSpread < totalSpreads - 1) { currentSpread++; update(); } }\n function jump(val) { currentSpread = parseInt(val); update(); }\n\n // \u952E\u76D8\u7FFB\u9875\u652F\u6301\n document.addEventListener('keydown', (e) => {\n if(e.key === 'ArrowLeft') prev();\n if(e.key === 'ArrowRight') next();\n });\n\n init();\n </script>\n</body>\n</html>");
146
+ blob = new Blob([htmlContent], {
147
+ type: 'text/html'
148
+ });
149
+ url = URL.createObjectURL(blob);
150
+ link = document.createElement('a');
151
+ link.href = url;
152
+ link.download = filename.endsWith('.html') ? filename : "".concat(filename, ".html");
153
+ document.body.appendChild(link);
154
+ link.click();
155
+ document.body.removeChild(link);
156
+ URL.revokeObjectURL(url);
157
+ message.success('HTML 翻书导出成功');
158
+ _context2.next = 48;
159
+ break;
160
+ case 44:
161
+ _context2.prev = 44;
162
+ _context2.t1 = _context2["catch"](2);
163
+ console.error('HTML 导出失败:', _context2.t1);
164
+ message.error('HTML 导出失败');
165
+ case 48:
166
+ _context2.prev = 48;
167
+ hide();
168
+ return _context2.finish(48);
169
+ case 51:
170
+ case "end":
171
+ return _context2.stop();
172
+ }
173
+ }, _callee2, null, [[2, 44, 48, 51], [10, 25]]);
174
+ }));
175
+ return function exportArchivePagesToHtml(_x2) {
176
+ return _ref2.apply(this, arguments);
177
+ };
178
+ }();
@@ -0,0 +1,27 @@
1
+ import type { BuiltPage, PdfDocumentLike } from './types';
2
+ export declare function renderPdfPageToDataUrl(params: {
3
+ getDocument: (path: string) => Promise<PdfDocumentLike>;
4
+ file: string;
5
+ pageNum: number;
6
+ scale: number;
7
+ }): Promise<{
8
+ dataUrl: string;
9
+ width: number;
10
+ height: number;
11
+ }>;
12
+ export declare function renderImageToDataUrl(file: string): Promise<{
13
+ dataUrl: string;
14
+ width: number;
15
+ height: number;
16
+ }>;
17
+ export declare function buildArchivePdfBlob(params: {
18
+ pages: BuiltPage[];
19
+ getDocument: (path: string) => Promise<PdfDocumentLike>;
20
+ scale?: number;
21
+ }): Promise<Blob>;
22
+ export declare function exportArchivePagesToPdf(params: {
23
+ pages: BuiltPage[];
24
+ getDocument: (path: string) => Promise<PdfDocumentLike>;
25
+ filename: string;
26
+ scale?: number;
27
+ }): Promise<void>;