From d108379f4124a3b54e7e3d22e66f896e8a84a69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Fri, 11 Apr 2025 16:26:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(knowledge):=20=E6=B7=BB=E5=8A=A0=20MinerU?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BB=A5=E6=94=AF=E6=8C=81=20PDF=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 RenderMinerU 组件,用于 PDF 文件的预处理和 Markdown 编辑 - 在 create.vue 中集成 RenderMinerU组件,实现预处理结果预览功能 - 更新公共样式以支持 Markdown 渲染 - 在 main.js 中注册 RMinerU组件 - 修改 package.json,添加 markdown-it 和 markdown-it-katex 依赖 - 更新 vue.config.js,添加对 mjs 文件的处理规则 --- package.json | 2 + src/api/generatedApi/index.js | 18 +++ src/assets/sass/public.scss | 90 ++++++++++++ src/components/RenderMinerU/index.vue | 173 +++++++++++++++++++++++ src/components/RenderMinerU/pdf-color.js | 37 +++++ src/main.js | 2 + src/views/knowledge/detail/create.vue | 90 ++++++------ vue.config.js | 9 ++ 8 files changed, 379 insertions(+), 42 deletions(-) create mode 100644 src/components/RenderMinerU/index.vue create mode 100644 src/components/RenderMinerU/pdf-color.js diff --git a/package.json b/package.json index 0ca77a4..cc87196 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,8 @@ "exif-js": "^2.3.0", "file-saver": "^2.0.5", "js-cookie": "2.2.0", + "markdown-it": "^14.1.0", + "markdown-it-katex": "^2.0.3", "mavon-editor": "^2.9.1", "node-gyp": "^8.0.0", "normalize.css": "7.0.0", diff --git a/src/api/generatedApi/index.js b/src/api/generatedApi/index.js index b63946c..6388bec 100644 --- a/src/api/generatedApi/index.js +++ b/src/api/generatedApi/index.js @@ -40,3 +40,21 @@ export function datasetDelete(data) { method: 'delete', }) } + + + +//minerU 获取bbox +export function minerUBbox(params) { + return request({ + url:'http://192.168.8.165:7196/document/mineru/bbox_json', + // url: getUrl('/document/mineru/bbox_json'), + method: 'get', + params:params + }) +} +//minerU 获取markdown +export function minerUMarkDown(params) { + return `http://192.168.8.165:7196/document/mineru/md?documentId=${params.documentId}` + // url: getUrl('/document/mineru/md'), + +} diff --git a/src/assets/sass/public.scss b/src/assets/sass/public.scss index 18923c8..c319698 100644 --- a/src/assets/sass/public.scss +++ b/src/assets/sass/public.scss @@ -142,6 +142,9 @@ .lineH35 { line-height: 35px; } +.lineH25 { + line-height: 25px; +} .lineH40 { line-height: 40px; } @@ -258,3 +261,90 @@ body .el-collapse-item__wrap { .cursor-pointer { cursor: pointer; } +.view-body { + text-align: left; + font-size: 14px; + div{ + outline: unset; + + } + + /* 添加一些基本的样式以美化 Markdown 内容 */ + + p { + font-size: 16px; + line-height: 1.6; + margin-bottom: 16px; + } + + h1, h2, h3, h4, h5, h6 { + margin-top: 24px; + margin-bottom: 12px; + border-bottom: 1px dashed #cecece; + padding:5px; + } + + ul, ol { + margin: 16px 0; + padding-left: 32px; + } + + li { + margin-bottom: 8px; + } + + a { + color: #007BFF; + text-decoration: none; + } + + a:hover { + text-decoration: underline; + } + + code { + background-color: #f1f1f1; + padding: 4px 8px; + border-radius: 4px; + font-family: 'Courier New', Courier, monospace; + } + + img { + max-width: 100%; + } + + pre { + background-color: #f1f1f1; + padding: 16px; + border-radius: 4px; + overflow-x: auto; + font-family: 'Courier New', Courier, monospace; + } + + pre code { + background-color: transparent; + padding: 0; + } + + table { + border: 1px solid #f9f9f9; + width: 100%; + border-collapse: collapse; + background: linear-gradient(to bottom, #ffffff, #f9f9f9); + } + + th, td { + border: 1px solid #ccc; + padding: 8px; + text-align: left; + } + + th { + background-color: #f2f2f2; + } + + // 添加斑马条纹效果 + tr:nth-child(even) { + background-color: #f9fafc; + } +} diff --git a/src/components/RenderMinerU/index.vue b/src/components/RenderMinerU/index.vue new file mode 100644 index 0000000..448eacd --- /dev/null +++ b/src/components/RenderMinerU/index.vue @@ -0,0 +1,173 @@ + + + diff --git a/src/components/RenderMinerU/pdf-color.js b/src/components/RenderMinerU/pdf-color.js new file mode 100644 index 0000000..d80ff0b --- /dev/null +++ b/src/components/RenderMinerU/pdf-color.js @@ -0,0 +1,37 @@ +export const PDF_COLOR_PICKER = { + title: { + line: 'rgba(121, 124, 255, 1)', + fill: 'rgba(121, 124, 255, 0.4)' + }, + text: { + line: 'rgba(230, 122, 171, 1)', + fill: 'rgba(230, 122, 171, 0.4)' + }, + interline_equation: { + line: 'rgba(240, 240, 124, 1)', + fill: 'rgba(240, 240, 124, 0.4)' + }, + discarded: { + line: 'rgba(164,164,164,1)', + fill: 'rgba(164,164,164,0.4)' + }, + image: { + line: 'rgba(149, 226, 115, 1)', + fill: 'rgba(149, 226, 115, 0.4)' + }, + table: { + line: 'rgba(230, 113, 230, 1)', + fill: 'rgba(230, 113, 230, 0.4)' + }, + inline_equation: { + line: 'rgba(150, 232, 172, 1)', + fill: 'rgba(150, 232, 172, 0.4)' + } +}; + +export const DEFAULT_COLOR_SECTION = { + line: 'rgba(166, 113, 230, 1)', + fill: 'rgba(166, 113, 230, 0.4)' +}; + +export const PDF_TEMPLATE_URL_KEY = 't'; diff --git a/src/main.js b/src/main.js index 50698bd..7819775 100644 --- a/src/main.js +++ b/src/main.js @@ -11,6 +11,7 @@ import RenderTable from './components/RenderTable' import RenderSwiper from './components/RenderSwiper' import VueEditor from './components/VueEditor' import MavonEditor from './components/MavonEditor' +import RenderMinerU from '@/components/RenderMinerU/index.vue' import utils from '@/assets/js/common' // 生成的数据交互api import generatedApi from '@/api/generatedApi' @@ -32,6 +33,7 @@ Vue.use(ElementUI, { locale }) //二次封装的el-table Vue.component('RTable', RenderTable) Vue.component('RSwiper', RenderSwiper) +Vue.component('RMinerU', RenderMinerU) // 富文本编辑器 Vue.component('VEditor', VueEditor) // 富文本编辑器 可视化代码 diff --git a/src/views/knowledge/detail/create.vue b/src/views/knowledge/detail/create.vue index 3941fab..2855996 100644 --- a/src/views/knowledge/detail/create.vue +++ b/src/views/knowledge/detail/create.vue @@ -1,83 +1,89 @@ - diff --git a/vue.config.js b/vue.config.js index 0a94662..b76f002 100644 --- a/vue.config.js +++ b/vue.config.js @@ -47,6 +47,15 @@ module.exports = { //在webpack的名称字段中提供应用程序的标题,以便 //可以在index.html中对其进行访问以注入正确的标题。 name: name, + module: { + rules: [ + { + test: /\.mjs$/, + include: /node_modules/, + type: 'javascript/auto', + }, + ], + }, resolve: { alias: { '@': resolve('src')