Skip to content

Commit 2a6be3e

Browse files
committed
feat: 在文件上传组件中添加OCR警告提醒,提示用户启用OCR功能以提取PDF或图片文件的文本内容
1 parent 25584e3 commit 2a6be3e

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ services:
217217
container_name: mineru
218218
profiles:
219219
- all
220+
env_file:
221+
- .env
220222
ports:
221223
- 30000:30000
222224
environment:
@@ -253,6 +255,8 @@ services:
253255
container_name: mineru-api
254256
profiles:
255257
- all
258+
env_file:
259+
- .env
256260
ports:
257261
- 30001:30001
258262
environment:

docs/advanced/document-processing.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ docker compose up -d api
2121

2222
### 2. 高精度 OCR (MinerU)
2323

24+
需要配置:
25+
26+
```bash
27+
MINERU_VL_SERVER=http://localhost:30000
28+
MINERU_API_URI=http://localhost:30001
29+
```
30+
31+
然后启动相关服务
32+
2433
```bash
2534
# 需要 GPU,启动 MinerU 服务
2635
docker compose up -d mineru-vllm-server mineru-api

web/src/components/FileUploadModal.vue

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
</a-form>
9898
</div>
9999

100+
<!-- PDF/图片OCR提醒 -->
101+
<div v-if="uploadMode === 'file' && hasPdfOrImageFiles && !isOcrEnabled" class="ocr-warning-alert">
102+
⚠️ 检测到PDF或图片文件,请启用OCR功能以提取文本内容
103+
</div>
104+
100105
<!-- 文件上传区域 -->
101106
<div class="upload" v-if="uploadMode === 'file'">
102107
<a-upload-dragger
@@ -187,6 +192,7 @@ import {
187192
LinkOutlined,
188193
SettingOutlined,
189194
CheckCircleOutlined,
195+
ExclamationCircleOutlined,
190196
} from '@ant-design/icons-vue';
191197
import { h } from 'vue';
192198
@@ -338,6 +344,36 @@ const isGraphBased = computed(() => {
338344
return type === 'lightrag';
339345
});
340346
347+
// 计算属性:是否启用了OCR
348+
const isOcrEnabled = computed(() => {
349+
return chunkParams.value.enable_ocr !== 'disable';
350+
});
351+
352+
// 计算属性:是否有PDF或图片文件
353+
const hasPdfOrImageFiles = computed(() => {
354+
if (fileList.value.length === 0) {
355+
return false;
356+
}
357+
358+
const pdfExtensions = ['.pdf'];
359+
const imageExtensions = ['.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.tif', '.gif', '.webp'];
360+
const ocrExtensions = [...pdfExtensions, ...imageExtensions];
361+
362+
return fileList.value.some(file => {
363+
if (file.status !== 'done') {
364+
return false;
365+
}
366+
367+
const filePath = file.response?.file_path || file.name;
368+
if (!filePath) {
369+
return false;
370+
}
371+
372+
const ext = filePath.substring(filePath.lastIndexOf('.')).toLowerCase();
373+
return ocrExtensions.includes(ext);
374+
});
375+
});
376+
341377
// 计算属性:OCR选项
342378
const enableOcrOptions = computed(() => [
343379
{
@@ -677,4 +713,15 @@ const chunkData = async () => {
677713
.chunk-config-content .params-info {
678714
margin-bottom: 16px;
679715
}
716+
717+
// OCR警告提醒样式
718+
.ocr-warning-alert {
719+
margin: 12px 0;
720+
padding: 8px 12px;
721+
background: #fff7e6;
722+
border: 1px solid #ffd666;
723+
border-radius: 4px;
724+
color: #d46b08;
725+
font-size: 13px;
726+
}
680727
</style>

0 commit comments

Comments
 (0)