import { useEffect } from 'react'; import { useGatewayStore } from '../store/gatewayStore'; import { Radio, RefreshCw, MessageCircle, Settings } from 'lucide-react'; const CHANNEL_ICONS: Record = { feishu: '飞', qqbot: 'QQ', wechat: '微', }; interface ChannelListProps { onOpenSettings?: () => void; } export function ChannelList({ onOpenSettings }: ChannelListProps) { const { channels, connectionState, loadChannels, loadPluginStatus } = useGatewayStore(); const connected = connectionState === 'connected'; useEffect(() => { if (connected) { loadPluginStatus().then(() => loadChannels()); } }, [connected]); const handleRefresh = () => { loadPluginStatus().then(() => loadChannels()); }; if (!connected) { return (

IM 频道

连接 Gateway 后可用

); } return (
{/* Header */}
频道列表
{/* Configured channels */} {channels.map((ch) => (
{CHANNEL_ICONS[ch.type] || }
{ch.label}
{ch.status === 'active' ? '已连接' : ch.status === 'error' ? ch.error || '错误' : '未配置'} {ch.accounts !== undefined && ch.accounts > 0 && ` · ${ch.accounts} 个账号`}
))} {/* Always show available channels that aren't configured */} {!channels.find(c => c.type === 'feishu') && (
飞书 (Feishu)
未配置
)} {!channels.find(c => c.type === 'qqbot') && (
QQ
QQ 机器人
未安装插件
)} {/* Help text */}

在设置中配置 IM 频道

{onOpenSettings && ( )}
); }