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
@@ -65,8 +65,8 @@ class ImageModel extends BaseModel {
|
||||
const query = `
|
||||
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at, ocr_text)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`;
|
||||
|
||||
return this.execute(query, [
|
||||
@@ -83,7 +83,8 @@ class ImageModel extends BaseModel {
|
||||
data.fileHash,
|
||||
data.thumbnailPath,
|
||||
data.thumbnailSize,
|
||||
Date.now()
|
||||
Date.now(),
|
||||
data.ocrText || ''
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -94,8 +95,8 @@ class ImageModel extends BaseModel {
|
||||
const query = `
|
||||
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at, ocr_text)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`;
|
||||
|
||||
return this.transaction(() => {
|
||||
@@ -105,7 +106,7 @@ class ImageModel extends BaseModel {
|
||||
data.path, data.filename, data.folder, data.size,
|
||||
data.width, data.height, data.format, data.fileType || 'image',
|
||||
data.createdAt, data.modifiedAt, data.fileHash,
|
||||
data.thumbnailPath, data.thumbnailSize, Date.now()
|
||||
data.thumbnailPath, data.thumbnailSize, Date.now(), data.ocrText || ''
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -168,8 +169,8 @@ class ImageModel extends BaseModel {
|
||||
if (filters.keywords) {
|
||||
const terms = filters.keywords.trim().split(/\s+/);
|
||||
terms.forEach(term => {
|
||||
query += ' AND filename LIKE ?';
|
||||
params.push(`%${term}%`);
|
||||
query += ' AND (filename LIKE ? OR ocr_text LIKE ?)';
|
||||
params.push(`%${term}%`, `%${term}%`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* 素材库服务层
|
||||
* 封装素材库相关的业务逻辑
|
||||
*/
|
||||
const logger = require('../utils/logger');
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
@@ -50,21 +51,8 @@ class LibraryService {
|
||||
|
||||
// 检查文件夹访问权限
|
||||
try {
|
||||
// 尝试读取目录
|
||||
// 只验证读取权限,不要求写入(素材库可只读挂载)
|
||||
fs.readdirSync(normalizedPath);
|
||||
|
||||
// 尝试在目录中创建测试文件(检查写权限)
|
||||
const testFile = path.join(normalizedPath, '.flypic-test');
|
||||
try {
|
||||
fs.writeFileSync(testFile, 'test');
|
||||
fs.unlinkSync(testFile);
|
||||
} catch (writeError) {
|
||||
logger.warn(`无写入权限: ${normalizedPath}`);
|
||||
throw new ValidationError(
|
||||
'无法访问该文件夹。请在飞牛 fnOS 的"数据共享"中将此文件夹添加到 FlyPic 应用的访问权限。',
|
||||
'permission'
|
||||
);
|
||||
}
|
||||
} catch (readError) {
|
||||
if (readError.code === 'EACCES' || readError.code === 'EPERM') {
|
||||
logger.warn(`无访问权限: ${normalizedPath}`);
|
||||
|
||||
Reference in new issue
Block a user