From 491c42b321c85844b660e5c66297b8758abe7461 Mon Sep 17 00:00:00 2001 From: feie9456 Date: Tue, 18 Nov 2025 21:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=87=87=E6=A0=B7=E6=BA=A2?= =?UTF-8?q?=E5=87=BA=E5=A4=84=E7=90=86=EF=BC=8C=E8=B0=83=E6=95=B4=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=9C=A8=E9=87=87=E6=A0=B7=E6=BA=A2=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E4=BD=BF=E7=94=A8=E5=9B=BA=E5=AE=9A=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=9B=E6=9B=B4=E6=96=B0=E6=98=BE=E7=A4=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E7=A4=BA=E7=94=A8=E6=88=B7=E9=87=87=E6=A0=B7?= =?UTF-8?q?=E6=BA=A2=E5=87=BA=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/export/route.ts | 2 ++ app/records/[id]/page.tsx | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/api/export/route.ts b/app/api/export/route.ts index 802a8a8..bba522c 100644 --- a/app/api/export/route.ts +++ b/app/api/export/route.ts @@ -57,6 +57,8 @@ export async function POST(req: NextRequest) { const dtMs = Number((r.rec_end_ms as bigint) - (r.rec_start_ms as bigint)) if (Number.isFinite(dtMs) && dtMs > 0) stepMs = dtMs / r.sample_count } + // 采样溢出时强制 1ms 步长(与 16.384s/16384 对齐) + if (r.sample_count >= 16384) stepMs = 1 const hasFit = r.fit_a != null for (let i = 0; i < r.code_data.length; i++) { const t = (i * stepMs).toFixed(3) diff --git a/app/records/[id]/page.tsx b/app/records/[id]/page.tsx index 108f6c5..8df0638 100644 --- a/app/records/[id]/page.tsx +++ b/app/records/[id]/page.tsx @@ -117,8 +117,10 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) { const timeAxis = useMemo(() => { if (!rec) return [] as number[] - // 使用秒为单位,保留3位小数 - const step = rec.sampleCount > 0 ? rec.duration / rec.sampleCount : 0 + // 使用秒为单位,保留3位小数;若采样溢出,固定为 16.384s + const overflow = rec.sampleCount >= 16384 + const effectiveDuration = overflow ? 16.384 : rec.duration + const step = rec.sampleCount > 0 ? effectiveDuration / rec.sampleCount : 0 return Array.from({ length: rec.sampleCount }, (_, i) => +(i * step).toFixed(3)) }, [rec]) @@ -198,7 +200,23 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
采样
-
{rec.sampleCount} 点 · {rec.duration.toFixed(3)} s · {(rec.sampleCount / rec.duration).toFixed(2)} Hz
+ {(() => { + const overflow = rec.sampleCount >= 16384 + const effectiveDuration = overflow ? 16.384 : rec.duration + const hz = effectiveDuration > 0 ? (rec.sampleCount / effectiveDuration) : 0 + return ( +
+ {rec.sampleCount} 点 ·{' '} + + {effectiveDuration.toFixed(3)} s + + {' '}· {hz.toFixed(2)} Hz +
+ ) + })()}
拟合