From cbb26873e88a7a13e868448c1cc578ce70b8c6ae Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Mon, 09 Nov 2026 10:54:51 +0800
Subject: [PATCH] feat: 新增客户端版本管理与下载页,重构配置加载方式

---
 server/main.go |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/server/main.go b/server/main.go
index d219814..42a8f8a 100644
--- a/server/main.go
+++ b/server/main.go
@@ -1,6 +1,8 @@
 package main
 
 import (
+	"fmt"
+	"net/http"
 	"os"
 	"path/filepath"
 
@@ -12,6 +14,8 @@
 )
 
 func main() {
+	config.Load("config.yaml")
+
 	// 大文件上传时 multipart 会先写系统临时目录(C盘),
 	// 系统盘空间不足会导致大压缩包上传失败,这里指到程序目录下的 uploads/tmp
 	if abs, err := filepath.Abs(filepath.Join("uploads", "tmp")); err == nil {
@@ -41,6 +45,8 @@
 		api.GET("/tools", handlers.GetTools)
 		api.GET("/tools/:id/download", handlers.ToolDownloadInfo)
 		api.GET("/announcements", handlers.GetAnnouncements)
+		api.GET("/client/latest", handlers.GetClientLatest)   // 客户端下载页:最新版本信息(公开)
+		api.GET("/client/download", handlers.ClientDownload)  // 客户端下载页:下载最新版(公开,累计下载次数)
 		api.GET("/games/:id", middleware.OptionalUserAuth(), handlers.GetGameDetail) // 支持可选登录:登录后返回收藏/资源库状态
 
 		auth := api.Group("", middleware.UserAuth())
@@ -56,6 +62,19 @@
 		}
 	}
 
+	// ---------- 游戏目录展示页(公开,仅浏览不可下载) ----------
+	r.GET("/showcase", func(c *gin.Context) {
+		c.File("./showcase/index.html")
+	})
+	r.GET("/", func(c *gin.Context) {
+		c.Redirect(http.StatusFound, "/showcase")
+	})
+
+	// ---------- 客户端下载页(公开,无需登录) ----------
+	r.GET("/download", func(c *gin.Context) {
+		c.File("./download/index.html")
+	})
+
 	// ---------- 管理后台 ----------
 	r.GET("/admin", func(c *gin.Context) {
 		c.File("./admin/index.html")
@@ -77,6 +96,10 @@
 			a.POST("/tools", handlers.AdminSaveTool)
 			a.DELETE("/tools/:id", handlers.AdminDeleteTool)
 
+			a.GET("/versions", handlers.AdminListVersions)
+			a.POST("/versions", handlers.AdminSaveVersion)
+			a.DELETE("/versions/:id", handlers.AdminDeleteVersion)
+
 			a.GET("/games", handlers.AdminListGames)
 			a.POST("/games", handlers.AdminSaveGame)
 			a.DELETE("/games/:id", handlers.AdminDeleteGame)
@@ -97,5 +120,5 @@
 		}
 	}
 
-	r.Run(":8080")
+	r.Run(fmt.Sprintf(":%d", config.App.Server.Port))
 }

--
Gitblit v1.10.0