fix: create new canvas instead of redirecting when canvas not found
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-01-26 22:17:58 +08:00
parent b936e58637
commit 0c4a2a455e
2 changed files with 17 additions and 15 deletions

View File

@ -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);
};

View File

@ -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>