feat(orbitviewer): add satellite orbit viewer with 2D track, 10-day pass prediction, and AR sky view
Build and Push Docker Image / build (push) Successful in 2m31s

This commit is contained in:
2026-09-23 00:06:01 -07:00
parent c4caed6569
commit fa3dc66278
17 changed files with 4381 additions and 95 deletions
+63
View File
@@ -4,11 +4,17 @@ import (
"bytes"
"encoding/json"
"fmt"
"html/template"
"io/fs"
"net/http"
"net/http/httptest"
"os"
"os/exec"
"testing"
"time"
"toolbox/pkg/base"
"github.com/gin-gonic/gin"
)
const (
@@ -16,6 +22,63 @@ const (
baseURL = "http://localhost:" + testPort
)
func TestOrbitViewerTemplatesAndRoutes(t *testing.T) {
gin.SetMode(gin.TestMode)
r := gin.New()
for id, tool := range base.Registry {
if err := tool.Init(); err != nil {
t.Fatalf("Failed to initialize tool %s: %v", id, err)
}
tool.RegisterRoutes(r.Group("/api/" + id))
}
subFS, err := fs.Sub(webFS, "web")
if err != nil {
t.Fatalf("Failed to fs.Sub: %v", err)
}
tmpl, err := template.ParseFS(subFS, "layout.html", "index.html", "tools/*.html")
if err != nil {
t.Fatalf("Failed to parse templates: %v", err)
}
serveIndex := func(c *gin.Context) {
data := gin.H{
"Title": "测试",
"Description": "描述",
"Keywords": "关键词",
"CanonicalURL": "https://toolbox.pengzhan.dev/orbit-viewer",
"GA_ID": "",
}
var buf bytes.Buffer
if err := tmpl.ExecuteTemplate(&buf, "layout.html", data); err != nil {
c.String(http.StatusInternalServerError, "Template error: %v", err)
return
}
c.Data(http.StatusOK, "text/html; charset=utf-8", buf.Bytes())
}
r.GET("/orbit-viewer", serveIndex)
// Test GET /orbit-viewer
req, _ := http.NewRequest("GET", "/orbit-viewer", nil)
w := httptest.NewRecorder()
r.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("Expected status 200 for /orbit-viewer, got %d: %s", w.Code, w.Body.String())
}
bodyStr := w.Body.String()
if !bytes.Contains([]byte(bodyStr), []byte("panel-orbit-viewer")) {
t.Errorf("Expected body to contain panel-orbit-viewer")
}
if !bytes.Contains([]byte(bodyStr), []byte("阶段一:卫星轨道与全球投影轨迹")) {
t.Errorf("Expected body to contain orbit viewer content")
}
}
func TestToolboxE2E(t *testing.T) {
// 1. Build the binary
fmt.Println("--- Step 1: Building binary... ---")