refactor(deploy,update): drop standalone edition and add sandbox upgrade confirmation

- Remove standalone Docker edition (Dockerfile.standalone, docker-compose.standalone.yml, release.yml standalone jobs, and dual-edition env/script branches).
- Remove deploy_edition field from /api/update/check and dual-edition UI/i18n branching in UpdateCard.
- Replace window.confirm on upgrade with AlertDialog informing users of the irreversible Standalone -> Sandbox security upgrade.
This commit is contained in:
ji ruo committed 2026-12-04 15:14:06 +08:00
1 parent 8efd26b8b7
commit f5b446e3bf
15 files changed
+330 -944

No files matched your search

+8 -14
View File
@@ -11,7 +11,6 @@ import (
"sync"
"time"
"github.com/Autumn-27/artex/internal/sandbox"
"github.com/Autumn-27/artex/selfupdate"
)
@@ -215,21 +214,16 @@ func (s *Server) updateCheck(w http.ResponseWriter, r *http.Request) {
if selfupdate.InDocker() {
mode = "docker"
}
deployEdition := "standalone"
if mgr := sandbox.Default(); mgr != nil && mgr.Enabled() {
deployEdition = "sandbox"
}
boot := bootUpdateState()
out := map[string]any{
"current": current,
"mode": mode,
"deploy_edition": deployEdition,
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"has_backup": selfupdate.HasBackup(),
"repo": selfupdate.Repo,
"boot_notice": boot.Detail,
"rolled_back": boot.RolledBack,
"current": current,
"mode": mode,
"os": runtime.GOOS,
"arch": runtime.GOARCH,
"has_backup": selfupdate.HasBackup(),
"repo": selfupdate.Repo,
"boot_notice": boot.Detail,
"rolled_back": boot.RolledBack,
}
// 顶栏提示走缓存(默认);用户点"检查更新"时带 force=1 强制回源。
-65
View File
@@ -2,14 +2,11 @@ package server
import (
"context"
"encoding/json"
"errors"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/Autumn-27/artex/internal/sandbox"
"github.com/Autumn-27/artex/selfupdate"
)
@@ -199,65 +196,3 @@ func TestUpdateSettingsValidation(t *testing.T) {
}
}
}
func TestUpdateCheckReportsDeployEdition(t *testing.T) {
origMgr := sandbox.Default()
origFetch := relCache.fetch
t.Cleanup(func() {
sandbox.SetDefault(origMgr)
relCache.mu.Lock()
relCache.fetch = origFetch
relCache.at = time.Time{}
relCache.mu.Unlock()
})
relCache.mu.Lock()
relCache.fetch = func(context.Context, *http.Client) (*selfupdate.Release, error) {
return &selfupdate.Release{TagName: "v0.3.33"}, nil
}
relCache.at = time.Time{}
relCache.mu.Unlock()
s := &Server{m: &Manager{}}
// Local/standalone mode
localMgr, err := sandbox.New(sandbox.Config{Mode: sandbox.ModeLocal, DataDir: t.TempDir()})
if err != nil {
t.Fatalf("sandbox.New local: %v", err)
}
sandbox.SetDefault(localMgr)
rec := httptest.NewRecorder()
s.updateCheck(rec, httptest.NewRequest(http.MethodGet, "/api/update/check", nil))
if rec.Code != http.StatusOK {
t.Fatalf("updateCheck local status=%d body=%s", rec.Code, rec.Body.String())
}
var resp map[string]any
if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
t.Fatalf("decode local resp: %v", err)
}
if resp["deploy_edition"] != "standalone" {
t.Fatalf("expected deploy_edition=standalone, got %v", resp["deploy_edition"])
}
// Docker sandbox mode
dockerMgr, err := sandbox.New(sandbox.Config{
Mode: sandbox.ModeDocker,
DockerHost: "http://127.0.0.1:2375",
DataDir: t.TempDir(),
})
if err != nil {
t.Fatalf("sandbox.New docker: %v", err)
}
sandbox.SetDefault(dockerMgr)
rec2 := httptest.NewRecorder()
s.updateCheck(rec2, httptest.NewRequest(http.MethodGet, "/api/update/check", nil))
if rec2.Code != http.StatusOK {
t.Fatalf("updateCheck docker status=%d body=%s", rec2.Code, rec2.Body.String())
}
var resp2 map[string]any
if err := json.Unmarshal(rec2.Body.Bytes(), &resp2); err != nil {
t.Fatalf("decode docker resp: %v", err)
}
if resp2["deploy_edition"] != "sandbox" {
t.Fatalf("expected deploy_edition=sandbox, got %v", resp2["deploy_edition"])
}
}