diff --git a/web/client/src/components/accounts/AccountList.tsx b/web/client/src/components/accounts/AccountList.tsx index 150166a..e628d3a 100644 --- a/web/client/src/components/accounts/AccountList.tsx +++ b/web/client/src/components/accounts/AccountList.tsx @@ -1,12 +1,11 @@ import { Plus } from 'lucide-react'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; 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'; export function AccountList() { const { accountId } = useParams<{ accountId?: string }>(); @@ -14,21 +13,29 @@ export function AccountList() { const { accounts, create, update, remove } = useAccounts(); const [creating, setCreating] = useState(false); const [subTab, setSubTab] = useState<'info' | 'prompts'>('info'); - const editing = accounts.find((a) => a.id === accountId) || null; + + const editing = accountId ? accounts.find((a) => a.id === accountId) || null : null; + + // Reset creating when navigating to an account + useEffect(() => { setCreating(false); }, [accountId]); + + const handleSelectAccount = (id: string) => { + navigate(`/accounts/${id}`); + }; return (

账户列表

-
{accounts.map((a) => ( ); })}
)} -
-
+ + {/* Input bar */} +
+