fix(service-party-app): 修复 threshold 为 undefined 导致的崩溃
问题: - Session.tsx 直接访问 session.threshold.n 和 session.threshold.t - 当后端返回的 session 数据中 threshold 为 undefined 时崩溃 修复: - 添加空值检查 session.threshold?.n || 0 - 阈值信息部分添加条件渲染 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
30ec0a1c8e
commit
aa9171ce2c
|
|
@ -187,7 +187,7 @@ export default function Session() {
|
|||
{/* 参与方列表 */}
|
||||
<div className={styles.section}>
|
||||
<h3 className={styles.sectionTitle}>
|
||||
参与方 ({(session.participants || []).length} / {session.threshold.n})
|
||||
参与方 ({(session.participants || []).length} / {session.threshold?.n || 0})
|
||||
</h3>
|
||||
<div className={styles.participantList}>
|
||||
{(session.participants || []).map((participant, index) => (
|
||||
|
|
@ -201,7 +201,7 @@ export default function Session() {
|
|||
</span>
|
||||
</div>
|
||||
))}
|
||||
{Array.from({ length: Math.max(0, session.threshold.n - (session.participants || []).length) }).map((_, index) => (
|
||||
{Array.from({ length: Math.max(0, (session.threshold?.n || 0) - (session.participants || []).length) }).map((_, index) => (
|
||||
<div key={`empty-${index}`} className={`${styles.participant} ${styles.participantEmpty}`}>
|
||||
<div className={styles.participantInfo}>
|
||||
<span className={styles.participantIndex}>#{(session.participants || []).length + index + 1}</span>
|
||||
|
|
@ -214,6 +214,7 @@ export default function Session() {
|
|||
</div>
|
||||
|
||||
{/* 阈值信息 */}
|
||||
{session.threshold && (
|
||||
<div className={styles.section}>
|
||||
<h3 className={styles.sectionTitle}>阈值设置</h3>
|
||||
<div className={styles.thresholdInfo}>
|
||||
|
|
@ -225,6 +226,7 @@ export default function Session() {
|
|||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 完成状态 */}
|
||||
{session.status === 'completed' && session.publicKey && (
|
||||
|
|
|
|||
Loading…
Reference in New Issue