Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 桌面端支持搜索图片 OCR 文本 https://github.com/siyuan-note/siyuan/issues/3470

Liang Ding5593542f73b6
diff --git a/kernel/util/ocr.go b/kernel/util/ocr.go
index 34791045bf..b5d9f353f9 100644
--- a/kernel/util/ocr.go
+++ b/kernel/util/ocr.go
@@ -42,10 +42,22 @@ var (
assetsTextsChanged = false
)
-func GetAssetText(assets string) string {
+func GetAssetText(asset string) string {
assetsTextsLock.Lock()
- defer assetsTextsLock.Unlock()
- return assetsTexts[assets]
+ ret, ok := assetsTexts[asset]
+ assetsTextsLock.Unlock()
+ if ok {
+ return ret
+ }
+
+ assetsPath := GetDataAssetsAbsPath()
+ assetAbsPath := strings.TrimPrefix(asset, "assets")
+ assetAbsPath = filepath.Join(assetsPath, assetAbsPath)
+ ret = Tesseract(assetAbsPath)
+ assetsTextsLock.Lock()
+ assetsTexts[asset] = ret
+ assetsTextsLock.Unlock()
+ return ret
}
func Tesseract(imgAbsPath string) string {