refactor: 调整主文件位置

This commit is contained in:
tbphp
2025-07-09 16:02:33 +08:00
parent 9bd32d5885
commit 51695c2245
5 changed files with 6 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
# 变量定义 # 变量定义
BINARY_NAME=gpt-load BINARY_NAME=gpt-load
MAIN_PATH=./cmd/gpt-load MAIN_PATH=./
BUILD_DIR=./build BUILD_DIR=./build
VERSION=2.0.0 VERSION=2.0.0
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -s -w" LDFLAGS=-ldflags "-X main.Version=$(VERSION) -s -w"
@@ -43,7 +43,7 @@ build-all: clean ## 为所有支持的平台构建二进制文件
.PHONY: run .PHONY: run
run: ## 构建前端并运行服务器 run: ## 构建前端并运行服务器
@echo "--- Building frontend... ---" @echo "--- Building frontend... ---"
@rm -rf cmd/gpt-load/dist @rm -rf web/dist
cd web && pnpm install && pnpm run build cd web && pnpm install && pnpm run build
@echo "--- Preparing backend... ---" @echo "--- Preparing backend... ---"
@echo "--- Starting backend... ---" @echo "--- Starting backend... ---"

View File

@@ -167,7 +167,7 @@ func registerFrontendRoutes(router *gin.Engine, buildFS embed.FS, indexPage []by
c.JSON(http.StatusMethodNotAllowed, gin.H{"error": "Method not allowed"}) 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) { router.NoRoute(func(c *gin.Context) {
if strings.HasPrefix(c.Request.RequestURI, "/api") || strings.HasPrefix(c.Request.RequestURI, "/proxy") { if strings.HasPrefix(c.Request.RequestURI, "/api") || strings.HasPrefix(c.Request.RequestURI, "/proxy") {
c.JSON(http.StatusNotFound, gin.H{"error": "Not Found"}) c.JSON(http.StatusNotFound, gin.H{"error": "Not Found"})

View File

@@ -18,10 +18,10 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
//go:embed dist //go:embed web/dist
var buildFS embed.FS var buildFS embed.FS
//go:embed dist/index.html //go:embed web/dist/index.html
var indexPage []byte var indexPage []byte
func main() { func main() {

0
web/.gitignore vendored
View File

View File

@@ -28,7 +28,7 @@ export default defineConfig(({ mode }) => {
}, },
// 构建配置 // 构建配置
build: { build: {
outDir: "../cmd/gpt-load/dist", outDir: "dist",
assetsDir: "assets", assetsDir: "assets",
}, },
}; };