改为本地依赖
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
"pack:ia32": "npm run build && electron-builder --dir --ia32",
|
"pack:ia32": "npm run build && electron-builder --dir --ia32",
|
||||||
"dist": "npm run build && electron-builder",
|
"dist": "npm run build && electron-builder",
|
||||||
"dist:ia32": "npm run build && electron-builder --ia32",
|
"dist:ia32": "npm run build && electron-builder --ia32",
|
||||||
|
"update-pdf-worker": "node -e \"require('fs').copyFileSync('node_modules/react-pdf/node_modules/pdfjs-dist/build/pdf.worker.min.js', 'public/pdf.worker.min.js')\"",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
|
|||||||
22
public/pdf.worker.min.js
vendored
Normal file
22
public/pdf.worker.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -10,8 +10,10 @@ import ui8A from "../../assets/ui8A.png";
|
|||||||
import ui8B from "../../assets/ui8B.png";
|
import ui8B from "../../assets/ui8B.png";
|
||||||
import testPdf from "../../assets/testPdf.pdf";
|
import testPdf from "../../assets/testPdf.pdf";
|
||||||
|
|
||||||
// 设置 PDF.js worker(react-pdf 5.7.2 使用 pdfjs-dist 2.12.313)
|
// 设置 PDF.js worker - 使用本地文件以支持 Electron 环境
|
||||||
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.12.313/pdf.worker.min.js`;
|
// 开发环境:Vite 会从 public 目录提供服务
|
||||||
|
// 生产环境:打包到 dist 目录
|
||||||
|
pdfjs.GlobalWorkerOptions.workerSrc = "/pdf.worker.min.js";
|
||||||
|
|
||||||
// 使用本地 PDF 文件进行测试
|
// 使用本地 PDF 文件进行测试
|
||||||
const PDF_URL = testPdf;
|
const PDF_URL = testPdf;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import react from "@vitejs/plugin-react";
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
base: "./", // 确保资源路径是相对的,以便在 Electron 中加载
|
base: "./", // 确保资源路径是相对的,以便在 Electron 中加载
|
||||||
|
publicDir: "public", // 指定 public 目录
|
||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user