From 9d018aae5cbb3be84d83e5d1617ffbdd9ba9439d Mon Sep 17 00:00:00 2001 From: SHINCHVEN Date: Sat, 19 Nov 2022 15:22:51 +0800 Subject: [PATCH] fix: Hash router was ignored in getInitialState() (#10352) Use `history.location.pathname` instead of `window.location.pathname` to support hash router. --- src/app.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app.tsx b/src/app.tsx index f989ec33..65f1563c 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -33,7 +33,8 @@ export async function getInitialState(): Promise<{ return undefined; }; // 如果不是登录页面,执行 - if (window.location.pathname !== loginPath) { + const { location } = history; + if (location.pathname !== loginPath) { const currentUser = await fetchUserInfo(); return { fetchUserInfo,