Conversation
- 在 ResultCode 中添加 Disabled 状态码 - 在 HTTP 工具类中增加对 Disabled 状态的处理 - 在多语言文件中添加禁用账号的错误信息 - 优化未授权错误的提示信息
📝 WalkthroughWalkthrough本次变更在后端和前端均新增了对“账号被禁用”状态的支持。后端通过在 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
User->>Frontend: 发起请求
Frontend->>Backend: 发送 API 请求
Backend-->>Frontend: 返回结果(含 ResultCode)
alt ResultCode = DISABLED
Frontend->>User: 显示“账号已被禁用”消息
Frontend->>User: 执行登出操作
else ResultCode = UNAUTHORIZED
Frontend->>User: 显示“登录已过期”消息
Frontend->>User: 执行登出操作
else 其他
Frontend->>User: 正常处理响应
end
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
🧰 Additional context used🧬 Code Graph Analysis (2)app/Service/PassportService.php (2)
app/Http/Admin/Middleware/PermissionMiddleware.php (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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
Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (4)
storage/languages/zh_TW/result.php (1)
21-21: 统一翻译条目顺序
建议将'disabled' => '帳號已禁用'的位置与其他语言文件保持一致(建议放在最后),以提高多语言文件的维护可读性和一致性。storage/languages/en/result.php (1)
21-21: 统一翻译条目顺序
建议将'disabled' => 'Account disabled'的位置与其他语言文件保持一致(建议放在最后),以提高多语言文件的维护可读性和一致性。storage/languages/zh_CN/result.php (1)
16-16: 统一翻译条目顺序
在zh_CN文件中,'disabled' => '账号已禁用'被插入到unauthorized和forbidden之间,与其他语言文件不一致,建议将其调整到数组末尾以保持一致性。web/src/utils/http.ts (1)
164-168: 良好实现账号禁用的错误处理代码正确实现了账号禁用状态的处理逻辑,包括显示错误消息和登出用户。建议为这个新增的状态码添加简短注释,说明其用途。
case ResultCode.UNAUTHORIZED: { const logout = async () => { if (isLogout === false) { isLogout = true setTimeout(() => isLogout = false, 5000) Message.error(response?.data?.message ?? '登录已过期', { zIndex: 9999 }) await useUserStore().logout() } } // ... 其他代码 } + // 处理账号被禁用的情况,显示错误消息并登出用户 case ResultCode.Disabled: { Message.error(response?.data?.message ?? '账号已被禁用', {zIndex: 9999}) await useUserStore().logout() break }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
app/Http/Common/ResultCode.php(1 hunks)storage/languages/en/result.php(1 hunks)storage/languages/zh_CN/result.php(1 hunks)storage/languages/zh_TW/result.php(1 hunks)web/src/utils/ResultCode.ts(1 hunks)web/src/utils/http.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (21)
- GitHub Check: Test on PHP8.1 Swoole-master
- GitHub Check: Test on PHP8.2 Swoole-v5.1.5
- GitHub Check: Test on PHP8.3 Swoole-master
- GitHub Check: Test on PHP8.1 Swoole-v5.0.3
- GitHub Check: Test on PHP8.2 Swoole-v5.0.3
- GitHub Check: Test on PHP8.1 Swow-develop
- GitHub Check: Test on PHP8.3 Swow-develop
- GitHub Check: Test on PHP8.2 Swow-develop
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Test on PHP8.2 Swoole-master
- GitHub Check: Test on PHP8.2 Swoole-v5.0.3
- GitHub Check: Test on PHP8.1 Swoole-v5.1.5
- GitHub Check: Test on PHP8.1 Swoole-v5.0.3
- GitHub Check: Test on PHP8.2 Swoole-v5.1.5
- GitHub Check: Test on PHP8.1 Swoole-master
- GitHub Check: Test on PHP8.3 Swoole-master
- GitHub Check: Test on PHP8.3 Swoole-v5.1.5
- GitHub Check: Test on PHP8.2 Swow-develop
- GitHub Check: Test on PHP8.1 Swow-develop
- GitHub Check: Test on PHP8.3 Swow-develop
- GitHub Check: build Code coverage report (ubuntu-latest, 8.1, v5.1.3)
🔇 Additional comments (2)
web/src/utils/http.ts (2)
102-103: 优化了代码结构添加大括号使得
case语句块更加清晰,避免变量作用域混淆,是一个良好的编码实践。
108-108: 支持了错误消息国际化使用
response?.data?.message ?? '登录已过期'替代固定字符串,优先使用服务器返回的消息,这符合国际化要求,同时提供了合理的默认值。
- 在 PassportService 中增加对用户禁用状态的检查 - 更新 ResultCode枚举,将 Disabled 改为大写的 DISABLED - 在 HTTP 工具类中增加对 DISABLED 错误码的处理
- 将错误代码从 ResultCode::FORBIDDEN 更改为 ResultCode::DISABLED - 优化了用户状态检查的异常处理
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #593 +/- ##
=============================
=============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit