kra/web/src/pages/error/reload.tsx

37 lines
859 B
TypeScript

/**
* KRA - Reload Page
* Used for route refresh without full page reload
*/
import React, { useEffect } from 'react';
import { Spin } from 'antd';
import { history, useLocation } from '@umijs/max';
const ReloadPage: React.FC = () => {
const location = useLocation();
useEffect(() => {
const params = new URLSearchParams(location.search);
const redirect = params.get('redirect') || '/';
// Small delay to ensure the route change is processed
const timer = setTimeout(() => {
history.replace(redirect);
}, 100);
return () => clearTimeout(timer);
}, [location.search]);
return (
<div style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '100vh',
}}>
<Spin size="large" tip="页面刷新中..." />
</div>
);
};
export default ReloadPage;