From d251ca2f629cfbca285ec54b3b8e6aa7259d5d20 Mon Sep 17 00:00:00 2001
From: LiuJiaNan <15703339975@163.com>
Date: Mon, 22 Dec 2025 14:47:41 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Pdf?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/Pdf/index.js | 83 +++++++++++++++++++++++++--------------
components/Pdf/index.less | 3 ++
2 files changed, 57 insertions(+), 29 deletions(-)
create mode 100644 components/Pdf/index.less
diff --git a/components/Pdf/index.js b/components/Pdf/index.js
index 038397f..857070b 100644
--- a/components/Pdf/index.js
+++ b/components/Pdf/index.js
@@ -1,8 +1,12 @@
-import { message, Modal, Spin } from "antd";
-import { useState } from "react";
+import { useFullscreen } from "ahooks";
+import { Button, message, Modal, Spin } from "antd";
+import { useRef, useState } from "react";
import { Document, Page, pdfjs } from "react-pdf";
import useDownloadFile from "../../hooks/useDownloadFile";
-import { getFileUrl } from "../../utils/index";
+import { getFileUrl } from "../../utils";
+import "react-pdf/dist/Page/AnnotationLayer.css";
+import "react-pdf/dist/Page/TextLayer.css";
+import "./index.less";
/**
* PDF查看组件
@@ -22,6 +26,11 @@ function Pdf(props) {
const [pdfWidth, setPdfWidth] = useState(600);
const [loading, setLoading] = useState(true);
+ const fullscreenRef = useRef(null);
+
+ const [isFullscreen, { enterFullscreen, exitFullscreen }] = useFullscreen(fullscreenRef);
+ const { downloadFile } = useDownloadFile();
+
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.mjs`;
const onDocumentLoadSuccess = ({ numPages }) => {
@@ -48,14 +57,14 @@ function Pdf(props) {