From 2fbe6901f53de93994f63f300d14be7460262044 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Mon, 10 Nov 2025 14:49:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=A1=A3=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/common/DocumentSearch.vue | 10 ++++++++++ vue.config.js | 25 +++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/views/common/DocumentSearch.vue b/src/views/common/DocumentSearch.vue index 5cc480c..dd87665 100644 --- a/src/views/common/DocumentSearch.vue +++ b/src/views/common/DocumentSearch.vue @@ -122,6 +122,13 @@ export default { if ('GlobalStandardFontDataUrl' in pdfjsLib) { pdfjsLib.GlobalStandardFontDataUrl = this.standardFontDataUrl } + if (pdfjsLib.GlobalOptions) { + pdfjsLib.GlobalOptions.disableFontFace = false + if ('useSystemFonts' in pdfjsLib.GlobalOptions) { + pdfjsLib.GlobalOptions.useSystemFonts = true + } + } + this.pdfUrl = this.$route.query.url || 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/10/30/fe5b46ea37554516a71e7c0c486d3715.pdf' if (this.pdfUrl) { this.loadDocument() @@ -164,6 +171,9 @@ export default { useWorkerFetch: !!resolvedWorkerSrc, cMapUrl: this.cMapUrl, cMapPacked: true, + standardFontDataUrl: this.standardFontDataUrl, + useSystemFonts: true, + fontExtraProperties: true, }) this.pdfDoc = await loadingTask.promise console.log('PDF 文档加载成功', this.pdfDoc) diff --git a/vue.config.js b/vue.config.js index 952a967..6fd85c0 100644 --- a/vue.config.js +++ b/vue.config.js @@ -6,11 +6,13 @@ function resolve(dir) { } const CompressionPlugin = require('compression-webpack-plugin') +const CopyWebpackPlugin = require('copy-webpack-plugin') const name = process.env.VUE_APP_TITLE || '智能投标系统' // 网页标题 // const baseUrl = 'http://localhost:8080' // 后端接口 const baseUrl = 'http://192.168.0.39:8080' +// const baseUrl = 'http://192.168.31.170:8080' const port = process.env.port || process.env.npm_config_port || 80 // 端口 @@ -21,7 +23,7 @@ module.exports = { // 部署生产环境和开发环境下的URL。 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 - publicPath: process.env.NODE_ENV === "production" ? "/smart-archiving/" : "/", + publicPath: process.env.NODE_ENV === "production" ? "/smart-bid/" : "/", // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) outputDir: 'dist', // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) @@ -74,7 +76,26 @@ module.exports = { algorithm: 'gzip', // 使用gzip压缩 minRatio: 0.8, // 压缩比例,小于 80% 的文件不会被压缩 deleteOriginalAssets: false // 压缩后删除原文件 - }) + }), + new CopyWebpackPlugin([ + { + from: path.resolve(__dirname, 'node_modules/pdfjs-dist/legacy/build/pdf.worker.min.js'), + to: 'pdfjs/pdf.worker.min.js', + force: true + }, + { + from: path.resolve(__dirname, 'node_modules/pdfjs-dist/cmaps'), + to: 'pdfjs/cmaps', + toType: 'dir', + noErrorOnMissing: true + }, + { + from: path.resolve(__dirname, 'node_modules/pdfjs-dist/standard_fonts'), + to: 'pdfjs/standard_fonts', + toType: 'dir', + noErrorOnMissing: true + } + ]) ], }, chainWebpack(config) {