Refactor navigation and authentication flow

- Move navigation setup to AppRouter
- Prevent protected route logic to handle login 401
This commit is contained in:
yangdx
2025-03-19 19:08:09 +08:00
parent 0339273fe9
commit 99814b57d9
5 changed files with 75 additions and 46 deletions

View File

@@ -173,9 +173,12 @@ axiosInstance.interceptors.response.use(
(error: AxiosError) => {
if (error.response) {
if (error.response?.status === 401) {
// Use navigation service to handle redirection
// For login API, throw error directly
if (error.config?.url?.includes('/login')) {
throw error;
}
// For other APIs, navigate to login page
navigationService.navigateToLogin();
// Return a never-resolving promise to prevent further execution
return new Promise(() => {});
}