fix(agents): explain missing channel targets

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 11:32:07 +08:00
1 parent 13336cfe12
commit 8289f27f3e
5 files changed
+222 -9

No files matched your search

+9 -3
View File
@@ -251,6 +251,11 @@ export function ChannelAccounts() {
{flow?.target && !targetAgent && selected?.target_agent_slug === flow.target && <option value={flow.target} disabled>{selected.target_agent_name ?? '原智能体'}(暂不可用)</option>}
{agents.map(agent => <option key={agent.slug} value={agent.slug}>{agent.name}</option>)}
</>;
const agentRequiredHint = <div className="rounded-2xl border border-[#e5def0] bg-[#f6f2fb] p-5 text-sm leading-7 text-[#75618e]">
<h2 className="font-semibold text-[#3c3549]">还没有可连接的智能体</h2>
<p className="mt-2">先创建一个智能体,配置完成后点击“开始使用”,就能连接到微信。</p>
<Button variant="outline" className="mt-4 rounded-xl" onClick={() => navigate('/cloud-agents?view=mine')}>去我的智能体<ArrowRight className="ml-2 h-4 w-4" /></Button>
</div>;
return <section className="h-full overflow-auto bg-[#fffcf7] p-4 sm:p-7 lg:p-9" data-testid="channel-accounts-page">
<div className="mx-auto max-w-6xl space-y-6">
@@ -266,12 +271,13 @@ export function ChannelAccounts() {
</div>
</header>
{!flow && messages}
{!loading && loaded && !agents.length && !flow && agentRequiredHint}
{loading ? <div role="status" className="flex items-center justify-center gap-3 rounded-3xl bg-[#f4f1fb] p-12 text-[#75618e]"><Loader2 className="h-5 w-5 animate-spin" />正在查看你的微信绑定…</div>
: !loaded ? <div className="rounded-3xl border border-[#e4e2de] bg-white p-10 text-center text-sm text-[#677286]"><p>暂时没能读到微信绑定,请刷新后再试。</p><Button variant="outline" className="mt-5 rounded-xl" onClick={() => void refresh().catch(failure => setError(errorText(failure)))}>重新加载</Button></div>
: !accounts.length ? <div className="rounded-[28px] border border-[#dfe9e2] bg-[#f1f8f2] px-6 py-14 text-center">
: !accounts.length ? (agents.length > 0 && <div className="rounded-[28px] border border-[#dfe9e2] bg-[#f1f8f2] px-6 py-14 text-center">
<Link2 className="mx-auto h-10 w-10 text-[#678b70]" /><h2 className="mt-5 text-xl font-bold text-[#303747]">把你的智能体带到微信吧</h2><p className="mx-auto mt-3 max-w-md text-sm leading-7 text-[#677286]">绑定后,就可以回到微信和它聊聊。每个微信绑定一个智能体,也可以把多个微信交给同一个智能体。</p>
<Button className="mt-7 h-11 rounded-2xl px-6" onClick={() => { setError(''); setFlow({ mode: 'new', step: 'choose', accountId: '', target: '', remark: '' }); }}>添加第一个微信<ArrowRight className="ml-2 h-4 w-4" /></Button>
</div> : <div className="grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3" aria-label="我的微信绑定">
</div>) : <div className="grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-3" aria-label="我的微信绑定">
{accounts.map(account => {
const agent = agents.find(item => item.slug === account.target_agent_slug);
const state = accountState(account);
@@ -298,7 +304,7 @@ export function ChannelAccounts() {
{recoveryBlocked && <p className="rounded-2xl bg-[#fff0d8] p-3 text-sm text-[#876033]">有一次绑定操作的结果需要确认,请先关闭此窗口并处理页面上的恢复提醒。</p>}
{flow.step === 'choose' && <>
{flow.mode === 'manage' && selectedState && <div className="flex items-center justify-between rounded-2xl bg-[#eaf5ec] p-4 text-sm"><span>微信连接与绑定</span><span className={`rounded-full px-3 py-1.5 text-xs font-semibold ${selectedState.tone}`}>{selectedState.text}</span></div>}
{!agents.length ? <div className="rounded-2xl border border-[#e5def0] bg-[#f6f2fb] p-5 text-sm leading-7 text-[#75618e]"><p>先准备一个可以使用的智能体,再把它带到微信里。</p><Button variant="outline" className="mt-4 rounded-xl" onClick={() => navigate('/cloud-agents?view=mine')}>去我的智能体<ArrowRight className="ml-2 h-4 w-4" /></Button></div>
{!agents.length ? agentRequiredHint
: <label className="space-y-2 text-sm font-medium text-[#3c3549]"><span>{flow.mode === 'new' ? '选择智能体' : '绑定的智能体'}</span><Select aria-label={flow.mode === 'new' ? '选择智能体' : '绑定的智能体'} className="h-12 rounded-xl bg-white" style={{ backgroundPosition: 'right 12px center', backgroundSize: '16px 16px', backgroundRepeat: 'no-repeat' }} value={flow.target} disabled={disabled} onChange={event => setFlow({ ...flow, target: event.target.value })}>{options}</Select></label>}
{flow.mode === 'new' && !flow.accountId && <label className="space-y-2 text-sm font-medium text-[#3c3549]"><span>微信备注(可选)</span><Input aria-label="微信备注(可选)" className="h-12 rounded-xl bg-white" disabled={disabled} value={flow.remark} maxLength={100} onChange={event => setFlow({ ...flow, remark: event.target.value })} placeholder="给这个微信起个方便辨认的名字" /></label>}
{flow.mode === 'manage' && selected?.blockers.length ? <p className="rounded-2xl bg-[#fff0d8] p-3 text-sm leading-6 text-[#876033]">{selected.blockers.map(item => blockerText[item] ?? '连接暂时不可用,请刷新后重试').join(';')}</p> : null}