fix: show and dismiss teacher introductions as one group
This commit is contained in:
1 parent
a77ddbd681
commit
7458c37fb0
12 files changed
+290
-148
No files matched your search
@@ -19,7 +19,7 @@ export function Layout() {
|
||||
const [refreshStatus, setRefreshStatus] = useState<'idle' | 'success' | 'error'>('idle');
|
||||
const [selected, setSelected] = useState(0);
|
||||
const welcomeMode = new URLSearchParams(location.search).has('welcomes');
|
||||
const [dismissed, setDismissed] = useState<string[]>([]);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
const agents = Array.from({ length: count }, (_, index) => ({
|
||||
teacher_id: `agent-${index}`, version: index + 1, is_default: index === 0,
|
||||
definition: { config_id: `agent-${index}`, name: `智能体${index + 1}`, avatar_id: 'avatar-06',
|
||||
@@ -31,8 +31,8 @@ export function Layout() {
|
||||
definition: agents[selected]?.definition ?? { name: '编程老师', avatar_id: 'avatar-06' },
|
||||
invitation: !welcomeMode && visible ? { response: long ? '你刚才说想做一个宠物游戏。我们一起想想,什么样的小动作,会让你愿意一直陪它玩下去?可以先挑一个最想试的想法。' : '有什么编程问题想一起讨论?' } : null,
|
||||
welcome: null, enabled: true, loading: false, checking: false, error: null,
|
||||
welcomes: welcomeMode && !open ? agents.flatMap((agent, index) => dismissed.includes(agent.teacher_id) ? [] : [{ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index % 3 }]) : [],
|
||||
dismissWelcome: (id: string) => setDismissed(ids => [...new Set([...ids, id])]),
|
||||
welcomes: welcomeMode && !open && !dismissed ? agents.map((agent, index) => ({ agentId: agent.teacher_id, definition: agent.definition, text: agent.definition.description, tone: index % 3 })) : [],
|
||||
dismissWelcomes: () => setDismissed(true),
|
||||
refreshing, refreshStatus,
|
||||
refresh: async () => {
|
||||
setRefreshing(true);
|
||||
|
||||
Reference in new issue
Block a user