feat(platform-web): query raw frames with post body

This commit is contained in:
lingniu
2026-07-04 00:48:13 +08:00
parent a4ff210c82
commit 894d200a16
3 changed files with 77 additions and 2 deletions

View File

@@ -16,6 +16,18 @@ import type {
VehicleRow
} from './types';
export type RawFrameQuery = {
keyword?: string;
vin?: string;
protocol?: string;
dateFrom?: string;
dateTo?: string;
fields?: string[];
includeFields?: boolean;
limit?: number;
offset?: number;
};
async function request<T>(path: string, init?: RequestInit): Promise<T> {
const response = await fetch(path, init);
if (!response.ok) {
@@ -34,6 +46,11 @@ export const api = {
realtimeLocations: (params = new URLSearchParams()) => request<Page<RealtimeLocationRow>>(`/api/realtime/locations?${params.toString()}`),
historyLocations: (params = new URLSearchParams()) => request<Page<HistoryLocationRow>>(`/api/history/locations?${params.toString()}`),
rawFrames: (params = new URLSearchParams()) => request<Page<RawFrameRow>>(`/api/history/raw-frames?${params.toString()}`),
rawFramesQuery: (query: RawFrameQuery) => request<Page<RawFrameRow>>('/api/history/raw-frames/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(query)
}),
mileageSummary: (params = new URLSearchParams()) => request<MileageSummary>(`/api/mileage/summary?${params.toString()}`),
dailyMileage: (params = new URLSearchParams()) => request<Page<DailyMileageRow>>(`/api/mileage/daily?${params.toString()}`),
qualitySummary: (params = new URLSearchParams()) => request<QualitySummary>(`/api/quality/summary?${params.toString()}`),