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,63 @@
package app
import (
"net/http"
"strings"
)
func handleTransportSingBoxProfileCardDelete(w http.ResponseWriter, r *http.Request, id string) {
baseRevision, err := parseOptionalInt64(strings.TrimSpace(r.URL.Query().Get("base_revision")))
if err != nil {
writeJSON(w, http.StatusBadRequest, SingBoxProfilesResponse{
OK: false,
Code: singBoxProfileCodeBadBaseRevision,
Message: "invalid base_revision",
})
return
}
singBoxProfilesMu.Lock()
defer singBoxProfilesMu.Unlock()
st := loadSingBoxProfilesState()
idx := findSingBoxProfileIndex(st.Items, id)
if idx < 0 {
writeJSON(w, http.StatusNotFound, SingBoxProfilesResponse{
OK: false,
Code: singBoxProfileCodeNotFound,
Message: "not found",
})
return
}
cur := st.Items[idx]
if baseRevision > 0 && baseRevision != cur.ProfileRevision {
writeJSON(w, http.StatusConflict, SingBoxProfilesResponse{
OK: false,
Code: singBoxProfileCodeRevisionMismatch,
Message: "base_revision mismatch",
Item: &cur,
})
return
}
st.Items = append(st.Items[:idx], st.Items[idx+1:]...)
ensureSingBoxProfilesActiveID(&st)
st.Revision++
if err := saveSingBoxProfilesState(st); err != nil {
writeJSON(w, http.StatusInternalServerError, SingBoxProfilesResponse{
OK: false,
Code: singBoxProfileCodeSaveFailed,
Message: "save failed: " + err.Error(),
})
return
}
_ = writeSingBoxSecrets(id, nil)
events.push("singbox_profile_saved", map[string]any{
"id": id,
"deleted": true,
})
writeJSON(w, http.StatusOK, SingBoxProfilesResponse{
OK: true,
Message: "deleted",
ActiveProfileID: st.ActiveProfileID,
})
}