diff --git a/components/canvas/CanvasFileList.tsx b/components/canvas/CanvasFileList.tsx index ca17f4b..689ea52 100644 --- a/components/canvas/CanvasFileList.tsx +++ b/components/canvas/CanvasFileList.tsx @@ -64,9 +64,13 @@ export function CanvasFileList({ open, onOpenChange, currentId }: CanvasFileList onOpenChange(false); return; } + // 先导航,再关闭弹窗(使用 setTimeout 确保导航生效) + const targetUrl = `/canvas/${id}`; onOpenChange(false); - // 使用完整的 URL 导航确保页面重新加载 - window.location.href = `/canvas/${id}`; + // 使用 setTimeout 确保在 React 状态更新完成后再导航 + setTimeout(() => { + window.location.assign(targetUrl); + }, 100); }; // 删除画布