mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
* refactor(ocr): streamline OCR service registration and improve image preprocessing - Simplified the registration of the system OCR service by removing the conditional check for Linux. - Updated SystemOcrService to directly import necessary modules, enhancing clarity. - Refactored image preprocessing to use a static import of the 'sharp' library for better performance. * add patch for system-ocr * add patch * add patch again * add patch * delete setting * delete i18n * lint error * add isLinux * Revert "delete i18n" This reverts commit173e65bbd0. * Revert "delete setting" This reverts commitde39c76f83. * fix: add system check for error message --------- Co-authored-by: icarus <eurfelux@gmail.com>
31 lines
987 B
Diff
Vendored
31 lines
987 B
Diff
Vendored
diff --git a/index.js b/index.js
|
|
index dc071739e79876dff88e1be06a9168e294222d13..b9df7525c62bdf777e89e732e1b0c81f84d872f2 100644
|
|
--- a/index.js
|
|
+++ b/index.js
|
|
@@ -380,7 +380,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
}
|
|
}
|
|
|
|
-if (!nativeBinding) {
|
|
+if (!nativeBinding && process.platform !== 'linux') {
|
|
if (loadErrors.length > 0) {
|
|
throw new Error(
|
|
`Cannot find native binding. ` +
|
|
@@ -392,6 +392,13 @@ if (!nativeBinding) {
|
|
throw new Error(`Failed to load native binding`)
|
|
}
|
|
|
|
-module.exports = nativeBinding
|
|
-module.exports.OcrAccuracy = nativeBinding.OcrAccuracy
|
|
-module.exports.recognize = nativeBinding.recognize
|
|
+if (process.platform === 'linux') {
|
|
+ module.exports = {OcrAccuracy: {
|
|
+ Fast: 0,
|
|
+ Accurate: 1
|
|
+ }, recognize: () => Promise.resolve({text: '', confidence: 1.0})}
|
|
+}else{
|
|
+ module.exports = nativeBinding
|
|
+ module.exports.OcrAccuracy = nativeBinding.OcrAccuracy
|
|
+ module.exports.recognize = nativeBinding.recognize
|
|
+}
|