feat: version banner UI + GET /api/v1/version backend endpoint
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user