refactor: router guard

This commit is contained in:
yangsy
2025-08-26 16:33:35 +08:00
parent 0c1d1b2886
commit c875deb488
3 changed files with 27 additions and 17 deletions

View File

@@ -1,3 +1,4 @@
import { userClient } from '@/apis/client';
import type { Station } from '@/apis/domains';
import { ndmVerify } from '@/apis/requests';
import { STATION_LIST_QUERY_KEY } from '@/constants';
@@ -22,6 +23,12 @@ export function useStationListQuery() {
enabled: computed(() => pollingEnabled.value),
refetchInterval: getAppEnvConfig().requestInterval * 1000,
queryFn: async () => {
// 主动登录校验
const [err] = await userClient.post<void>(`/api/ndm/ndmKeepAlive/verify`, {}, { timeout: 5000 });
if (err) {
throw err;
}
const { data: ndmStationList } = await axios.get<{ code: string; name: string }[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`);
let stations = ndmStationList.map<Station>((station) => ({