-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: when the api returns 401, the page is refreshed not as expected #4440
Conversation
|
WalkthroughThe changes in this pull request primarily focus on enhancing the error handling of the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AuthStore
participant API
User->>AuthStore: Call logout()
AuthStore->>API: await logoutApi()
alt Error Occurs
API-->>AuthStore: Error
AuthStore->>AuthStore: // do nothing
else Success
API-->>AuthStore: Success
end
AuthStore->>AuthStore: resetAllStores()
AuthStore->>AuthStore: setLoginExpired(false)
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Outside diff range and nitpick comments (1)
apps/web-ele/src/store/auth.ts (1)
80-84
: Consider adding error logging or user feedback in the catch block.The try-catch block is a good addition to handle potential errors from the
logoutApi
call and prevent disruptions in the application flow. However, silently catching the error without any logging or user feedback might make it difficult to identify and debug issues related to the logout process.Consider adding error logging or user feedback in the catch block to help identify and debug potential issues with the logout process. For example:
try { await logoutApi(); } catch (error) { - // 不做任何处理 + console.error('Error during logout:', error); + ElNotification({ + message: $t('authentication.logoutError'), + title: $t('authentication.logoutFailed'), + type: 'error', + }); }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- apps/web-antd/src/store/auth.ts (1 hunks)
- apps/web-ele/src/store/auth.ts (1 hunks)
- apps/web-naive/src/store/auth.ts (1 hunks)
- docs/src/components/common-ui/vben-drawer.md (1 hunks)
- docs/src/components/common-ui/vben-modal.md (1 hunks)
- docs/src/components/introduction.md (1 hunks)
- playground/src/store/auth.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- docs/src/components/common-ui/vben-modal.md
- docs/src/components/introduction.md
Additional comments not posted (3)
playground/src/store/auth.ts (1)
80-84
: Verify if the current implementation addresses the specific issue mentioned in the PR objectives.The PR objectives mention fixing the issue of the frontend not being able to handle 401 responses properly, resulting in users having to refresh the page to be redirected to the login page. However, the current implementation does not seem to address this specific issue.
Please ensure that the changes made in this PR effectively handle the 401 response scenario and provide a smooth user experience without requiring a page refresh.
docs/src/components/common-ui/vben-drawer.md (2)
9-9
: Good addition to guide users to online examples.The note helpfully directs users to refer to online examples if parameter descriptions are missing in the documentation. This sets the right expectation that the docs may not be exhaustive while providing an alternative source of information.
11-15
: Excellent framing of the framework's flexibility.The introductory note does a great job of emphasizing the adaptability of the framework's components. By encouraging users to either leverage native components or create custom ones based on their needs, it promotes a flexible and empowering approach. The language used frames the components as enablers of the user's requirements rather than as constraints, which is a very positive message to convey.
Description
fixed #4431
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit