From 8a0d5600b3bd6616c19ddb1fa8d4a106a27c6a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Mon, 14 Sep 2026 18:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=20UI=20=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E8=B7=AF=E5=BE=84=E5=A4=8D=E5=88=B6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将剪贴板状态与写入逻辑提取为独立小组件 保持保存结果弹窗只负责结果布局与动作编排 --- .../components/UiEditorCopyPathButton.tsx | 43 +++++++++++++++++++ .../components/UiEditorSaveResultModal.tsx | 35 +-------------- 2 files changed, 45 insertions(+), 33 deletions(-) create mode 100644 apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorCopyPathButton.tsx diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorCopyPathButton.tsx b/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorCopyPathButton.tsx new file mode 100644 index 000000000..ea19e48bf --- /dev/null +++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorCopyPathButton.tsx @@ -0,0 +1,43 @@ +import { writeText } from '@tauri-apps/plugin-clipboard-manager'; +import { Copy } from 'lucide-react'; +import { useEffect, useState } from 'react'; + +export function UiEditorCopyPathButton({ + relativePath, +}: { + relativePath: string; +}) { + const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>( + 'idle', + ); + + useEffect(() => setCopyState('idle'), [relativePath]); + + async function copyPath() { + setCopyState('idle'); + try { + await writeText(relativePath); + setCopyState('copied'); + } catch { + setCopyState('failed'); + } + } + + return ( + <> + {copyState === 'failed' ? ( +

+ 复制失败,请手动复制路径。 +

+ ) : null} + + + ); +} diff --git a/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorSaveResultModal.tsx b/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorSaveResultModal.tsx index 8d5bc45c5..a78620a7d 100644 --- a/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorSaveResultModal.tsx +++ b/apps/ai-game-creator-shell/src/view/ui-editor/components/UiEditorSaveResultModal.tsx @@ -1,8 +1,5 @@ -import { writeText } from '@tauri-apps/plugin-clipboard-manager'; -import { Copy } from 'lucide-react'; -import { useEffect, useState } from 'react'; - import { ThemedModal } from '../../../components/modal/ThemedModal'; +import { UiEditorCopyPathButton } from './UiEditorCopyPathButton'; export type UiEditorSaveResultNotice = | { @@ -51,22 +48,6 @@ function GeneratedNotice({ relativePath: string; onClose: () => void; }) { - const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>( - 'idle', - ); - - useEffect(() => setCopyState('idle'), [relativePath]); - - async function copyPath() { - setCopyState('idle'); - try { - await writeText(relativePath); - setCopyState('copied'); - } catch { - setCopyState('failed'); - } - } - return ( <>

代码已生成

@@ -74,20 +55,8 @@ function GeneratedNotice({ {relativePath} - {copyState === 'failed' ? ( -

- 复制失败,请手动复制路径。 -

- ) : null}
- +