fix: harden OCR refinement integration
Some checks failed
Desktop Release / Bootstrap updater signing key (push) Has been cancelled
Desktop Release / Windows x64 NSIS (push) Has been cancelled
Desktop Release / Linux x64 DEB + AppImage (push) Has been cancelled
Desktop Release / Publish public desktop release (push) Has been cancelled

This commit is contained in:
Admin 2026-09-25 21:22:42 +00:00
parent d39c66eb82
commit 618ff80e6a
3 changed files with 6 additions and 2 deletions

View File

@ -321,6 +321,9 @@ fn save_ocr_profile(profile: Value, state: State<'_, AppState>) -> Result<Value,
let temp = state.shared.data_dir.join("ocr-profile.json.tmp"); let temp = state.shared.data_dir.join("ocr-profile.json.tmp");
let bytes = serde_json::to_vec_pretty(&profile).map_err(|error| error.to_string())?; let bytes = serde_json::to_vec_pretty(&profile).map_err(|error| error.to_string())?;
fs::write(&temp, bytes).map_err(|error| error.to_string())?; fs::write(&temp, bytes).map_err(|error| error.to_string())?;
if path.exists() {
fs::remove_file(&path).map_err(|error| error.to_string())?;
}
fs::rename(&temp, &path).map_err(|error| error.to_string())?; fs::rename(&temp, &path).map_err(|error| error.to_string())?;
Ok(profile) Ok(profile)
} }

View File

@ -1132,7 +1132,7 @@ await listen<Job>('capture-job', (event) => {
void refreshStatus() void refreshStatus()
}) })
initOcrRefinement(el('ocr-refinement-root'), invoke) initOcrRefinement(el('ocr-refinement-root'))
config = await invoke<AppConfig>('get_config') config = await invoke<AppConfig>('get_config')
writeForm(config) writeForm(config)

View File

@ -1,3 +1,4 @@
import { invoke } from '@tauri-apps/api/core'
import * as pdfjsLib from 'pdfjs-dist' import * as pdfjsLib from 'pdfjs-dist'
import pdfWorker from 'pdfjs-dist/build/pdf.worker.min.mjs?url' import pdfWorker from 'pdfjs-dist/build/pdf.worker.min.mjs?url'
import type { Worker } from 'tesseract.js' import type { Worker } from 'tesseract.js'
@ -160,7 +161,7 @@ async function getOcrWorker(updateStatus: (message: string) => void) {
return ocrWorkerPromise return ocrWorkerPromise
} }
export function initOcrRefinement(root: HTMLElement, invoke: <T>(command: string, args?: Record<string, unknown>) => Promise<T>) { export function initOcrRefinement(root: HTMLElement) {
root.innerHTML = [ root.innerHTML = [
'<div class="ocr-workbench">', '<div class="ocr-workbench">',
'<section class="card ocr-toolbar-card">', '<section class="card ocr-toolbar-card">',