tanjingyu 1 неделя назад
Родитель
Сommit
7c2c1cce77
1 измененных файлов с 30 добавлено и 15 удалено
  1. 30 15
      app/static/records.html

+ 30 - 15
app/static/records.html

@@ -668,7 +668,7 @@
                 });
                 sortedOut.forEach(l => {
                     const files = (r.outputs || []).filter(f => (f.label || '输出') === l);
-                    h += `<td>${renderFiles(files)}</td>`;
+                    h += `<td>${renderPlainFiles(files)}</td>`;
                 });
                 h += `</tr>`;
             });
@@ -725,6 +725,23 @@
             return cnt;
         }
 
+        function renderFileItem(f, depth = 0) {
+            const name = f.relative_path ? f.relative_path.split('/').pop() : '未知文件';
+            const padding = `padding-left: ${(depth === 0 ? 8 : 24 + (depth - 1) * 16)}px;`;
+            return `
+                <div class="file-row" style="${padding}">
+                    <span class="f-icon">${IC.file}</span>
+                    <div class="f-info">
+                        <div class="f-name-line">
+                            <span class="f-name" title="${esc(f.relative_path)}">${esc(name)}</span>
+                            <span class="f-size">${fmtSize(f.file_size)}</span>
+                            <a class="btn-dl" href="/files/${f.id}/content" download title="下载">${IC.download}</a>
+                        </div>
+                        ${f.extracted_value ? `<div class="f-extracted">↳ ${esc(f.extracted_value)}</div>` : ''}
+                    </div>
+                </div>`;
+        }
+
         function renderTree(node, depth) {
             let h = '';
             const dirKeys = Object.keys(node.dirs).sort((a, b) => a.localeCompare(b));
@@ -748,20 +765,7 @@
             });
 
             node.files.sort((a, b) => (a.relative_path || '').localeCompare(b.relative_path || '')).forEach(f => {
-                const name = f.relative_path ? f.relative_path.split('/').pop() : '未知文件';
-                const padding = `padding-left: ${(depth === 0 ? 8 : 24 + (depth - 1) * 16)}px;`;
-                h += `
-                    <div class="file-row" style="${padding}">
-                        <span class="f-icon">${IC.file}</span>
-                        <div class="f-info">
-                            <div class="f-name-line">
-                                <span class="f-name" title="${esc(f.relative_path)}">${esc(name)}</span>
-                                <span class="f-size">${fmtSize(f.file_size)}</span>
-                                <a class="btn-dl" href="/files/${f.id}/content" download title="下载">${IC.download}</a>
-                            </div>
-                            ${f.extracted_value ? `<div class="f-extracted">↳ ${esc(f.extracted_value)}</div>` : ''}
-                        </div>
-                    </div>`;
+                h += renderFileItem(f, depth);
             });
             return h;
         }
@@ -774,10 +778,21 @@
 
         function renderFiles(files) {
             if (!files || !files.length) return '-';
+            // 如果只有一个文件,不再使用文件夹树,直接展示文件
+            if (files.length === 1) {
+                return renderPlainFiles(files);
+            }
             const tree = buildFileTree(files);
             return `<div class="bubble-tree">${renderTree(tree, 0)}</div>`;
         }
 
+        function renderPlainFiles(files) {
+            if (!files || !files.length) return '-';
+            // Flat list for outputs, slightly cleaner padding
+            return `<div class="bubble-tree" style="min-width: 180px;">${files.map(f => renderFileItem(f, 0)).join('')}</div>`;
+        }
+
+
         init();
     </script>
 </body>