feat: 添加简单模式功能
新增简单模式设置,适合个人使用场景: - 隐藏多用户管理相关菜单(用户管理、兑换码等) - 自动关闭用户注册功能 - 管理员并发数自动设为无限制(99999) - 侧边栏根据模式动态调整菜单项 同时优化分组页面的"专属分组"功能,添加帮助提示说明使用场景
This commit is contained in:
@@ -90,6 +90,9 @@ const (
|
||||
|
||||
// 管理员 API Key
|
||||
SettingKeyAdminApiKey = "admin_api_key" // 全局管理员 API Key(用于外部系统集成)
|
||||
|
||||
// 使用模式
|
||||
SettingKeySimpleMode = "simple_mode" // 简单模式(隐藏多用户管理功能)
|
||||
)
|
||||
|
||||
// Admin API Key prefix (distinct from user "sk-" keys)
|
||||
|
||||
@@ -64,6 +64,7 @@ func (s *SettingService) GetPublicSettings(ctx context.Context) (*PublicSettings
|
||||
SettingKeyApiBaseUrl,
|
||||
SettingKeyContactInfo,
|
||||
SettingKeyDocUrl,
|
||||
SettingKeySimpleMode,
|
||||
}
|
||||
|
||||
settings, err := s.settingRepo.GetMultiple(ctx, keys)
|
||||
@@ -82,6 +83,7 @@ func (s *SettingService) GetPublicSettings(ctx context.Context) (*PublicSettings
|
||||
ApiBaseUrl: settings[SettingKeyApiBaseUrl],
|
||||
ContactInfo: settings[SettingKeyContactInfo],
|
||||
DocUrl: settings[SettingKeyDocUrl],
|
||||
SimpleMode: settings[SettingKeySimpleMode] == "true",
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -123,6 +125,9 @@ func (s *SettingService) UpdateSettings(ctx context.Context, settings *SystemSet
|
||||
updates[SettingKeyDefaultConcurrency] = strconv.Itoa(settings.DefaultConcurrency)
|
||||
updates[SettingKeyDefaultBalance] = strconv.FormatFloat(settings.DefaultBalance, 'f', 8, 64)
|
||||
|
||||
// 使用模式
|
||||
updates[SettingKeySimpleMode] = strconv.FormatBool(settings.SimpleMode)
|
||||
|
||||
return s.settingRepo.SetMultiple(ctx, updates)
|
||||
}
|
||||
|
||||
@@ -223,6 +228,7 @@ func (s *SettingService) parseSettings(settings map[string]string) *SystemSettin
|
||||
ApiBaseUrl: settings[SettingKeyApiBaseUrl],
|
||||
ContactInfo: settings[SettingKeyContactInfo],
|
||||
DocUrl: settings[SettingKeyDocUrl],
|
||||
SimpleMode: settings[SettingKeySimpleMode] == "true",
|
||||
}
|
||||
|
||||
// 解析整数类型
|
||||
|
||||
@@ -25,6 +25,8 @@ type SystemSettings struct {
|
||||
|
||||
DefaultConcurrency int
|
||||
DefaultBalance float64
|
||||
|
||||
SimpleMode bool // 简单模式
|
||||
}
|
||||
|
||||
type PublicSettings struct {
|
||||
@@ -39,4 +41,5 @@ type PublicSettings struct {
|
||||
ContactInfo string
|
||||
DocUrl string
|
||||
Version string
|
||||
SimpleMode bool // 简单模式
|
||||
}
|
||||
|
||||
@@ -164,6 +164,14 @@ func (s *UserService) UpdateBalance(ctx context.Context, userID int64, amount fl
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateConcurrency 更新用户并发数(管理员功能)
|
||||
func (s *UserService) UpdateConcurrency(ctx context.Context, userID int64, concurrency int) error {
|
||||
if err := s.userRepo.UpdateConcurrency(ctx, userID, concurrency); err != nil {
|
||||
return fmt.Errorf("update concurrency: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateStatus 更新用户状态(管理员功能)
|
||||
func (s *UserService) UpdateStatus(ctx context.Context, userID int64, status string) error {
|
||||
user, err := s.userRepo.GetByID(ctx, userID)
|
||||
|
||||
Reference in New Issue
Block a user