feat: Docker 独立部署版 v1.1.0 + OCR 图片文字搜索
上游 ZangXincz/FlyPic 已归档停更、飞牛应用商店下架,本提交使其脱离 飞牛应用框架,以普通 Docker 容器继续运行。 - ✨ Docker 独立部署:多阶段 Dockerfile + docker-compose.yml,一键构建 - ✨ OCR 图片内文字搜索:扫描时 tesseract(chi_sim+eng) 提取文字入 ocr_text 列, 搜索同时匹配文件名与图片内容 - 🐛 修复 LibraryService 缺少 logger 引用导致添加素材库 500 - 🐛 移除写权限校验,支持只读挂载素材目录 - 📝 容器内路径与宿主机一致(中文路径直接可用) - 🎨 保持原交互:单击选中、Ctrl/Shift 多选、双击放大 - 🔒 config/(JWT 密钥)加入 gitignore
This commit is contained in:
1 parent
7359937892
commit
d96986ec79
11 files changed
+254
-118
No files matched your search
+15
-5
@@ -90,6 +90,13 @@ class LibraryDatabase {
|
||||
// 列已存在,忽略错误
|
||||
}
|
||||
|
||||
// 添加 ocr_text 列(如果不存在)
|
||||
try {
|
||||
this.db.exec(`ALTER TABLE images ADD COLUMN ocr_text TEXT DEFAULT ''`);
|
||||
} catch (e) {
|
||||
// 列已存在,忽略错误
|
||||
}
|
||||
|
||||
// Folders table
|
||||
this.db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS folders (
|
||||
@@ -115,6 +122,8 @@ class LibraryDatabase {
|
||||
-- 评分和收藏索引:优化筛选查询
|
||||
CREATE INDEX IF NOT EXISTS idx_rating ON images(rating DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_favorite ON images(favorite DESC);
|
||||
-- OCR 文本索引:优化关键词搜索
|
||||
CREATE INDEX IF NOT EXISTS idx_ocr_text ON images(ocr_text);
|
||||
`);
|
||||
|
||||
// Metadata table for tracking database modifications
|
||||
@@ -168,8 +177,8 @@ class LibraryDatabase {
|
||||
insertImage(imageData) {
|
||||
const stmt = this.db.prepare(`
|
||||
INSERT OR REPLACE INTO images
|
||||
(path, filename, folder, size, width, height, format, file_type, created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
(path, filename, folder, size, width, height, format, file_type, created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at, ocr_text)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`);
|
||||
const result = stmt.run(
|
||||
imageData.path,
|
||||
@@ -185,7 +194,8 @@ class LibraryDatabase {
|
||||
imageData.file_hash,
|
||||
imageData.thumbnail_path,
|
||||
imageData.thumbnail_size,
|
||||
Date.now()
|
||||
Date.now(),
|
||||
imageData.ocr_text || ''
|
||||
);
|
||||
// 更新数据库修改时间
|
||||
this.updateLastModified();
|
||||
@@ -219,8 +229,8 @@ class LibraryDatabase {
|
||||
if (keywords && keywords.trim()) {
|
||||
const terms = keywords.trim().split(/\s+/);
|
||||
terms.forEach(term => {
|
||||
baseQuery += ' AND filename LIKE ?';
|
||||
params.push(`%${term}%`);
|
||||
baseQuery += ' AND (filename LIKE ? OR ocr_text LIKE ?)';
|
||||
params.push(`%${term}%`, `%${term}%`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user