fix(web): stabilize client file downloads

This commit is contained in:
lingniu
2026-07-16 08:23:45 +08:00
parent 4b2e743229
commit 22d069a404
5 changed files with 51 additions and 16 deletions

View File

@@ -9,6 +9,7 @@ import { InlineError } from '../shared/AsyncState';
import { usePlatformSession } from '../auth/AuthGate';
import { canAdminister } from '../auth/session';
import { QUERY_MEMORY, queryScopeKey, retainPreviousPageWithinScope } from '../queryPolicy';
import { downloadBlob } from '../domain/download';
const PROTOCOLS = ['GB32960', 'JT808', 'YUTONG_MQTT'] as const;
const EMPTY_FILTERS = { keyword: '', protocol: '', oem: '', connectionState: '', onlineState: '', model: '', provider: '', firstSeenFrom: '', firstSeenTo: '', latestSeenFrom: '', latestSeenTo: '', delayState: '' };
@@ -88,8 +89,7 @@ function ThresholdSettings({ config, draft, editable, saving, error, onChange, o
function downloadRows(rows: AccessVehicleRow[]) {
const blob = new Blob([accessRowsToCSV(rows)], { type: 'text/csv;charset=utf-8' });
const href = URL.createObjectURL(blob); const anchor = document.createElement('a');
anchor.href = href; anchor.download = `vehicle-access-${new Date().toISOString().slice(0, 10)}.csv`; anchor.click(); URL.revokeObjectURL(href);
downloadBlob(blob, `vehicle-access-${new Date().toISOString().slice(0, 10)}.csv`);
}
export default function AccessPage() {