/** 专家库:浏览所有专家,选择后跳转到对应智囊场景咨询 * 卡片样式参考管理端专家管理:长方形头像 + 姓名/评分 + 简介 + 专长标签 */ import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import { Users, Star, ChevronRight, Briefcase } from 'lucide-react' import { PageLayout } from '@/components/common/PageLayout' import { Card, CardContent } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { LoadingState } from '@/components/common/LoadingState' import { ErrorState } from '@/components/common/ErrorState' import { EmptyState } from '@/components/common/EmptyState' import { ExpertAvatar } from '@/components/common/ExpertAvatar' import { api } from '@/lib/api' import { SCENE_LABELS, cn } from '@/lib/utils' import type { Expert, Scene } from '@/types' const CATEGORY_FILTERS: { value: Scene | 'all'; label: string }[] = [ { value: 'all', label: '全部' }, { value: 'legal', label: '法务' }, { value: 'decision', label: '决策' }, { value: 'life', label: '生活' }, { value: 'emotion', label: '情绪' }, ] export function Experts() { const navigate = useNavigate() const [experts, setExperts] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState('') const [filter, setFilter] = useState('all') const load = () => { setLoading(true); setError('') api.listExperts(filter === 'all' ? undefined : filter) .then((r) => { setExperts(r.results); setLoading(false) }) .catch((e) => { setError(e.message); setLoading(false) }) } useEffect(load, [filter]) if (loading) return if (error) return return ( {/* 分类筛选 */}
{CATEGORY_FILTERS.map((f) => ( ))}
{experts.length === 0 ? ( ) : (
{experts.map((ex) => { const stars = (ex.rate / 100).toFixed(1) return ( {/* 头部:长方形头像(左) + 姓名/评分(右) */}

{ex.name}

{ex.title}

{ex.rating_count > 0 && (
{stars} ({ex.rating_count}人评价)
)} {/* 简介 */} {ex.bio && (

{ex.bio}

)} {/* 专长标签 */} {ex.expertise && (
{ex.expertise.split(',').map((tag, i) => ( {tag.trim()} ))}
)}
{/* 底部:分类 + 咨询按钮 */}
{SCENE_LABELS[ex.category] || ex.category}
) })}
)}
) }