diff --git a/web/client/src/components/accounts/AccountList.tsx b/web/client/src/components/accounts/AccountList.tsx index 61cb8d3..83f2704 100644 --- a/web/client/src/components/accounts/AccountList.tsx +++ b/web/client/src/components/accounts/AccountList.tsx @@ -2,6 +2,7 @@ import { Plus } from 'lucide-react'; import { useState } from 'react'; import { useAccounts } from '@/hooks/useAccounts'; import { AccountForm } from './AccountForm'; +import { PromptEditor } from '@/components/prompts/PromptEditor'; import { Button } from '@/components/ui/button'; import { ScrollArea } from '@/components/ui/scroll-area'; import type { Account } from '@/types'; @@ -10,6 +11,7 @@ export function AccountList() { const { accounts, create, update, remove } = useAccounts(); const [editing, setEditing] = useState(null); const [creating, setCreating] = useState(false); + const [subTab, setSubTab] = useState<'info' | 'prompts'>('info'); return (
@@ -23,7 +25,7 @@ export function AccountList() { {accounts.map((a) => ( + +
+
+ {subTab === 'info' ? ( + (editing || creating) ? ( +
+ { + if (creating) { + create(data).then(() => setCreating(false)); + } else { + update(editing!.id, data).then(() => setEditing(null)); + } + }} + onDelete={editing ? () => { + if (confirm(`确定删除账户「${editing.name}」?`)) { + remove(editing.id).then(() => setEditing(null)); + } + } : undefined} + onCancel={() => { setEditing(null); setCreating(false); }} + /> +
+ ) : ( +
+ 选择一个账户或创建新账户 +
+ ) + ) : ( + + )} +
); diff --git a/web/client/src/components/prompts/PromptEditor.tsx b/web/client/src/components/prompts/PromptEditor.tsx new file mode 100644 index 0000000..a607870 --- /dev/null +++ b/web/client/src/components/prompts/PromptEditor.tsx @@ -0,0 +1,84 @@ +import { useState, useEffect } from 'react'; +import { useAccounts } from '@/hooks/useAccounts'; +import { usePrompts } from '@/hooks/usePrompts'; +import { Button } from '@/components/ui/button'; + +const PROMPT_TYPES = [ + { type: 'storyboard', label: '分镜' }, + { type: 'image', label: '图片提示词' }, + { type: 'video', label: '视频提示词' }, +] as const; + +export function PromptEditor() { + const { accounts } = useAccounts(); + const [selectedAccount, setSelectedAccount] = useState(''); + const [selectedType, setSelectedType] = useState('storyboard'); + const { content, path, loading, load, save, setContent } = usePrompts(); + + useEffect(() => { + if (accounts.length > 0 && !selectedAccount) { + setSelectedAccount(accounts[0].id); + } + }, [accounts]); + + useEffect(() => { + if (selectedAccount) { + load(selectedAccount, selectedType); + } + }, [selectedAccount, selectedType]); + + return ( +
+
+
+ + +
+
+ +
+ {PROMPT_TYPES.map(({ type, label }) => ( + + ))} +
+
+
+ +
+
+ {path} + +
+