feat: version banner UI + GET /api/v1/version backend endpoint

This commit is contained in:
Александр Зимин
2026-05-10 16:50:50 +00:00
parent 17386ba0b4
commit e8f98230f2
9 changed files with 355 additions and 0 deletions
+27
View File
@@ -507,3 +507,30 @@ export const useRecordRaw = (
...recordRawQuery(dictionaryName, businessKey ?? ''),
enabled: Boolean(businessKey),
})
// ─────────────────────────────────────────────────────────────────────────────
// App version + update detection
// ─────────────────────────────────────────────────────────────────────────────
export type ServerVersion = {
version: string
commit: string
branch: string
tag: string
builtAt: string
}
export const serverVersionQuery = queryOptions({
queryKey: ['version'] as const,
queryFn: async (): Promise<ServerVersion> => {
const { data } = await apiClient.get<ServerVersion>('/version')
return data
},
// Poll каждые 5 минут — обновление detection без excessive load.
// Stale-while-revalidate: даже если нет focus, перезапрашиваем по таймеру.
refetchInterval: 5 * 60 * 1000,
refetchIntervalInBackground: true,
staleTime: 60 * 1000,
})
export const useServerVersion = () => useQuery(serverVersionQuery)