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 ( <>
{relativePath}
- {copyState === 'failed' ? (
- - 复制失败,请手动复制路径。 -
- ) : null}