task-128(记录与版本中心): 实现软件版本上传表单
新增 version-upload-model.ts(版本号/文件校验与表单字段) 与 uploadSoftwareVersion (multipart POST /api/admin/version)。 TDD: task-128.test.ts 8 用例 RED→GREEN。
This commit is contained in:
@@ -4,8 +4,17 @@ import { parseSoftwareVersionList } from './version-model.ts'
|
||||
import type { SoftwareVersionList } from './version-dto.ts'
|
||||
|
||||
export const SOFTWARE_VERSIONS_ENDPOINT = '/api/admin/versions'
|
||||
export const SOFTWARE_VERSION_UPLOAD_ENDPOINT = '/api/admin/version'
|
||||
|
||||
export async function fetchSoftwareVersions(): Promise<SoftwareVersionList> {
|
||||
const { data } = await http.get<unknown>(SOFTWARE_VERSIONS_ENDPOINT)
|
||||
return parseSoftwareVersionList(data)
|
||||
}
|
||||
|
||||
/** 上传客户端软件版本(multipart version + file)。 */
|
||||
export async function uploadSoftwareVersion(version: string, file: Blob, filename = ''): Promise<void> {
|
||||
const form = new FormData()
|
||||
form.append('version', version)
|
||||
form.append('file', file, filename || (file instanceof File ? file.name : 'version.zip'))
|
||||
await http.post<unknown>(SOFTWARE_VERSION_UPLOAD_ENDPOINT, form)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user