From 51695c22457cedfbff39f4645c4a0119813d19d4 Mon Sep 17 00:00:00 2001 From: tbphp Date: Wed, 9 Jul 2025 16:02:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E4=B8=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 4 ++-- internal/router/router.go | 2 +- cmd/gpt-load/main.go => main.go | 4 ++-- web/.gitignore | 0 web/vite.config.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename cmd/gpt-load/main.go => main.go (97%) delete mode 100644 web/.gitignore diff --git a/Makefile b/Makefile index 2389dbf..1ce76bf 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # 变量定义 BINARY_NAME=gpt-load -MAIN_PATH=./cmd/gpt-load +MAIN_PATH=./ BUILD_DIR=./build VERSION=2.0.0 LDFLAGS=-ldflags "-X main.Version=$(VERSION) -s -w" @@ -43,7 +43,7 @@ build-all: clean ## 为所有支持的平台构建二进制文件 .PHONY: run run: ## 构建前端并运行服务器 @echo "--- Building frontend... ---" - @rm -rf cmd/gpt-load/dist + @rm -rf web/dist cd web && pnpm install && pnpm run build @echo "--- Preparing backend... ---" @echo "--- Starting backend... ---" diff --git a/internal/router/router.go b/internal/router/router.go index 5901e55..2f4bbaa 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -167,7 +167,7 @@ func registerFrontendRoutes(router *gin.Engine, buildFS embed.FS, indexPage []by c.JSON(http.StatusMethodNotAllowed, gin.H{"error": "Method not allowed"}) }) - router.Use(static.Serve("/", EmbedFolder(buildFS, "dist"))) + router.Use(static.Serve("/", EmbedFolder(buildFS, "web/dist"))) router.NoRoute(func(c *gin.Context) { if strings.HasPrefix(c.Request.RequestURI, "/api") || strings.HasPrefix(c.Request.RequestURI, "/proxy") { c.JSON(http.StatusNotFound, gin.H{"error": "Not Found"}) diff --git a/cmd/gpt-load/main.go b/main.go similarity index 97% rename from cmd/gpt-load/main.go rename to main.go index 4e221c1..883069f 100644 --- a/cmd/gpt-load/main.go +++ b/main.go @@ -18,10 +18,10 @@ import ( "github.com/sirupsen/logrus" ) -//go:embed dist +//go:embed web/dist var buildFS embed.FS -//go:embed dist/index.html +//go:embed web/dist/index.html var indexPage []byte func main() { diff --git a/web/.gitignore b/web/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/web/vite.config.ts b/web/vite.config.ts index 2f88b7a..e049282 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -28,7 +28,7 @@ export default defineConfig(({ mode }) => { }, // 构建配置 build: { - outDir: "../cmd/gpt-load/dist", + outDir: "dist", assetsDir: "assets", }, };