This commit is contained in:
2026-03-10 17:49:53 +08:00
parent bf4c114ee2
commit 6b80182986
4 changed files with 2088 additions and 6 deletions

View File

@@ -53,9 +53,8 @@ COPY --from=builder /app/tyapi-server .
COPY config.yaml .
COPY configs/ ./configs/
# 复制资源文件(直接从构建上下文复制,与配置文件一致
COPY resources/etc ./resources/etc
COPY resources/pdf ./resources/pdf
# 复制资源文件(报告模板、PDF、组件等
COPY resources ./resources
# 暴露端口
EXPOSE 8080

View File

@@ -89,7 +89,8 @@ services:
- "25000:8080"
volumes:
- ./logs:/app/logs
- ./resources/Pure_Component:/app/resources/Pure_Component
# 挂载完整 resources 目录(包含 qiye.html、Pure_Component、pdf 等)
- ./resources:/app/resources
# 持久化PDF缓存目录确保生成的PDF在容器重启后仍然存在
- ./storage/pdfg-cache:/app/storage/pdfg-cache
# user: "1001:1001" # 注释掉使用root权限运行

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net/http"
"os"
"sort"
"time"
@@ -38,8 +39,16 @@ func NewGinRouter(cfg *config.Config, logger *zap.Logger) *GinRouter {
engine := gin.New()
// 加载HTML模板企业报告等页面
// 这里直接加载项目根目录下的 qiye.html后续如有更多模板可改为 LoadHTMLGlob
engine.LoadHTMLFiles("qiye.html")
// 为避免生产环境文件不存在导致panic这里先检查文件是否存在
const reportTemplatePath = "resources/qiye.html"
if _, err := os.Stat(reportTemplatePath); err == nil {
engine.LoadHTMLFiles(reportTemplatePath)
logger.Info("已加载企业报告模板文件", zap.String("template", reportTemplatePath))
} else {
logger.Warn("未找到企业报告模板文件,将跳过模板加载(请确认部署时包含 resources/qiye.html",
zap.String("template", reportTemplatePath),
zap.Error(err))
}
return &GinRouter{
engine: engine,

2073
resources/qiye.html Normal file

File diff suppressed because it is too large Load Diff