From 85e7711c1ac043b5fdcad44b7c04a8cfc33de096 Mon Sep 17 00:00:00 2001 From: Chen Date: Sat, 6 Dec 2025 23:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=8B=96=E5=85=A5=E6=93=8D=E4=BD=9C=E5=92=8C=E8=AF=84=E5=88=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=92=8C=E4=BC=98=E5=8C=96=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 1 + backend/src/app.js | 6 +- backend/src/routes/image.js | 26 + backend/src/routes/upload.js | 231 +++++++++ backend/src/services/ImageService.js | 46 ++ frontend/src/api/endpoints/image.js | 11 + frontend/src/api/file.js | 32 ++ frontend/src/components/ContextMenu.jsx | 2 +- frontend/src/components/Header.jsx | 176 +++++-- frontend/src/components/ImageWaterfall.jsx | 525 ++++++++++++++++++++- frontend/src/components/RatingStars.jsx | 68 +++ frontend/src/components/RatingToast.jsx | 50 ++ frontend/src/components/RightPanel.jsx | 81 +++- frontend/src/stores/useImageStore.js | 8 +- package-lock.json | 92 ++++ 15 files changed, 1283 insertions(+), 72 deletions(-) create mode 100644 backend/src/routes/upload.js create mode 100644 frontend/src/components/RatingStars.jsx create mode 100644 frontend/src/components/RatingToast.jsx diff --git a/backend/package.json b/backend/package.json index dd8f955..5a99446 100644 --- a/backend/package.json +++ b/backend/package.json @@ -14,6 +14,7 @@ "crypto": "^1.0.1", "express": "^4.18.2", "glob": "^10.3.10", + "multer": "^2.0.0-rc.4", "p-limit": "^7.2.0", "sharp": "^0.33.0", "socket.io": "^4.6.0", diff --git a/backend/src/app.js b/backend/src/app.js index 69f5bc3..51a846a 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -57,7 +57,9 @@ function createApp(dependencies) { const fileService = new FileService(dbPool, configManager); - // 将服务注入到 app 中,供路由使用 + // 将服务和依赖注入到 app 中,供路由使用 + app.set('configManager', configManager); + app.set('dbPool', dbPool); app.set('libraryService', libraryService); app.set('imageService', imageService); app.set('scanService', scanService); @@ -68,11 +70,13 @@ function createApp(dependencies) { const imageRouter = require('./routes/image'); const scanRouter = require('./routes/scan'); const fileRouter = require('./routes/file'); + const uploadRouter = require('./routes/upload'); app.use('/api/library', libraryRouter); app.use('/api/image', imageRouter); app.use('/api/scan', scanRouter); app.use('/api/file', fileRouter); + app.use('/api/upload', uploadRouter); // 健康检查 app.get('/api/health', (req, res) => { diff --git a/backend/src/routes/image.js b/backend/src/routes/image.js index 418f56e..4929286 100644 --- a/backend/src/routes/image.js +++ b/backend/src/routes/image.js @@ -167,4 +167,30 @@ router.get('/original/:libraryId/*', (req, res) => { } }); +/** + * 更新图片评分 + * PUT /api/image/rating + * Body: { libraryId, paths: [string], rating: number } + */ +router.put('/rating', asyncHandler(async (req, res) => { + const { libraryId, paths, rating } = req.body; + + if (!libraryId || !paths || !Array.isArray(paths) || paths.length === 0) { + return res.status(400).json({ + success: false, + message: '缺少必要参数: libraryId, paths' + }); + } + + if (typeof rating !== 'number' || rating < 0 || rating > 5) { + return res.status(400).json({ + success: false, + message: '评分必须是 0-5 之间的整数' + }); + } + + const result = await imageService.updateRating(libraryId, paths, rating); + res.json({ success: true, data: result }); +})); + module.exports = router; diff --git a/backend/src/routes/upload.js b/backend/src/routes/upload.js new file mode 100644 index 0000000..e8b1da1 --- /dev/null +++ b/backend/src/routes/upload.js @@ -0,0 +1,231 @@ +/** + * 文件上传路由 + * 支持拖拽上传图片到指定文件夹 + */ + +const express = require('express'); +const router = express.Router(); +const multer = require('multer'); +const path = require('path'); +const fs = require('fs'); +const { asyncHandler } = require('../middleware/errorHandler'); +const { processImage } = require('../../utils/scanner'); + +// 配置 multer 使用内存存储 +const storage = multer.memoryStorage(); +const upload = multer({ + storage: storage, + limits: { + fileSize: 100 * 1024 * 1024, // 100MB + } + // 移除文件格式限制,让扫描逻辑自动处理 +}); + +/** + * 上传图片到指定文件夹 + * POST /api/upload + * FormData: { libraryId, targetFolder, files[], conflictAction? } + * conflictAction: 'skip' | 'replace' | 'rename' + */ +router.post('/', upload.array('files', 50), asyncHandler(async (req, res) => { + console.log('📤 收到上传请求'); + console.log(' libraryId:', req.body.libraryId); + console.log(' targetFolder:', req.body.targetFolder); + console.log(' conflictAction:', req.body.conflictAction); + console.log(' 文件数量:', req.files?.length); + + const { libraryId, targetFolder, conflictAction } = req.body; + const files = req.files; + + if (!libraryId) { + console.error('❌ 缺少 libraryId 参数'); + return res.status(400).json({ + success: false, + error: '缺少 libraryId 参数' + }); + } + + if (!files || files.length === 0) { + console.error('❌ 没有上传文件'); + return res.status(400).json({ + success: false, + error: '没有上传文件' + }); + } + + // 获取依赖 + const dbPool = req.app.get('dbPool'); + const configManager = req.app.get('configManager'); + + if (!dbPool || !configManager) { + console.error('❌ 服务未初始化'); + return res.status(500).json({ + success: false, + error: '服务未初始化' + }); + } + + // 获取素材库配置 + const config = configManager.load(); + const library = config.libraries.find(lib => lib.id === libraryId); + + if (!library) { + console.error('❌ 素材库不存在:', libraryId); + return res.status(404).json({ + success: false, + error: '素材库不存在' + }); + } + + // 获取数据库实例 + const db = dbPool.acquire(library.path); + const libraryPath = library.path; + const targetPath = targetFolder + ? path.join(libraryPath, targetFolder) + : libraryPath; + + // 确保目标文件夹存在 + if (!fs.existsSync(targetPath)) { + fs.mkdirSync(targetPath, { recursive: true }); + } + + const results = { + success: [], + failed: [], + conflicts: [] // 改为 conflicts,与粘贴逻辑一致 + }; + + // 用于后台处理的文件列表 + const filesToProcess = []; + + // 第一阶段:保存文件(根据 conflictAction 处理冲突) + for (const file of files) { + try { + // 修复中文文件名乱码:multer 默认使用 latin1 编码,需要转换为 utf8 + let filename = Buffer.from(file.originalname, 'latin1').toString('utf8'); + let filePath = path.join(targetPath, filename); + + // 检查文件是否已存在 + if (fs.existsSync(filePath)) { + // 如果没有指定冲突处理方式,收集冲突信息返回给前端 + if (!conflictAction) { + const relativePath = targetFolder + ? path.join(targetFolder, filename).replace(/\\/g, '/') + : filename; + results.conflicts.push({ + name: filename, + path: relativePath + }); + console.log(`⚠️ 冲突: ${filename} (文件已存在)`); + continue; + } + + // 根据 conflictAction 处理冲突 + if (conflictAction === 'skip') { + console.log(`⏭️ 跳过: ${filename} (文件已存在)`); + continue; + } else if (conflictAction === 'replace') { + // 覆盖:删除旧文件 + console.log(`🔄 覆盖: ${filename}`); + fs.unlinkSync(filePath); + } else if (conflictAction === 'rename') { + // 重命名:生成新文件名 + const ext = path.extname(filename); + const nameWithoutExt = filename.substring(0, filename.length - ext.length); + let counter = 1; + let newFilename = filename; + let newFilePath = filePath; + + while (fs.existsSync(newFilePath)) { + newFilename = `${nameWithoutExt} (${counter})${ext}`; + newFilePath = path.join(targetPath, newFilename); + counter++; + } + + filename = newFilename; + filePath = newFilePath; + console.log(`📝 重命名: ${file.originalname} → ${filename}`); + } + } + + // 写入文件(同步,快速) + fs.writeFileSync(filePath, file.buffer); + console.log(`📥 已保存: ${filename} (${(file.size / 1024).toFixed(2)} KB)`); + + // 计算相对路径(使用最终的文件名) + const relativePath = targetFolder + ? path.join(targetFolder, filename).replace(/\\/g, '/') + : filename; + + results.success.push({ + filename, + path: relativePath, + size: file.size + }); + + // 添加到待处理列表(只处理图片文件) + const ext = path.extname(filename).toLowerCase(); + const imageExts = ['.jpg', '.jpeg', '.png', '.webp', '.gif', '.bmp', '.tiff', '.svg']; + if (imageExts.includes(ext)) { + filesToProcess.push({ filePath, filename }); + } + } catch (error) { + console.error(`❌ 保存失败: ${file.originalname}`, error); + results.failed.push({ + filename: file.originalname, + error: error.message + }); + } + } + + // 第二阶段:后台异步处理图片(生成缩略图、提取元数据) + // 不阻塞响应,让前端可以立即刷新 + if (filesToProcess.length > 0) { + setImmediate(async () => { + console.log(`🔄 开始后台处理 ${filesToProcess.length} 个图片...`); + for (const { filePath, filename } of filesToProcess) { + try { + await processImage(filePath, libraryPath, db.db); + console.log(`✅ 已处理: ${filename}`); + } catch (processError) { + console.error(`❌ 处理图片失败: ${filename}`, processError.message); + } + } + console.log(`✅ 后台处理完成`); + }); + } + + // 更新文件夹图片计数 + if (targetFolder && results.success.length > 0) { + try { + console.log(`📊 更新文件夹计数: ${targetFolder}`); + const updateStmt = db.db.prepare(` + UPDATE folders + SET image_count = ( + SELECT COUNT(*) FROM images WHERE folder = ? OR folder LIKE ? + ), + last_scan = ? + WHERE path = ? + `); + updateStmt.run( + targetFolder, + targetFolder + '/%', + Date.now(), + targetFolder + ); + console.log(`✅ 文件夹计数已更新`); + } catch (error) { + console.error('❌ 更新文件夹计数失败:', error); + console.error(' 错误详情:', error.stack); + } + } + + console.log(`📋 上传结果: 成功 ${results.success.length}, 失败 ${results.failed.length}, 冲突 ${results.conflicts.length}`); + + res.json({ + success: true, + data: results + }); +})); + +module.exports = router; diff --git a/backend/src/services/ImageService.js b/backend/src/services/ImageService.js index c0d9e19..62c992a 100644 --- a/backend/src/services/ImageService.js +++ b/backend/src/services/ImageService.js @@ -162,6 +162,52 @@ class ImageService { } } + /** + * 批量更新图片评分 + */ + async updateRating(libraryId, paths, rating) { + const library = this._getLibrary(libraryId); + const db = this.dbPool.acquire(library.path); + + try { + const imageModel = new ImageModel(db.db); + const results = { + success: [], + failed: [] + }; + + // 批量更新 + for (const imagePath of paths) { + try { + const stmt = db.db.prepare('UPDATE images SET rating = ? WHERE path = ?'); + const result = stmt.run(rating, imagePath); + + if (result.changes > 0) { + results.success.push(imagePath); + } else { + results.failed.push({ path: imagePath, error: '图片不存在' }); + } + } catch (error) { + results.failed.push({ path: imagePath, error: error.message }); + } + } + + // 更新数据库修改时间 + if (results.success.length > 0) { + db.updateLastModified(); + } + + return { + updated: results.success.length, + failed: results.failed.length, + success: results.success, + failed: results.failed + }; + } finally { + this.dbPool.release(library.path); + } + } + /** * 获取素材库对象 * @private diff --git a/frontend/src/api/endpoints/image.js b/frontend/src/api/endpoints/image.js index 8a88ec0..5fcfc9d 100644 --- a/frontend/src/api/endpoints/image.js +++ b/frontend/src/api/endpoints/image.js @@ -65,3 +65,14 @@ export function getOriginalUrl(libraryId, path) { export async function openInExplorer(libraryId, path) { return api.post(`/image/${libraryId}/open-file`, { path }); } + +/** + * 更新图片评分(支持批量) + */ +export async function updateRating(libraryId, paths, rating) { + return api.put('/image/rating', { + libraryId, + paths: Array.isArray(paths) ? paths : [paths], + rating + }); +} diff --git a/frontend/src/api/file.js b/frontend/src/api/file.js index b9f8c9c..ca08067 100644 --- a/frontend/src/api/file.js +++ b/frontend/src/api/file.js @@ -105,5 +105,37 @@ export const fileAPI = { folderPath }); return response.data; + }, + + /** + * 上传文件到指定文件夹 + * @param {string} libraryId - 素材库ID + * @param {string} targetFolder - 目标文件夹路径(可选,默认根目录) + * @param {File[]} files - 待上传的文件数组 + * @param {Function} onProgress - 进度回调函数 (progressEvent) => {} + * @param {string} conflictAction - 冲突处理方式: 'skip'|'replace'|'rename' + */ + async upload(libraryId, targetFolder, files, onProgress, conflictAction) { + const formData = new FormData(); + formData.append('libraryId', libraryId); + if (targetFolder) { + formData.append('targetFolder', targetFolder); + } + if (conflictAction) { + formData.append('conflictAction', conflictAction); + } + + // 添加所有文件 + for (const file of files) { + formData.append('files', file); + } + + const response = await axios.post(`${API_BASE}/api/upload`, formData, { + headers: { + 'Content-Type': 'multipart/form-data' + }, + onUploadProgress: onProgress + }); + return response.data; } }; diff --git a/frontend/src/components/ContextMenu.jsx b/frontend/src/components/ContextMenu.jsx index 2428a29..e6fd235 100644 --- a/frontend/src/components/ContextMenu.jsx +++ b/frontend/src/components/ContextMenu.jsx @@ -138,7 +138,7 @@ export const menuItems = { }), move: (action) => ({ icon: , - label: '移动到...', + label: '移动到', action }), copy: (action) => ({ diff --git a/frontend/src/components/Header.jsx b/frontend/src/components/Header.jsx index 9555794..305c0a5 100644 --- a/frontend/src/components/Header.jsx +++ b/frontend/src/components/Header.jsx @@ -1,5 +1,5 @@ import { useState, useEffect, useMemo, useRef } from 'react'; -import { Sun, Moon, Search, Filter, Sliders, RefreshCw } from 'lucide-react'; +import { Sun, Moon, Search, Filter, Sliders, RefreshCw, Star } from 'lucide-react'; import { useLibraryStore } from '../stores/useLibraryStore'; import { useImageStore } from '../stores/useImageStore'; import { useUIStore } from '../stores/useUIStore'; @@ -23,7 +23,8 @@ function Header() { // 从全局 store 获取筛选状态 const selectedFormats = filters.formats || []; const selectedSizes = filters.sizes || []; - const selectedOrientation = filters.orientation || ''; + const selectedOrientations = filters.orientations || []; + const selectedRatings = filters.ratings || []; // 检测移动端 useEffect(() => { @@ -172,13 +173,15 @@ function Header() { // 分析原始图片列表,生成可选项(基于 originalImages,不受筛选影响) const filterOptions = useMemo(() => { if (originalImages.length === 0) { - return { formats: [], sizes: [], hasHorizontal: false, hasVertical: false }; + return { formats: [], sizes: [], hasHorizontal: false, hasVertical: false, hasSquare: false, ratings: [] }; } const formats = new Set(); const sizes = []; + const ratings = new Set(); let hasHorizontal = false; let hasVertical = false; + let hasSquare = false; originalImages.forEach(img => { // 格式 @@ -187,9 +190,20 @@ function Header() { } // 文件大小 sizes.push(img.size / 1024); - // 横竖图 - if (img.width > img.height) hasHorizontal = true; - if (img.height > img.width) hasVertical = true; + + // 方向检测 + const aspectRatio = img.width / img.height; + if (aspectRatio > 1.05) { + hasHorizontal = true; // 横图 + } else if (aspectRatio < 0.95) { + hasVertical = true; // 竖图 + } else { + hasSquare = true; // 方图(宽高比在0.95-1.05之间) + } + + // 评分统计 + const rating = img.rating || 0; + ratings.add(rating); }); // 计算文件大小范围 @@ -199,7 +213,9 @@ function Header() { formats: Array.from(formats).sort(), sizes: sizeRanges, hasHorizontal, - hasVertical + hasVertical, + hasSquare, + ratings: Array.from(ratings).sort((a, b) => b - a) // 评分降序排列 }; }, [originalImages]); @@ -219,13 +235,22 @@ function Header() { }; const toggleOrientation = (orientation) => { - const newOrientation = selectedOrientation === orientation ? '' : orientation; - setFilters({ orientation: newOrientation }); + const newOrientations = selectedOrientations.includes(orientation) + ? selectedOrientations.filter(o => o !== orientation) + : [...selectedOrientations, orientation]; + setFilters({ orientations: newOrientations }); + }; + + const toggleRating = (rating) => { + const newRatings = selectedRatings.includes(rating) + ? selectedRatings.filter(r => r !== rating) + : [...selectedRatings, rating]; + setFilters({ ratings: newRatings }); }; // 清除筛选 const clearFilters = () => { - setFilters({ formats: [], sizes: [], orientation: '' }); + setFilters({ formats: [], sizes: [], orientations: [], ratings: [] }); }; const handleThumbnailHeightChange = async (height) => { @@ -257,11 +282,14 @@ function Header() { const availableSizes = filterOptions.sizes.map(size => ({ label: size })); const availableOrientations = [ { value: 'horizontal', label: '横图' }, - { value: 'vertical', label: '竖图' } + { value: 'vertical', label: '竖图' }, + { value: 'square', label: '方图' } ].filter(o => (o.value === 'horizontal' && filterOptions.hasHorizontal) || - (o.value === 'vertical' && filterOptions.hasVertical) + (o.value === 'vertical' && filterOptions.hasVertical) || + (o.value === 'square' && filterOptions.hasSquare) ); + const availableRatings = filterOptions.ratings; // 移动端布局 if (isMobile) { @@ -320,13 +348,13 @@ function Header() { + ))} + + + )} )} @@ -460,22 +518,22 @@ function Header() { - )} - {filterOptions.hasVertical && ( - - )} - {!filterOptions.hasHorizontal && !filterOptions.hasVertical && ( + {availableOrientations.length > 0 ? ( + availableOrientations.map(orientation => ( + + )) + ) : ( 暂无方向数据 )} + + {/* 评分筛选 */} +
+ +
+ {availableRatings.length > 0 ? ( + [5, 4, 3, 2, 1, 0].filter(r => availableRatings.includes(r)).map(rating => ( + + )) + ) : ( + 暂无评分数据 + )} +
+
diff --git a/frontend/src/components/ImageWaterfall.jsx b/frontend/src/components/ImageWaterfall.jsx index d3ffded..60d41ac 100644 --- a/frontend/src/components/ImageWaterfall.jsx +++ b/frontend/src/components/ImageWaterfall.jsx @@ -13,6 +13,7 @@ import requestManager, { RequestType } from '../services/requestManager'; import FileViewer from './FileViewer'; import ContextMenu, { menuItems } from './ContextMenu'; import UndoToast from './UndoToast'; +import RatingToast from './RatingToast'; import FolderSelector from './FolderSelector'; import ConflictDialog from './ConflictDialog'; @@ -69,12 +70,13 @@ function ImageWaterfall() { // 前端筛选逻辑:基于 filters 过滤图片 const filteredImages = useMemo(() => { - const { formats, sizes, orientation } = filters; + const { formats, sizes, orientations, ratings } = filters; // 如果没有任何筛选条件,直接返回原始图片 if ((!formats || formats.length === 0) && (!sizes || sizes.length === 0) && - !orientation) { + (!orientations || orientations.length === 0) && + (!ratings || ratings.length === 0)) { return images; } @@ -101,11 +103,31 @@ function ImageWaterfall() { if (!matchesSize) return false; } - // 横竖图筛选 - if (orientation === 'horizontal') { - if (img.width <= img.height) return false; - } else if (orientation === 'vertical') { - if (img.height <= img.width) return false; + // 方向筛选(多选) + if (orientations && orientations.length > 0) { + const aspectRatio = img.width / img.height; + let matchesOrientation = false; + + for (const orientation of orientations) { + if (orientation === 'horizontal' && aspectRatio > 1.05) { + matchesOrientation = true; + break; + } else if (orientation === 'vertical' && aspectRatio < 0.95) { + matchesOrientation = true; + break; + } else if (orientation === 'square' && aspectRatio >= 0.95 && aspectRatio <= 1.05) { + matchesOrientation = true; + break; + } + } + + if (!matchesOrientation) return false; + } + + // 评分筛选(多选) + if (ratings && ratings.length > 0) { + const imgRating = img.rating || 0; + if (!ratings.includes(imgRating)) return false; } return true; @@ -121,11 +143,14 @@ function ImageWaterfall() { const [contextMenu, setContextMenu] = useState({ isOpen: false, position: null, image: null }); const [undoToast, setUndoToast] = useState({ isVisible: false, message: '', count: 0 }); const [undoHistory, setUndoHistory] = useState([]); // 撤销历史栈,支持多次撤销 + const [ratingToast, setRatingToast] = useState({ isVisible: false, rating: 0, count: 0 }); // 评分提醒 const [showFolderSelector, setShowFolderSelector] = useState(false); // 显示文件夹选择器 const [moveItems, setMoveItems] = useState([]); // 待移动的项 const [editingFilename, setEditingFilename] = useState(''); // 编辑中的文件名 const editInputRef = useRef(null); // 编辑输入框引用 - const [conflictDialog, setConflictDialog] = useState({ isOpen: false, conflicts: [], pendingPaste: null }); // 冲突对话框 + const [conflictDialog, setConflictDialog] = useState({ isOpen: false, conflicts: [], pendingPaste: null, pendingUpload: null }); // 冲突对话框 + const [isDraggingOver, setIsDraggingOver] = useState(false); // 拖拽悬停状态 + const [uploadProgress, setUploadProgress] = useState({ isUploading: false, percent: 0, current: 0, total: 0 }); // 上传进度 // 剪贴板状态 const { copyToClipboard, getClipboard, hasClipboard } = useClipboardStore(); @@ -136,6 +161,23 @@ function ImageWaterfall() { setUndoToast({ isVisible: false, message: '', count: 0 }); }, [selectedFolder]); + // 全局阻止浏览器默认的拖放行为(防止浏览器打开文件) + useEffect(() => { + const preventDefaults = (e) => { + e.preventDefault(); + e.stopPropagation(); + }; + + // 阻止整个文档的默认拖放行为 + document.addEventListener('dragover', preventDefaults); + document.addEventListener('drop', preventDefaults); + + return () => { + document.removeEventListener('dragover', preventDefaults); + document.removeEventListener('drop', preventDefaults); + }; + }, []); + // 全局快捷键监听 - Del 键删除, Ctrl+Z 撤销, F2/Enter 重命名, Ctrl+C 复制, Ctrl+V 粘贴 useEffect(() => { const handleGlobalKeyDown = async (e) => { @@ -182,6 +224,26 @@ function ImageWaterfall() { e.preventDefault(); await handleQuickDelete(); } + return; + } + + // 数字键 1-5 → 快速评分 + if (['1', '2', '3', '4', '5'].includes(e.key)) { + if (selectedImages.length > 0 || selectedImage) { + e.preventDefault(); + const rating = parseInt(e.key); + await handleQuickRating(rating); + } + return; + } + + // 数字键 0 → 取消评分 + if (e.key === '0') { + if (selectedImages.length > 0 || selectedImage) { + e.preventDefault(); + await handleQuickRating(0); + } + return; } }; @@ -584,6 +646,57 @@ function ImageWaterfall() { }); }; + // 快速评分(数字键 0-5) + const handleQuickRating = async (rating) => { + const imagesToRate = selectedImages.length > 0 + ? selectedImages + : selectedImage + ? [selectedImage] + : []; + + if (imagesToRate.length === 0) return; + + try { + const paths = imagesToRate.map(img => img.path); + await imageAPI.updateRating(currentLibraryId, paths, rating); + + // 更新本地状态 + const updatedImages = images.map(img => { + if (paths.includes(img.path)) { + return { ...img, rating }; + } + return img; + }); + setImages(updatedImages); + + // 更新选中状态 + if (selectedImage && paths.includes(selectedImage.path)) { + useImageStore.getState().setSelectedImage({ ...selectedImage, rating }); + } + if (selectedImages.length > 0) { + const updatedSelected = selectedImages.map(img => { + if (paths.includes(img.path)) { + return { ...img, rating }; + } + return img; + }); + useImageStore.getState().setSelectedImages(updatedSelected); + } + + // 显示评分提醒 + setRatingToast({ + isVisible: true, + rating, + count: imagesToRate.length + }); + + console.log(`⭐ 已将 ${imagesToRate.length} 张图片评为 ${rating} 星`); + } catch (error) { + console.error('评分失败:', error); + alert('评分失败: ' + (error.message || '未知错误')); + } + }; + // 快速删除(乐观更新,立即响应) const handleQuickDelete = async () => { const items = selectedImages.length > 0 @@ -980,18 +1093,244 @@ function ImageWaterfall() { // 处理冲突对话框的选择 const handleConflictResolve = useCallback(async (action) => { - const { pendingPaste } = conflictDialog; - if (!pendingPaste) return; - - setConflictDialog({ isOpen: false, conflicts: [], pendingPaste: null }); - await executePaste(pendingPaste.items, pendingPaste.targetFolder, action); - }, [conflictDialog, executePaste]); + const { pendingPaste, pendingUpload } = conflictDialog; + + // 关闭对话框 + setConflictDialog({ isOpen: false, conflicts: [], pendingPaste: null, pendingUpload: null }); + + if (pendingPaste) { + // 粘贴冲突 + await executePaste(pendingPaste.items, pendingPaste.targetFolder, action); + } else if (pendingUpload) { + // 上传冲突 - 重新上传并带上 conflictAction 参数 + console.log(`处理上传冲突: ${action}`); + + if (action === 'skip') { + // 跳过:不再上传 + console.log('用户选择跳过上传'); + return; + } + + // 开始上传 + setUploadProgress({ isUploading: true, percent: 0, current: 0, total: pendingUpload.files.length }); + + try { + const result = await fileAPI.upload( + currentLibraryId, + pendingUpload.targetFolder, + pendingUpload.files, + (progressEvent) => { + const percent = Math.round((progressEvent.loaded * 100) / progressEvent.total); + setUploadProgress(prev => ({ ...prev, percent })); + }, + action // 传递 conflictAction + ); + + // 上传完成 + setUploadProgress({ isUploading: false, percent: 100, current: result.data.success.length, total: pendingUpload.files.length }); + + // 显示结果提示 + const successCount = result.data.success?.length || 0; + const failedCount = result.data.failed?.length || 0; + + let message = `上传完成: 成功 ${successCount} 个`; + if (failedCount > 0) message += `, 失败 ${failedCount} 个`; + + setUndoToast({ + isVisible: true, + message: message, + count: successCount + }); + + setTimeout(() => { + setUndoToast({ isVisible: false, message: '', count: 0 }); + setUploadProgress({ isUploading: false, percent: 0, current: 0, total: 0 }); + }, 3000); + + // 立即刷新当前文件夹的图片列表 + if (successCount > 0) { + const params = { folder: selectedFolder || '' }; + const response = await imageAPI.search(currentLibraryId, params); + setImages(response.images); + + // 刷新文件夹列表 + const foldersRes = await imageAPI.getFolders(currentLibraryId); + setFolders(foldersRes.folders); + + // 2秒后再刷新一次,确保缩略图已生成 + setTimeout(async () => { + try { + const response2 = await imageAPI.search(currentLibraryId, params); + setImages(response2.images); + console.log('✅ 缩略图刷新完成'); + } catch (err) { + console.error('刷新缩略图失败:', err); + } + }, 2000); + } + } catch (error) { + console.error('上传失败:', error); + setUploadProgress({ isUploading: false, percent: 0, current: 0, total: 0 }); + alert('上传失败: ' + (error.response?.data?.error || error.message || '未知错误')); + } + } + }, [conflictDialog, executePaste, currentLibraryId, selectedFolder, setImages, setFolders]); // 取消冲突对话框 const handleConflictCancel = useCallback(() => { - setConflictDialog({ isOpen: false, conflicts: [], pendingPaste: null }); + setConflictDialog({ isOpen: false, conflicts: [], pendingPaste: null, pendingUpload: null }); }, []); + // 拖放事件处理 - 拖拽进入 + const handleDragEnter = useCallback((e) => { + e.preventDefault(); + e.stopPropagation(); + + // 关键修复:只检测外部文件拖入,排除应用内部拖动 + const types = e.dataTransfer.types; + // 外部文件拖入的特征:包含 Files 且不包含 application/json + const hasFiles = types.includes('Files'); + const hasJson = types.includes('application/json'); + + if (hasFiles && !hasJson) { + setIsDraggingOver(true); + } + }, []); + + // 拖放事件处理 - 拖拽悬停 + const handleDragOver = useCallback((e) => { + e.preventDefault(); + e.stopPropagation(); + + // 检查是否为外部文件 + const types = e.dataTransfer.types; + const hasFiles = types.includes('Files'); + const hasJson = types.includes('application/json'); + + if (hasFiles && !hasJson) { + e.dataTransfer.dropEffect = 'copy'; + } else { + e.dataTransfer.dropEffect = 'none'; + } + }, []); + + // 拖放事件处理 - 拖拽离开(立即取消提示) + const handleDragLeave = useCallback((e) => { + e.preventDefault(); + e.stopPropagation(); + + // 关键修复:离开容器区域立即取消提示 + const rect = containerRef.current?.getBoundingClientRect(); + if (rect) { + const x = e.clientX; + const y = e.clientY; + // 检查鼠标是否离开容器区域 + if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) { + setIsDraggingOver(false); + } + } + }, []); + + // 拖放事件处理 - 文件放下 + const handleDrop = useCallback(async (e) => { + e.preventDefault(); + e.stopPropagation(); + setIsDraggingOver(false); + + if (!currentLibraryId) { + alert('请先选择素材库'); + return; + } + + const files = Array.from(e.dataTransfer.files); + if (files.length === 0) return; + + console.log(`📤 准备上传 ${files.length} 个文件到: ${selectedFolder || '根目录'}`); + + // 开始上传(不过滤格式,让后端处理) + setUploadProgress({ isUploading: true, percent: 0, current: 0, total: files.length }); + + try { + const result = await fileAPI.upload( + currentLibraryId, + selectedFolder || '', + files, + (progressEvent) => { + const percent = Math.round((progressEvent.loaded * 100) / progressEvent.total); + setUploadProgress(prev => ({ ...prev, percent })); + } + ); + + // 上传完成 + setUploadProgress({ isUploading: false, percent: 100, current: result.data.success.length, total: files.length }); + + // 检查是否有冲突 + const conflicts = result.data.conflicts || []; + if (conflicts.length > 0) { + // 有冲突,显示冲突对话框 + console.log(`⚠️ 检测到 ${conflicts.length} 个文件冲突`); + setConflictDialog({ + isOpen: true, + conflicts: conflicts, + pendingUpload: { + files: files.filter(f => { + const filename = f.name; + return conflicts.some(c => c.name === filename); + }), + targetFolder: selectedFolder || '' + } + }); + setUploadProgress({ isUploading: false, percent: 0, current: 0, total: 0 }); + return; + } + + // 显示结果提示 + const successCount = result.data.success?.length || 0; + const failedCount = result.data.failed?.length || 0; + + let message = `上传完成: 成功 ${successCount} 个`; + if (failedCount > 0) message += `, 失败 ${failedCount} 个`; + + setUndoToast({ + isVisible: true, + message: message, + count: successCount + }); + + setTimeout(() => { + setUndoToast({ isVisible: false, message: '', count: 0 }); + setUploadProgress({ isUploading: false, percent: 0, current: 0, total: 0 }); + }, 3000); + + // 立即刷新当前文件夹的图片列表(不等待后台处理) + if (successCount > 0) { + // 立即刷新,让用户看到文件(缩略图可能还在生成中) + const params = { folder: selectedFolder || '' }; + const response = await imageAPI.search(currentLibraryId, params); + setImages(response.images); + + // 刷新文件夹列表 + const foldersRes = await imageAPI.getFolders(currentLibraryId); + setFolders(foldersRes.folders); + + // 2秒后再刷新一次,确保缩略图已生成 + setTimeout(async () => { + try { + const response2 = await imageAPI.search(currentLibraryId, params); + setImages(response2.images); + console.log('✅ 缩略图刷新完成'); + } catch (err) { + console.error('刷新缩略图失败:', err); + } + }, 2000); + } + } catch (error) { + console.error('上传失败:', error); + setUploadProgress({ isUploading: false, percent: 0, current: 0, total: 0 }); + alert('上传失败: ' + (error.response?.data?.error || error.message || '未知错误')); + } + }, [currentLibraryId, selectedFolder, setImages, setFolders]); + // 开始重命名 const handleStartRename = useCallback((image) => { if (!image) return; @@ -1242,17 +1581,112 @@ function ImageWaterfall() { // 加载中时显示空容器,避免闪烁"暂无图片" if (!filteredImages.length && imageLoadingState.isLoading) { return ( -
+
+ {/* 拖拽提示覆盖层 */} + {isDraggingOver && ( +
+
+
+
📤
+

+ 拖放图片到这里 +

+

+ 支持 JPG、PNG、GIF、WebP 等格式 +

+
+
+
+ )} + + {/* 上传进度提示 */} + {uploadProgress.isUploading && ( +
+
+ + 正在上传... + + + {uploadProgress.percent}% + +
+
+
+
+
+ 共 {uploadProgress.total} 个文件 +
+
+ )} +
); } // 真正没有图片时才显示提示 if (!filteredImages.length) { return ( -
+
+ {/* 拖拽提示覆盖层 */} + {isDraggingOver && ( +
+
+
+
📤
+

+ 拖放图片到这里 +

+

+ 支持 JPG、PNG、GIF、WebP 等格式 +

+
+
+
+ )} + + {/* 上传进度提示 */} + {uploadProgress.isUploading && ( +
+
+ + 正在上传... + + + {uploadProgress.percent}% + +
+
+
+
+
+ 共 {uploadProgress.total} 个文件 +
+
+ )} +

