修复更新中心发送的下载项和普通下载故障覆盖的问题

This commit is contained in:
2026-04-13 13:29:58 +08:00
parent 763af5c37e
commit f044c6c3df
18 changed files with 981 additions and 39 deletions
+5 -6
View File
@@ -7,7 +7,7 @@ import {
currentAppApmInstalled,
} from "../global/storeConfig";
import { APM_STORE_BASE_URL } from "../global/storeConfig";
import { downloads } from "../global/downloadStatus";
import { downloads, getNextDownloadId } from "../global/downloadStatus";
import {
InstallLog,
@@ -18,7 +18,6 @@ import {
} from "../global/typedefinition";
import axios from "axios";
let downloadIdCounter = 0;
const logger = pino({ name: "processInstall.ts" });
export const handleInstall = async (appObj?: App) => {
@@ -51,14 +50,14 @@ export const handleInstall = async (appObj?: App) => {
return;
}
downloadIdCounter += 1;
// 创建下载任务
const arch = window.apm_store.arch || "amd64";
const finalArch =
targetApp.origin === "spark" ? `${arch}-store` : `${arch}-apm`;
const downloadId = getNextDownloadId();
const download: DownloadItem = {
id: downloadIdCounter,
id: downloadId,
name: targetApp.name,
pkgname: targetApp.pkgname,
version: targetApp.version,
@@ -140,12 +139,12 @@ export const handleUpgrade = async (app: App) => {
return;
}
downloadIdCounter += 1;
const arch = window.apm_store.arch || "amd64";
const finalArch = app.origin === "spark" ? `${arch}-store` : `${arch}-apm`;
const downloadId = getNextDownloadId();
const download: DownloadItem = {
id: downloadIdCounter,
id: downloadId,
name: app.name,
pkgname: app.pkgname,
version: app.version,
+23 -12
View File
@@ -4,8 +4,9 @@ import type {
UpdateCenterItem,
UpdateCenterSnapshot,
DownloadItem,
UpdateCenterStartTask,
} from "@/global/typedefinition";
import { downloads } from "@/global/downloadStatus";
import { downloads, getNextUpdateDownloadId } from "@/global/downloadStatus";
import { APM_STORE_BASE_URL } from "@/global/storeConfig";
const EMPTY_SNAPSHOT: UpdateCenterSnapshot = {
@@ -88,12 +89,18 @@ export const createUpdateCenterStore = (): UpdateCenterStore => {
const allSelected = computed(() => {
const selectable = selectableItems.value;
return selectable.length > 0 && selectable.every((item) => selectedTaskKeys.value.has(item.taskKey));
return (
selectable.length > 0 &&
selectable.every((item) => selectedTaskKeys.value.has(item.taskKey))
);
});
const someSelected = computed(() => {
const selectable = selectableItems.value;
return selectable.length > 0 && selectable.some((item) => selectedTaskKeys.value.has(item.taskKey));
return (
selectable.length > 0 &&
selectable.some((item) => selectedTaskKeys.value.has(item.taskKey))
);
});
const handleState = (nextSnapshot: UpdateCenterSnapshot): void => {
@@ -173,18 +180,13 @@ export const createUpdateCenterStore = (): UpdateCenterStore => {
const startSelected = async (): Promise<void> => {
const selectedItems = getSelectedItems();
const taskKeys = selectedItems.map((item) => item.taskKey);
if (taskKeys.length === 0) {
if (selectedItems.length === 0) {
return;
}
// 在前端创建下载项,这样用户能在下载列表中看到更新任务
const arch = window.apm_store.arch || "amd64";
let downloadIdCounter =
downloads.value.length > 0
? Math.max(...downloads.value.map((d) => d.id)) + 1
: 1;
const startTasks: UpdateCenterStartTask[] = [];
selectedItems.forEach((item) => {
// 检查任务是否已存在
@@ -200,8 +202,9 @@ export const createUpdateCenterStore = (): UpdateCenterStore => {
const icon =
item.remoteIcon ||
`${APM_STORE_BASE_URL}/${finalArch}/unknown/${item.packageName}/icon.png`;
const downloadId = getNextUpdateDownloadId();
const download: DownloadItem = {
id: downloadIdCounter++,
id: downloadId,
name: item.displayName,
pkgname: item.packageName,
version: item.newVersion,
@@ -224,10 +227,18 @@ export const createUpdateCenterStore = (): UpdateCenterStore => {
: undefined,
};
downloads.value.push(download);
startTasks.push({
taskKey: item.taskKey,
id: downloadId,
});
}
});
await window.updateCenter.start(taskKeys);
if (startTasks.length === 0) {
return;
}
await window.updateCenter.start(startTasks);
};
const requestClose = (): void => {