|
|
@@ -96,10 +96,11 @@ class VersionUpdateService {
|
|
|
// 调用下载API
|
|
|
await downloadPackage(version);
|
|
|
|
|
|
+ console.log('[VersionUpdateService] 设置状态为下载中');
|
|
|
// 设置状态为下载中
|
|
|
store.dispatch(setUpdateStatus('downloading'));
|
|
|
|
|
|
- console.log('下载已开始,等待进度消息...');
|
|
|
+ console.log('[VersionUpdateService] 下载已开始,等待进度消息...');
|
|
|
} catch (error) {
|
|
|
console.error('启动下载失败:', error);
|
|
|
store.dispatch(setUpdateError(error instanceof Error ? error.message : '启动下载失败'));
|
|
|
@@ -111,7 +112,7 @@ class VersionUpdateService {
|
|
|
*/
|
|
|
private handleMqttDownloadMessage(message: MqttDownloadMessage): void {
|
|
|
try {
|
|
|
- console.log('收到下载进度消息:', message);
|
|
|
+ console.log('[VersionUpdateService] 收到下载进度消息:', message);
|
|
|
|
|
|
// 转换数据格式
|
|
|
const progress: DownloadProgress = {
|
|
|
@@ -124,8 +125,15 @@ class VersionUpdateService {
|
|
|
message: message.msg,
|
|
|
};
|
|
|
|
|
|
- // 更新Redux状态
|
|
|
- store.dispatch(updateDownloadProgress(progress));
|
|
|
+ // 检查是否需要初始化下载进度状态
|
|
|
+ const currentState = store.getState().versionUpdate;
|
|
|
+ if (!currentState.downloadProgress) {
|
|
|
+ // 如果是第一条消息,初始化下载进度
|
|
|
+ store.dispatch(setDownloadProgress(progress));
|
|
|
+ } else {
|
|
|
+ // 更新现有进度
|
|
|
+ store.dispatch(updateDownloadProgress(progress));
|
|
|
+ }
|
|
|
|
|
|
// 处理不同状态
|
|
|
switch (message.status) {
|