feat(system/client): 添加双token认证配置#85
Conversation
📝 WalkthroughWalkthrough此PR向客户端配置系统添加了刷新令牌功能支持,包括类型定义扩展、表单字段添加、详情页面显示和列表列配置更新。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/views/system/config/client/DetailDrawer.vue (2)
17-17: 建议为refreshTokenTimeout补充单位并处理特殊值语义。
- 同一字段在
index.vue表格列中以${refreshTokenTimeout} 秒形式渲染(见src/views/system/config/client/index.vueLine 153),此处直接输出数字会造成跨页面展示格式不一致。AddModal.vue的 tooltip 明确写到 “小于0,则和 Token 有效期相同”(Line 138)。若后端可能持久化负值,直接显示-1等原始数字对用户不友好,建议与录入端语义保持一致。♻️ 建议修改
- <a-descriptions-item label="Refresh Token 有效期">{{ dataDetail?.refreshTokenTimeout }}</a-descriptions-item> + <a-descriptions-item label="Refresh Token 有效期"> + {{ (dataDetail?.refreshTokenTimeout ?? 0) < 0 ? '与 Token 有效期一致' : `${dataDetail?.refreshTokenTimeout} 秒` }} + </a-descriptions-item>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/views/system/config/client/DetailDrawer.vue` at line 17, The DetailDrawer.vue currently renders refreshTokenTimeout as a raw number; make it consistent with index.vue and AddModal.vue by appending the unit ("秒") when the value is non-negative and mapping special/negative values to the same semantic text used in AddModal (e.g., display "与 Token 有效期相同" or an equivalent label when refreshTokenTimeout < 0). Update the rendering logic in DetailDrawer.vue (the a-descriptions-item for refreshTokenTimeout) to check dataDetail?.refreshTokenTimeout, format non-negative numbers as `${value} 秒`, and render the semantic string for negative values to match AddModal.vue and index.vue behavior.
16-16: 文案一致性建议。
AddModal.vue中对应表单项 label 为 “是否启用Refresh Token”(Line 124),而此处及index.vue列标题为 “启用Refresh Token”。三处展示同一字段,建议统一措辞以减少认知负担。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/views/system/config/client/DetailDrawer.vue` at line 16, The labels for the same field are inconsistent across components: update the label in DetailDrawer.vue's a-descriptions-item (currently "启用Refresh Token") to match AddModal.vue's "是否启用Refresh Token" and also update the corresponding column title in index.vue so all three places use the identical phrasing; locate the template element <a-descriptions-item label="启用Refresh Token"> in DetailDrawer.vue and the column definition in index.vue and replace their label/title text with "是否启用Refresh Token" to ensure consistent wording.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/views/system/config/client/AddModal.vue`:
- Around line 123-155: The refreshTokenTimeout field must be tied to the
isEnableRefreshToken switch and have proper value validation: add disabled: ()
=> !formModel.isEnableRefreshToken (same pattern as replacedRange/maxLoginCount)
so the input is readonly/disabled when isEnableRefreshToken is false, and update
its rules to include a validator (like maxLoginCount's validator) that enforces
an integer value and disallows 0 (allow negatives per the tooltip for "less than
0 means same as Token timeout") and set props.min to -Infinity or a sensible min
(e.g. -1) to prevent invalid positives; also ensure the submit path
(addClient/updateClient) does not send refreshTokenTimeout when
isEnableRefreshToken is false (clear or omit the field before sending).
In `@src/views/system/config/client/index.vue`:
- Around line 152-153: Update the two column render functions for
isEnableRefreshToken and refreshTokenTimeout: for the isEnableRefreshToken
column (render for record.isEnableRefreshToken) return the boolean ternary
directly (record.isEnableRefreshToken ? '是' : '否') instead of wrapping in a
template string; for the refreshTokenTimeout column, if
record.isEnableRefreshToken is false return an empty string or a placeholder
(e.g. '-') and otherwise render a semantic label when record.refreshTokenTimeout
< 0 (e.g. '与 Token 有效期一致') instead of showing raw '-1 秒', otherwise render
`${record.refreshTokenTimeout} 秒`; ensure these changes are applied to the
column render functions in index.vue and align them with the AddModal.vue
semantics.
---
Nitpick comments:
In `@src/views/system/config/client/DetailDrawer.vue`:
- Line 17: The DetailDrawer.vue currently renders refreshTokenTimeout as a raw
number; make it consistent with index.vue and AddModal.vue by appending the unit
("秒") when the value is non-negative and mapping special/negative values to the
same semantic text used in AddModal (e.g., display "与 Token 有效期相同" or an
equivalent label when refreshTokenTimeout < 0). Update the rendering logic in
DetailDrawer.vue (the a-descriptions-item for refreshTokenTimeout) to check
dataDetail?.refreshTokenTimeout, format non-negative numbers as `${value} 秒`,
and render the semantic string for negative values to match AddModal.vue and
index.vue behavior.
- Line 16: The labels for the same field are inconsistent across components:
update the label in DetailDrawer.vue's a-descriptions-item (currently "启用Refresh
Token") to match AddModal.vue's "是否启用Refresh Token" and also update the
corresponding column title in index.vue so all three places use the identical
phrasing; locate the template element <a-descriptions-item label="启用Refresh
Token"> in DetailDrawer.vue and the column definition in index.vue and replace
their label/title text with "是否启用Refresh Token" to ensure consistent wording.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3bbff9a4-9c91-41f3-a809-cfd060fcdab8
📒 Files selected for processing (4)
src/apis/system/type.tssrc/views/system/config/client/AddModal.vuesrc/views/system/config/client/DetailDrawer.vuesrc/views/system/config/client/index.vue
5f065bf to
2861b5d
Compare
2861b5d to
c4440b3
Compare
PR 类型
PR 目的
解决方案
PR 测试
Changelog
其他信息
提交前确认
Summary by CodeRabbit
发布说明