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:
Hermes Agent committed 2026-10-22 12:25:20 +08:00
1 parent 7359937892
commit d96986ec79
11 files changed
+254 -118

No files matched your search

+3
View File
@@ -53,3 +53,6 @@ test-library/
*.db *.db
*.db-shm *.db-shm
*.db-wal *.db-wal
# FlyPic 运行时配置(含 JWT 密钥/密码哈希,禁止提交)
config/
+18
View File
@@ -0,0 +1,18 @@
# 更新日志
## 2026-08-05 → v1.1.0
本次版本为 FlyPic 的 **Docker 独立部署版**,脱离飞牛应用商店(原开发者已于 2026-03-27 归档停更),可在任何 Linux + Docker 环境运行,并新增 OCR 图片文字搜索。
- ✨ 新功能:**Docker 独立部署** — 多阶段 Dockerfile(前端 Vite 编译 → 后端依赖 → 运行时)+ docker-compose.yml,不再依赖飞牛 fnOS 应用框架,`docker compose up -d --build` 一键启动
- ✨ 新功能:**OCR 图片文字搜索** — 扫描时调用系统 tesseract(中英双语 chi_sim+eng)提取图片内文字写入 `ocr_text` 列,搜索关键词同时匹配文件名与图片内文字
- 🐛 修复:添加素材库报 `Internal server error`(`LibraryService.js` 使用 `logger` 但未 require,已补引用)
- 🐛 修复:只读挂载的素材目录添加失败(移除创建测试文件的写权限校验,仅验证可读,素材库允许 `:ro` 挂载)
- 🐛 修复:中文路径素材库提示 `Path does not exist`(compose 挂载示例支持任意中文目录,容器内路径与宿主机一致)
- 🎨 样式:瀑布流点击逻辑保持原交互并补充注释 —— 单击选中、Ctrl/Shift 多选、双击放大预览
## 2026-03-27 → v1.0.0(上游)
- 🐛 修复:筛选不生效的问题
- ✨ 新功能:拖入文件上传速度优化
- 🐛 修复:上游 README 增加停更说明(原开发者不再使用飞牛,项目归档)
+51
View File
@@ -0,0 +1,51 @@
# ====== Stage 1: 构建前端 ======
FROM node:22-slim AS frontend-builder
WORKDIR /app/frontend
COPY frontend/ ./
RUN npm install --legacy-peer-deps && npm run build
# ====== Stage 2: 安装后端依赖 ======
FROM node:22-slim AS backend-builder
# 安装编译工具(better-sqlite3 / sharp 需要)
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 make g++ build-essential \
libvips-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app/backend
COPY backend/package.json ./
RUN npm install --legacy-peer-deps
# ====== Stage 3: 运行 ======
FROM node:22-slim AS runner
WORKDIR /app
# 运行时依赖:sharp + tesseract OCR + 中英文语言包
RUN apt-get update && apt-get install -y --no-install-recommends \
libvips-dev \
tesseract-ocr \
tesseract-ocr-chi-sim \
tesseract-ocr-eng \
&& rm -rf /var/lib/apt/lists/*
# 复制后端代码和依赖
COPY --from=backend-builder /app/backend/node_modules ./backend/node_modules
COPY backend/ ./backend/
# 复制前端构建产物到后端 public 目录
COPY --from=frontend-builder /app/frontend/dist ./backend/public
# 设置环境变量
ENV PORT=15002
ENV FRONTEND_DIST=/app/backend/public
ENV NODE_ENV=production
# Tesseract 语言数据路径
ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/5/tessdata
EXPOSE 15002
WORKDIR /app/backend
CMD ["node", "--expose-gc", "server.js"]
+57 -88
View File
@@ -1,124 +1,93 @@
**因某些原因,本人不再使用飞牛,所以项目暂停更新维护** # FlyPic 飞图(Docker 独立部署版)
# FlyPic 飞图 轻量、快速、稳定的图像素材检索浏览管理应用 —— 支持数十万张图片流畅浏览与 **OCR 图片内文字搜索**。本仓库为 [ZangXincz/FlyPic](https://github.com/ZangXincz/FlyPic) 的 Docker 化分支:上游已归档停更(原开发者不再使用飞牛)、飞牛应用商店下架,本分支让它以普通 Docker 容器继续运行,**不依赖飞牛 fnOS 应用框架**。
主要飞牛 fnOS 设计的轻量、快速、稳定的图像素材检索浏览应用。 - 在线地址:`http://<主机IP>:15002`(首次打开设置管理员密码,随后添加素材库)
## ✨ 核心特性 ## ✨ 核心特性
- 🚀 **轻量快速** - 支持数十万级别图片流畅浏览,基于 SQLite 本地数据库,毫秒级响应 - 🚀 **轻量快速** - 数十万级图片流畅浏览,SQLite 本地索引 + 虚拟滚动瀑布流,毫秒级响应
- 🛡️ **非侵入式** - 只在素材库目录创建 .flypic 文件夹存储索引和缩略图,不修改任何原始文件 - 🔍 **智能搜索** - 多关键词 AND 匹配,**文件名 + 图片内 OCR 文字**同时检索(中英双语)
- 🔄 **实时同步** - 基于 Worker Thread 的文件监控,自动检测新增、删除、修改 - 🛡️ **非侵入式** - 只在素材目录创建 `.flypic` 索引文件夹,不修改任何原始文件
- 🌐 **远程访问** - 支持 FN Connect 远程访问,随时随地浏览管理图片素材库 - 🔄 **实时同步** - 文件新增/删除/修改自动更新索引,无需手动刷新
- 🎨 **现代界面** - 固定行高瀑布流布局,支持亮色/暗色主题,响应式设计 - 📱 **现代界面** - 固定行高瀑布流、亮/暗主题、响应式移动端适配、右键菜单、撤销操作
- 🔍 **智能搜索** - 多关键词组合搜索,高级筛选(格式/大小/方向) - 🔒 **管理员密码** - 登录保护素材库隐私
- 📱 **移动适配** - 响应式设计,手机上也能流畅使用 - 🐳 **Docker 独立部署** - 多阶段构建,容器内路径与宿主机一致(中文路径直接可用)
- 🆓 **开源免费** - 100% 开源,MIT 协议
- 📦 **其他平台** - 可自行部署 Node.js 后端,前端 H5
## 🛠️ 技术栈 ## 🛠️ 技术栈
**前端**:React 18 + Vite 5 + TailwindCSS + Zustand + react-window + react-photo-view **前端**:React 18 + Vite 5 + TailwindCSS + Zustand + react-window + react-photo-view
**后端**:Node.js + Express + Sharp + better-sqlite3 + Socket.IO **后端**:Node.js + Express + Sharp + better-sqlite3 + Socket.IO + tesseract(系统命令行 OCR)
**架构**:三层架构(Config → Model → Service → Route)+ 模块化前端(Store → Hooks → API) **架构**:三层架构(Config → Model → Service → Route)+ 模块化前端(Store → Hooks → API)
## 🚀 快速开始 ## 📁 目录说明
### 开发环境 ```
flypic/
├── Dockerfile # 多阶段构建(前端编译 → 后端依赖 → 运行时 + tesseract)
├── docker-compose.yml # 一键部署(挂载素材库 + 持久化配置)
├── CHANGELOG.md # 更新日志
├── backend/ # Node.js 后端
│ ├── utils/ocr.js # ✨ OCR 模块(系统 tesseract,chi_sim+eng)
│ ├── utils/scanner.js # 扫描器(已集成 OCR 提取)
│ ├── database/db.js # SQLite schema(新增 ocr_text 列 + 索引)
│ └── src/ # config / models / services / routes / middleware
├── frontend/ # React 前端(stores / hooks / api / components)
├── scripts/ # 飞牛 fpk 打包脚本(上游遗留,Docker 部署不需要)
├── 飞牛打包部署指南.md # 上游的 fpk 打包文档
└── config/ # 运行时配置(gitignore,不入库)
```
## 🚀 部署 / 更新
```bash ```bash
# 安装依赖 # 首次部署:编辑 docker-compose.yml 挂载你的素材库目录(容器内路径与宿主机一致)
npm install docker compose up -d --build
# 启动前端开发服务器 # 添加新素材库目录:volumes 加一行挂载后重启
npm run dev:frontend # - /vol2/1000/HD2/我的文档:/vol2/1000/HD2/我的文档
# 访问 http://localhost:5173 docker compose up -d
# 启动后端开发服务器 # 更新代码
npm run dev:backend git pull && docker compose up -d --build
# API 运行在 http://localhost:15002
# 日志 / 重启 / 停止
docker compose logs -f
docker compose restart
docker compose down
``` ```
### 构建部署 > 新增素材库需**重新扫描**后 OCR 文字才可被搜索到。镜像内预装 `tesseract-ocr` + `chi-sim` + `eng` 语言包,OCR 失败不影响扫描主流程。
```bash ## 📦 其他部署方式
# 使用 Docker 构建(推荐)
# 包含 Linux 版本的依赖,上传后直接可用
npm run build:fpk:docker
```
## 📦 部署到飞牛 fnOS - **飞牛 fpk 应用包**:见 [飞牛打包部署指南](./飞牛打包部署指南.md)(`npm run build:fpk:docker` → `fnpack build`,仅当飞牛应用框架可用时适用)
- **裸机开发**:`npm install` 后分别 `npm run dev:frontend`(5173)与 `npm run dev:backend`(15002)
详细步骤请查看:**[飞牛打包部署指南](./飞牛打包部署指南.md)** ## 📝 数据存储
### 快速部署
1. **构建**:`npm run build:fpk:docker`
2. **上传**:将 `flypic/` 目录上传到飞牛
3. **打包**:`fnpack build`
4. **安装**:`appcenter-cli install-fpk flypic.fpk`
5. **访问**:`http://你的飞牛IP:15002`(端口可在安装时自定义)
### 安装提示
- **自定义端口**:安装时可自定义应用端口(默认 15002),避免与其他应用冲突
- **素材库路径**:添加素材库时需输入飞牛文件系统的完整路径,如 `/vol1/1000/图片库`
- **文件夹权限**:请确保应用对素材库文件夹有读取权限,可在飞牛应用设置中配置授权目录
## 📁 项目结构
``` ```
FlyPic/ 素材库目录/
├── frontend/ # React 前端 ├── 用户图片文件...
│ └── src/ └── .flypic/ # 索引数据(隐藏目录)
│ ├── stores/ # 状态管理(Zustand) ├── thumbnails/ # WebP 缩略图
│ ├── api/ # HTTP 客户端 └── metadata.db # SQLite(含 ocr_text 列)
│ ├── hooks/ # 自定义 Hooks
│ └── components/ # UI 组件 项目 config/ # 应用配置(JWT 密钥、素材库列表),已 gitignore
│
├── backend/ # Node.js 后端
│ ├── src/ # 新架构代码
│ │ ├── config/ # 配置管理
│ │ ├── models/ # 数据访问层
│ │ ├── services/ # 业务逻辑层
│ │ ├── routes/ # HTTP 接口层
│ │ ├── middleware/ # 中间件
│ │ └── utils/ # 工具函数
│ ├── database/ # 数据库管理
│ ├── utils/ # 扫描、缩略图等工具
│ └── server.js # 服务器入口
│
├── flypic/ # 飞牛打包目录(构建生成)
├── scripts/ # 构建脚本
└── 飞牛打包部署指南.md # 完整部署文档
``` ```
删除素材库下的 `.flypic` 即可完全清除该库索引,重新扫描重建。
## 🎯 支持的文件格式 ## 🎯 支持的文件格式
**完整支持**:JPG、PNG、WebP、GIF、BMP、TIFF、SVG **完整支持**:JPG、PNG、WebP、GIF、BMP、TIFF、SVG
**可识别**:视频(MP4/MOV/AVI...)、音频(MP3/WAV...)、文档(PDF/TXT...)、设计文件(PSD/AI...) **可识别**:视频(MP4/MOV/AVI...)、音频(MP3/WAV...)、文档(PDF/TXT...)、设计文件(PSD/AI...)
## 📝 数据存储
```
素材库目录/
├── 用户图片文件...
└── .flypic/ # FlyPic 数据目录(隐藏)
├── thumbnails/ # WebP 缩略图
└── metadata.db # SQLite 数据库
```
删除 `.flypic` 文件夹即可完全清除索引数据,不留任何痕迹。
## 🐛 故障排查
常见问题请查看 [飞牛打包部署指南 - 故障排查](./飞牛打包部署指南.md#故障排查)
## 📄 License ## 📄 License
MIT License - 详见 [LICENSE](./LICENSE) 文件 MIT License - 详见 [LICENSE](./LICENSE) 文件,衍生自 [ZangXincz/FlyPic](https://github.com/ZangXincz/FlyPic)。
**官网**:[FlyPic 介绍页](https://flypic.shikejk.com/) | **最后更新**:2024-12-03 **上游官网**:[FlyPic 介绍页](https://flypic.shikejk.com/) | **本分支**:Docker 化 + OCR 搜索
+15 -5
View File
@@ -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 // Folders table
this.db.exec(` this.db.exec(`
CREATE TABLE IF NOT EXISTS folders ( 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_rating ON images(rating DESC);
CREATE INDEX IF NOT EXISTS idx_favorite ON images(favorite 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 // Metadata table for tracking database modifications
@@ -168,8 +177,8 @@ class LibraryDatabase {
insertImage(imageData) { insertImage(imageData) {
const stmt = this.db.prepare(` const stmt = this.db.prepare(`
INSERT OR REPLACE INTO images 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) (path, filename, folder, size, width, height, format, file_type, created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at, ocr_text)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`); `);
const result = stmt.run( const result = stmt.run(
imageData.path, imageData.path,
@@ -185,7 +194,8 @@ class LibraryDatabase {
imageData.file_hash, imageData.file_hash,
imageData.thumbnail_path, imageData.thumbnail_path,
imageData.thumbnail_size, imageData.thumbnail_size,
Date.now() Date.now(),
imageData.ocr_text || ''
); );
// 更新数据库修改时间 // 更新数据库修改时间
this.updateLastModified(); this.updateLastModified();
@@ -219,8 +229,8 @@ class LibraryDatabase {
if (keywords && keywords.trim()) { if (keywords && keywords.trim()) {
const terms = keywords.trim().split(/\s+/); const terms = keywords.trim().split(/\s+/);
terms.forEach(term => { terms.forEach(term => {
baseQuery += ' AND filename LIKE ?'; baseQuery += ' AND (filename LIKE ? OR ocr_text LIKE ?)';
params.push(`%${term}%`); params.push(`%${term}%`, `%${term}%`);
}); });
} }
+9 -8
View File
@@ -65,8 +65,8 @@ class ImageModel extends BaseModel {
const query = ` const query = `
INSERT OR REPLACE INTO images INSERT OR REPLACE INTO images
(path, filename, folder, size, width, height, format, file_type, (path, filename, folder, size, width, height, format, file_type,
created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at) created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at, ocr_text)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`; `;
return this.execute(query, [ return this.execute(query, [
@@ -83,7 +83,8 @@ class ImageModel extends BaseModel {
data.fileHash, data.fileHash,
data.thumbnailPath, data.thumbnailPath,
data.thumbnailSize, data.thumbnailSize,
Date.now() Date.now(),
data.ocrText || ''
]); ]);
} }
@@ -94,8 +95,8 @@ class ImageModel extends BaseModel {
const query = ` const query = `
INSERT OR REPLACE INTO images INSERT OR REPLACE INTO images
(path, filename, folder, size, width, height, format, file_type, (path, filename, folder, size, width, height, format, file_type,
created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at) created_at, modified_at, file_hash, thumbnail_path, thumbnail_size, indexed_at, ocr_text)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`; `;
return this.transaction(() => { return this.transaction(() => {
@@ -105,7 +106,7 @@ class ImageModel extends BaseModel {
data.path, data.filename, data.folder, data.size, data.path, data.filename, data.folder, data.size,
data.width, data.height, data.format, data.fileType || 'image', data.width, data.height, data.format, data.fileType || 'image',
data.createdAt, data.modifiedAt, data.fileHash, 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) { if (filters.keywords) {
const terms = filters.keywords.trim().split(/\s+/); const terms = filters.keywords.trim().split(/\s+/);
terms.forEach(term => { terms.forEach(term => {
query += ' AND filename LIKE ?'; query += ' AND (filename LIKE ? OR ocr_text LIKE ?)';
params.push(`%${term}%`); params.push(`%${term}%`, `%${term}%`);
}); });
} }
+2 -14
View File
@@ -2,6 +2,7 @@
* 素材库服务层 * 素材库服务层
* 封装素材库相关的业务逻辑 * 封装素材库相关的业务逻辑
*/ */
const logger = require('../utils/logger');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
@@ -50,21 +51,8 @@ class LibraryService {
// 检查文件夹访问权限 // 检查文件夹访问权限
try { try {
// 尝试读取目录 // 只验证读取权限,不要求写入(素材库可只读挂载)
fs.readdirSync(normalizedPath); 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) { } catch (readError) {
if (readError.code === 'EACCES' || readError.code === 'EPERM') { if (readError.code === 'EACCES' || readError.code === 'EPERM') {
logger.warn(`无访问权限: ${normalizedPath}`); logger.warn(`无访问权限: ${normalizedPath}`);
+61
View File
@@ -0,0 +1,61 @@
/**
* OCR 文字识别模块
* 直接调用系统 tesseract 命令行,无需 npm 依赖
* Docker 镜像已预装 tesseract-ocr + chi_sim + eng
*/
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const fs = require('fs');
const logger = require('../src/utils/logger');
const execFileAsync = promisify(execFile);
// Tesseract 路径
const TESSERACT_BIN = process.env.TESSERACT_BIN || 'tesseract';
/**
* 对单张图片进行 OCR 文字识别
* @param {string} imagePath - 图片绝对路径
* @returns {Promise<string>} 识别出的文字(清理后的纯文本)
*/
async function extractText(imagePath) {
try {
// 检查文件是否存在
if (!fs.existsSync(imagePath)) return '';
// 使用临时文件输出(tesseract 不支持直接输出到 stdout 处理图片)
const tmpFile = `/tmp/ocr_${Date.now()}_${Math.random().toString(36).slice(2)}.txt`;
try {
await execFileAsync(TESSERACT_BIN, [
imagePath,
tmpFile.replace('.txt', ''), // tesseract 自动加 .txt 后缀
'-l', 'chi_sim+eng', // 中英文
'--psm', '3', // 自动页面分割
'--oem', '3' // 默认 OCR 引擎
], { timeout: 15000 }); // 15秒超时
// 读取结果
const resultPath = tmpFile.replace('.txt', '.txt');
if (fs.existsSync(resultPath)) {
const text = fs.readFileSync(resultPath, 'utf-8');
fs.unlinkSync(resultPath);
return text.replace(/\s+/g, ' ').trim();
}
} catch (e) {
// OCR 失败静默处理
} finally {
// 清理临时文件
try { fs.unlinkSync(tmpFile); } catch(e) {}
try { fs.unlinkSync(tmpFile.replace('.txt', '.txt')); } catch(e) {}
}
return '';
} catch (error) {
return '';
}
}
module.exports = { extractText };
+10 -2
View File
@@ -10,6 +10,7 @@ const {
clearSharpCache clearSharpCache
} = require('./thumbnail'); } = require('./thumbnail');
const scanManager = require('./scanManager'); const scanManager = require('./scanManager');
const { extractText } = require('./ocr');
const { constants } = require('../src/config'); const { constants } = require('../src/config');
const logger = require('../src/utils/logger'); const logger = require('../src/utils/logger');
@@ -304,6 +305,11 @@ async function processImage(imagePath, libraryPath, db, dryRun = false) {
const actualWidth = thumbnails.width || metadata.width; const actualWidth = thumbnails.width || metadata.width;
const actualHeight = thumbnails.height || metadata.height; const actualHeight = thumbnails.height || metadata.height;
// OCR 文字识别(可选:tesseract 失败时返回空字符串,不影响主流程)
stepStart = Date.now();
const ocrText = await extractText(imagePath);
stepTimes.ocr = Date.now() - stepStart;
const imageData = { const imageData = {
path: relativePath.replace(/\\/g, '/'), path: relativePath.replace(/\\/g, '/'),
filename: filename, filename: filename,
@@ -317,7 +323,8 @@ async function processImage(imagePath, libraryPath, db, dryRun = false) {
modified_at: Math.floor(metadata.modified_at), modified_at: Math.floor(metadata.modified_at),
file_hash: currentHash, file_hash: currentHash,
thumbnail_path: thumbnails.thumbnail_path, thumbnail_path: thumbnails.thumbnail_path,
thumbnail_size: thumbnails.thumbnail_size thumbnail_size: thumbnails.thumbnail_size,
ocr_text: ocrText
}; };
if (dryRun) { if (dryRun) {
@@ -336,7 +343,8 @@ async function processImage(imagePath, libraryPath, db, dryRun = false) {
`总计${totalTime}ms`, `总计${totalTime}ms`,
`哈希${stepTimes.hashCalc}ms`, `哈希${stepTimes.hashCalc}ms`,
`元数据${stepTimes.metadata}ms`, `元数据${stepTimes.metadata}ms`,
`缩略图${stepTimes.thumbnail}ms` `缩略图${stepTimes.thumbnail}ms`,
`OCR${stepTimes.ocr}ms`
]; ];
// 只有当总耗时超过 500ms 时才输出警告 // 只有当总耗时超过 500ms 时才输出警告
+24
View File
@@ -0,0 +1,24 @@
services:
flypic:
build:
context: .
dockerfile: Dockerfile
container_name: flypic
restart: unless-stopped
ports:
- "15002:15002"
volumes:
# 素材库目录(容器内路径与飞牛一致,直接填实际路径即可)
- /vol2/1000/HD2/壁纸:/vol2/1000/HD2/壁纸
- /vol2/1000/HD2/我的文档:/vol2/1000/HD2/我的文档
# 持久化配置(config.json 存储素材库路径、密码等,不用改)
- /vol1/1000/HD1/docker/flypic/config:/root/.flypic
environment:
- PORT=15002
- FRONTEND_DIST=/app/backend/public
- NODE_ENV=production
# 如需挂载多个素材库,取消注释并修改路径:
# volumes:
# - /vol1/1000/图片库:/data/library1:ro
# - /vol2/1000/素材:/data/library2:ro
# - /vol1/1000/docker/flypic/config:/root/.flypic
+4 -1
View File
@@ -197,21 +197,24 @@ function ImageWaterfall() {
return filteredImages.map(img => ({ src: getOriginalUrl(img), key: img.id })); return filteredImages.map(img => ({ src: getOriginalUrl(img), key: img.id }));
}, [filteredImages, getOriginalUrl]); }, [filteredImages, getOriginalUrl]);
// 图片点击处理 // 图片点击处理 —— 单击选中,双击放大
const handleImageClick = useCallback((image, event, imageIndex) => { const handleImageClick = useCallback((image, event, imageIndex) => {
setSelectedFolderItem(null); setSelectedFolderItem(null);
if (event.ctrlKey || event.metaKey) { if (event.ctrlKey || event.metaKey) {
// Ctrl/⌘+单击 = 多选
event.preventDefault(); event.preventDefault();
toggleImageSelection(image); toggleImageSelection(image);
setLastSelectedIndex(imageIndex); setLastSelectedIndex(imageIndex);
} else if (event.shiftKey && lastSelectedIndex !== null) { } else if (event.shiftKey && lastSelectedIndex !== null) {
// Shift+单击 = 范围选
event.preventDefault(); event.preventDefault();
const start = Math.min(lastSelectedIndex, imageIndex); const start = Math.min(lastSelectedIndex, imageIndex);
const end = Math.max(lastSelectedIndex, imageIndex); const end = Math.max(lastSelectedIndex, imageIndex);
const rangeImages = flatImages.slice(start, end + 1); const rangeImages = flatImages.slice(start, end + 1);
setSelectedImages(rangeImages); setSelectedImages(rangeImages);
} else { } else {
// 普通单击 = 选中
clearSelection(); clearSelection();
setSelectedImage(image); setSelectedImage(image);
setLastSelectedIndex(imageIndex); setLastSelectedIndex(imageIndex);