优化
This commit is contained in:
truewhile
2026-08-24 17:40:43 +08:00
parent 99ef2ed410
commit 44ca451cd4
374 changed files with 1029 additions and 1028 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"sync"
"time"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MMTL/internal/config"
)
const defaultLogMaxSizeMB = 20
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MMTL/internal/config"
)
// newLogger 根据 cfg.Logging 构建 Zap。
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"go.uber.org/zap"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MMTL/internal/config"
)
func TestProductionLoggerWritesConfiguredInfoToAppLogAndSplitsWarnError(t *testing.T) {
+7 -7
View File
@@ -1,6 +1,6 @@
// Package main is the MediaStationGo HTTP server entry point.
// Package main is the MMTL HTTP server entry point.
//
// MediaStationGo is a Go rewrite of the legacy Python implementation,
// MMTL is a Go rewrite of the legacy Python implementation,
// adopting the same tech stack as cropflre/nowen-video:
//
// Backend: Go 1.25 + Gin + GORM + PostgreSQL/SQLite + Viper + Zap + JWT
@@ -24,10 +24,10 @@ import (
"go.uber.org/zap"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MediaStationGo/internal/database"
"github.com/ShukeBta/MediaStationGo/internal/repository"
"github.com/ShukeBta/MediaStationGo/internal/service"
"github.com/ShukeBta/MMTL/internal/config"
"github.com/ShukeBta/MMTL/internal/database"
"github.com/ShukeBta/MMTL/internal/repository"
"github.com/ShukeBta/MMTL/internal/service"
)
// version is overwritten at build time via -ldflags="-X main.version=...".
@@ -38,7 +38,7 @@ func effectiveVersion(buildVersion string) string {
if buildVersion != "" && buildVersion != "dev" {
return buildVersion
}
if envVersion := strings.TrimSpace(os.Getenv("MEDIASTATION_VERSION")); envVersion != "" {
if envVersion := strings.TrimSpace(os.Getenv("MMTL_VERSION")); envVersion != "" {
return envVersion
}
if buildVersion == "" {
+9 -9
View File
@@ -12,23 +12,23 @@ import (
)
func TestEffectiveVersionPrefersBuildVersion(t *testing.T) {
t.Setenv("MEDIASTATION_VERSION", "MediaStationGo-v0.1.15")
t.Setenv("MMTL_VERSION", "MMTL-v0.1.15")
if got := effectiveVersion("MediaStationGo-v0.1.16"); got != "MediaStationGo-v0.1.16" {
t.Fatalf("effectiveVersion = %q, want MediaStationGo-v0.1.16", got)
if got := effectiveVersion("MMTL-v0.1.16"); got != "MMTL-v0.1.16" {
t.Fatalf("effectiveVersion = %q, want MMTL-v0.1.16", got)
}
}
func TestEffectiveVersionUsesEnvWhenBuildVersionIsDev(t *testing.T) {
t.Setenv("MEDIASTATION_VERSION", " MediaStationGo-v0.1.16 ")
t.Setenv("MMTL_VERSION", " MMTL-v0.1.16 ")
if got := effectiveVersion("dev"); got != "MediaStationGo-v0.1.16" {
t.Fatalf("effectiveVersion = %q, want MediaStationGo-v0.1.16", got)
if got := effectiveVersion("dev"); got != "MMTL-v0.1.16" {
t.Fatalf("effectiveVersion = %q, want MMTL-v0.1.16", got)
}
}
func TestEffectiveVersionDefaultsToDev(t *testing.T) {
t.Setenv("MEDIASTATION_VERSION", "")
t.Setenv("MMTL_VERSION", "")
if got := effectiveVersion(""); got != "dev" {
t.Fatalf("effectiveVersion = %q, want dev", got)
@@ -85,7 +85,7 @@ func TestServeSPAServesAssetsImmutableAndBypassesAPIRoutes(t *testing.T) {
if err := os.WriteFile(filepath.Join(webDir, "assets", "app.js"), []byte("console.log('ok')"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(webDir, "brand", "mediastationgo-logo.svg"), []byte("<svg></svg>"), 0o644); err != nil {
if err := os.WriteFile(filepath.Join(webDir, "brand", "mmtl-logo.svg"), []byte("<svg></svg>"), 0o644); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(webDir, "artwork-cache-sw.js"), []byte("self.addEventListener('fetch', () => {})"), 0o644); err != nil {
@@ -105,7 +105,7 @@ func TestServeSPAServesAssetsImmutableAndBypassesAPIRoutes(t *testing.T) {
t.Fatalf("asset Cache-Control = %q, want immutable", got)
}
brandReq := httptest.NewRequest(http.MethodGet, "/brand/mediastationgo-logo.svg", nil)
brandReq := httptest.NewRequest(http.MethodGet, "/brand/mmtl-logo.svg", nil)
brandResp := httptest.NewRecorder()
router.ServeHTTP(brandResp, brandReq)
if brandResp.Code != http.StatusOK {
+5 -5
View File
@@ -9,10 +9,10 @@ import (
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MediaStationGo/internal/handler"
"github.com/ShukeBta/MediaStationGo/internal/middleware"
"github.com/ShukeBta/MediaStationGo/internal/service"
"github.com/ShukeBta/MMTL/internal/config"
"github.com/ShukeBta/MMTL/internal/handler"
"github.com/ShukeBta/MMTL/internal/middleware"
"github.com/ShukeBta/MMTL/internal/service"
)
func buildRouter(cfg *config.Config, logger *zap.Logger, svc *service.Container) *gin.Engine {
@@ -79,7 +79,7 @@ func serveNoCacheFile(filePath string) gin.HandlerFunc {
func serveSPAIndex(c *gin.Context, indexPath string) {
setNoCacheHeaders(c)
if _, err := os.Stat(indexPath); err != nil {
c.String(http.StatusNotFound, "MediaStationGo web UI not found: %s", indexPath)
c.String(http.StatusNotFound, "MMTL web UI not found: %s", indexPath)
return
}
c.File(indexPath)
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"go.uber.org/zap"
"github.com/ShukeBta/MediaStationGo/internal/config"
"github.com/ShukeBta/MMTL/internal/config"
)
func applyCPUThreadLimit(cfg *config.Config, logger *zap.Logger) {