Browse Source

fix: preserve original URL when redirecting to login (#11722)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
pull/11724/head
Alex Zhu 4 weeks ago
committed by GitHub
parent
commit
53de59ea35
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      src/app.tsx

9
src/app.tsx

@ -35,7 +35,10 @@ export async function getInitialState(): Promise<{
});
return msg.data;
} catch (_error) {
history.push(loginPath);
const { pathname, search, hash } = history.location;
history.replace(
`${loginPath}?redirect=${encodeURIComponent(pathname + search + hash)}`,
);
}
return undefined;
};
@ -92,7 +95,9 @@ export const layout: RunTimeLayoutConfig = ({
const { location } = history;
// 如果没有登录,重定向到 login
if (!initialState?.currentUser && location.pathname !== loginPath) {
history.push(loginPath);
history.replace(
`${loginPath}?redirect=${encodeURIComponent(location.pathname + location.search + location.hash)}`,
);
}
},
bgLayoutImgList: [

Loading…
Cancel
Save