Bläddra i källkod

可视化修改

刘立冬 2 veckor sedan
förälder
incheckning
e2b45fee7b
1 ändrade filer med 24 tillägg och 15 borttagningar
  1. 24 15
      src/visualizers/deconstruction_visualizer.py

+ 24 - 15
src/visualizers/deconstruction_visualizer.py

@@ -4074,10 +4074,19 @@ def generate_html(data: List[Dict[str, Any]], stats: Dict[str, Any],
                 <div class="search-result-header" style="position:sticky;top:0;z-index:100;padding:20px;background:#f9fafb;border-bottom:2px solid #e5e7eb;">
                     <h3 style="margin:0;">📝 ${{searchWord}} · ${{notes.length}}个搜索结果</h3>
                 </div>
-                <div class="notes-grid" style="padding:20px;display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:15px;">
+                <div class="notes-grid" style="padding:20px;display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:24px;">
             `;
 
-            notes.forEach((note, noteIdx) => {{
+            // 获取评估数据并排序notes(按综合得分降序)
+            const notesEvaluation = sw.evaluation_with_filter?.notes_evaluation || [];
+            const notesWithScores = notes.map((note, idx) => ({{
+                note: note,
+                originalIndex: idx,
+                score: notesEvaluation[idx]?.['综合得分'] || 0
+            }}));
+            notesWithScores.sort((a, b) => b.score - a.score);
+
+            notesWithScores.forEach(({{note, originalIndex: noteIdx}}) => {{
                 const noteCard = note.note_card || {{}};
                 const title = noteCard.display_title || '无标题';
                 const imageList = noteCard.image_list || [];
@@ -4145,7 +4154,7 @@ def generate_html(data: List[Dict[str, Any]], stats: Dict[str, Any],
 
                 const cardId = `card-${{featureIdx}}-${{baseWordIdx}}-${{swIdx}}-${{noteIdx}}`;
                 html += `
-                    <div class="note-card ${{matchClass}}" style="border:2px solid #fbbf24;border-radius:12px;overflow:hidden;background:white;transition:all 0.2s;cursor:pointer;" onclick="openAllNotesModal(` + featureIdx + `, ` + baseWordIdx + `, ` + swIdx + `, ` + noteIdx + `)">
+                    <div class="note-card ${{matchClass}}" style="border:3px solid #e5e7eb;border-radius:12px;overflow:hidden;background:white;transition:all 0.3s;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,0.08);" onclick="openAllNotesModal(` + featureIdx + `, ` + baseWordIdx + `, ` + swIdx + `, ` + noteIdx + `)">
                         <!-- 图片轮播区域 -->
                         <div id="${{cardId}}" style="position:relative;width:100%;height:260px;background:#f3f4f6;" data-current-index="0" data-images='${{JSON.stringify(imageList)}}'>
                             <img src="${{imageList[0] || ''}}" style="width:100%;height:100%;object-fit:cover;" onerror="this.parentElement.innerHTML='<div style=\\"width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#9ca3af;\\">${{typeIcon}}</div>'">
@@ -4176,7 +4185,7 @@ def generate_html(data: List[Dict[str, Any]], stats: Dict[str, Any],
 
                             <!-- 评分徽章 -->
                             <div style="padding:8px;background:#f9fafb;border-radius:6px;margin-bottom:8px;">
-                                <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;">
+                                <div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:${{hasSimilarityInfo ? '6px' : '0'}};">
                                     <span style="font-size:12px;color:${{matchColor}};font-weight:600;">
                                         ${{matchIcon}} 搜索结果与目标匹配: ${{comprehensiveScore.toFixed(2)}}
                                     </span>
@@ -4186,8 +4195,8 @@ def generate_html(data: List[Dict[str, Any]], stats: Dict[str, Any],
                                     </button>
                                 </div>
                                 ${{hasSimilarityInfo ? `
-                                    <div style="font-size:11px;color:#6b7280;margin-top:4px;">
-                                        解构结果与目标匹配: ${{maxSimilarityScore.toFixed(2)}}
+                                    <div style="font-size:12px;color:#8b5cf6;font-weight:600;">
+                                        🔮 解构结果与目标匹配: ${{maxSimilarityScore.toFixed(2)}}
                                     </div>
                                 ` : ''}}
                             </div>
@@ -4221,16 +4230,16 @@ def generate_html(data: List[Dict[str, Any]], stats: Dict[str, Any],
                                     </div>
                                 ` : ''}}
                             </div>
-                        </div>
 
-                        <!-- 解构按钮(仅当有解构数据时显示) -->
-                        ` + (hasDeconstruction ? `
-                            <button class="deconstruction-toggle-btn"
-                                    onclick="event.stopPropagation(); openDeconstructionModal('${{noteId}}', '${{title.replace(/'/g, "\\'")}}')"
-                                    style="width:100%;padding:10px;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:white;border:none;border-top:1px solid #e5e7eb;cursor:pointer;font-size:13px;font-weight:600;transition:all 0.3s;display:flex;align-items:center;justify-content:center;gap:6px;">
-                                🎯 查看解构
-                            </button>
-                        ` : '') + `
+                            <!-- 解构按钮(仅当有解构数据时显示) -->
+                            ` + (hasDeconstruction ? `
+                                <button class="deconstruction-toggle-btn"
+                                        onclick="event.stopPropagation(); openDeconstructionModal('${{noteId}}', '${{title.replace(/'/g, "\\'")}}')"
+                                        style="width:100%;padding:10px;background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);color:white;border:none;border-radius:6px;cursor:pointer;font-size:13px;font-weight:600;transition:all 0.3s;display:flex;align-items:center;justify-content:center;gap:6px;margin-top:8px;">
+                                    🎯 查看解构
+                                </button>
+                            ` : '') + `
+                        </div>
                     </div>
                 `;
             }});