更新数据模式,增加代码数组最大值至65535;修改主页标题为“ESP32 微弱压力数据采集系统”;调整记录页面的EMA参数默认值和启用状态;更新ESLint配置以关闭no-explicit-any规则提示
This commit is contained in:
parent
ed6b3393d7
commit
d1647d3114
@ -4,7 +4,7 @@ import { prisma } from '@/src/lib/prisma'
|
|||||||
import { applyFit, basicStats, genId, getSampleRateHz } from '@/src/lib/utils'
|
import { applyFit, basicStats, genId, getSampleRateHz } from '@/src/lib/utils'
|
||||||
|
|
||||||
const DataSchema = z.object({
|
const DataSchema = z.object({
|
||||||
code: z.array(z.number().int()).min(1, 'code array empty').max(4096, 'too many points'),
|
code: z.array(z.number().int()).min(1, 'code array empty').max(65535, 'too many points'),
|
||||||
fit: z.object({ a: z.number(), b: z.number() }).optional(),
|
fit: z.object({ a: z.number(), b: z.number() }).optional(),
|
||||||
recStartMs: z.number().int().nonnegative().optional(),
|
recStartMs: z.number().int().nonnegative().optional(),
|
||||||
recEndMs: z.number().int().nonnegative().optional(),
|
recEndMs: z.number().int().nonnegative().optional(),
|
||||||
@ -16,10 +16,12 @@ export async function POST(req: NextRequest) {
|
|||||||
const parsed = DataSchema.safeParse(json)
|
const parsed = DataSchema.safeParse(json)
|
||||||
if (!parsed.success) {
|
if (!parsed.success) {
|
||||||
const first = parsed.error.errors[0]
|
const first = parsed.error.errors[0]
|
||||||
|
console.log(first, json);
|
||||||
|
|
||||||
return Response.json({ error: first?.message ?? 'invalid body' }, { status: 400 })
|
return Response.json({ error: first?.message ?? 'invalid body' }, { status: 400 })
|
||||||
}
|
}
|
||||||
const { code, fit, recStartMs, recEndMs } = parsed.data
|
const { code, fit, recStartMs, recEndMs } = parsed.data
|
||||||
if (code.length > 16384) {
|
if (code.length > 65535) {
|
||||||
return Response.json({ error: 'payload too large' }, { status: 413 })
|
return Response.json({ error: 'payload too large' }, { status: 413 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,7 @@ export default function Home() {
|
|||||||
<div className="min-h-screen bg-zinc-50 text-zinc-900 dark:bg-black dark:text-zinc-100">
|
<div className="min-h-screen bg-zinc-50 text-zinc-900 dark:bg-black dark:text-zinc-100">
|
||||||
<div className="mx-auto max-w-6xl p-4 sm:p-6">
|
<div className="mx-auto max-w-6xl p-4 sm:p-6">
|
||||||
<header className="mb-4 flex flex-col gap-3 sm:mb-6 sm:flex-row sm:items-end sm:justify-between">
|
<header className="mb-4 flex flex-col gap-3 sm:mb-6 sm:flex-row sm:items-end sm:justify-between">
|
||||||
<h1 className="text-2xl font-semibold">ESP32 数据采集系统</h1>
|
<h1 className="text-2xl font-semibold">ESP32 微弱压力数据采集系统</h1>
|
||||||
<div className="flex flex-wrap items-end gap-2">
|
<div className="flex flex-wrap items-end gap-2">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<label className="text-sm">开始</label>
|
<label className="text-sm">开始</label>
|
||||||
|
|||||||
@ -42,8 +42,8 @@ export default function Page({ params }: { params: Promise<{ id: string }> }) {
|
|||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
const [rec, setRec] = useState<Detail | null>(null)
|
const [rec, setRec] = useState<Detail | null>(null)
|
||||||
const [emaAlpha, setEmaAlpha] = useState(0.2)
|
const [emaAlpha, setEmaAlpha] = useState(0.01)
|
||||||
const [enableEma, setEnableEma] = useState(false)
|
const [enableEma, setEnableEma] = useState(true)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
|
|||||||
@ -13,6 +13,12 @@ const eslintConfig = defineConfig([
|
|||||||
"build/**",
|
"build/**",
|
||||||
"next-env.d.ts",
|
"next-env.d.ts",
|
||||||
]),
|
]),
|
||||||
|
// 自定义规则覆盖:关闭 @typescript-eslint/no-explicit-any 提示
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export default eslintConfig;
|
export default eslintConfig;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user