@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.
- package/dist/cjs/ArchiveCover.d.ts +9 -0
- package/dist/cjs/ArchiveCover.js +142 -0
- package/dist/cjs/DocumentFlipBook.d.ts +32 -0
- package/dist/cjs/DocumentFlipBook.js +644 -0
- package/dist/cjs/ExportModal.d.ts +10 -0
- package/dist/cjs/ExportModal.js +96 -0
- package/dist/cjs/HeaderBar.d.ts +25 -0
- package/dist/cjs/HeaderBar.js +220 -0
- package/dist/cjs/PdfPage.d.ts +9 -0
- package/dist/cjs/PdfPage.js +143 -0
- package/dist/cjs/ProjectCover.d.ts +8 -0
- package/dist/cjs/ProjectCover.js +201 -0
- package/dist/cjs/SideTabs.d.ts +8 -0
- package/dist/cjs/SideTabs.js +34 -0
- package/dist/cjs/exportHtml.d.ts +19 -0
- package/dist/cjs/exportHtml.js +189 -0
- package/dist/cjs/exportPdf.d.ts +27 -0
- package/dist/cjs/exportPdf.js +232 -0
- package/dist/cjs/globalCache.d.ts +5 -0
- package/dist/cjs/globalCache.js +20 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.less +637 -0
- package/dist/cjs/printPdf.d.ts +6 -0
- package/dist/cjs/printPdf.js +51 -0
- package/dist/cjs/types.d.ts +31 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/utils.d.ts +17 -0
- package/dist/cjs/utils.js +220 -0
- package/dist/esm/ArchiveCover.d.ts +9 -0
- package/dist/esm/ArchiveCover.js +136 -0
- package/dist/esm/DocumentFlipBook.d.ts +32 -0
- package/dist/esm/DocumentFlipBook.js +630 -0
- package/dist/esm/ExportModal.d.ts +10 -0
- package/dist/esm/ExportModal.js +88 -0
- package/dist/esm/HeaderBar.d.ts +25 -0
- package/dist/esm/HeaderBar.js +211 -0
- package/dist/esm/PdfPage.d.ts +9 -0
- package/dist/esm/PdfPage.js +136 -0
- package/dist/esm/ProjectCover.d.ts +8 -0
- package/dist/esm/ProjectCover.js +195 -0
- package/dist/esm/SideTabs.d.ts +8 -0
- package/dist/esm/SideTabs.js +27 -0
- package/dist/esm/exportHtml.d.ts +19 -0
- package/dist/esm/exportHtml.js +178 -0
- package/dist/esm/exportPdf.d.ts +27 -0
- package/dist/esm/exportPdf.js +223 -0
- package/dist/esm/globalCache.d.ts +5 -0
- package/dist/esm/globalCache.js +15 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.less +637 -0
- package/dist/esm/printPdf.d.ts +6 -0
- package/dist/esm/printPdf.js +45 -0
- package/dist/esm/types.d.ts +31 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils.d.ts +17 -0
- package/dist/esm/utils.js +214 -0
- package/package.json +57 -0
|
@@ -0,0 +1,630 @@
|
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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); } }
|
|
8
|
+
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); }); }; }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import HTMLFlipBook from 'react-pageflip';
|
|
17
|
+
import { Image, message, Spin } from 'antd';
|
|
18
|
+
import HeaderBar from "./HeaderBar";
|
|
19
|
+
import PdfPage from "./PdfPage";
|
|
20
|
+
import SideTabs from "./SideTabs";
|
|
21
|
+
import { buildPagesFromSingleAttachment, formatPath, VIEWPORT_HEIGHT, VIEWPORT_WIDTH, setupPdfWorker } from "./utils";
|
|
22
|
+
import { globalPdfCache } from "./globalCache";
|
|
23
|
+
import ArchiveCover from "./ArchiveCover"; // 引入封面组件
|
|
24
|
+
import ProjectCover from "./ProjectCover";
|
|
25
|
+
import "./index.less";
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
var DocumentFlipBook = function DocumentFlipBook(_ref) {
|
|
29
|
+
var _ref$mode = _ref.mode,
|
|
30
|
+
initialMode = _ref$mode === void 0 ? 'page' : _ref$mode,
|
|
31
|
+
title = _ref.title,
|
|
32
|
+
id = _ref.id,
|
|
33
|
+
_ref$themeColor = _ref.themeColor,
|
|
34
|
+
themeColor = _ref$themeColor === void 0 ? '#9F7D4E' : _ref$themeColor,
|
|
35
|
+
documentInfo = _ref.documentInfo,
|
|
36
|
+
onBack = _ref.onBack,
|
|
37
|
+
onRequestFullscreen = _ref.onRequestFullscreen,
|
|
38
|
+
onClose = _ref.onClose,
|
|
39
|
+
_ref$onSearch = _ref.onSearch,
|
|
40
|
+
onSearch = _ref$onSearch === void 0 ? function () {} : _ref$onSearch,
|
|
41
|
+
_ref$showHeaderBar = _ref.showHeaderBar,
|
|
42
|
+
showHeaderBar = _ref$showHeaderBar === void 0 ? true : _ref$showHeaderBar,
|
|
43
|
+
pdfWorkerSrc = _ref.pdfWorkerSrc;
|
|
44
|
+
var flipRef = useRef(null);
|
|
45
|
+
|
|
46
|
+
// 初始化 PDF Worker
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
setupPdfWorker(pdfWorkerSrc);
|
|
49
|
+
}, [pdfWorkerSrc]);
|
|
50
|
+
var _useState = useState([]),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
pages = _useState2[0],
|
|
53
|
+
setPages = _useState2[1];
|
|
54
|
+
var _useState3 = useState(true),
|
|
55
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
loading = _useState4[0],
|
|
57
|
+
setLoading = _useState4[1];
|
|
58
|
+
var _useState5 = useState(0),
|
|
59
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
+
current = _useState6[0],
|
|
61
|
+
setCurrent = _useState6[1];
|
|
62
|
+
var _useState7 = useState(''),
|
|
63
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
64
|
+
activeTab = _useState8[0],
|
|
65
|
+
setActiveTab = _useState8[1];
|
|
66
|
+
var _useState9 = useState(initialMode),
|
|
67
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
68
|
+
mode = _useState10[0],
|
|
69
|
+
setMode = _useState10[1];
|
|
70
|
+
var isFirstLoadOfDocument = useRef(true);
|
|
71
|
+
|
|
72
|
+
// 内部处理全屏切换
|
|
73
|
+
var handleRequestFullscreen = useCallback(function () {
|
|
74
|
+
setMode('modal');
|
|
75
|
+
onRequestFullscreen === null || onRequestFullscreen === void 0 || onRequestFullscreen();
|
|
76
|
+
}, [onRequestFullscreen]);
|
|
77
|
+
var handleClose = useCallback(function () {
|
|
78
|
+
setMode('page');
|
|
79
|
+
onClose === null || onClose === void 0 || onClose();
|
|
80
|
+
}, [onClose]);
|
|
81
|
+
|
|
82
|
+
// 内部处理返回逻辑
|
|
83
|
+
var handleBack = useCallback(function () {
|
|
84
|
+
if (onBack) {
|
|
85
|
+
onBack();
|
|
86
|
+
} else {
|
|
87
|
+
window.history.back();
|
|
88
|
+
}
|
|
89
|
+
}, [onBack]);
|
|
90
|
+
var archiveId = useMemo(function () {
|
|
91
|
+
return id || (documentInfo === null || documentInfo === void 0 ? void 0 : documentInfo.id) || (documentInfo === null || documentInfo === void 0 ? void 0 : documentInfo.code);
|
|
92
|
+
}, [id, documentInfo]);
|
|
93
|
+
var isProjectMode = useMemo(function () {
|
|
94
|
+
// 数据结构判断:如果有 edr04bs 或顶层 attachments 且没有 com00cs,视为项目模式
|
|
95
|
+
return !!(documentInfo !== null && documentInfo !== void 0 && documentInfo.edr04bs || documentInfo !== null && documentInfo !== void 0 && documentInfo.attachments) && !(documentInfo !== null && documentInfo !== void 0 && documentInfo.com00cs);
|
|
96
|
+
}, [documentInfo]);
|
|
97
|
+
|
|
98
|
+
// 当文档变化时,重置首次加载标识及页码、标签、数据
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
isFirstLoadOfDocument.current = true;
|
|
101
|
+
setPages([]); // 立即清空旧页面,防止切换时闪烁旧数据
|
|
102
|
+
setCurrent(0);
|
|
103
|
+
setActiveTab('');
|
|
104
|
+
if (flipRef.current) {
|
|
105
|
+
try {
|
|
106
|
+
var _flipRef$current;
|
|
107
|
+
(_flipRef$current = flipRef.current) === null || _flipRef$current === void 0 || (_flipRef$current = _flipRef$current.pageFlip()) === null || _flipRef$current === void 0 || _flipRef$current.turnToPage(0);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.warn('Reset flipbook failed', e);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, [id, documentInfo === null || documentInfo === void 0 ? void 0 : documentInfo.id]);
|
|
113
|
+
|
|
114
|
+
// 动态生成侧边栏标签
|
|
115
|
+
var tabItems = useMemo(function () {
|
|
116
|
+
var sds = [];
|
|
117
|
+
if (documentInfo !== null && documentInfo !== void 0 && documentInfo.com00cs) {
|
|
118
|
+
// 档案模式:取 sd 字段
|
|
119
|
+
sds = Array.from(new Set((documentInfo.com00cs || []).map(function (item) {
|
|
120
|
+
return item.sd;
|
|
121
|
+
}).filter(Boolean)));
|
|
122
|
+
} else if (documentInfo !== null && documentInfo !== void 0 && documentInfo.edr04bs) {
|
|
123
|
+
// 项目模式:取 acc17c_fd 字段
|
|
124
|
+
sds = Array.from(new Set((documentInfo.edr04bs || []).map(function (item) {
|
|
125
|
+
return item.acc17c_fd;
|
|
126
|
+
}).filter(Boolean)));
|
|
127
|
+
}
|
|
128
|
+
if (sds.length === 0) return [];
|
|
129
|
+
var colors = ['#1abc9c', '#e67e22', '#9b59b6', '#3498db', '#e74c3c', '#2ecc71', '#f1c40f'];
|
|
130
|
+
return sds.map(function (sd, i) {
|
|
131
|
+
return {
|
|
132
|
+
key: sd,
|
|
133
|
+
label: sd,
|
|
134
|
+
color: colors[i % colors.length],
|
|
135
|
+
pageIndex: 0
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}, [documentInfo]);
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
var isMounted = true;
|
|
141
|
+
var init = /*#__PURE__*/function () {
|
|
142
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
143
|
+
var list, filteredDocs, topList, filteredSubItems, subList, firstBatch, firstBatchResults, firstBatchPages, remainingAttachments, CONCURRENCY_LIMIT, allRemainingPages, i, chunk, chunkResults;
|
|
144
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
145
|
+
while (1) switch (_context.prev = _context.next) {
|
|
146
|
+
case 0:
|
|
147
|
+
_context.prev = 0;
|
|
148
|
+
setLoading(true);
|
|
149
|
+
list = []; // 数据结构判断与解析
|
|
150
|
+
if (documentInfo.com00cs) {
|
|
151
|
+
// 模式 1: 档案模式 (包含 com00cs)
|
|
152
|
+
filteredDocs = activeTab ? (documentInfo.com00cs || []).filter(function (item) {
|
|
153
|
+
return item.sd === activeTab;
|
|
154
|
+
}) : documentInfo.com00cs || [];
|
|
155
|
+
list = filteredDocs.map(function (item, i) {
|
|
156
|
+
return {
|
|
157
|
+
id: 'c-' + i,
|
|
158
|
+
path: formatPath(item.fn0_path),
|
|
159
|
+
acc17c_fd: item.fd
|
|
160
|
+
};
|
|
161
|
+
});
|
|
162
|
+
} else {
|
|
163
|
+
// 模式 2: 项目模式 (包含 edr04bs 或 attachments)
|
|
164
|
+
// 1. 解析主表附件
|
|
165
|
+
topList = (documentInfo.attachments || []).map(function (att, i) {
|
|
166
|
+
return {
|
|
167
|
+
id: "top-".concat(i),
|
|
168
|
+
path: formatPath(att.path),
|
|
169
|
+
acc17c_fd: '相关附件'
|
|
170
|
+
};
|
|
171
|
+
}); // 如果选中了标签,主表附件通常不显示(除非标签匹配)
|
|
172
|
+
if (activeTab) {
|
|
173
|
+
topList = [];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 2. 解析子表明细附件
|
|
177
|
+
filteredSubItems = activeTab ? (documentInfo.edr04bs || []).filter(function (sub) {
|
|
178
|
+
return sub.acc17c_fd === activeTab;
|
|
179
|
+
}) : documentInfo.edr04bs || [];
|
|
180
|
+
subList = filteredSubItems.flatMap(function (sub, i) {
|
|
181
|
+
return (sub.attachments || []).map(function (att, j) {
|
|
182
|
+
return {
|
|
183
|
+
id: "sub-".concat(i, "-").concat(j),
|
|
184
|
+
path: formatPath(att.path),
|
|
185
|
+
acc17c_fd: sub.acc17c_fd || '明细附件'
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
list = [].concat(_toConsumableArray(topList), _toConsumableArray(subList));
|
|
190
|
+
}
|
|
191
|
+
if (!(list.length === 0)) {
|
|
192
|
+
_context.next = 8;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
setPages([]);
|
|
196
|
+
setLoading(false);
|
|
197
|
+
return _context.abrupt("return");
|
|
198
|
+
case 8:
|
|
199
|
+
// 渐进式加载优化:先并发加载前 2 个附件,快速填充首屏
|
|
200
|
+
firstBatch = list.slice(0, 2);
|
|
201
|
+
_context.next = 11;
|
|
202
|
+
return Promise.all(firstBatch.map(function (item) {
|
|
203
|
+
return buildPagesFromSingleAttachment(item, function (p) {
|
|
204
|
+
return globalPdfCache.getPageCount(p);
|
|
205
|
+
});
|
|
206
|
+
}));
|
|
207
|
+
case 11:
|
|
208
|
+
firstBatchResults = _context.sent;
|
|
209
|
+
if (isMounted) {
|
|
210
|
+
_context.next = 14;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
return _context.abrupt("return");
|
|
214
|
+
case 14:
|
|
215
|
+
firstBatchPages = firstBatchResults.flat();
|
|
216
|
+
setPages(firstBatchPages);
|
|
217
|
+
setLoading(false);
|
|
218
|
+
if (isFirstLoadOfDocument.current) {
|
|
219
|
+
setCurrent(0);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 如果还有剩余附件,继续并发渐进式加载
|
|
223
|
+
if (!(list.length > 2)) {
|
|
224
|
+
_context.next = 39;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
_context.next = 21;
|
|
228
|
+
return new Promise(function (resolve) {
|
|
229
|
+
return setTimeout(resolve, 200);
|
|
230
|
+
});
|
|
231
|
+
case 21:
|
|
232
|
+
if (isMounted) {
|
|
233
|
+
_context.next = 23;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
return _context.abrupt("return");
|
|
237
|
+
case 23:
|
|
238
|
+
remainingAttachments = list.slice(2);
|
|
239
|
+
CONCURRENCY_LIMIT = 5; // 后续采用 5 个一组的并发加载
|
|
240
|
+
allRemainingPages = [];
|
|
241
|
+
i = 0;
|
|
242
|
+
case 27:
|
|
243
|
+
if (!(i < remainingAttachments.length)) {
|
|
244
|
+
_context.next = 39;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
chunk = remainingAttachments.slice(i, i + CONCURRENCY_LIMIT);
|
|
248
|
+
_context.next = 31;
|
|
249
|
+
return Promise.all(chunk.map(function (item) {
|
|
250
|
+
return buildPagesFromSingleAttachment(item, function (p) {
|
|
251
|
+
return globalPdfCache.getPageCount(p);
|
|
252
|
+
});
|
|
253
|
+
}));
|
|
254
|
+
case 31:
|
|
255
|
+
chunkResults = _context.sent;
|
|
256
|
+
if (isMounted) {
|
|
257
|
+
_context.next = 34;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return _context.abrupt("return");
|
|
261
|
+
case 34:
|
|
262
|
+
allRemainingPages.push.apply(allRemainingPages, _toConsumableArray(chunkResults.flat()));
|
|
263
|
+
// 增量更新页面列表
|
|
264
|
+
setPages([].concat(_toConsumableArray(firstBatchPages), allRemainingPages));
|
|
265
|
+
case 36:
|
|
266
|
+
i += CONCURRENCY_LIMIT;
|
|
267
|
+
_context.next = 27;
|
|
268
|
+
break;
|
|
269
|
+
case 39:
|
|
270
|
+
isFirstLoadOfDocument.current = false;
|
|
271
|
+
_context.next = 47;
|
|
272
|
+
break;
|
|
273
|
+
case 42:
|
|
274
|
+
_context.prev = 42;
|
|
275
|
+
_context.t0 = _context["catch"](0);
|
|
276
|
+
console.error('档案初始化失败:', _context.t0);
|
|
277
|
+
message.error('档案内容加载失败');
|
|
278
|
+
if (isMounted) setLoading(false);
|
|
279
|
+
case 47:
|
|
280
|
+
case "end":
|
|
281
|
+
return _context.stop();
|
|
282
|
+
}
|
|
283
|
+
}, _callee, null, [[0, 42]]);
|
|
284
|
+
}));
|
|
285
|
+
return function init() {
|
|
286
|
+
return _ref2.apply(this, arguments);
|
|
287
|
+
};
|
|
288
|
+
}();
|
|
289
|
+
if (documentInfo) {
|
|
290
|
+
init();
|
|
291
|
+
}
|
|
292
|
+
return function () {
|
|
293
|
+
isMounted = false;
|
|
294
|
+
};
|
|
295
|
+
}, [documentInfo, activeTab, id]);
|
|
296
|
+
var total = useMemo(function () {
|
|
297
|
+
return 1 + pages.length;
|
|
298
|
+
}, [pages]);
|
|
299
|
+
var first = useCallback(function () {
|
|
300
|
+
var _flipRef$current2;
|
|
301
|
+
setActiveTab('');
|
|
302
|
+
(_flipRef$current2 = flipRef.current) === null || _flipRef$current2 === void 0 || _flipRef$current2.pageFlip().flip(0);
|
|
303
|
+
}, []);
|
|
304
|
+
var prev = useCallback(function () {
|
|
305
|
+
var _flipRef$current3;
|
|
306
|
+
return (_flipRef$current3 = flipRef.current) === null || _flipRef$current3 === void 0 ? void 0 : _flipRef$current3.pageFlip().flipPrev();
|
|
307
|
+
}, []);
|
|
308
|
+
var next = useCallback(function () {
|
|
309
|
+
var _flipRef$current4;
|
|
310
|
+
return (_flipRef$current4 = flipRef.current) === null || _flipRef$current4 === void 0 ? void 0 : _flipRef$current4.pageFlip().flipNext();
|
|
311
|
+
}, []);
|
|
312
|
+
var last = useCallback(function () {
|
|
313
|
+
var _flipRef$current5;
|
|
314
|
+
return (_flipRef$current5 = flipRef.current) === null || _flipRef$current5 === void 0 ? void 0 : _flipRef$current5.pageFlip().flip(total - 1);
|
|
315
|
+
}, [total]);
|
|
316
|
+
var handleRefresh = useCallback(function () {
|
|
317
|
+
isFirstLoadOfDocument.current = true; // 标记为首次加载,使 init 逻辑停留在封面 (第 0 页)
|
|
318
|
+
setActiveTab('');
|
|
319
|
+
setCurrent(0);
|
|
320
|
+
if (flipRef.current) {
|
|
321
|
+
try {
|
|
322
|
+
flipRef.current.pageFlip().turnToPage(0);
|
|
323
|
+
} catch (e) {
|
|
324
|
+
console.warn('Refresh turnToPage failed', e);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}, []);
|
|
328
|
+
var handleDownload = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
329
|
+
var type,
|
|
330
|
+
_yield$import,
|
|
331
|
+
exportArchivePagesToHtml,
|
|
332
|
+
hide,
|
|
333
|
+
filename,
|
|
334
|
+
_yield$import2,
|
|
335
|
+
exportArchivePagesToPdf,
|
|
336
|
+
_args2 = arguments;
|
|
337
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
338
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
339
|
+
case 0:
|
|
340
|
+
type = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 'pdf';
|
|
341
|
+
if (!(type === 'html')) {
|
|
342
|
+
_context2.next = 9;
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
_context2.next = 4;
|
|
346
|
+
return import("./exportHtml");
|
|
347
|
+
case 4:
|
|
348
|
+
_yield$import = _context2.sent;
|
|
349
|
+
exportArchivePagesToHtml = _yield$import.exportArchivePagesToHtml;
|
|
350
|
+
_context2.next = 8;
|
|
351
|
+
return exportArchivePagesToHtml({
|
|
352
|
+
pages: pages,
|
|
353
|
+
filename: "\u6863\u6848\u7FFB\u4E66-".concat(new Date().toISOString().slice(0, 10)),
|
|
354
|
+
title: title || '档案翻书',
|
|
355
|
+
getDocument: globalPdfCache.getDocument,
|
|
356
|
+
coverInfo: {
|
|
357
|
+
data: documentInfo === null || documentInfo === void 0 ? void 0 : documentInfo.acc51c,
|
|
358
|
+
archiveInfo: documentInfo,
|
|
359
|
+
themeColor: themeColor,
|
|
360
|
+
companyName: (documentInfo === null || documentInfo === void 0 ? void 0 : documentInfo.companyName) || '-',
|
|
361
|
+
isProjectMode: isProjectMode
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
case 8:
|
|
365
|
+
return _context2.abrupt("return");
|
|
366
|
+
case 9:
|
|
367
|
+
hide = message.loading('正在生成 PDF,请稍候…', 0);
|
|
368
|
+
_context2.prev = 10;
|
|
369
|
+
filename = "\u6863\u6848-".concat(new Date().toISOString().slice(0, 10), ".pdf");
|
|
370
|
+
_context2.next = 14;
|
|
371
|
+
return import("./exportPdf");
|
|
372
|
+
case 14:
|
|
373
|
+
_yield$import2 = _context2.sent;
|
|
374
|
+
exportArchivePagesToPdf = _yield$import2.exportArchivePagesToPdf;
|
|
375
|
+
_context2.next = 18;
|
|
376
|
+
return exportArchivePagesToPdf({
|
|
377
|
+
pages: pages,
|
|
378
|
+
getDocument: globalPdfCache.getDocument,
|
|
379
|
+
filename: filename,
|
|
380
|
+
scale: 2
|
|
381
|
+
});
|
|
382
|
+
case 18:
|
|
383
|
+
message.success('已开始下载');
|
|
384
|
+
_context2.next = 24;
|
|
385
|
+
break;
|
|
386
|
+
case 21:
|
|
387
|
+
_context2.prev = 21;
|
|
388
|
+
_context2.t0 = _context2["catch"](10);
|
|
389
|
+
message.error((_context2.t0 === null || _context2.t0 === void 0 ? void 0 : _context2.t0.message) || 'PDF 生成失败');
|
|
390
|
+
case 24:
|
|
391
|
+
_context2.prev = 24;
|
|
392
|
+
hide();
|
|
393
|
+
return _context2.finish(24);
|
|
394
|
+
case 27:
|
|
395
|
+
case "end":
|
|
396
|
+
return _context2.stop();
|
|
397
|
+
}
|
|
398
|
+
}, _callee2, null, [[10, 21, 24, 27]]);
|
|
399
|
+
})), [pages, title]);
|
|
400
|
+
var handlePrint = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
401
|
+
var hide, _yield$import3, printArchiveAsPdf;
|
|
402
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
403
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
404
|
+
case 0:
|
|
405
|
+
hide = message.loading('正在生成打印内容,请稍候…', 0);
|
|
406
|
+
_context3.prev = 1;
|
|
407
|
+
_context3.next = 4;
|
|
408
|
+
return import("./printPdf");
|
|
409
|
+
case 4:
|
|
410
|
+
_yield$import3 = _context3.sent;
|
|
411
|
+
printArchiveAsPdf = _yield$import3.printArchiveAsPdf;
|
|
412
|
+
_context3.next = 8;
|
|
413
|
+
return printArchiveAsPdf({
|
|
414
|
+
pages: pages,
|
|
415
|
+
getDocument: globalPdfCache.getDocument,
|
|
416
|
+
scale: 2
|
|
417
|
+
});
|
|
418
|
+
case 8:
|
|
419
|
+
_context3.next = 13;
|
|
420
|
+
break;
|
|
421
|
+
case 10:
|
|
422
|
+
_context3.prev = 10;
|
|
423
|
+
_context3.t0 = _context3["catch"](1);
|
|
424
|
+
message.error((_context3.t0 === null || _context3.t0 === void 0 ? void 0 : _context3.t0.message) || '打印内容生成失败');
|
|
425
|
+
case 13:
|
|
426
|
+
_context3.prev = 13;
|
|
427
|
+
hide();
|
|
428
|
+
return _context3.finish(13);
|
|
429
|
+
case 16:
|
|
430
|
+
case "end":
|
|
431
|
+
return _context3.stop();
|
|
432
|
+
}
|
|
433
|
+
}, _callee3, null, [[1, 10, 13, 16]]);
|
|
434
|
+
})), [pages]);
|
|
435
|
+
|
|
436
|
+
// 提取为独立的渲染函数,增加懒加载逻辑
|
|
437
|
+
var renderContent = useCallback(function (idx) {
|
|
438
|
+
// 懒加载逻辑:只渲染当前页及其前后的 5 页
|
|
439
|
+
var isNear = Math.abs(idx - current) <= 5;
|
|
440
|
+
if (!isNear) {
|
|
441
|
+
return /*#__PURE__*/_jsx("div", {
|
|
442
|
+
style: {
|
|
443
|
+
background: '#fff',
|
|
444
|
+
height: '100%'
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
if (idx === 0) {
|
|
449
|
+
// 封面页
|
|
450
|
+
if (isProjectMode) {
|
|
451
|
+
return /*#__PURE__*/_jsx(ProjectCover, {
|
|
452
|
+
documentInfo: documentInfo,
|
|
453
|
+
themeColor: themeColor
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return /*#__PURE__*/_jsx(ArchiveCover, {
|
|
457
|
+
data: documentInfo === null || documentInfo === void 0 ? void 0 : documentInfo.acc51c,
|
|
458
|
+
archiveInfo: documentInfo,
|
|
459
|
+
themeColor: themeColor
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
var p = pages[idx - 1];
|
|
463
|
+
if (!p) return /*#__PURE__*/_jsx("div", {
|
|
464
|
+
style: {
|
|
465
|
+
background: '#fff',
|
|
466
|
+
height: '100%'
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// 统一的错误渲染逻辑
|
|
471
|
+
var renderError = function renderError(msg) {
|
|
472
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
473
|
+
className: "attachment-page",
|
|
474
|
+
style: {
|
|
475
|
+
height: '100%',
|
|
476
|
+
display: 'flex',
|
|
477
|
+
flexDirection: 'column',
|
|
478
|
+
alignItems: 'center',
|
|
479
|
+
justifyContent: 'center',
|
|
480
|
+
background: '#fff'
|
|
481
|
+
},
|
|
482
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
483
|
+
style: {
|
|
484
|
+
color: themeColor,
|
|
485
|
+
fontSize: '16px',
|
|
486
|
+
fontWeight: 'bold'
|
|
487
|
+
},
|
|
488
|
+
children: msg
|
|
489
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
490
|
+
style: {
|
|
491
|
+
marginTop: 12,
|
|
492
|
+
color: '#8c8c8c'
|
|
493
|
+
},
|
|
494
|
+
children: p.acc17c_fd
|
|
495
|
+
})]
|
|
496
|
+
}, "error-".concat(idx));
|
|
497
|
+
};
|
|
498
|
+
if (p.type === 'pdf-error') return renderError('PDF 加载失败');
|
|
499
|
+
if (p.type === 'pdf') return /*#__PURE__*/_jsx(PdfPage, {
|
|
500
|
+
file: p.file,
|
|
501
|
+
pageNum: p.pageNum,
|
|
502
|
+
getPdfDocument: globalPdfCache.getDocument
|
|
503
|
+
});
|
|
504
|
+
if (p.type === 'image') return /*#__PURE__*/_jsx(Image, {
|
|
505
|
+
src: p.file,
|
|
506
|
+
preview: false,
|
|
507
|
+
style: {
|
|
508
|
+
width: '100%',
|
|
509
|
+
minHeight: VIEWPORT_HEIGHT,
|
|
510
|
+
height: '100%',
|
|
511
|
+
objectFit: 'contain',
|
|
512
|
+
objectPosition: 'center top'
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
return null;
|
|
516
|
+
}, [pages, documentInfo, current, themeColor]);
|
|
517
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
518
|
+
className: "dfb-root ".concat(mode === 'modal' ? 'is-fullscreen-modal' : ''),
|
|
519
|
+
children: [showHeaderBar && /*#__PURE__*/_jsx(HeaderBar, {
|
|
520
|
+
mode: mode,
|
|
521
|
+
title: title,
|
|
522
|
+
currentPage: current,
|
|
523
|
+
totalPages: total,
|
|
524
|
+
onBack: handleBack,
|
|
525
|
+
onRequestFullscreen: handleRequestFullscreen,
|
|
526
|
+
onClose: handleClose,
|
|
527
|
+
onGoFirst: first,
|
|
528
|
+
onPrevPage: prev,
|
|
529
|
+
onNextPage: next,
|
|
530
|
+
onGoLast: last,
|
|
531
|
+
onPrint: handlePrint,
|
|
532
|
+
onDownload: handleDownload,
|
|
533
|
+
onRefresh: handleRefresh,
|
|
534
|
+
themeColor: themeColor
|
|
535
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
536
|
+
className: "dfb-stage",
|
|
537
|
+
children: /*#__PURE__*/_jsx(Spin, {
|
|
538
|
+
size: "large",
|
|
539
|
+
tip: "\u6B63\u5728\u89E3\u6790\u6863\u6848\u7ED3\u6784...",
|
|
540
|
+
spinning: loading,
|
|
541
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
542
|
+
className: "dfb-book-wrapper",
|
|
543
|
+
style: {
|
|
544
|
+
minHeight: VIEWPORT_HEIGHT + 40
|
|
545
|
+
},
|
|
546
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
547
|
+
className: current === 0 && !activeTab ? 'dfb-bookShell1' : 'dfb-bookShell',
|
|
548
|
+
style: {
|
|
549
|
+
backgroundColor: current === 0 && !activeTab ? 'transparent' : themeColor
|
|
550
|
+
},
|
|
551
|
+
children: [(current > 0 || activeTab) && /*#__PURE__*/_jsx("div", {
|
|
552
|
+
className: "dfb-book-spine"
|
|
553
|
+
}), (pages === null || pages === void 0 ? void 0 : pages.length) > 0 && tabItems.length > 0 && /*#__PURE__*/_jsx(SideTabs, {
|
|
554
|
+
items: tabItems,
|
|
555
|
+
activeKey: activeTab,
|
|
556
|
+
className: current === 0 ? 'is-on-cover' : !activeTab ? 'is-on-activeTab' : '',
|
|
557
|
+
onSelect: function onSelect(it) {
|
|
558
|
+
if (it.key === activeTab) return;
|
|
559
|
+
setLoading(true);
|
|
560
|
+
setPages([]); // 清空旧页面,触发 Spin
|
|
561
|
+
setActiveTab(it.key);
|
|
562
|
+
setCurrent(1);
|
|
563
|
+
}
|
|
564
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
565
|
+
className: "dfb-HTMLFlipBook",
|
|
566
|
+
children: [!loading && pages.length > 0 && /*#__PURE__*/_jsx(HTMLFlipBook, {
|
|
567
|
+
ref: flipRef,
|
|
568
|
+
width: VIEWPORT_WIDTH,
|
|
569
|
+
height: VIEWPORT_HEIGHT,
|
|
570
|
+
showCover: true,
|
|
571
|
+
size: "stretch",
|
|
572
|
+
minWidth: VIEWPORT_WIDTH,
|
|
573
|
+
maxWidth: VIEWPORT_WIDTH,
|
|
574
|
+
minHeight: VIEWPORT_HEIGHT,
|
|
575
|
+
maxHeight: VIEWPORT_HEIGHT,
|
|
576
|
+
maxShadowOpacity: 0.5,
|
|
577
|
+
onFlip: function onFlip(e) {
|
|
578
|
+
var pageIdx = e.data;
|
|
579
|
+
setCurrent(pageIdx);
|
|
580
|
+
if (pageIdx === 0) {
|
|
581
|
+
setCurrent(0);
|
|
582
|
+
setActiveTab('');
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
startPage: activeTab ? 1 : 0,
|
|
586
|
+
drawShadow: true,
|
|
587
|
+
startZIndex: 30,
|
|
588
|
+
flippingTime: 800,
|
|
589
|
+
usePortrait: false,
|
|
590
|
+
autoSize: false,
|
|
591
|
+
useMouseEvents: true,
|
|
592
|
+
showPageCorners: true,
|
|
593
|
+
clickEventForward: false,
|
|
594
|
+
swipeDistance: 0,
|
|
595
|
+
className: "",
|
|
596
|
+
style: {
|
|
597
|
+
margin: 'auto',
|
|
598
|
+
position: 'relative'
|
|
599
|
+
},
|
|
600
|
+
mobileScrollSupport: true,
|
|
601
|
+
disableFlipByClick: false,
|
|
602
|
+
children: Array.from({
|
|
603
|
+
length: total
|
|
604
|
+
}).map(function (_, i) {
|
|
605
|
+
return /*#__PURE__*/_jsx("div", {
|
|
606
|
+
className: "book-view bg-white",
|
|
607
|
+
style: {
|
|
608
|
+
width: '100%',
|
|
609
|
+
height: '100%'
|
|
610
|
+
},
|
|
611
|
+
children: renderContent(i)
|
|
612
|
+
}, i);
|
|
613
|
+
})
|
|
614
|
+
}, "".concat(archiveId, "-").concat(activeTab)), !loading && pages.length === 0 && /*#__PURE__*/_jsx("div", {
|
|
615
|
+
className: "book-view bg-white",
|
|
616
|
+
style: {
|
|
617
|
+
width: VIEWPORT_WIDTH,
|
|
618
|
+
height: VIEWPORT_HEIGHT,
|
|
619
|
+
margin: 'auto'
|
|
620
|
+
},
|
|
621
|
+
children: renderContent(0)
|
|
622
|
+
})]
|
|
623
|
+
})]
|
|
624
|
+
})
|
|
625
|
+
})
|
|
626
|
+
})
|
|
627
|
+
})]
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
export default DocumentFlipBook;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
interface ExportModalProps {
|
|
4
|
+
visible: boolean;
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
onConfirm: (type: 'pdf' | 'html') => void;
|
|
7
|
+
themeColor?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const ExportModal: React.FC<ExportModalProps>;
|
|
10
|
+
export default ExportModal;
|