tab4.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env python3
  2. """
  3. Tab4内容生成器 - 金句提取
  4. 包含:script_type、hooks、golden_sentences
  5. """
  6. import html as html_module
  7. from typing import Dict, Any, List
  8. def generate_tab4_content(data: Dict[str, Any]) -> str:
  9. """生成Tab4内容:金句提取"""
  10. html = '<div class="tab-content" id="tab4" style="display: none;">\n'
  11. html += '<div class="section">\n'
  12. html += '<h3>金句提取</h3>\n'
  13. golden_sentences = data.get("金句提取", {})
  14. if not golden_sentences:
  15. html += '<p>暂无数据</p>\n'
  16. else:
  17. card_id = "golden-sentences"
  18. html += f'<div class="point-card golden-card" data-card-id="{card_id}">\n'
  19. html += f'<div class="point-card-header" onclick="toggleCardDetails(\'{card_id}\')">\n'
  20. html += '<span class="point-text">金句提取结果</span>\n'
  21. html += '<span class="toggle-icon">▼</span>\n'
  22. html += '</div>\n'
  23. html += f'<div class="point-card-details" id="{card_id}-details">\n'
  24. # script_type
  25. script_type = golden_sentences.get("script_type", "")
  26. if script_type:
  27. html += '<div class="detail-section">\n'
  28. html += '<strong>脚本类型:</strong>\n'
  29. html += f'<div class="detail-text">{html_module.escape(script_type)}</div>\n'
  30. html += '</div>\n'
  31. # hooks
  32. hooks = golden_sentences.get("hooks", [])
  33. if hooks:
  34. html += '<div class="detail-section">\n'
  35. html += '<strong>Hooks(钩子):</strong>\n'
  36. html += '<ul class="detail-list">\n'
  37. for hook in hooks:
  38. html += f'<li class="hook-item">{html_module.escape(str(hook))}</li>\n'
  39. html += '</ul>\n'
  40. html += '</div>\n'
  41. # golden_sentences
  42. sentences = golden_sentences.get("golden_sentences", [])
  43. if sentences:
  44. html += '<div class="detail-section">\n'
  45. html += '<strong>金句:</strong>\n'
  46. html += '<ul class="detail-list">\n'
  47. for sentence in sentences:
  48. html += f'<li class="golden-item">{html_module.escape(str(sentence))}</li>\n'
  49. html += '</ul>\n'
  50. html += '</div>\n'
  51. html += '</div>\n'
  52. html += '</div>\n'
  53. html += '</div>\n'
  54. html += '</div>\n'
  55. return html