fix(ui): 修复充电状态筛选重置

This commit is contained in:
2026-05-12 00:18:00 +08:00
parent 4571cee2a1
commit 50e8e32bac
3 changed files with 46 additions and 46 deletions
+14 -12
View File
@@ -1,7 +1,7 @@
import { useQuery } from '@tanstack/react-query'
import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'
import { ArrowLeft, Battery, BatteryCharging, BatteryLow, Database, FilterX, Search, Zap } from 'lucide-react'
import { ArrowLeft, Battery, BatteryCharging, BatteryLow, FilterX, Search, Zap } from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
import { z } from 'zod'
import { orpc } from '@/client/orpc'
@@ -77,6 +77,8 @@ function parseSort(value: string): BatteryListSort {
}
function parsePowerStatus(value: string): PowerStatus | undefined {
if (value === '') return undefined
const parsed = Number(value)
return POWER_STATUS_VALUES.find((option) => option === parsed)
@@ -242,11 +244,11 @@ function BatteriesPage() {
<div className="flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between">
<div>
<Badge variant="info" className="mb-4">
<Database className="size-3.5" /> MySQL
<Battery className="size-3.5" />
</Badge>
<h1 className="text-3xl font-light tracking-tight text-white"></h1>
<h1 className="text-3xl font-light tracking-tight text-white"></h1>
<p className="mt-2 max-w-2xl text-sm leading-6 text-zinc-400">
ls_battery_info ORPC
</p>
<p className="mt-2 text-xs tabular-nums text-zinc-500">
{data ? `更新于 ${new Date(data.updatedAt).toLocaleString('zh-CN')}` : '加载中…'}
@@ -257,7 +259,7 @@ function BatteriesPage() {
to="/"
className="inline-flex items-center gap-2 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-2 text-sm text-zinc-300 transition-colors hover:border-teal-400/30 hover:text-teal-300"
>
<ArrowLeft className="size-4" /> SoH
<ArrowLeft className="size-4" />
</Link>
</nav>
</div>
@@ -290,7 +292,7 @@ function BatteriesPage() {
<SectionTitle
icon={<Search className="size-4" />}
title="筛选设备"
description="按真实采集字段筛选,不在前端伪造或补齐记录。"
description="按设备名称、编号、电量与充电状态快速缩小排查范围。"
/>
{hasActiveFilters && (
<Button type="button" className="h-9 px-3 text-xs" onClick={clearFilters}>
@@ -301,14 +303,14 @@ function BatteriesPage() {
<div className="flex flex-wrap items-end gap-4">
<div className="flex flex-col gap-2 min-w-[260px] flex-1">
<label htmlFor="search-input" className="text-xs font-medium text-zinc-500">
/ MAC
/
</label>
<div className="relative">
<Search className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-zinc-600" />
<Input
id="search-input"
type="text"
placeholder="搜索设备名称或 MAC..."
placeholder="搜索设备名称或编号..."
maxLength={100}
className="pl-9"
value={localSearch}
@@ -369,7 +371,7 @@ function BatteriesPage() {
<div className="flex flex-col gap-2">
<label htmlFor="page-size-select" className="text-xs font-medium text-zinc-500">
</label>
<Select
id="page-size-select"
@@ -411,7 +413,7 @@ function BatteriesPage() {
})
}
/>
<Zap className="size-4 text-amber-300" />
<Zap className="size-4 text-amber-300" />
</label>
</div>
</Card>
@@ -440,7 +442,7 @@ function BatteriesPage() {
) : data?.items.length === 0 ? (
<tr>
<td colSpan={columns.length} className="h-32 text-center text-zinc-500">
</td>
</tr>
) : (
@@ -461,7 +463,7 @@ function BatteriesPage() {
<div className="mt-6 flex items-center justify-between text-sm text-zinc-500">
<div>
{data?.items.length ?? 0}
{data?.items.length ?? 0}
{data?.total ? ` (共 ${data.total} 台)` : ''}
</div>
<div className="flex items-center gap-2">