feat(settings): add settings management API endpoints

- Add GET /settings/get and POST /settings/set endpoints for managing system settings
- Implement config file persistence for settings changes
- Update config schema to include notification and webhook settings
- Add API documentation for new endpoints
- Move config path variables to global package for consistency
This commit is contained in:
2026-04-23 12:43:11 +08:00
parent 489c37e095
commit ac51641e93
6 changed files with 303 additions and 16 deletions

View File

@@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"super-frpc/global"
"super-frpc/postLog"
"github.com/BurntSushi/toml"
)
@@ -94,6 +95,8 @@ func LoadConfig(configPath string, getInitSystem func() string) error {
return fmt.Errorf("failed to create config directory: %w", err)
}
postLog.Debug(fmt.Sprintf("Loaded config: %v", global.CurrentConfig))
return nil
}
@@ -101,13 +104,13 @@ func GetConfig() *global.Config {
return &global.CurrentConfig
}
func SaveConfig(configPath string) error {
func SaveConfig() error {
data, err := json.MarshalIndent(global.CurrentConfig, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal config: %w", err)
}
if err := os.WriteFile(configPath, data, 0644); err != nil {
if err := os.WriteFile(*global.ConfigPath, data, 0644); err != nil {
return fmt.Errorf("failed to write config file: %w", err)
}