diff --git a/sync.py b/sync.py index 319ade6..1f1d344 100644 --- a/sync.py +++ b/sync.py @@ -488,6 +488,10 @@ def create_diff_html(title, en_diff, en_old_lines, en_new_lines, cn_content=None return ''.join(result) + # 收集变更块信息用于导航 + change_blocks = [] + change_block_id = 0 + # 生成HTML html = f''' @@ -823,6 +827,166 @@ def create_diff_html(title, en_diff, en_old_lines, en_new_lines, cn_content=None .line-wrapper.blank-placeholder:hover .main-line {{ background-color: rgba(0, 123, 255, 0.02); }} + + /* 变更块高亮样式 */ + .line-wrapper.change-block {{ + border-left: 3px solid #007bff; + }} + + /* 导航浮窗样式 */ + .navigation-float {{ + position: fixed; + left: 20px; + top: 50%; + transform: translateY(-50%); + width: 280px; + max-height: 70vh; + background-color: #fff; + border: 1px solid #dee2e6; + border-radius: 8px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + z-index: 1000; + overflow: hidden; + }} + + .navigation-header {{ + background-color: #007bff; + color: white; + padding: 12px 16px; + font-weight: bold; + font-size: 14px; + display: flex; + justify-content: space-between; + align-items: center; + }} + + .navigation-toggle {{ + background: none; + border: none; + color: white; + cursor: pointer; + font-size: 16px; + padding: 4px 8px; + border-radius: 4px; + transition: background-color 0.2s; + }} + + .navigation-toggle:hover {{ + background-color: rgba(255, 255, 255, 0.2); + }} + + .navigation-content {{ + max-height: calc(70vh - 50px); + overflow-y: auto; + padding: 8px; + }} + + .navigation-item {{ + padding: 10px 12px; + margin-bottom: 6px; + background-color: #f8f9fa; + border-radius: 4px; + cursor: pointer; + transition: all 0.2s; + border-left: 3px solid transparent; + }} + + .navigation-item:hover {{ + background-color: #e9ecef; + border-left-color: #007bff; + }} + + .navigation-item.active {{ + background-color: #e3f2fd; + border-left-color: #007bff; + }} + + .navigation-item-header {{ + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 4px; + }} + + .navigation-item-number {{ + background-color: #007bff; + color: white; + font-size: 11px; + padding: 2px 6px; + border-radius: 10px; + font-weight: bold; + }} + + .navigation-item-type {{ + font-size: 11px; + padding: 2px 6px; + border-radius: 3px; + font-weight: bold; + text-transform: uppercase; + }} + + .navigation-item-type.added {{ + background-color: #28a745; + color: white; + }} + + .navigation-item-type.replaced {{ + background-color: #ffc107; + color: #212529; + }} + + .navigation-item-type.removed {{ + background-color: #dc3545; + color: white; + }} + + .navigation-item-preview {{ + font-size: 12px; + color: #6c757d; + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; + line-height: 1.3; + word-break: break-word; + }} + + .navigation-item-line {{ + font-size: 10px; + color: #adb5bd; + margin-top: 2px; + }} + + /* 导航浮窗收起状态 */ + .navigation-float.collapsed .navigation-content {{ + display: none; + }} + + .navigation-float.collapsed {{ + width: auto; + min-width: 160px; + }} + + /* 响应式设计 */ + @media (max-width: 768px) {{ + .navigation-float {{ + left: 10px; + width: 240px; + }} + + .navigation-float.collapsed {{ + min-width: 120px; + }} + }} + + @media (max-width: 480px) {{ + .navigation-float {{ + position: relative; + left: auto; + top: auto; + transform: none; + width: 100%; + max-height: none; + margin-bottom: 20px; + }} + }}
@@ -834,6 +998,16 @@ def create_diff_html(title, en_diff, en_old_lines, en_new_lines, cn_content=None + +