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

@@ -61,13 +61,28 @@ class NavigationService {
* @param skipReset whether to skip state reset (used for direct access scenario where reset is already handled)
*/
navigateToLogin() {
this.resetAllApplicationState();
useAuthStore.getState().logout();
if (this.navigate) {
this.navigate('/login');
if (!this.navigate) {
console.error('Navigation function not set');
return;
}
// First navigate to login page
this.navigate('/login');
// Then reset state after navigation
setTimeout(() => {
this.resetAllApplicationState();
useAuthStore.getState().logout();
}, 0);
}
navigateToHome() {
if (!this.navigate) {
console.error('Navigation function not set');
return;
}
this.navigate('/');
}
}