From e72f96da10177b3122c611e63d260629f2fb4d3a Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 29 Dec 2025 10:48:41 -0800 Subject: [PATCH] =?UTF-8?q?feat(service-party-app):=20=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=E8=87=AA=E5=8A=A8=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除手动输入名称和点击"确认加入"按钮的步骤 - 验证邀请码成功后自动触发 joinSession - 生成默认参与者名称(参与者-xxxx 格式) - 保留错误处理和重试功能 - 减少用户操作步骤,提高 co_managed_keygen 可靠性 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../service-party-app/src/pages/Join.tsx | 101 +++++++++++------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/backend/mpc-system/services/service-party-app/src/pages/Join.tsx b/backend/mpc-system/services/service-party-app/src/pages/Join.tsx index 96b9fc7a..15d6d13f 100644 --- a/backend/mpc-system/services/service-party-app/src/pages/Join.tsx +++ b/backend/mpc-system/services/service-party-app/src/pages/Join.tsx @@ -12,6 +12,12 @@ interface SessionInfo { totalParticipants?: number; } +// 生成默认参与者名称 +function generateParticipantName(): string { + const timestamp = Date.now().toString(36).slice(-4); + return `参与者-${timestamp}`; +} + interface ValidateResult { success: boolean; error?: string; @@ -24,13 +30,14 @@ export default function Join() { const navigate = useNavigate(); const [code, setCode] = useState(inviteCode || ''); - const [participantName, setParticipantName] = useState(''); + const [participantName] = useState(generateParticipantName()); const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null); const [sessionInfo, setSessionInfo] = useState(null); const [joinToken, setJoinToken] = useState(null); const [partyId, setPartyId] = useState(null); const [step, setStep] = useState<'input' | 'confirm' | 'joining'>('input'); + const [autoJoinAttempted, setAutoJoinAttempted] = useState(false); useEffect(() => { if (inviteCode) { @@ -38,6 +45,22 @@ export default function Join() { } }, [inviteCode]); + // 自动加入:验证成功后自动加入会话 + useEffect(() => { + if ( + step === 'confirm' && + sessionInfo && + joinToken && + partyId && + participantName && + !autoJoinAttempted && + !isLoading + ) { + setAutoJoinAttempted(true); + handleJoinSession(); + } + }, [step, sessionInfo, joinToken, partyId, participantName, autoJoinAttempted, isLoading]); + const handleValidateCode = async (codeToValidate: string) => { if (!codeToValidate.trim()) { setError('请输入邀请码'); @@ -76,8 +99,8 @@ export default function Join() { }; const handleJoinSession = async () => { - if (!sessionInfo || !participantName.trim()) { - setError('请输入参与者名称'); + if (!sessionInfo) { + setError('会话信息不完整'); return; } @@ -204,42 +227,42 @@ export default function Join() { -
- - setParticipantName(e.target.value)} - placeholder="输入您的名称(其他参与者可见)" - className={styles.input} - disabled={isLoading} - /> -
- - {error &&
{error}
} - -
- - -
+ {error ? ( + <> +
{error}
+
+ + +
+ + ) : ( +
+
+

正在自动加入会话...

+
+ )} )}