Compare commits
No commits in common. "11ebad7b4b4d208e85d18b2d466bdd32f718d246" and "99e3c70b2edafe121bfed2381f4b6f4019d5d345" have entirely different histories.
11ebad7b4b
...
99e3c70b2e
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "zy-react-library",
|
"name": "zy-react-library",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "1.1.8",
|
"version": "1.1.7",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "LiuJiaNan",
|
"author": "LiuJiaNan",
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ function Pdf(props) {
|
||||||
const fileUrl = getFileUrl();
|
const fileUrl = getFileUrl();
|
||||||
const [numPages, setNumPages] = useState(0);
|
const [numPages, setNumPages] = useState(0);
|
||||||
const [pdfWidth, setPdfWidth] = useState(600);
|
const [pdfWidth, setPdfWidth] = useState(600);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
const fullscreenRef = useRef(null);
|
const fullscreenRef = useRef(null);
|
||||||
|
|
||||||
|
|
@ -35,9 +36,11 @@ function Pdf(props) {
|
||||||
|
|
||||||
const onDocumentLoadSuccess = ({ numPages }) => {
|
const onDocumentLoadSuccess = ({ numPages }) => {
|
||||||
setNumPages(numPages);
|
setNumPages(numPages);
|
||||||
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onDocumentLoadError = () => {
|
const onDocumentLoadError = () => {
|
||||||
|
setLoading(false);
|
||||||
message.error("加载 PDF 文件失败");
|
message.error("加载 PDF 文件失败");
|
||||||
if (onCancel)
|
if (onCancel)
|
||||||
onCancel();
|
onCancel();
|
||||||
|
|
@ -50,16 +53,16 @@ function Pdf(props) {
|
||||||
// 内联模式的PDF内容
|
// 内联模式的PDF内容
|
||||||
const renderPdfContent = () => (
|
const renderPdfContent = () => (
|
||||||
<>
|
<>
|
||||||
|
{loading && (
|
||||||
|
<div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "72vh" }}>
|
||||||
|
<Spin size="large" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div style={{ height: isFullscreen ? "calc(100vh - 40px - 24px - 8px - 32px - 12px)" : "72vh", overflowY: "auto", padding: "24px", ...style }}>
|
<div style={{ height: isFullscreen ? "calc(100vh - 40px - 24px - 8px - 32px - 12px)" : "72vh", overflowY: "auto", padding: "24px", ...style }}>
|
||||||
<Document
|
<Document
|
||||||
file={!file.includes(fileUrl) ? fileUrl + file : file}
|
file={!file.includes(fileUrl) ? fileUrl + file : file}
|
||||||
onLoadSuccess={onDocumentLoadSuccess}
|
onLoadSuccess={onDocumentLoadSuccess}
|
||||||
onLoadError={onDocumentLoadError}
|
onLoadError={onDocumentLoadError}
|
||||||
loading={(
|
|
||||||
<div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "65vh" }}>
|
|
||||||
<Spin size="large" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
Array.from({ length: numPages }).map((_, index) => (
|
Array.from({ length: numPages }).map((_, index) => (
|
||||||
|
|
@ -108,6 +111,7 @@ function Pdf(props) {
|
||||||
>
|
>
|
||||||
关闭
|
关闭
|
||||||
</Button>,
|
</Button>,
|
||||||
|
!loading && (
|
||||||
<Button
|
<Button
|
||||||
key="fullScreen"
|
key="fullScreen"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
@ -115,7 +119,8 @@ function Pdf(props) {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{isFullscreen ? "退出全屏" : "全屏"}
|
{isFullscreen ? "退出全屏" : "全屏"}
|
||||||
</Button>,
|
</Button>
|
||||||
|
),
|
||||||
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
<Button key="download" type="primary" onClick={onDownloadFile}>下载</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue