feat(admin-web): restore parse-first UX — disable upload until parse completes

File select now auto-parses the APK/IPA (sends to /parse endpoint),
auto-fills versionName/buildNumber/minOsVersion, and keeps the upload
button disabled (isParsing=true) until parsing finishes — matching
RWADurian's proven UX exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-07 06:21:28 -08:00
parent a6cb7add60
commit d48f1df0ff
1 changed files with 18 additions and 2 deletions

View File

@ -3,20 +3,36 @@
import type { ChangeEvent } from 'react';
import type { AppType } from '@/domain/entities';
import { useUploadStore } from '@/store/zustand/upload.store';
import { uploadVersionUseCase } from '@/application/use-cases/version.use-cases';
import { parsePackageUseCase, uploadVersionUseCase } from '@/application/use-cases/version.use-cases';
export function useUpload(appType: AppType, onSuccess: () => void) {
const store = useUploadStore();
const handleFileChange = (e: ChangeEvent<HTMLInputElement>) => {
const handleFileChange = async (e: ChangeEvent<HTMLInputElement>) => {
const f = e.target.files?.[0];
if (!f) return;
store.setFile(f);
store.setParseWarning('');
store.setVersionName('');
store.setBuildNumber('');
store.setMinOsVersion('');
if (f.name.endsWith('.apk')) store.setPlatform('ANDROID');
else if (f.name.endsWith('.ipa')) store.setPlatform('IOS');
// 先解析,等解析完成后才允许点击上传(与 RWADurian 一致)
store.setIsParsing(true);
try {
const parsed = await parsePackageUseCase.execute(f);
if (parsed.versionName) store.setVersionName(parsed.versionName);
if (parsed.versionCode) store.setBuildNumber(String(parsed.versionCode));
if (parsed.minSdkVersion) store.setMinOsVersion(parsed.minSdkVersion);
} catch {
store.setParseWarning('无法自动解析安装包信息,请手动填写版本号和构建号');
} finally {
store.setIsParsing(false);
}
};
const handleSubmit = async () => {