feat: add navigation links management and user registration

Features:
- Custom navigation links management in admin settings
- Multi-language support for navigation links (Chinese/English)
- Control link behavior (open in new window)
- Sort order and enable/disable toggle for nav links
- User registration system with validation
- Admin can enable/disable user registration
- Registration form with username, display name, email, password
- Link to registration from login page

Navigation Links:
- Admin interface to add/edit/delete custom nav links
- Support for both internal and external URLs
- Display links in header navigation bar
- Respects language preference

User Registration:
- Username validation (3-32 characters, alphanumeric + underscore/dash)
- Password validation (minimum 6 characters)
- Password confirmation matching
- Optional display name and email fields
- Can be toggled on/off by admin in site settings

Templates:
- Added navigation links settings page
- Added user registration page
- Updated login page with registration link
- Updated base layout to render custom nav links

Documentation:
- NAV_LINKS_FEATURE.md - Navigation links feature documentation
- REGISTRATION_FEATURE.md - User registration documentation
- IMPLEMENTATION_SUMMARY.md - Overall implementation summary

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 21:01:38 +08:00
co-authored by Claude Fable 5
parent 2bdc368399
commit d9bb91af00
18 changed files with 1224 additions and 15 deletions
+13
View File
@@ -17,6 +17,7 @@ var configCache = struct {
comment *CommentConfig
types []UploadFileType
baseURLs []DownloadBaseURL
navLinks []NavLink
}{
site: &SiteSetting{},
upload: &UploadConfig{Enabled: true, DefaultMaxSize: DefaultUploadMaxSize, StorageDir: "attachments"},
@@ -58,6 +59,11 @@ func LoadConfigCache(db *gorm.DB) {
if err := db.Order("is_default desc, priority asc, id asc").Find(&b).Error; err == nil {
configCache.baseURLs = b
}
var n []NavLink
if err := db.Where("enabled = ?", true).Order("sort asc, id asc").Find(&n).Error; err == nil {
configCache.navLinks = n
}
}
// RefreshConfigCache reloads all cached platform configuration. Admin handlers
@@ -118,3 +124,10 @@ func DefaultDownloadBaseURL() string {
}
return ""
}
// GetNavLinks returns the cached list of enabled navigation links, sorted by sort order.
func GetNavLinks() []NavLink {
configCache.mu.RLock()
defer configCache.mu.RUnlock()
return configCache.navLinks
}