feat(desktop): add client release updater
Desktop Client Build / Resolve Build Metadata (push) Successful in 19s
Frontend CI / Frontend (push) Successful in 3m20s
Backend CI / Backend (push) Successful in 16m48s
Desktop Client Build / Build Desktop Client (push) Successful in 24m46s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 37s

This commit is contained in:
2026-05-25 19:23:49 +08:00
parent 41b4a765ac
commit 5f6e9f11da
46 changed files with 5508 additions and 160 deletions
@@ -0,0 +1,156 @@
import { http } from '@/lib/http'
export type DesktopReleasePlatform = 'darwin' | 'win32' | 'linux'
export type DesktopReleaseArch = 'universal' | 'x64' | 'arm64' | 'ia32'
export type DesktopReleaseSource = 'oss' | 'custom'
export interface DesktopClientRelease {
id: number
platform: DesktopReleasePlatform
arch: DesktopReleaseArch
channel: string
version: string
min_supported_version?: string | null
download_source: DesktopReleaseSource
oss_object_key?: string | null
custom_download_url?: string | null
download_url?: string | null
file_name?: string | null
file_size_bytes?: number | null
sha256?: string | null
updater_download_source?: DesktopReleaseSource | null
updater_oss_object_key?: string | null
updater_custom_download_url?: string | null
updater_download_url?: string | null
updater_file_name?: string | null
updater_file_size_bytes?: number | null
updater_sha256?: string | null
release_notes?: string | null
force_update: boolean
enabled: boolean
published_at?: string | null
created_at: string
updated_at: string
}
export interface DesktopClientReleasePayload {
platform: DesktopReleasePlatform
arch: DesktopReleaseArch
channel: string
version: string
min_supported_version?: string | null
download_source: DesktopReleaseSource
oss_object_key?: string | null
custom_download_url?: string | null
file_name?: string | null
file_size_bytes?: number | null
sha256?: string | null
updater_download_source?: DesktopReleaseSource | null
updater_oss_object_key?: string | null
updater_custom_download_url?: string | null
updater_file_name?: string | null
updater_file_size_bytes?: number | null
updater_sha256?: string | null
release_notes?: string | null
force_update: boolean
enabled: boolean
}
export interface DesktopClientReleaseList {
items: DesktopClientRelease[]
total: number
page: number
size: number
}
export interface DesktopClientReleaseUploadResult {
oss_object_key: string
file_name: string
file_size_bytes: number
sha256: string
}
export interface DesktopClientReleaseDownloadURLResult {
download_url: string
expires_in?: number | null
}
export const platformOptions = [
{ label: 'macOS', value: 'darwin' },
{ label: 'Windows', value: 'win32' },
{ label: 'Linux', value: 'linux' },
]
export const archOptions = [
{ label: 'Universal', value: 'universal' },
{ label: 'x64', value: 'x64' },
{ label: 'arm64', value: 'arm64' },
{ label: 'ia32', value: 'ia32' },
]
export const desktopClientReleaseApi = {
list(params: {
keyword?: string
platform?: string
channel?: string
enabled?: string
page?: number
size?: number
}) {
return http.get<DesktopClientReleaseList>('/desktop-client/releases', params)
},
create(payload: DesktopClientReleasePayload) {
return http.post<DesktopClientRelease, DesktopClientReleasePayload>(
'/desktop-client/releases',
payload,
)
},
update(id: number, payload: DesktopClientReleasePayload) {
return http.patch<DesktopClientRelease, DesktopClientReleasePayload>(
`/desktop-client/releases/${id}`,
payload,
)
},
setEnabled(id: number, enabled: boolean) {
return http.post<DesktopClientRelease, { enabled: boolean }>(
`/desktop-client/releases/${id}/enabled`,
{ enabled },
)
},
async uploadOSS(
file: File,
target: {
platform: string
arch: string
channel: string
version: string
kind?: 'installer' | 'updater'
},
) {
const form = new FormData()
form.append('file', file, file.name)
form.append('platform', target.platform)
form.append('arch', target.arch)
form.append('channel', target.channel)
form.append('version', target.version)
form.append('kind', target.kind ?? 'installer')
const response = await http.raw.post<{
code: number
message: string
data: DesktopClientReleaseUploadResult
}>('/desktop-client/releases/upload', form)
return response.data.data
},
resolveDownloadURL(id: number) {
return http.get<DesktopClientReleaseDownloadURLResult>(
`/desktop-client/releases/${id}/download-url`,
)
},
delete(id: number) {
return http.delete<{ id: number }>(`/desktop-client/releases/${id}`)
},
}
export function platformLabel(value: string): string {
return platformOptions.find((item) => item.value === value)?.label ?? value
}
+3 -1
View File
@@ -57,7 +57,8 @@ const client: AxiosInstance = axios.create({
function isLoginRequest(url: string | undefined, method: string | undefined): boolean {
return (
method?.toLowerCase() === 'post' && (url === '/auth/login' || Boolean(url?.endsWith('/auth/login')))
method?.toLowerCase() === 'post' &&
(url === '/auth/login' || Boolean(url?.endsWith('/auth/login')))
)
}
@@ -117,4 +118,5 @@ export const http = {
put: <T, B = unknown>(url: string, body?: B) => unwrap<T>(client.put(url, body)),
patch: <T, B = unknown>(url: string, body?: B) => unwrap<T>(client.patch(url, body)),
delete: <T>(url: string) => unwrap<T>(client.delete(url)),
raw: client,
}