perf: try to fix select options scroll to top when stations refresh

This commit is contained in:
yangsy
2025-08-24 02:10:51 +08:00
parent fafd6cd29f
commit e67809ad86
3 changed files with 49 additions and 35 deletions

View File

@@ -21,7 +21,7 @@ export function useStationListQuery() {
queryFn: async () => {
const { data: ndmStationList } = await axios.get<{ code: string; name: string; deviceIdPrefix: string }[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`);
const stations = ndmStationList.map<Station>((station) => ({
let stations = ndmStationList.map<Station>((station) => ({
code: station.code ?? '',
name: station.name ?? '',
deviceIdPrefix: station.deviceIdPrefix ?? '',
@@ -30,14 +30,16 @@ export function useStationListQuery() {
const pingResultList = await Promise.allSettled(stations.map((station) => ndmVerify(station.code)));
stationList.value = stations.map((station, index) => ({
stations = stations.map((station, index) => ({
...station,
online: pingResultList[index].status === 'fulfilled',
}));
stationList.value.splice(0, stationList.value.length, ...stations);
updatedTime.value = dayjs().toJSON();
return stationList.value;
return stations;
},
refetchInterval: getAppEnvConfig().requestInterval * 1000,
});