Files
codex-proxy-rs/frontend/src/api/modules/system.ts
T
ZyyandCodex 322b602154 fix(frontend): centralize admin API error notifications
Show server envelope messages from the response interceptor, with shared transport fallbacks, cancellation handling, and explicit silent requests. Remove duplicate page notifications while preserving contextual batch and irreversible-operation feedback.

Propagate request options through API modules and document notification ownership. Verify the notification-only tree with ESLint, vue-tsc, and a Vite build.

Co-authored-by: Codex <noreply@openai.com>
2026-09-12 23:09:04 +08:00

87 lines
1.9 KiB
TypeScript

import type { RequestOptions } from '../request'
import request from '../request'
export interface SystemVersion {
version: string
gitSha: string
buildTime: string
deploymentMode: string
deploymentModeLabel: string
updateChannel: string
latestVersion: string
hasUpdate: boolean
updateCached: boolean
updateWarning: string | null
}
export interface SystemUpdateDetail {
currentVersion: string
latestVersion: string
hasUpdate: boolean
deploymentMode: string
deploymentModeLabel: string
buildType: string
buildTypeLabel: string
releaseUrl: string | null
notes: string | null
cached: boolean
updateSupported: boolean
unsupportedReason: string | null
warning: string | null
}
export interface SystemUpdateAccepted {
operationId: string
deploymentMode: string
message: string
needRestart: boolean
targetVersion: string
}
export interface SystemRestartAccepted {
message: string
operationId: string
}
export function getSystemVersion(options: RequestOptions = {}) {
return request<SystemVersion>({
url: '/api/admin/system/version',
method: 'GET',
...options,
})
}
interface SystemUpdateDetailQuery {
refresh?: boolean
}
interface SystemUpdateTarget {
targetVersion?: string
}
export function getSystemUpdateDetail(data: SystemUpdateDetailQuery, options: RequestOptions = {}) {
return request<SystemUpdateDetail>({
url: '/api/admin/system/update/detail',
method: 'GET',
params: data,
...options,
})
}
export function performSystemUpdate(data: SystemUpdateTarget, options: RequestOptions = {}) {
return request<SystemUpdateAccepted>({
url: '/api/admin/system/update',
method: 'POST',
data,
...options,
})
}
export function restartSystem(options: RequestOptions = {}) {
return request<SystemRestartAccepted>({
url: '/api/admin/system/restart',
method: 'POST',
...options,
})
}