This commit is contained in:
cjw
2026-02-15 01:09:53 +08:00
parent c58e640430
commit 488f9b229c
3 changed files with 70 additions and 36 deletions
+14 -19
View File
@@ -30,11 +30,12 @@ class HTMLGenerator:
topology = geometry_data.get("topology", {})
center_of_mass = geometry_data.get("center_of_mass", [0, 0, 0])
cavity_html = ""
if cavity_data:
# 强制测试:无论cavity_data如何,都显示面板
if True:
# 安全获取嵌套数据
metadata = cavity_data.get("metadata", {})
manufacturing_info = cavity_data.get("manufacturing_info", {})
mold_cavities = cavity_data.get("mold_cavities", {})
metadata = cavity_data.get("metadata", {}) if cavity_data else {}
manufacturing_info = cavity_data.get("manufacturing_info", {}) if cavity_data else {}
mold_cavities = cavity_data.get("mold_cavities", {}) if cavity_data else {}
cavity_key_info = mold_cavities.get("cavity_key_info", {})
geo_chars = cavity_key_info.get("geometric_characteristics", {})
@@ -43,10 +44,10 @@ class HTMLGenerator:
logger.info(f"生成HTML - 产品体积: {geo_chars.get('product_volume')}")
cavity_html = f"""
<div id="cavity-info-panel" style="position: absolute; top: 10px; right: 10px;">
<h3>🔧 关键工艺参数</h3>
<div style="margin: 10px 0;">
<strong>模具参数</strong>
<div id="cavity-info-panel" style="position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,0.95); padding: 15px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); max-width: 320px;">
<h3 style="margin: 0 0 10px 0;">🔧 关键工艺参数</h3>
<div style="margin: 10px 0; border-bottom: 1px solid #ddd; padding-bottom: 5px;">
<strong style="color: #333;">模具参数</strong>
</div>
<div class="metric">
<span class="metric-label">收缩率:</span>
@@ -60,8 +61,8 @@ class HTMLGenerator:
<span class="metric-label">分型线长度:</span>
<span class="metric-value">{manufacturing_info.get("parting_line_length", "N/A")}</span>
</div>
<div style="margin: 10px 0;">
<strong>几何特性</strong>
<div style="margin: 10px 0; border-bottom: 1px solid #ddd; padding-bottom: 5px;">
<strong style="color: #333;">几何特性</strong>
</div>
<div class="metric">
<span class="metric-label">产品体积:</span>
@@ -75,8 +76,8 @@ class HTMLGenerator:
<span class="metric-label">壁厚范围:</span>
<span class="metric-value">{geo_chars.get("wall_thickness_range", "N/A")}</span>
</div>
<div style="margin: 10px 0;">
<strong>制造要求</strong>
<div style="margin: 10px 0; border-bottom: 1px solid #ddd; padding-bottom: 5px;">
<strong style="color: #333;">制造要求</strong>
</div>
<div class="metric">
<span class="metric-label">型腔材料:</span>
@@ -98,13 +99,7 @@ class HTMLGenerator:
"""
else:
logger.warning(f"cavity_data 为空,无法显示工艺参数 - 文件: {stp_filename}")
# 即使没有cavity_data,也生成一个空面板占位
cavity_html = """
<div id="cavity-info-panel" style="position: absolute; top: 10px; right: 10px; background: rgba(255,0,0,0.1); padding: 10px;">
<h3>🔧 关键工艺参数</h3>
<div style="color: red;">数据未加载</div>
</div>
"""
cavity_html = ""
html_content = f"""
<!DOCTYPE html>
<html lang="zh-CN">