Skip to content

Conversation

@zy84338719
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings September 24, 2025 15:37
@zy84338719 zy84338719 merged commit 72ac615 into main Sep 24, 2025
3 checks passed
Copy link

Copilot AI left a 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;
Copy link

Copilot AI Sep 24, 2025

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.

Suggested change
border-radius: 999px;
border-radius: var(--admin-radius-pill);

Copilot uses AI. Check for mistakes.
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;
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
gap: 6px;
padding: 6px 14px;
border-radius: 20px;
border-radius: 999px;
Copy link

Copilot AI Sep 24, 2025

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.

Suggested change
border-radius: 999px;
border-radius: var(--admin-radius-pill);

Copilot uses AI. Check for mistakes.
.file-status {
padding: 2px 8px;
border-radius: 12px;
border-radius: 999px;
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
background: #e9ecef;
border-radius: 12px;
background: var(--admin-chip-bg);
border-radius: 999px;
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
border-color: #495057;
}
}
/* 暗色主题支持通过 admin-theme-dark 变量自动生效 */
Copy link

Copilot AI Sep 24, 2025

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.

Suggested change
/* 暗色主题支持通过 admin-theme-dark 变量自动生效 */
/*
* 暗色主题支持说明:
* 暗色主题的样式现在通过在 admin-modern.css 中定义的 CSS 变量实现,
* 而不是通过媒体查询。只需在根元素上添加 admin-theme-dark 类,
* 即可自动应用暗色主题相关的变量和样式,无需额外的 CSS 代码。
* 这样可以更灵活地管理主题切换,并简化样式维护。
*/

Copilot uses AI. Check for mistakes.
default:
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{
"code": http.StatusForbidden,
"message": "系统已初始化,禁止重新初始化",
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
default:
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{
"code": http.StatusForbidden,
"message": "系统未初始化,请访问 /setup 完成初始化",
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
return
}
if initialized {
common.ForbiddenResponse(c, "系统已初始化,禁止重复初始化")
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
return
}
if initialized {
common.ForbiddenResponse(c, "系统已初始化,禁止重复初始化")
Copy link

Copilot AI Sep 24, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants