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);
|
loadCanvas(result.data.canvasData);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
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">
|
<Button variant="ghost" size="icon" className="h-8 w-8 rounded-full hover:bg-muted">
|
||||||
<Share2 className="h-4 w-4" />
|
<Share2 className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<button
|
<Button
|
||||||
type="button"
|
variant="ghost"
|
||||||
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]"
|
size="icon"
|
||||||
onMouseDown={(e) => {
|
className="h-8 w-8 rounded-full hover:bg-muted"
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
alert('🎯 MouseDown! onOpenFileList: ' + !!onOpenFileList);
|
|
||||||
}}
|
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
alert('🎯 Click! onOpenFileList: ' + !!onOpenFileList);
|
console.log('[CanvasChatPanel] File list button clicked');
|
||||||
console.log('[CanvasChatPanel] File list button clicked, onOpenFileList:', !!onOpenFileList);
|
|
||||||
if (onOpenFileList) {
|
if (onOpenFileList) {
|
||||||
onOpenFileList();
|
onOpenFileList();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
title="文件列表按钮 - 点我切换到文件列表"
|
title="已生成文件列表"
|
||||||
>
|
>
|
||||||
<LayoutGrid className="h-5 w-5" />
|
<LayoutGrid className="h-4 w-4" />
|
||||||
</button>
|
</Button>
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8 rounded-full hover:bg-muted">
|
<Button variant="ghost" size="icon" className="h-8 w-8 rounded-full hover:bg-muted">
|
||||||
<Maximize2 className="h-4 w-4" />
|
<Maximize2 className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user