Skip to content

Commit f8d8b6d

Browse files
committed
feat: Refactor file upload and chart components for improved file handling and hover synchronization
1 parent 58fde76 commit f8d8b6d

File tree

4 files changed

+214
-92
lines changed

4 files changed

+214
-92
lines changed

src/App.jsx

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function App() {
2828
const [lossRegex, setLossRegex] = useState('loss:\\s*([\\d.eE+-]+)');
2929
const [gradNormRegex, setGradNormRegex] = useState('grad[\\s_]norm:\\s*([\\d.eE+-]+)');
3030

31-
const [showDataPoints, setShowDataPoints] = useState(true);
3231
const [compareMode, setCompareMode] = useState('normal');
3332
const [relativeBaseline, setRelativeBaseline] = useState(0.002);
3433
const [absoluteBaseline, setAbsoluteBaseline] = useState(0.005);
@@ -59,9 +58,7 @@ function App() {
5958

6059
// 全局文件处理函数
6160
const processGlobalFiles = useCallback((files) => {
62-
const fileArray = Array.from(files).filter(file =>
63-
file.type === 'text/plain' || file.name.endsWith('.log') || file.name.endsWith('.txt')
64-
);
61+
const fileArray = Array.from(files);
6562

6663
if (fileArray.length === 0) return;
6764

@@ -238,28 +235,67 @@ function App() {
238235
🎯 释放文件以上传
239236
</h3>
240237
<p className="text-sm text-gray-600 mb-2">
241-
支持 <span className="font-semibold text-blue-600">.log</span> <span className="font-semibold text-blue-600">.txt</span> 格式
238+
支持 <span className="font-semibold text-blue-600">所有文本格式</span> 文件
242239
</p>
243240
<p className="text-xs text-gray-500">
244-
拖拽到页面任意位置即可快速上传日志文件
241+
拖拽到页面任意位置即可快速上传文件
245242
</p>
246243
</div>
247244
</div>
248245
)}
249246

250247
<div className="w-full px-3 py-3">
251-
<Header />
252248

253249
<main
254250
id="main-content"
255-
className="grid grid-cols-1 xl:grid-cols-5 gap-3 mt-4"
251+
className="grid grid-cols-1 xl:grid-cols-5 gap-3"
256252
role="main"
257253
>
258254
<aside
259255
className="xl:col-span-1 space-y-3"
260256
role="complementary"
261257
aria-label="控制面板"
262258
>
259+
{/* 标题信息 */}
260+
<div className="bg-white rounded-lg shadow-md p-3">
261+
<div className="flex items-center gap-2 mb-2">
262+
<div className="p-2 bg-blue-100 rounded-lg">
263+
<svg className="w-5 h-5 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
264+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
265+
</svg>
266+
</div>
267+
<h1 className="text-lg font-bold text-gray-800">
268+
Log Analyzer
269+
</h1>
270+
</div>
271+
<p className="text-sm text-gray-600 mb-3">
272+
📊 分析和可视化大模型训练日志中的损失函数和梯度范数数据
273+
</p>
274+
275+
{/* 状态和链接按钮 */}
276+
<div className="flex items-center gap-2" role="group" aria-label="工具状态和链接">
277+
<span
278+
className="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800"
279+
aria-label="当前为在线版本"
280+
>
281+
<span aria-hidden="true">🌐</span>
282+
<span className="ml-1">在线使用</span>
283+
</span>
284+
<a
285+
href="https://github.com/JavaZeroo/compare_tool"
286+
target="_blank"
287+
rel="noopener noreferrer"
288+
className="inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-700 hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
289+
aria-label="访问 GitHub 仓库(在新窗口中打开)"
290+
>
291+
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 20 20">
292+
<path fillRule="evenodd" d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z" clipRule="evenodd" />
293+
</svg>
294+
<span>GitHub</span>
295+
</a>
296+
</div>
297+
</div>
298+
263299
<FileUpload onFilesUploaded={handleFilesUploaded} />
264300

265301
<RegexControls
@@ -331,26 +367,6 @@ function App() {
331367
</label>
332368
</div>
333369
</div>
334-
335-
<div className="border-t pt-3">
336-
<h4 className="text-xs font-medium text-gray-700 mb-2">⚙️ 图表选项</h4>
337-
<label className="flex items-center cursor-pointer hover:bg-gray-50 p-1 rounded">
338-
<input
339-
type="checkbox"
340-
checked={showDataPoints}
341-
onChange={(e) => setShowDataPoints(e.target.checked)}
342-
className="rounded border-gray-300 text-blue-600 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
343-
aria-describedby="show-data-points-description"
344-
/>
345-
<span className="ml-2 text-xs text-gray-700">🔵 显示数据点</span>
346-
<span
347-
id="show-data-points-description"
348-
className="sr-only"
349-
>
350-
控制是否在图表上显示原始数据点
351-
</span>
352-
</label>
353-
</div>
354370

355371
<div className="border-t pt-3">
356372
<h4 className="text-xs font-medium text-gray-700 mb-2">基准线设置</h4>
@@ -419,7 +435,6 @@ function App() {
419435
files={uploadedFiles}
420436
lossRegex={lossRegex}
421437
gradNormRegex={gradNormRegex}
422-
showDataPoints={showDataPoints}
423438
compareMode={compareMode}
424439
relativeBaseline={relativeBaseline}
425440
absoluteBaseline={absoluteBaseline}

0 commit comments

Comments
 (0)