fix: 使用 setTimeout 确保画布切换导航生效

This commit is contained in:
Your Name 2026-02-02 13:21:57 +08:00
parent 0369bc361d
commit 83737c7b9c

View File

@ -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);
};
// 删除画布