f
This commit is contained in:
@@ -14,6 +14,8 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"hyapi-server/internal/shared/qyglreport"
|
||||
)
|
||||
|
||||
func parseBuiltReport(data []byte) (map[string]interface{}, error) {
|
||||
@@ -54,9 +56,7 @@ func renderPage(tmpl *template.Template, report map[string]interface{}, injectLi
|
||||
return nil, err
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := tmpl.Execute(&buf, map[string]interface{}{
|
||||
"ReportJSON": template.JS(reportBytes),
|
||||
}); err != nil {
|
||||
if err := tmpl.Execute(&buf, qyglreport.PageTemplateData(template.JS(reportBytes))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b := buf.Bytes()
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"hyapi-server/internal/domains/api/services/processors"
|
||||
"hyapi-server/internal/domains/api/services/processors/qygl/reportstore"
|
||||
"hyapi-server/internal/shared/pdf"
|
||||
"hyapi-server/internal/shared/qyglreport"
|
||||
)
|
||||
|
||||
// QYGLReportHandler 企业全景报告页面渲染处理器
|
||||
@@ -97,9 +98,7 @@ func (h *QYGLReportHandler) GetQYGLReportPage(c *gin.Context) {
|
||||
|
||||
reportJSON := template.JS(reportJSONBytes)
|
||||
|
||||
c.HTML(http.StatusOK, "qiye.html", gin.H{
|
||||
"ReportJSON": reportJSON,
|
||||
})
|
||||
c.HTML(http.StatusOK, "qiye.html", qyglreport.PageTemplateData(reportJSON))
|
||||
}
|
||||
|
||||
// GetQYGLReportPageByID 通过编号查看企业全景报告页面
|
||||
@@ -115,9 +114,7 @@ func (h *QYGLReportHandler) GetQYGLReportPageByID(c *gin.Context) {
|
||||
if h.reportRepo != nil {
|
||||
if entity, err := h.reportRepo.FindByReportID(c.Request.Context(), id); err == nil && entity != nil {
|
||||
h.maybeScheduleQYGLPDFPregen(c.Request.Context(), id)
|
||||
c.HTML(http.StatusOK, "qiye.html", gin.H{
|
||||
"ReportJSON": template.JS(entity.ReportData),
|
||||
})
|
||||
c.HTML(http.StatusOK, "qiye.html", qyglreport.PageTemplateData(template.JS(entity.ReportData)))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -140,9 +137,7 @@ func (h *QYGLReportHandler) GetQYGLReportPageByID(c *gin.Context) {
|
||||
|
||||
reportJSON := template.JS(reportJSONBytes)
|
||||
|
||||
c.HTML(http.StatusOK, "qiye.html", gin.H{
|
||||
"ReportJSON": reportJSON,
|
||||
})
|
||||
c.HTML(http.StatusOK, "qiye.html", qyglreport.PageTemplateData(reportJSON))
|
||||
}
|
||||
|
||||
// qyglReportExists 报告是否仍在库或本进程内存中(用于决定是否补开预生成)
|
||||
|
||||
@@ -10,6 +10,12 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// A4 纵向 @ 96dpi,与 CSS @page / 报告页 max-width 对齐
|
||||
const (
|
||||
htmlPDFViewportWidth = 794
|
||||
htmlPDFViewportHeight = 1123
|
||||
)
|
||||
|
||||
// HTMLPDFGenerator 使用 headless Chrome 将 HTML 页面渲染为 PDF
|
||||
type HTMLPDFGenerator struct {
|
||||
logger *zap.Logger
|
||||
@@ -26,41 +32,54 @@ func NewHTMLPDFGenerator(logger *zap.Logger) *HTMLPDFGenerator {
|
||||
}
|
||||
|
||||
// GenerateFromURL 使用 headless Chrome 打开指定 URL,并导出为 PDF 字节流
|
||||
// 这里固定使用 A4 纵向纸张,开启背景打印
|
||||
// 流程:A4 视口渲染 → 等待报告 DOM → 滚动触发展开 → 切换 print 媒体 → PrintToPDF(边距由 CSS @page 控制)
|
||||
func (g *HTMLPDFGenerator) GenerateFromURL(ctx context.Context, url string) ([]byte, error) {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
|
||||
// 整个生成过程增加超时时间,避免长时间卡死
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, 90*time.Second)
|
||||
defer cancel()
|
||||
|
||||
// 创建 Chrome 上下文(使用系统默认的 headless Chrome/Chromium)
|
||||
chromeCtx, cancelChrome := chromedp.NewContext(timeoutCtx)
|
||||
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||
chromedp.Flag("headless", true),
|
||||
chromedp.Flag("disable-gpu", true),
|
||||
chromedp.Flag("no-sandbox", true),
|
||||
chromedp.Flag("disable-dev-shm-usage", true),
|
||||
)
|
||||
allocCtx, allocCancel := chromedp.NewExecAllocator(timeoutCtx, opts...)
|
||||
defer allocCancel()
|
||||
|
||||
chromeCtx, cancelChrome := chromedp.NewContext(allocCtx)
|
||||
defer cancelChrome()
|
||||
|
||||
var pdfBuf []byte
|
||||
|
||||
tasks := chromedp.Tasks{
|
||||
chromedp.EmulateViewport(htmlPDFViewportWidth, htmlPDFViewportHeight),
|
||||
chromedp.Navigate(url),
|
||||
// 等待页面主体和报告容器就绪,确保数据渲染完成
|
||||
chromedp.WaitReady("body", chromedp.ByQuery),
|
||||
chromedp.WaitVisible(".page", chromedp.ByQuery),
|
||||
waitReportReadyForPDF(),
|
||||
waitReportPosterImages(),
|
||||
scrollPageForPrintLayout(),
|
||||
chromedp.ActionFunc(func(ctx context.Context) error {
|
||||
return chromedp.Evaluate(`document.body.classList.add('pdf-export')`, nil).Do(ctx)
|
||||
}),
|
||||
chromedp.ActionFunc(func(ctx context.Context) error {
|
||||
time.Sleep(150 * time.Millisecond)
|
||||
return nil
|
||||
}),
|
||||
chromedp.ActionFunc(func(ctx context.Context) error {
|
||||
g.logger.Info("开始通过 headless Chrome 生成企业报告 PDF", zap.String("url", url))
|
||||
var (
|
||||
buf []byte
|
||||
err error
|
||||
)
|
||||
buf, _, err = page.PrintToPDF().
|
||||
buf, _, err := page.PrintToPDF().
|
||||
WithPrintBackground(true).
|
||||
WithPaperWidth(8.27). // A4 宽度(英寸 -> 约 210mm)
|
||||
WithPaperHeight(11.69). // A4 高度(英寸 -> 约 297mm)
|
||||
WithMarginTop(0.4).
|
||||
WithMarginBottom(0.4).
|
||||
WithMarginLeft(0.4).
|
||||
WithMarginRight(0.4).
|
||||
WithPaperWidth(8.27).
|
||||
WithPaperHeight(11.69).
|
||||
WithMarginTop(0.39).
|
||||
WithMarginBottom(0.39).
|
||||
WithMarginLeft(0.47).
|
||||
WithMarginRight(0.47).
|
||||
Do(ctx)
|
||||
if err == nil {
|
||||
pdfBuf = buf
|
||||
@@ -86,3 +105,87 @@ func (g *HTMLPDFGenerator) GenerateFromURL(ctx context.Context, url string) ([]b
|
||||
return pdfBuf, nil
|
||||
}
|
||||
|
||||
// waitReportReadyForPDF 等待企业报告脚本渲染完成(qiye.html 设置 data-qygl-report-ready)
|
||||
func waitReportReadyForPDF() chromedp.Action {
|
||||
return chromedp.ActionFunc(func(ctx context.Context) error {
|
||||
deadline := time.Now().Add(45 * time.Second)
|
||||
for {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
var ready string
|
||||
_ = chromedp.Evaluate(`document.body && document.body.dataset.qyglReportReady || ''`, &ready).Do(ctx)
|
||||
if ready == "1" {
|
||||
return nil
|
||||
}
|
||||
var sectionCount float64
|
||||
_ = chromedp.Evaluate(`document.querySelectorAll('#reportSections .section-card, .report-sections .section-block').length`, §ionCount).Do(ctx)
|
||||
if sectionCount > 0 {
|
||||
return nil
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
return fmt.Errorf("等待报告内容渲染超时")
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func waitReportPosterImages() chromedp.Action {
|
||||
return chromedp.ActionFunc(func(ctx context.Context) error {
|
||||
deadline := time.Now().Add(20 * time.Second)
|
||||
for {
|
||||
if ctx.Err() != nil {
|
||||
return ctx.Err()
|
||||
}
|
||||
var pending float64
|
||||
js := `(function(){
|
||||
var imgs = document.querySelectorAll('img.header-poster, img.footer-poster');
|
||||
if (!imgs.length) return 0;
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
var img = imgs[i];
|
||||
if (!img.complete || img.naturalWidth === 0) return 1;
|
||||
}
|
||||
return 0;
|
||||
})()`
|
||||
if err := chromedp.Evaluate(js, &pending).Do(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if pending == 0 {
|
||||
return nil
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
return fmt.Errorf("等待报告海报图片加载超时")
|
||||
}
|
||||
time.Sleep(150 * time.Millisecond)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func scrollPageForPrintLayout() chromedp.Action {
|
||||
return chromedp.ActionFunc(func(ctx context.Context) error {
|
||||
var height float64
|
||||
if err := chromedp.Evaluate(`Math.max(document.body.scrollHeight, document.documentElement.scrollHeight)`, &height).Do(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
step := float64(900)
|
||||
if height < step {
|
||||
step = height
|
||||
}
|
||||
if step <= 0 {
|
||||
return nil
|
||||
}
|
||||
for y := float64(0); y <= height; y += step {
|
||||
js := fmt.Sprintf(`window.scrollTo(0, %f);`, y)
|
||||
if err := chromedp.Evaluate(js, nil).Do(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(120 * time.Millisecond)
|
||||
}
|
||||
if err := chromedp.Evaluate(`window.scrollTo(0, 0);`, nil).Do(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
77
internal/shared/qyglreport/poster_assets.go
Normal file
77
internal/shared/qyglreport/poster_assets.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package qyglreport
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"html/template"
|
||||
"mime"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultBannerRel = "resources/qygl-media/banner.jpg"
|
||||
defaultFooterRel = "resources/qygl-media/footer.png"
|
||||
)
|
||||
|
||||
var (
|
||||
loadOnce sync.Once
|
||||
bannerURL template.URL
|
||||
footerURL template.URL
|
||||
)
|
||||
|
||||
func loadPosterAssets() {
|
||||
bannerURL = dataURLFromFile(resolveMediaFile([]string{
|
||||
defaultBannerRel,
|
||||
"resources/qygl-media/banner.png",
|
||||
}), "/reports/qygl/media/banner.jpg")
|
||||
footerURL = dataURLFromFile(defaultFooterRel, "/reports/qygl/media/footer.png")
|
||||
}
|
||||
|
||||
func resolveMediaFile(candidates []string) string {
|
||||
for _, p := range candidates {
|
||||
if _, err := os.Stat(p); err == nil {
|
||||
return p
|
||||
}
|
||||
}
|
||||
if len(candidates) > 0 {
|
||||
return candidates[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func dataURLFromFile(path string, httpFallback string) template.URL {
|
||||
if path == "" {
|
||||
return template.URL(httpFallback)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return template.URL(httpFallback)
|
||||
}
|
||||
ext := filepath.Ext(path)
|
||||
mimeType := mime.TypeByExtension(ext)
|
||||
if mimeType == "" {
|
||||
switch ext {
|
||||
case ".jpg", ".jpeg":
|
||||
mimeType = "image/jpeg"
|
||||
case ".png":
|
||||
mimeType = "image/png"
|
||||
default:
|
||||
mimeType = "application/octet-stream"
|
||||
}
|
||||
}
|
||||
encoded := base64.StdEncoding.EncodeToString(data)
|
||||
return template.URL("data:" + mimeType + ";base64," + encoded)
|
||||
}
|
||||
|
||||
// PageTemplateData 企业报告 HTML 模板数据(海报内嵌 data URL,PDF 生成不依赖外链)
|
||||
func PageTemplateData(reportJSON template.JS) gin.H {
|
||||
loadOnce.Do(loadPosterAssets)
|
||||
return gin.H{
|
||||
"ReportJSON": reportJSON,
|
||||
"BannerPosterURL": bannerURL,
|
||||
"FooterPosterURL": footerURL,
|
||||
}
|
||||
}
|
||||
@@ -162,20 +162,32 @@
|
||||
border-radius: var(--radius);
|
||||
min-height: clamp(168px, 28vw, 220px);
|
||||
background-color: #f0f7ff;
|
||||
background-image: url("/reports/qygl/media/banner.jpg");
|
||||
background-size: cover;
|
||||
background-position: center right;
|
||||
background-repeat: no-repeat;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
color: var(--ink);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header-poster {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center right;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
|
||||
.header::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
@@ -184,21 +196,31 @@
|
||||
rgba(255, 255, 255, 0.25) 68%,
|
||||
transparent 100%
|
||||
);
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.header-inner {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: block;
|
||||
max-width: 72%;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
max-width: 78%;
|
||||
padding: 0;
|
||||
margin-top: 0;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.header-hero-badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.header {
|
||||
padding: 20px 14px 18px;
|
||||
background-position: 75% center;
|
||||
min-height: 200px;
|
||||
}
|
||||
.header::before {
|
||||
@@ -209,6 +231,9 @@
|
||||
rgba(255, 255, 255, 0.45) 100%
|
||||
);
|
||||
}
|
||||
.header-poster {
|
||||
object-position: 75% center;
|
||||
}
|
||||
.header-inner {
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -217,6 +242,8 @@
|
||||
.header-main {
|
||||
padding: 0;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.header-hero-kicker {
|
||||
@@ -683,6 +710,7 @@
|
||||
}
|
||||
|
||||
.report-brand-footer {
|
||||
position: relative;
|
||||
margin: 32px 0 16px;
|
||||
padding: 36px 16px;
|
||||
text-align: center;
|
||||
@@ -691,15 +719,30 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
background-color: #f4f8fc;
|
||||
background-image: url("/reports/qygl/media/footer.png");
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.footer-poster {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
|
||||
.report-brand-footer p {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin: 0;
|
||||
padding: 0 16px;
|
||||
font-size: clamp(1rem, 3vw, 1.25rem);
|
||||
font-weight: 700;
|
||||
color: var(--qy-accent);
|
||||
@@ -989,31 +1032,158 @@
|
||||
.section-card .section-body {
|
||||
padding: 18px 16px 20px;
|
||||
}
|
||||
.section-card h2 {
|
||||
padding: 12px 16px 12px 14px;
|
||||
}
|
||||
}
|
||||
|
||||
@page {
|
||||
size: A4 portrait;
|
||||
margin: 10mm 12mm;
|
||||
}
|
||||
|
||||
/* 全页斜向透明红字水印;position:fixed 在 Chrome 打印/PDF 时每页重复 */
|
||||
.report-watermark {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: max-content;
|
||||
max-width: none;
|
||||
transform: translate(-50%, -50%) rotate(-45deg);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: var(--font-sans);
|
||||
font-size: 56px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.14em;
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
color: rgba(220, 38, 38, 0.14);
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
z-index: 500;
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
|
||||
/* Headless Chrome 导出 PDF 时使用(不切换 print 媒体,避免海报/布局异常) */
|
||||
body.pdf-export {
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
body.pdf-export .pdf-actions-fixed,
|
||||
body.pdf-export .pdf-loading-overlay,
|
||||
body.pdf-export .top-nav {
|
||||
display: none !important;
|
||||
}
|
||||
body.pdf-export .page {
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0 0 24px;
|
||||
overflow: visible;
|
||||
}
|
||||
body.pdf-export .page-inner {
|
||||
padding: 0 !important;
|
||||
}
|
||||
body.pdf-export .report-sections,
|
||||
body.pdf-export #reportSections {
|
||||
padding: 0 12px;
|
||||
}
|
||||
body.pdf-export .section-card h2 {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
body.pdf-export .header {
|
||||
margin: 0 0 16px !important;
|
||||
border: none !important;
|
||||
border-radius: 0 !important;
|
||||
box-shadow: none !important;
|
||||
padding: 28px 20px 24px !important;
|
||||
min-height: clamp(168px, 22vw, 200px) !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
body.pdf-export .header-poster {
|
||||
position: absolute !important;
|
||||
inset: 0 !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
object-fit: cover !important;
|
||||
object-position: center right !important;
|
||||
}
|
||||
body.pdf-export .header::before {
|
||||
display: block !important;
|
||||
}
|
||||
body.pdf-export .header-inner {
|
||||
max-width: 78% !important;
|
||||
text-align: left !important;
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
body.pdf-export .header-main {
|
||||
text-align: left !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
body.pdf-export .header-score {
|
||||
justify-content: flex-start !important;
|
||||
width: 100% !important;
|
||||
margin-top: 12px !important;
|
||||
}
|
||||
body.pdf-export .header-score-inner {
|
||||
display: inline-flex !important;
|
||||
flex-direction: row !important;
|
||||
flex-wrap: nowrap !important;
|
||||
align-items: center !important;
|
||||
justify-content: flex-start !important;
|
||||
gap: 10px !important;
|
||||
max-width: none !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
body.pdf-export .header-score .label {
|
||||
display: inline-flex !important;
|
||||
margin: 0 !important;
|
||||
background: transparent !important;
|
||||
}
|
||||
body.pdf-export .header-score .score,
|
||||
body.pdf-export .header-score .pill {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
body.pdf-export .header-poster,
|
||||
body.pdf-export .footer-poster {
|
||||
display: block !important;
|
||||
visibility: visible !important;
|
||||
opacity: 1 !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
@media print {
|
||||
html,
|
||||
body {
|
||||
background: #fff !important;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
min-height: auto;
|
||||
-webkit-print-color-adjust: exact;
|
||||
print-color-adjust: exact;
|
||||
}
|
||||
.page {
|
||||
max-width: none;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
border-radius: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
.page::before {
|
||||
height: 2px;
|
||||
display: none;
|
||||
}
|
||||
.page-inner {
|
||||
padding: 0 12mm;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.top-nav {
|
||||
display: none !important;
|
||||
@@ -1023,44 +1193,68 @@
|
||||
display: none !important;
|
||||
}
|
||||
.header {
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
#e8f0ff 0%,
|
||||
#f8fafc 45%,
|
||||
#ffffff 100%
|
||||
) !important;
|
||||
background-color: #f0f7ff !important;
|
||||
color: var(--ink) !important;
|
||||
box-shadow: none !important;
|
||||
border: 1px solid var(--line);
|
||||
border-left: 3px solid var(--blue-800);
|
||||
border: none !important;
|
||||
border-radius: 0;
|
||||
margin-top: 8px;
|
||||
margin-top: 0;
|
||||
padding: 28px 20px 24px !important;
|
||||
min-height: 180px !important;
|
||||
overflow: hidden !important;
|
||||
page-break-inside: avoid;
|
||||
break-inside: avoid-page;
|
||||
}
|
||||
.header-poster,
|
||||
.footer-poster {
|
||||
position: absolute !important;
|
||||
inset: 0 !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
max-width: none !important;
|
||||
object-fit: cover !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
.header-poster {
|
||||
object-position: center right !important;
|
||||
}
|
||||
.footer-poster {
|
||||
object-position: center !important;
|
||||
}
|
||||
.header-inner {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 20px 0 16px;
|
||||
gap: 20px;
|
||||
padding: 0 !important;
|
||||
margin-top: 0 !important;
|
||||
max-width: 78% !important;
|
||||
gap: 0;
|
||||
background: transparent !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
.header::before {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
var(--header-strip-start) 0%,
|
||||
var(--header-strip-mid) 62%,
|
||||
var(--header-strip-end) 100%
|
||||
);
|
||||
display: block !important;
|
||||
}
|
||||
.header-main {
|
||||
padding: 0;
|
||||
text-align: left !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
.header-score-inner {
|
||||
border-top-width: 3px;
|
||||
border-top-color: var(--blue-700);
|
||||
border-color: rgba(37, 99, 235, 0.2);
|
||||
background: #fff !important;
|
||||
display: inline-flex !important;
|
||||
flex-direction: row !important;
|
||||
flex-wrap: nowrap !important;
|
||||
align-items: center !important;
|
||||
justify-content: flex-start !important;
|
||||
gap: 10px !important;
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
box-shadow: none;
|
||||
max-width: 260px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
max-width: none !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.header-score .label {
|
||||
display: inline-flex !important;
|
||||
background: transparent !important;
|
||||
}
|
||||
.header-main h1.report-title {
|
||||
color: var(--blue-950) !important;
|
||||
@@ -1085,21 +1279,13 @@
|
||||
.header-score {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
margin: 0 !important;
|
||||
justify-content: center;
|
||||
margin: 12px 0 0 !important;
|
||||
justify-content: flex-start !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
.header-score .score {
|
||||
color: var(--blue-900) !important;
|
||||
}
|
||||
.header-score .label {
|
||||
color: var(--muted) !important;
|
||||
}
|
||||
.header-main {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.header-score {
|
||||
width: 100%;
|
||||
color: #fff !important;
|
||||
background: var(--qy-gradient) !important;
|
||||
}
|
||||
.section-card {
|
||||
box-shadow: none;
|
||||
@@ -1113,13 +1299,37 @@
|
||||
background: #fff !important;
|
||||
}
|
||||
.section-card h2 {
|
||||
background: var(--table-head) !important;
|
||||
border-left-color: var(--blue-800);
|
||||
color: var(--ink);
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
color: var(--qy-accent);
|
||||
padding: 0 6px 0 2px !important;
|
||||
page-break-after: avoid;
|
||||
break-after: avoid-page;
|
||||
}
|
||||
.section-card .section-body {
|
||||
padding: 12px 0 16px !important;
|
||||
}
|
||||
.kv-table thead {
|
||||
display: table-header-group;
|
||||
}
|
||||
.kv-table tr,
|
||||
.qy-info-grid tr {
|
||||
page-break-inside: avoid;
|
||||
break-inside: avoid-page;
|
||||
}
|
||||
.record-card,
|
||||
.item-block,
|
||||
.report-brand-footer {
|
||||
page-break-inside: avoid;
|
||||
break-inside: avoid-page;
|
||||
}
|
||||
.report-brand-footer {
|
||||
min-height: 100px !important;
|
||||
padding: 36px 16px !important;
|
||||
margin: 24px 0 0;
|
||||
background-color: #f4f8fc !important;
|
||||
}
|
||||
.item-list li {
|
||||
page-break-inside: auto;
|
||||
break-inside: auto;
|
||||
@@ -1133,11 +1343,17 @@
|
||||
color: var(--ink);
|
||||
text-decoration: none;
|
||||
}
|
||||
.report-watermark {
|
||||
display: block !important;
|
||||
font-size: 42pt;
|
||||
color: rgba(220, 38, 38, 0.16) !important;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="report-watermark" aria-hidden="true">海宇数据</div>
|
||||
<div class="page">
|
||||
<div class="page-inner">
|
||||
<!-- 隐藏的导航容器,仅用于脚本生成目录,页面不展示 -->
|
||||
@@ -1145,6 +1361,12 @@
|
||||
<div id="navLinks"></div>
|
||||
</nav>
|
||||
<header class="header">
|
||||
<img
|
||||
class="header-poster"
|
||||
src="{{ .BannerPosterURL }}"
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div class="header-inner">
|
||||
<div class="header-main">
|
||||
<div class="header-hero-kicker">
|
||||
@@ -1167,19 +1389,21 @@
|
||||
<div class="header-tags" id="headerTags"></div>
|
||||
</div>
|
||||
<aside class="header-score" aria-label="综合评分">
|
||||
<div class="header-score-inner">
|
||||
<div class="header-score-inner header-hero-badges">
|
||||
<div class="score" id="overallScore">--</div>
|
||||
<div class="label">
|
||||
<span id="riskLevelPill" class="pill low"
|
||||
>风险:-</span
|
||||
>
|
||||
</div>
|
||||
<span id="riskLevelPill" class="pill low">风险:-</span>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</header>
|
||||
<main id="reportSections" class="report-sections"></main>
|
||||
<footer class="report-brand-footer">
|
||||
<img
|
||||
class="footer-poster"
|
||||
src="{{ .FooterPosterURL }}"
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<p>更新更全信息欢迎使用海宇数据</p>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -3790,6 +4014,7 @@
|
||||
card.appendChild(body);
|
||||
container.appendChild(card);
|
||||
});
|
||||
document.body.dataset.qyglReportReady = "1";
|
||||
}
|
||||
|
||||
function loadReport() {
|
||||
@@ -3810,6 +4035,8 @@
|
||||
}
|
||||
loadReport();
|
||||
|
||||
document.body.dataset.qyglReportReady = document.body.dataset.qyglReportReady || "1";
|
||||
|
||||
// 绑定「保存为 PDF」:先轮询预生成状态,再 GET /pdf(服务端优先读缓存,必要时现场生成)
|
||||
var saveBtn = document.getElementById("btnSavePdf");
|
||||
var loadingOverlay = document.getElementById("pdfLoadingOverlay");
|
||||
|
||||
BIN
resources/qygl-media/banner.jpg
Normal file
BIN
resources/qygl-media/banner.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 275 KiB After Width: | Height: | Size: 295 KiB |
Reference in New Issue
Block a user