feat: 在文件上传组件中添加OCR警告提醒,提示用户启用OCR功能以提取PDF或图片文件的文本内容

This commit is contained in:
Wenjie Zhang 2025-10-26 18:30:59 +08:00
parent 25584e366a
commit 2a6be3e2ac
3 changed files with 60 additions and 0 deletions

View File

@ -217,6 +217,8 @@ services:
container_name: mineru container_name: mineru
profiles: profiles:
- all - all
env_file:
- .env
ports: ports:
- 30000:30000 - 30000:30000
environment: environment:
@ -253,6 +255,8 @@ services:
container_name: mineru-api container_name: mineru-api
profiles: profiles:
- all - all
env_file:
- .env
ports: ports:
- 30001:30001 - 30001:30001
environment: environment:

View File

@ -21,6 +21,15 @@ docker compose up -d api
### 2. 高精度 OCR (MinerU) ### 2. 高精度 OCR (MinerU)
需要配置:
```bash
MINERU_VL_SERVER=http://localhost:30000
MINERU_API_URI=http://localhost:30001
```
然后启动相关服务
```bash ```bash
# 需要 GPU启动 MinerU 服务 # 需要 GPU启动 MinerU 服务
docker compose up -d mineru-vllm-server mineru-api docker compose up -d mineru-vllm-server mineru-api

View File

@ -97,6 +97,11 @@
</a-form> </a-form>
</div> </div>
<!-- PDF/图片OCR提醒 -->
<div v-if="uploadMode === 'file' && hasPdfOrImageFiles && !isOcrEnabled" class="ocr-warning-alert">
检测到PDF或图片文件请启用OCR功能以提取文本内容
</div>
<!-- 文件上传区域 --> <!-- 文件上传区域 -->
<div class="upload" v-if="uploadMode === 'file'"> <div class="upload" v-if="uploadMode === 'file'">
<a-upload-dragger <a-upload-dragger
@ -187,6 +192,7 @@ import {
LinkOutlined, LinkOutlined,
SettingOutlined, SettingOutlined,
CheckCircleOutlined, CheckCircleOutlined,
ExclamationCircleOutlined,
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import { h } from 'vue'; import { h } from 'vue';
@ -338,6 +344,36 @@ const isGraphBased = computed(() => {
return type === 'lightrag'; return type === 'lightrag';
}); });
// OCR
const isOcrEnabled = computed(() => {
return chunkParams.value.enable_ocr !== 'disable';
});
// PDF
const hasPdfOrImageFiles = computed(() => {
if (fileList.value.length === 0) {
return false;
}
const pdfExtensions = ['.pdf'];
const imageExtensions = ['.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.tif', '.gif', '.webp'];
const ocrExtensions = [...pdfExtensions, ...imageExtensions];
return fileList.value.some(file => {
if (file.status !== 'done') {
return false;
}
const filePath = file.response?.file_path || file.name;
if (!filePath) {
return false;
}
const ext = filePath.substring(filePath.lastIndexOf('.')).toLowerCase();
return ocrExtensions.includes(ext);
});
});
// OCR // OCR
const enableOcrOptions = computed(() => [ const enableOcrOptions = computed(() => [
{ {
@ -677,4 +713,15 @@ const chunkData = async () => {
.chunk-config-content .params-info { .chunk-config-content .params-info {
margin-bottom: 16px; margin-bottom: 16px;
} }
// OCR
.ocr-warning-alert {
margin: 12px 0;
padding: 8px 12px;
background: #fff7e6;
border: 1px solid #ffd666;
border-radius: 4px;
color: #d46b08;
font-size: 13px;
}
</style> </style>