fix: 默认OCR引擎换成MinerU而不是mistral
This commit is contained in:
parent
5c1c66bd8f
commit
b019917c18
|
|
@ -1758,10 +1758,10 @@ async function handleProcessClick() {
|
||||||
|
|
||||||
// 2. 检查 OCR 配置(如果有 PDF 文件)
|
// 2. 检查 OCR 配置(如果有 PDF 文件)
|
||||||
if (hasPdfFiles) {
|
if (hasPdfFiles) {
|
||||||
let ocrEngine = 'mistral';
|
let ocrEngine = 'mineru';
|
||||||
try {
|
try {
|
||||||
if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
||||||
ocrEngine = window.ocrSettingsManager.getCurrentConfig().engine || 'mistral';
|
ocrEngine = window.ocrSettingsManager.getCurrentConfig().engine || 'mineru';
|
||||||
const validation = window.ocrSettingsManager.validateConfig();
|
const validation = window.ocrSettingsManager.validateConfig();
|
||||||
if (!validation.valid) {
|
if (!validation.valid) {
|
||||||
const engineNames = { mistral: 'Mistral OCR', mineru: 'MinerU', doc2x: 'Doc2X', none: '不需要 OCR' };
|
const engineNames = { mistral: 'Mistral OCR', mineru: 'MinerU', doc2x: 'Doc2X', none: '不需要 OCR' };
|
||||||
|
|
|
||||||
|
|
@ -137,13 +137,13 @@ const fileType = fileToProcess.name.split('.').pop().toLowerCase();
|
||||||
let usedOcrEngine = null;
|
let usedOcrEngine = null;
|
||||||
let usedOcrSource = null;
|
let usedOcrSource = null;
|
||||||
// 更合理的开始日志:显示 OCR 引擎而不是固定显示 Mistral Key
|
// 更合理的开始日志:显示 OCR 引擎而不是固定显示 Mistral Key
|
||||||
let ocrEngineForLog = 'mistral';
|
let ocrEngineForLog = 'mineru';
|
||||||
try {
|
try {
|
||||||
if (typeof window !== 'undefined' && window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
if (typeof window !== 'undefined' && window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
||||||
const cfg = window.ocrSettingsManager.getCurrentConfig();
|
const cfg = window.ocrSettingsManager.getCurrentConfig();
|
||||||
if (cfg && cfg.engine) ocrEngineForLog = cfg.engine;
|
if (cfg && cfg.engine) ocrEngineForLog = cfg.engine;
|
||||||
} else {
|
} else {
|
||||||
ocrEngineForLog = localStorage.getItem('ocrEngine') || 'mistral';
|
ocrEngineForLog = localStorage.getItem('ocrEngine') || 'mineru';
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
if (typeof addProgressLog === "function") {
|
if (typeof addProgressLog === "function") {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class OcrManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: 直接从 localStorage 读取
|
// Fallback: 直接从 localStorage 读取
|
||||||
const engine = localStorage.getItem('ocrEngine') || 'mistral';
|
const engine = localStorage.getItem('ocrEngine') || 'mineru';
|
||||||
|
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case 'local':
|
case 'local':
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ KeyManagerUI.exportAllModelData = function() {
|
||||||
|
|
||||||
// 添加 OCR 配置导出
|
// 添加 OCR 配置导出
|
||||||
const ocrConfig = {
|
const ocrConfig = {
|
||||||
engine: localStorage.getItem('ocrEngine') || 'mistral',
|
engine: localStorage.getItem('ocrEngine') || 'mineru', // 默认为 mineru
|
||||||
mistralKeys: localStorage.getItem('ocrMistralKeys') || '',
|
mistralKeys: localStorage.getItem('ocrMistralKeys') || '',
|
||||||
workerAuthKey: localStorage.getItem('ocrWorkerAuthKey') || '',
|
workerAuthKey: localStorage.getItem('ocrWorkerAuthKey') || '',
|
||||||
mineruToken: localStorage.getItem('ocrMinerUToken') || '',
|
mineruToken: localStorage.getItem('ocrMinerUToken') || '',
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class OcrSettingsManager {
|
||||||
loadSettings() {
|
loadSettings() {
|
||||||
try {
|
try {
|
||||||
// 引擎选择
|
// 引擎选择
|
||||||
const engine = localStorage.getItem(this.keys.engine) || 'mistral';
|
const engine = localStorage.getItem(this.keys.engine) || 'mineru';
|
||||||
if (this.elements.ocrEngine) {
|
if (this.elements.ocrEngine) {
|
||||||
this.elements.ocrEngine.value = engine;
|
this.elements.ocrEngine.value = engine;
|
||||||
this.switchEngine(engine); // 显示对应的配置面板
|
this.switchEngine(engine); // 显示对应的配置面板
|
||||||
|
|
@ -476,7 +476,7 @@ class OcrSettingsManager {
|
||||||
* @returns {Object} 配置对象
|
* @returns {Object} 配置对象
|
||||||
*/
|
*/
|
||||||
getCurrentConfig() {
|
getCurrentConfig() {
|
||||||
const engine = localStorage.getItem(this.keys.engine) || 'mistral';
|
const engine = localStorage.getItem(this.keys.engine) || 'mineru';
|
||||||
|
|
||||||
switch (engine) {
|
switch (engine) {
|
||||||
case 'none':
|
case 'none':
|
||||||
|
|
|
||||||
|
|
@ -131,18 +131,18 @@
|
||||||
const hasPdfFiles = effectiveFiles.some(file => file.name.toLowerCase().endsWith('.pdf'));
|
const hasPdfFiles = effectiveFiles.some(file => file.name.toLowerCase().endsWith('.pdf'));
|
||||||
|
|
||||||
// 检查 OCR 引擎与所需配置
|
// 检查 OCR 引擎与所需配置
|
||||||
let ocrEngine = 'mistral';
|
let ocrEngine = 'mineru';
|
||||||
let ocrConfigValid = true;
|
let ocrConfigValid = true;
|
||||||
let ocrConfigMessage = '';
|
let ocrConfigMessage = '';
|
||||||
try {
|
try {
|
||||||
if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
||||||
ocrEngine = window.ocrSettingsManager.getCurrentConfig().engine || (localStorage.getItem('ocrEngine') || 'mistral');
|
ocrEngine = window.ocrSettingsManager.getCurrentConfig().engine || (localStorage.getItem('ocrEngine') || 'mineru');
|
||||||
// 使用 validateConfig 检查配置是否完整
|
// 使用 validateConfig 检查配置是否完整
|
||||||
const validation = window.ocrSettingsManager.validateConfig();
|
const validation = window.ocrSettingsManager.validateConfig();
|
||||||
ocrConfigValid = validation.valid;
|
ocrConfigValid = validation.valid;
|
||||||
ocrConfigMessage = validation.message;
|
ocrConfigMessage = validation.message;
|
||||||
} else {
|
} else {
|
||||||
ocrEngine = localStorage.getItem('ocrEngine') || 'mistral';
|
ocrEngine = localStorage.getItem('ocrEngine') || 'mineru';
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,13 +186,13 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// 检查当前 OCR 引擎配置
|
// 检查当前 OCR 引擎配置
|
||||||
let currentOcrEngine = 'mistral';
|
let currentOcrEngine = 'mineru';
|
||||||
let currentOcrConfigured = false;
|
let currentOcrConfigured = false;
|
||||||
try {
|
try {
|
||||||
if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
if (window.ocrSettingsManager && typeof window.ocrSettingsManager.getCurrentConfig === 'function') {
|
||||||
currentOcrEngine = window.ocrSettingsManager.getCurrentConfig().engine || (localStorage.getItem('ocrEngine') || 'mistral');
|
currentOcrEngine = window.ocrSettingsManager.getCurrentConfig().engine || (localStorage.getItem('ocrEngine') || 'mineru');
|
||||||
} else {
|
} else {
|
||||||
currentOcrEngine = localStorage.getItem('ocrEngine') || 'mistral';
|
currentOcrEngine = localStorage.getItem('ocrEngine') || 'mineru';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentOcrEngine === 'none' || currentOcrEngine === 'local') {
|
if (currentOcrEngine === 'none' || currentOcrEngine === 'local') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue