Skip to content

Commit 8426879

Browse files
author
pengyu
committed
implement toast component
1 parent d7531f9 commit 8426879

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// GlobalToastListener.tsx
2+
'use client';
3+
import { useContext, useEffect } from 'react';
4+
import { toast } from 'sonner'; // 或你使用的 toast 库
5+
import { ProjectContext } from './chat/code-engine/project-context';
6+
7+
const GlobalToastListener = () => {
8+
const { recentlyCompletedProjectId, setRecentlyCompletedProjectId } =
9+
useContext(ProjectContext);
10+
11+
useEffect(() => {
12+
if (recentlyCompletedProjectId) {
13+
toast.success('Project is ready! 🎉');
14+
15+
// 可选:重置,避免重复 toast
16+
setRecentlyCompletedProjectId(null);
17+
}
18+
}, [recentlyCompletedProjectId]);
19+
20+
return null; // 不渲染任何内容,只是监听
21+
};
22+
23+
export default GlobalToastListener;

0 commit comments

Comments
 (0)