添加前端页面以及相关打包脚本和内置 web 的逻辑

This commit is contained in:
2026-01-14 23:09:16 +08:00
parent e456d3a823
commit 9b646321e1
45 changed files with 583 additions and 10 deletions

40
build.ps1 Normal file
View File

@@ -0,0 +1,40 @@
# 设置变量
$APP_NAME = "FileRelay.exe"
$DIST_DIR = "dist"
$CONFIG_SRC = "config\config.yaml"
$CONFIG_DEST = "$DIST_DIR\config\config.yaml"
Write-Host "开始构建 $APP_NAME..." -ForegroundColor Cyan
# 清理 dist 目录
if (Test-Path $DIST_DIR) {
Write-Host "正在清理 $DIST_DIR 目录..."
Remove-Item -Path $DIST_DIR -Recurse -Force
}
# 创建 dist 目录
if (-not (Test-Path "$DIST_DIR\config")) {
New-Item -Path "$DIST_DIR\config" -ItemType Directory -Force | Out-Null
}
# 编译 Go 二进制文件
Write-Host "正在编译..."
go build -o "$DIST_DIR\$APP_NAME" main.go
if ($LASTEXITCODE -eq 0) {
Write-Host "编译成功!" -ForegroundColor Green
} else {
Write-Host "编译失败!" -ForegroundColor Red
exit 1
}
# 复制配置文件
if (Test-Path $CONFIG_SRC) {
Write-Host "正在复制配置文件..."
Copy-Item -Path $CONFIG_SRC -Destination $CONFIG_DEST -Force
} else {
Write-Host "警告: 未找到源配置文件 $CONFIG_SRC,跳过复制。" -ForegroundColor Yellow
}
Write-Host "打包完成!输出目录: $DIST_DIR" -ForegroundColor Green
Write-Host "你可以运行 .\$DIST_DIR\$APP_NAME 来启动服务。"