task-260(admin.html观感对齐): 软件版本页对齐(zip 校验文案/发布成功含链接/下载列/空态)
This commit is contained in:
@@ -10,14 +10,17 @@ export interface VersionUploadErrors {
|
||||
file?: string
|
||||
}
|
||||
|
||||
/** 校验上传表单(版本号必填非空、文件已选且非空);返回逐字段错误。 */
|
||||
/** 校验上传表单(版本号必填非空、zip 已选且非空);文案对齐 admin.js。 */
|
||||
export function validateSoftwareVersionUpload(form: VersionUploadForm): { valid: boolean; errors: VersionUploadErrors } {
|
||||
const errors: VersionUploadErrors = {}
|
||||
const version = (form.version || '').trim()
|
||||
if (!version) errors.version = '版本号不能为空'
|
||||
if (!version) errors.version = '请填写版本号'
|
||||
const file = form.file
|
||||
if (!file) errors.file = '请选择安装包文件'
|
||||
else if (typeof file.size === 'number' && file.size <= 0) errors.file = '安装包为空或无效'
|
||||
if (!file) errors.file = '请选择 zip 压缩包'
|
||||
else {
|
||||
if (typeof file.size === 'number' && file.size <= 0) errors.file = '安装包为空或无效'
|
||||
else if (file.name && !/\.zip$/i.test(file.name)) errors.file = '仅支持 .zip 格式'
|
||||
}
|
||||
return { valid: Object.keys(errors).length === 0, errors }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user