From b910110b6d1b71da4ee76cfb2bc8da88f994cfc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E6=B6=9B?= Date: Mon, 15 Sep 2025 23:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=95=B4=E4=BD=93UI?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 14 +++- src/components/Header.tsx | 2 +- src/components/HistoryPanel.tsx | 58 +++++++------- src/components/ImageCanvas.tsx | 128 +++++++++++++++--------------- src/components/PromptComposer.tsx | 2 +- 5 files changed, 103 insertions(+), 101 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 6af9b66..c8b97b1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -53,18 +53,24 @@ function AppContent() { }, [setShowPromptPanel, setShowHistory]); return ( -
-
+
+
+
+
- +
+ +
- +
+ +
diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 70a86c4..25f6624 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -8,7 +8,7 @@ export const Header: React.FC = () => { return ( <> -
+
🍌
diff --git a/src/components/HistoryPanel.tsx b/src/components/HistoryPanel.tsx index dddab0c..b954d55 100644 --- a/src/components/HistoryPanel.tsx +++ b/src/components/HistoryPanel.tsx @@ -211,7 +211,7 @@ export const HistoryPanel: React.FC = () => { } return ( -
+
{/* 头部 */}
@@ -306,7 +306,7 @@ export const HistoryPanel: React.FC = () => { className={cn( 'relative aspect-square rounded border cursor-pointer transition-all duration-200 overflow-hidden', selectedGenerationId === generation.id - ? 'border-yellow-400' + ? 'border-yellow-400 ring-2 ring-yellow-400/30' : 'border-gray-200 hover:border-gray-300' )} onClick={() => { @@ -325,7 +325,8 @@ export const HistoryPanel: React.FC = () => { if (asset.url) { setHoveredImage({ url: asset.url, - title: `生成记录 G${index + 1}: ${generation.prompt.substring(0, 50)}${generation.prompt.length > 50 ? '...' : ''}` + title: `生成记录 G${index + 1}`, + description: generation.prompt }); setPreviewPosition({x: e.clientX, y: e.clientY}); } @@ -405,7 +406,7 @@ export const HistoryPanel: React.FC = () => { className={cn( 'relative aspect-square rounded border cursor-pointer transition-all duration-200 overflow-hidden', selectedEditId === edit.id - ? 'border-purple-400' + ? 'border-purple-400 ring-2 ring-purple-400/30' : 'border-gray-200 hover:border-gray-300' )} onClick={() => { @@ -425,7 +426,8 @@ export const HistoryPanel: React.FC = () => { if (asset.url) { setHoveredImage({ url: asset.url, - title: `编辑记录 E${index + 1}: ${edit.instruction.substring(0, 50)}${edit.instruction.length > 50 ? '...' : ''}` + title: `编辑记录 E${index + 1}`, + description: edit.instruction }); setPreviewPosition({x: e.clientX, y: e.clientY}); } @@ -501,24 +503,7 @@ export const HistoryPanel: React.FC = () => { )}
- {/* 当前图像信息 */} - {(canvasImage || imageDimensions) && ( -
-

当前图像

-
- {imageDimensions && ( -
- 尺寸: - {imageDimensions.width} × {imageDimensions.height} -
- )} -
- 模式: - {selectedTool} -
-
-
- )} + {/* 生成详情 */}
@@ -794,22 +779,35 @@ export const HistoryPanel: React.FC = () => { {/* 悬浮预览 */} {hoveredImage && (
-
+
{hoveredImage.title}
预览 + {/* 图像信息 */} +
+ {imageDimensions && ( +
+ 尺寸: + {imageDimensions.width} × {imageDimensions.height} +
+ )} +
+ 模式: + {selectedTool} +
+
)}
diff --git a/src/components/ImageCanvas.tsx b/src/components/ImageCanvas.tsx index 3588f70..aa5f0df 100644 --- a/src/components/ImageCanvas.tsx +++ b/src/components/ImageCanvas.tsx @@ -20,7 +20,9 @@ export const ImageCanvas: React.FC = () => { selectedTool, isGenerating, brushSize, - setBrushSize + setBrushSize, + showHistory, + showPromptPanel } = useAppStore(); const stageRef = useRef(null); @@ -80,6 +82,22 @@ export const ImageCanvas: React.FC = () => { return () => window.removeEventListener('resize', updateSize); }, []); + // 监听面板状态变化以调整画布大小 + useEffect(() => { + // 使用 setTimeout 确保 DOM 已更新 + const timer = setTimeout(() => { + const container = document.getElementById('canvas-container'); + if (container) { + setStageSize({ + width: container.offsetWidth, + height: container.offsetHeight + }); + } + }, 100); + + return () => clearTimeout(timer); + }, [showPromptPanel, showHistory]); + // 处理鼠标滚轮缩放 useEffect(() => { const container = document.getElementById('canvas-container'); @@ -188,69 +206,7 @@ export const ImageCanvas: React.FC = () => { return (
{/* 工具栏 */} -
-
- {/* 左侧 - 缩放控制 */} -
- - - {Math.round(canvasZoom * 100)}% - - - -
- - {/* 右侧 - 工具和操作 */} -
- {selectedTool === 'mask' && ( - <> -
- 画笔: - setBrushSize(parseInt(e.target.value))} - className="w-12 h-2 bg-gray-800 rounded-lg appearance-none cursor-pointer slider" - /> - {brushSize} -
- - - )} - - - - {canvasImage && ( - - )} -
-
-
+ {/* 画布区域 */}
{ {isGenerating && (
-
+

正在创建图像...

@@ -349,6 +305,48 @@ export const ImageCanvas: React.FC = () => { )} + + {/* 悬浮操作按钮 */} + {image && !isGenerating && ( +
+ + + {Math.round(canvasZoom * 100)}% + + + +
+ +
+ )}
{/* 状态栏 */} diff --git a/src/components/PromptComposer.tsx b/src/components/PromptComposer.tsx index 4699779..be89a82 100644 --- a/src/components/PromptComposer.tsx +++ b/src/components/PromptComposer.tsx @@ -156,7 +156,7 @@ export const PromptComposer: React.FC = () => { return ( <> -
+

模式