Add navigation service for centralized login redirect routing

- Simplify token validation logic in API
- Update axios interceptor to use navigation service
This commit is contained in:
yangdx
2025-03-18 19:45:43 +08:00
parent 79b32026ec
commit c42f08c0e6
5 changed files with 51 additions and 41 deletions

View File

@@ -0,0 +1,17 @@
import { NavigateFunction } from 'react-router-dom';
class NavigationService {
private navigate: NavigateFunction | null = null;
setNavigate(navigate: NavigateFunction) {
this.navigate = navigate;
}
navigateToLogin() {
if (this.navigate) {
this.navigate('/login');
}
}
}
export const navigationService = new NavigationService();