platform: modularize api/gui, add docs-tests-web foundation, and refresh root config

This commit is contained in:
beckline
2026-03-26 22:40:54 +03:00
parent 0e2d7f61ea
commit 6a56d734c2
562 changed files with 70151 additions and 16423 deletions

View File

@@ -0,0 +1,42 @@
package app
import (
"encoding/json"
"os"
"path/filepath"
"time"
)
func loadSingBoxProfilesState() singBoxProfilesState {
st := singBoxProfilesState{
Version: singBoxProfilesStateVersion,
Revision: 0,
}
data, err := os.ReadFile(singBoxProfilesStatePath)
if err != nil {
return st
}
if err := json.Unmarshal(data, &st); err != nil {
return singBoxProfilesState{Version: singBoxProfilesStateVersion, Revision: 0}
}
return normalizeSingBoxProfilesState(st)
}
func saveSingBoxProfilesState(st singBoxProfilesState) error {
st = normalizeSingBoxProfilesState(st)
st.Version = singBoxProfilesStateVersion
st.UpdatedAt = time.Now().UTC().Format(time.RFC3339)
data, err := json.MarshalIndent(st, "", " ")
if err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(singBoxProfilesStatePath), 0o755); err != nil {
return err
}
tmp := singBoxProfilesStatePath + ".tmp"
if err := os.WriteFile(tmp, data, 0o644); err != nil {
return err
}
return os.Rename(tmp, singBoxProfilesStatePath)
}