fix: 视频文件右侧面板显示图片信息 — RightPanel 增加视频判定(v1.4.4)

This commit is contained in:
jinghui committed 2026-11-18 18:56:30 +08:00
1 parent e17b78cd19
commit 9c7c72e3e7
9 files changed
+96 -34

No files matched your search

+52 -12
View File
@@ -15,7 +15,7 @@ const logger = createLogger('RightPanel');
function RightPanel() {
const { currentLibraryId } = useLibraryStore();
const { selectedImage, selectedImages, selectedFolder, selectedFolderItem, images, setSelectedImage, setSelectedImages, updateImage } = useImageStore();
const { setMobileView, isResizingPanels, resizingSide, setEditingImage } = useUIStore();
const { setMobileView, isResizingPanels, resizingSide, setEditingImage, setVideoEditFile } = useUIStore();
const { copyToClipboard } = useClipboardStore();
const [isMobile, setIsMobile] = useState(false);
const [imageUrl, setImageUrl] = useState(''); // 当前显示的图片URL
@@ -50,6 +50,8 @@ function RightPanel() {
// 判断是单选还是多选
const isMultiSelect = actualSelectedCount > 1;
const displayImage = selectedImages.length > 0 ? selectedImages[0] : selectedImage;
// 视频文件判定:右侧面板按文件类型展示,视频不再套用图片文案/操作
const singleIsVideo = !isMultiSelect && (displayImage?.fileType === 'video');
const { getCurrentLibrary } = useLibraryStore();
const currentLibrary = getCurrentLibrary();
@@ -597,7 +599,14 @@ function RightPanel() {
// 2. 获取原图URL,写入系统剪贴板
const imageUrl = imageAPI.getOriginalUrl(currentLibraryId, selectedImage.path);
// 视频无法转换为图片写入系统剪贴板,仅保留应用内复制(供粘贴移动)
if (selectedImage?.fileType === 'video') {
setImageCopied(true);
setTimeout(() => setImageCopied(false), 2000);
return;
}
// 方案1:尝试现代 Clipboard API(需要 HTTPS)
if (isClipboardApiSupported()) {
try {
@@ -770,6 +779,9 @@ function RightPanel() {
return selectedImage ? [selectedImage] : [];
};
// 选中集合是否含视频(决定多选计数单位文案:视频用「个」,图片用「张」)
const selectionHasVideo = getImagesToProcess().some(img => img?.fileType === 'video');
// 批量复制图片
const copyMultipleImages = async () => {
try {
@@ -1312,7 +1324,16 @@ function RightPanel() {
}}
title="双击查看原文件"
>
{imageUrl ? (
{singleIsVideo ? (
// 视频:直接播放原文件(不再以图片缩略图形式展示)
<video
src={getOriginalUrl()}
poster={imageUrl || undefined}
controls
preload="metadata"
className="w-full h-full object-contain bg-black"
/>
) : imageUrl ? (
<img
src={imageUrl}
alt={displayImage.filename}
@@ -1346,7 +1367,7 @@ function RightPanel() {
<div className="flex-1 overflow-y-auto p-4 space-y-4 min-h-0">
<div>
<h3 className="text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2">
{isMultiSelect ? `已选择 ${actualSelectedCount} 张图片` : '基本信息'}
{isMultiSelect ? `已选择 ${actualSelectedCount} ${selectionHasVideo ? '个文件' : '张图片'}` : '基本信息'}
</h3>
<div className="space-y-2 text-xs">
{isMultiSelect ? (
@@ -1359,7 +1380,7 @@ function RightPanel() {
<>
<div>
<span className="text-gray-500 dark:text-gray-400">数量:</span>
<p className="text-gray-900 dark:text-gray-100 text-xs">{stats.count} 张图片</p>
<p className="text-gray-900 dark:text-gray-100 text-xs">{stats.count} {selectionHasVideo ? '个文件' : '张图片'}</p>
</div>
<div>
<span className="text-gray-500 dark:text-gray-400">评分:</span>
@@ -1492,6 +1513,14 @@ function RightPanel() {
<span className="text-gray-500 dark:text-gray-400">尺寸:</span>
<p className="text-gray-900 dark:text-gray-100 text-xs">{selectedImage.width} × {selectedImage.height}</p>
</div>
{singleIsVideo && selectedImage.duration > 0 && (
<div>
<span className="text-gray-500 dark:text-gray-400">时长:</span>
<p className="text-gray-900 dark:text-gray-100 text-xs font-mono tabular-nums">
{Math.floor(selectedImage.duration / 60)}:{String(Math.floor(selectedImage.duration % 60)).padStart(2, '0')}
</p>
</div>
)}
<div>
<span className="text-gray-500 dark:text-gray-400">文件大小:</span>
<p className="text-gray-900 dark:text-gray-100 text-xs">{formatFileSize(selectedImage.size)}</p>
@@ -1552,7 +1581,7 @@ function RightPanel() {
</div>
{isMultiSelect && (
<p className="text-xs text-gray-400 dark:text-gray-500 mt-1">
已选择 {actualSelectedCount} 张图片的共同父路径
已选择 {actualSelectedCount} {selectionHasVideo ? '个文件' : '张图片'}的共同父路径
</p>
)}
</div>
@@ -1563,16 +1592,23 @@ function RightPanel() {
{/* Actions - 仅桌面端显示 */}
{!isMobile && (
<div className="p-4 border-t border-gray-200 dark:border-gray-700 space-y-2 flex-shrink-0">
{/* 编辑图片(单选时) */}
{/* 编辑图片/视频(单选时) */}
{!isMultiSelect && selectedImage && (
<button
onClick={() => setEditingImage(selectedImage)}
onClick={() => {
if (singleIsVideo) {
// 视频 → 视频编辑弹窗(水印/字幕声音)
setVideoEditFile(selectedImage);
} else {
setEditingImage(selectedImage);
}
}}
className="w-full flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
编辑图片
{singleIsVideo ? '编辑视频' : '编辑图片'}
</button>
)}
{/* 复制按钮 */}
@@ -1587,12 +1623,16 @@ function RightPanel() {
{imageCopied ? (
<>
<Check className="w-4 h-4" />
<span>已复制{isMultiSelect ? ` ${actualSelectedCount} 张` : ''}</span>
<span>已复制{isMultiSelect ? ` ${actualSelectedCount} ${selectionHasVideo ? '个' : '张'}` : ''}</span>
</>
) : (
<>
<Copy className="w-4 h-4" />
<span>复制图片{isMultiSelect ? ` (${actualSelectedCount})` : ''}</span>
<span>
{singleIsVideo
? '复制视频'
: `${selectionHasVideo ? '复制文件' : '复制图片'}${isMultiSelect ? ` (${actualSelectedCount})` : ''}`}
</span>
</>
)}
</button>
@@ -1608,7 +1648,7 @@ function RightPanel() {
<span>
{isExporting
? `打包中... ${exportProgress}%`
: `导出图片${isMultiSelect ? ` (${actualSelectedCount})` : ''}`
: `${singleIsVideo ? '导出视频' : selectionHasVideo ? '导出文件' : '导出图片'}${isMultiSelect ? ` (${actualSelectedCount})` : ''}`
}
</span>
</div>