fix: AgentList 展示模型名称而非JSON
parent
85090899e6
commit
0832930bcb
|
|
@ -37,6 +37,41 @@ export default function AgentList() {
|
|||
};
|
||||
|
||||
const isImageUrl = (url: string) => url?.startsWith('http') || url?.startsWith('/');
|
||||
const getModelLabel = (value: unknown) => {
|
||||
if (Array.isArray(value)) {
|
||||
const names = value
|
||||
.map((item: any) => (typeof item === 'string' ? item : item?.name))
|
||||
.map((v) => String(v || '').trim())
|
||||
.filter(Boolean);
|
||||
return names.join('、');
|
||||
}
|
||||
if (typeof value !== 'string') {
|
||||
return '';
|
||||
}
|
||||
const raw = value.trim();
|
||||
if (!raw) {
|
||||
return '';
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
if (Array.isArray(parsed)) {
|
||||
const names = parsed
|
||||
.map((item: any) => (typeof item === 'string' ? item : item?.name))
|
||||
.map((v) => String(v || '').trim())
|
||||
.filter(Boolean);
|
||||
return names.join('、');
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
if (raw.includes(',')) {
|
||||
return raw
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
.join('、');
|
||||
}
|
||||
return raw;
|
||||
};
|
||||
const publicCount = useMemo(() => list.filter((a) => a.visibility === 'public').length, [list]);
|
||||
const teamCount = useMemo(() => list.filter((a) => a.visibility === 'team').length, [list]);
|
||||
|
||||
|
|
@ -208,10 +243,10 @@ export default function AgentList() {
|
|||
私有
|
||||
</Tag>
|
||||
)}
|
||||
{a.model && (
|
||||
{getModelLabel(a.model) && (
|
||||
<Tag bordered={false} style={{ background: 'var(--color-brand-soft)', color: 'var(--color-brand)', borderRadius: 999, margin: 0, maxWidth: '100%' }}>
|
||||
<span style={{ display: 'inline-block', maxWidth: 190, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{a.model}
|
||||
{getModelLabel(a.model)}
|
||||
</span>
|
||||
</Tag>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue