-
Notifications
You must be signed in to change notification settings - Fork 2
Enforce setup gating and align admin UI theme #12
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
Conversation
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.
Pull Request Overview
This PR enforces setup gating to prevent re-initialization of an already configured system and aligns the admin UI theme with CSS variable-based theming for better consistency and maintainability.
- Adds setup guard middleware to control access before/after initialization
- Implements comprehensive CSS variable-based theming for admin components
- Prevents duplicate initialization attempts through proper state validation
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/middleware/setup_guard.go | New middleware for enforcing setup access control with configurable paths |
| internal/routes/setup.go | Integrates setup guard middleware with cached initialization checking |
| internal/handlers/setup.go | Adds initialization state validation to prevent duplicate setup |
| themes/2025/admin/css/admin-modern.css | Extends CSS variable system with additional theme tokens and shared components |
| themes/2025/admin/css/users.css | Migrates hardcoded styles to CSS variables for consistent theming |
| themes/2025/admin/css/pagination.css | Updates pagination styling to use theme variables |
| themes/2025/admin/css/files.css | Converts file management UI to variable-based theming |
| background: linear-gradient(135deg, #667eea, #764ba2); | ||
| border-radius: 2px; | ||
| background: linear-gradient(135deg, var(--admin-nav-active-start), var(--admin-nav-active-end)); | ||
| border-radius: 999px; |
Copilot
AI
Sep 24, 2025
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.
The hardcoded 999px border-radius should use the CSS variable --admin-radius-pill or similar for consistency with the design system. Consider adding this variable to admin-modern.css if it doesn't exist.
| border-radius: 999px; | |
| border-radius: var(--admin-radius-pill); |
| background: linear-gradient(135deg, #667eea, #764ba2); | ||
| border-radius: 2px; | ||
| background: linear-gradient(135deg, var(--admin-nav-active-start), var(--admin-nav-active-end)); | ||
| border-radius: 999px; |
Copilot
AI
Sep 24, 2025
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.
Multiple instances of hardcoded 999px border-radius should be replaced with a consistent CSS variable like --admin-radius-pill to maintain design system consistency.
| gap: 6px; | ||
| padding: 6px 14px; | ||
| border-radius: 20px; | ||
| border-radius: 999px; |
Copilot
AI
Sep 24, 2025
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.
Multiple instances of hardcoded 999px border-radius should be replaced with a consistent CSS variable like --admin-radius-pill to maintain design system consistency.
| border-radius: 999px; | |
| border-radius: var(--admin-radius-pill); |
| .file-status { | ||
| padding: 2px 8px; | ||
| border-radius: 12px; | ||
| border-radius: 999px; |
Copilot
AI
Sep 24, 2025
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.
The hardcoded 999px border-radius values should use a CSS variable like --admin-radius-pill for consistency with the design system approach used throughout the rest of the file.
| background: #e9ecef; | ||
| border-radius: 12px; | ||
| background: var(--admin-chip-bg); | ||
| border-radius: 999px; |
Copilot
AI
Sep 24, 2025
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.
The hardcoded 999px border-radius values should use a CSS variable like --admin-radius-pill for consistency with the design system approach used throughout the rest of the file.
| border-color: #495057; | ||
| } | ||
| } | ||
| /* 暗色主题支持通过 admin-theme-dark 变量自动生效 */ |
Copilot
AI
Sep 24, 2025
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.
[nitpick] The comment should be more descriptive about how the dark theme support works. Consider expanding it to explain that dark theme styles are now handled through CSS variables defined in admin-modern.css rather than media queries.
| /* 暗色主题支持通过 admin-theme-dark 变量自动生效 */ | |
| /* | |
| * 暗色主题支持说明: | |
| * 暗色主题的样式现在通过在 admin-modern.css 中定义的 CSS 变量实现, | |
| * 而不是通过媒体查询。只需在根元素上添加 admin-theme-dark 类, | |
| * 即可自动应用暗色主题相关的变量和样式,无需额外的 CSS 代码。 | |
| * 这样可以更灵活地管理主题切换,并简化样式维护。 | |
| */ |
| default: | ||
| c.AbortWithStatusJSON(http.StatusForbidden, gin.H{ | ||
| "code": http.StatusForbidden, | ||
| "message": "系统已初始化,禁止重新初始化", |
Copilot
AI
Sep 24, 2025
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.
Hard-coded Chinese error messages should be externalized to a localization system or constants file for better maintainability and internationalization support.
| default: | ||
| c.AbortWithStatusJSON(http.StatusForbidden, gin.H{ | ||
| "code": http.StatusForbidden, | ||
| "message": "系统未初始化,请访问 /setup 完成初始化", |
Copilot
AI
Sep 24, 2025
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.
Hard-coded Chinese error messages should be externalized to a localization system or constants file for better maintainability and internationalization support.
| return | ||
| } | ||
| if initialized { | ||
| common.ForbiddenResponse(c, "系统已初始化,禁止重复初始化") |
Copilot
AI
Sep 24, 2025
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.
The duplicate Chinese error message should be extracted to a constant to avoid repetition and facilitate easier maintenance and localization.
| return | ||
| } | ||
| if initialized { | ||
| common.ForbiddenResponse(c, "系统已初始化,禁止重复初始化") |
Copilot
AI
Sep 24, 2025
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.
The duplicate Chinese error message should be extracted to a constant to avoid repetition and facilitate easier maintenance and localization.
No description provided.