feat: 在文件上传组件中添加OCR警告提醒,提示用户启用OCR功能以提取PDF或图片文件的文本内容
This commit is contained in:
parent
25584e366a
commit
2a6be3e2ac
@ -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:
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user