fix(个人主页): 退出按钮返回进入前页面而非首页

iframe沙箱隔离保证父页面history不被污染,history.back()可安全回到进入前页面;无历史时fallback到首页
This commit is contained in:
Pine
2026-09-05 00:04:20 +08:00
parent fb4af3b304
commit 3ce364c29c
@@ -122,12 +122,14 @@ export default function UserHomePage() {
}, [load]);
const handleClose = useCallback(() => {
// 直接退出:OS 桌面关闭窗口;浏览器直接回首页,忽略 iframe 内部任何导航/历史状态
// 退出:OS 桌面关闭窗口;浏览器返回进入前的页面
// iframe 纯沙箱隔离(无 allow-top-navigation),父页面 history 不会被内部导航污染,back 安全。
if (isOsPath(window.location.pathname)) {
close(HOME_ROUTE_ID);
return;
}
window.location.replace("/");
if (window.history.length > 1) window.history.back();
else window.location.replace("/");
}, [close]);
/** 打开编辑弹窗,回填当前页(仅本人;无页时按新建处理)。 */