fix: create new canvas instead of redirecting when canvas not found
This commit is contained in:
parent
b936e58637
commit
0c4a2a455e
@ -142,8 +142,15 @@ export default function CanvasEditorPage({ params }: PageProps) {
|
||||
loadCanvas(result.data.canvasData);
|
||||
}
|
||||
} else {
|
||||
toast.error(result.error || "加载画布失败");
|
||||
router.push("/canvas");
|
||||
// 画布不存在时,创建一个新画布
|
||||
console.log('画布不存在,创建新画布:', id);
|
||||
setProject(id, '未命名画布');
|
||||
// 保存新画布到数据库
|
||||
try {
|
||||
await canvasService.saveCanvasState(id, { nodes: [], connections: [] });
|
||||
} catch (error) {
|
||||
console.error('创建新画布失败:', error);
|
||||
}
|
||||
}
|
||||
setIsLoading(false);
|
||||
};
|
||||
|
||||
@ -327,27 +327,22 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8 rounded-full hover:bg-muted">
|
||||
<Share2 className="h-4 w-4" />
|
||||
</Button>
|
||||
<button
|
||||
type="button"
|
||||
className="h-10 w-10 rounded-full inline-flex items-center justify-center bg-red-500 text-white border-4 border-yellow-400 animate-pulse relative z-[9999]"
|
||||
onMouseDown={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
alert('🎯 MouseDown! onOpenFileList: ' + !!onOpenFileList);
|
||||
}}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 rounded-full hover:bg-muted"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
alert('🎯 Click! onOpenFileList: ' + !!onOpenFileList);
|
||||
console.log('[CanvasChatPanel] File list button clicked, onOpenFileList:', !!onOpenFileList);
|
||||
console.log('[CanvasChatPanel] File list button clicked');
|
||||
if (onOpenFileList) {
|
||||
onOpenFileList();
|
||||
}
|
||||
}}
|
||||
title="文件列表按钮 - 点我切换到文件列表"
|
||||
title="已生成文件列表"
|
||||
>
|
||||
<LayoutGrid className="h-5 w-5" />
|
||||
</button>
|
||||
<LayoutGrid className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" className="h-8 w-8 rounded-full hover:bg-muted">
|
||||
<Maximize2 className="h-4 w-4" />
|
||||
</Button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user