feat: report desktop release upload completion progress
This commit is contained in:
@@ -205,6 +205,14 @@
|
||||
{{ uploadButtonText('installer') }}
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<div v-if="uploading" class="upload-progress">
|
||||
<a-progress
|
||||
:percent="uploadProgress ?? 0"
|
||||
:status="uploadStage === 'verifying' ? 'active' : 'normal'"
|
||||
size="small"
|
||||
/>
|
||||
<span>{{ uploadProgressText('installer') }}</span>
|
||||
</div>
|
||||
<div v-if="form.file_name" class="upload-result">
|
||||
<strong>{{ form.file_name }}</strong>
|
||||
<span>{{ formatBytes(form.file_size_bytes) }}</span>
|
||||
@@ -271,6 +279,14 @@
|
||||
{{ uploadButtonText('updater') }}
|
||||
</a-button>
|
||||
</a-upload>
|
||||
<div v-if="updaterUploading" class="upload-progress">
|
||||
<a-progress
|
||||
:percent="updaterUploadProgress ?? 0"
|
||||
:status="updaterUploadStage === 'verifying' ? 'active' : 'normal'"
|
||||
size="small"
|
||||
/>
|
||||
<span>{{ uploadProgressText('updater') }}</span>
|
||||
</div>
|
||||
<div v-if="form.updater_file_name" class="upload-result">
|
||||
<strong>{{ form.updater_file_name }}</strong>
|
||||
<span>{{ formatBytes(form.updater_file_size_bytes) }}</span>
|
||||
@@ -403,6 +419,8 @@ const uploadProgress = ref<number | null>(null)
|
||||
const updaterUploadProgress = ref<number | null>(null)
|
||||
const uploadStage = ref<DesktopClientReleaseUploadProgress['stage'] | null>(null)
|
||||
const updaterUploadStage = ref<DesktopClientReleaseUploadProgress['stage'] | null>(null)
|
||||
const uploadMessage = ref<string | null>(null)
|
||||
const updaterUploadMessage = ref<string | null>(null)
|
||||
|
||||
const enabledRows = computed(() => rows.value.filter((row) => row.enabled).length)
|
||||
const forceRows = computed(() => rows.value.filter((row) => row.force_update).length)
|
||||
@@ -573,10 +591,12 @@ async function beforeUploadReleasePackage(file: File, kind: 'installer' | 'updat
|
||||
uploading.value = true
|
||||
uploadProgress.value = 0
|
||||
uploadStage.value = 'hashing'
|
||||
uploadMessage.value = null
|
||||
} else {
|
||||
updaterUploading.value = true
|
||||
updaterUploadProgress.value = 0
|
||||
updaterUploadStage.value = 'hashing'
|
||||
updaterUploadMessage.value = null
|
||||
}
|
||||
try {
|
||||
const result = await desktopClientReleaseApi.uploadOSS(file, {
|
||||
@@ -590,9 +610,11 @@ async function beforeUploadReleasePackage(file: File, kind: 'installer' | 'updat
|
||||
if (kind === 'installer') {
|
||||
uploadProgress.value = progress.percent
|
||||
uploadStage.value = progress.stage ?? null
|
||||
uploadMessage.value = progress.message ?? null
|
||||
} else {
|
||||
updaterUploadProgress.value = progress.percent
|
||||
updaterUploadStage.value = progress.stage ?? null
|
||||
updaterUploadMessage.value = progress.message ?? null
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -620,6 +642,8 @@ async function beforeUploadReleasePackage(file: File, kind: 'installer' | 'updat
|
||||
updaterUploadProgress.value = null
|
||||
uploadStage.value = null
|
||||
updaterUploadStage.value = null
|
||||
uploadMessage.value = null
|
||||
updaterUploadMessage.value = null
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -648,10 +672,21 @@ function uploadButtonText(kind: 'installer' | 'updater') {
|
||||
return hasUploaded ? '重新上传' : '选择文件并上传'
|
||||
}
|
||||
|
||||
function uploadButtonLoading(kind: 'installer' | 'updater') {
|
||||
const isUploading = kind === 'installer' ? uploading.value : updaterUploading.value
|
||||
function uploadProgressText(kind: 'installer' | 'updater') {
|
||||
const progress = kind === 'installer' ? uploadProgress.value : updaterUploadProgress.value
|
||||
return isUploading && progress !== 100
|
||||
const stage = kind === 'installer' ? uploadStage.value : updaterUploadStage.value
|
||||
const message = kind === 'installer' ? uploadMessage.value : updaterUploadMessage.value
|
||||
if (message) return `${message} ${progress ?? 0}%`
|
||||
if (stage === 'hashing') return `正在计算 SHA256 ${progress ?? 0}%`
|
||||
if (stage === 'signing') return '正在获取 OSS 直传地址'
|
||||
if (stage === 'uploading') return `正在上传 ${progress ?? 0}%`
|
||||
if (stage === 'verifying') return '服务端正在确认文件完整性'
|
||||
if (stage === 'complete') return '上传完成'
|
||||
return '准备上传'
|
||||
}
|
||||
|
||||
function uploadButtonLoading(kind: 'installer' | 'updater') {
|
||||
return kind === 'installer' ? uploading.value : updaterUploading.value
|
||||
}
|
||||
|
||||
function beforeUploadInstallerPackage(file: File) {
|
||||
@@ -1011,6 +1046,18 @@ onMounted(() => {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.upload-progress {
|
||||
display: grid;
|
||||
max-width: 360px;
|
||||
gap: 4px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.upload-progress span {
|
||||
color: #64748b;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.upload-result strong {
|
||||
color: #0f172a;
|
||||
font-weight: 750;
|
||||
|
||||
Reference in New Issue
Block a user