暂无图片

请添加素材库或调整搜索条件

+

可以直接拖拽文件到这里上传

); @@ -1266,7 +1700,54 @@ function ImageWaterfall() { } return ( -
+
+ {/* 拖拽提示覆盖层 */} + {isDraggingOver && ( +
+
+
+
📤
+

+ 拖放图片到这里 +

+

+ 支持 JPG、PNG、GIF、WebP 等格式 +

+
+
+
+ )} + + {/* 上传进度提示 */} + {uploadProgress.isUploading && ( +
+
+ + 正在上传... + + + {uploadProgress.percent}% + +
+
+
+
+
+ 共 {uploadProgress.total} 个文件 +
+
+ )} + = 0} @@ -1356,6 +1837,14 @@ function ImageWaterfall() { }} /> + {/* 评分提醒 */} + setRatingToast({ isVisible: false, rating: 0, count: 0 })} + /> + {/* 文件夹选择器 */} {showFolderSelector && ( { + if (disabled) return; + // 点击已选中的星星则取消评分 + const newRating = rating === star ? 0 : star; + onChange?.(newRating); + }; + + return ( +
setHoverRating(0)} + > + {[1, 2, 3, 4, 5].map((star) => { + const isFilled = star <= displayRating; + const isHovering = hoverRating > 0 && star <= hoverRating; + + return ( + + ); + })} + + {/* 评分文字提示 */} + {displayRating > 0 && ( + + {displayRating} 星 + + )} +
+ ); +} + +export default RatingStars; diff --git a/frontend/src/components/RatingToast.jsx b/frontend/src/components/RatingToast.jsx new file mode 100644 index 0000000..ec09e2f --- /dev/null +++ b/frontend/src/components/RatingToast.jsx @@ -0,0 +1,50 @@ +/** + * 评分提醒 Toast 组件 + * 按下数字键快速评分后显示提醒 + */ + +import { useEffect } from 'react'; +import { Star } from 'lucide-react'; + +function RatingToast({ isVisible, rating, count, onClose, duration = 2000 }) { + useEffect(() => { + if (!isVisible) return; + + const timer = setTimeout(() => { + onClose(); + }, duration); + + return () => clearTimeout(timer); + }, [isVisible, rating, count, duration, onClose]); + + if (!isVisible) return null; + + return ( +
+
+
+ {[...Array(rating)].map((_, i) => ( + + ))} + {[...Array(5 - rating)].map((_, i) => ( + + ))} +
+ + {rating === 0 ? '已取消评分' : `已评 ${rating} 星`} + {count > 1 ? ` (${count} 张)` : ''} + +
+
+ ); +} + +export default RatingToast; diff --git a/frontend/src/components/RightPanel.jsx b/frontend/src/components/RightPanel.jsx index 9b6113a..b230011 100644 --- a/frontend/src/components/RightPanel.jsx +++ b/frontend/src/components/RightPanel.jsx @@ -7,10 +7,11 @@ import { useScanStore } from '../stores/useScanStore'; import { useClipboardStore } from '../stores/useClipboardStore'; import { imageAPI, fileAPI } from '../api'; import JSZip from 'jszip'; +import RatingStars from './RatingStars'; function RightPanel() { const { currentLibraryId } = useLibraryStore(); - const { selectedImage, selectedImages, selectedFolder, selectedFolderItem, images, setSelectedImage, updateImage } = useImageStore(); + const { selectedImage, selectedImages, selectedFolder, selectedFolderItem, images, setSelectedImage, setSelectedImages, updateImage } = useImageStore(); const { setMobileView, isResizingPanels, resizingSide } = useUIStore(); const { copyToClipboard } = useClipboardStore(); const [isMobile, setIsMobile] = useState(false); @@ -25,6 +26,7 @@ function RightPanel() { const [isEditingFilename, setIsEditingFilename] = useState(false); const [editingFilename, setEditingFilename] = useState(''); const filenameInputRef = useRef(null); + const [isUpdatingRating, setIsUpdatingRating] = useState(false); // 计算实际选中的图片数量(合并 selectedImage 和 selectedImages) const actualSelectedCount = (() => { @@ -180,6 +182,44 @@ function RightPanel() { setEditingFilename(''); }; + // 更新评分(支持单选和多选) + const handleRatingChange = async (newRating) => { + const imagesToRate = getImagesToProcess(); + if (imagesToRate.length === 0) return; + + setIsUpdatingRating(true); + try { + const paths = imagesToRate.map(img => img.path); + await imageAPI.updateRating(currentLibraryId, paths, newRating); + + // 更新本地状态 - images 数组 + imagesToRate.forEach(img => { + updateImage(img.path, { rating: newRating }); + }); + + // 关键修复:同时更新选中状态,确保详情面板立即显示最新评分 + if (selectedImage && paths.includes(selectedImage.path)) { + setSelectedImage({ ...selectedImage, rating: newRating }); + } + if (selectedImages.length > 0) { + const updatedSelectedImages = selectedImages.map(img => { + if (paths.includes(img.path)) { + return { ...img, rating: newRating }; + } + return img; + }); + setSelectedImages(updatedSelectedImages); + } + + console.log(`✅ 已更新 ${paths.length} 张图片的评分为 ${newRating} 星`); + } catch (error) { + console.error('更新评分失败:', error); + alert('更新评分失败: ' + (error.message || '未知错误')); + } finally { + setIsUpdatingRating(false); + } + }; + // 检测移动端 useEffect(() => { const checkMobile = () => { @@ -1079,6 +1119,35 @@ function RightPanel() { 数量:

{stats.count} 张图片

+
+ 评分: +
+ { + const images = getImagesToProcess(); + const ratings = images.map(img => img.rating || 0); + const uniqueRatings = [...new Set(ratings)]; + // 如果所有图片评分相同,显示该评分;否则显示 0 + return uniqueRatings.length === 1 ? uniqueRatings[0] : 0; + })()} + onChange={handleRatingChange} + disabled={isUpdatingRating} + /> +
+ {(() => { + const images = getImagesToProcess(); + const ratings = images.map(img => img.rating || 0); + const uniqueRatings = [...new Set(ratings)]; + if (uniqueRatings.length > 1) { + return ( +

+ 已选择的图片评分不一致,点击星星可批量设置评分 +

+ ); + } + return null; + })()} +
尺寸范围:

@@ -1167,6 +1236,16 @@ function RightPanel() {

)}
+
+ 评分: +
+ +
+
尺寸:

{selectedImage.width} × {selectedImage.height}

diff --git a/frontend/src/stores/useImageStore.js b/frontend/src/stores/useImageStore.js index d47e2cf..77256bd 100644 --- a/frontend/src/stores/useImageStore.js +++ b/frontend/src/stores/useImageStore.js @@ -22,8 +22,9 @@ export const useImageStore = create((set, get) => ({ searchKeywords: '', filters: { formats: [], - sizes: [], // 文件大小范围筛选 - orientation: '', // 横竖图筛选: 'horizontal' | 'vertical' | '' + sizes: [], // 文件大小范围筛选 + orientations: [], // 图片方向筛选(多选): ['horizontal', 'vertical', 'square'] + ratings: [], // 评分筛选(多选): [0, 1, 2, 3, 4, 5] }, // 原始图片列表(用于生成筛选选项,不受筛选影响) @@ -89,7 +90,8 @@ export const useImageStore = create((set, get) => ({ filters: { formats: [], sizes: [], - orientation: '' + orientations: [], + ratings: [] } }), diff --git a/package-lock.json b/package-lock.json index 202ffa8..fbc1b49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "crypto": "^1.0.1", "express": "^4.18.2", "glob": "^10.3.10", + "multer": "^2.0.0-rc.4", "p-limit": "^7.2.0", "sharp": "^0.33.0", "socket.io": "^4.6.0", @@ -1998,6 +1999,12 @@ "node": ">= 8" } }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==", + "license": "MIT" + }, "node_modules/arg": { "version": "5.0.2", "resolved": "https://registry.npmmirror.com/arg/-/arg-5.0.2.tgz", @@ -2303,6 +2310,23 @@ "ieee754": "^1.1.13" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmmirror.com/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmmirror.com/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -2528,6 +2552,21 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "license": "MIT" }, + "node_modules/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "engines": [ + "node >= 6.0" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, "node_modules/confbox": { "version": "0.1.8", "resolved": "https://registry.npmmirror.com/confbox/-/confbox-0.1.8.tgz", @@ -4208,6 +4247,18 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmmirror.com/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmmirror.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", @@ -4278,6 +4329,24 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/multer": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/multer/-/multer-2.0.2.tgz", + "integrity": "sha512-u7f2xaZ/UG8oLXHvtF/oWTRvT44p9ecwBBqTwgJVq0+4BW1g8OW01TyMEGWBHbyMOYVHXslaut7qEQ1meATXgw==", + "license": "MIT", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.6.0", + "concat-stream": "^2.0.0", + "mkdirp": "^0.5.6", + "object-assign": "^4.1.1", + "type-is": "^1.6.18", + "xtend": "^4.0.2" + }, + "engines": { + "node": ">= 10.16.0" + } + }, "node_modules/mz": { "version": "2.7.0", "resolved": "https://registry.npmmirror.com/mz/-/mz-2.7.0.tgz", @@ -5875,6 +5944,14 @@ "dev": true, "license": "MIT" }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmmirror.com/string_decoder/-/string_decoder-1.3.0.tgz", @@ -6350,6 +6427,12 @@ "node": ">= 0.6" } }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmmirror.com/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "license": "MIT" + }, "node_modules/ufo": { "version": "1.6.1", "resolved": "https://registry.npmmirror.com/ufo/-/ufo-1.6.1.tgz", @@ -6795,6 +6878,15 @@ "node": ">=0.4.0" } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",