feat(apm): 在安装和更新应用前检查并提示安装APM

添加APM可用性检查逻辑,在安装或更新APM应用时,若检测到APM未安装,则弹出对话框提示用户安装
安装流程完成后显示成功提示并告知需要重启电脑
This commit is contained in:
2026-03-30 18:39:03 +08:00
parent dd7e4adead
commit 57410370b7
3 changed files with 89 additions and 11 deletions

View File

@@ -834,11 +834,11 @@ const toggleAllUpgrades = () => {
}));
};
const upgradeSingleApp = (app: UpdateAppItem) => {
const upgradeSingleApp = async (app: UpdateAppItem) => {
if (!app?.pkgname) return;
const target = apps.value.find((a) => a.pkgname === app.pkgname);
if (target) {
handleUpgrade(target);
await handleUpgrade(target);
} else {
// If we can't find it in the list (e.g. category not loaded?), use the info we have
// But handleUpgrade expects App. Let's try to construct minimal App
@@ -861,15 +861,15 @@ const upgradeSingleApp = (app: UpdateAppItem) => {
origin: "apm", // Default to APM if unknown, or try to guess
currentStatus: "installed",
};
handleUpgrade(minimalApp);
await handleUpgrade(minimalApp);
}
};
const upgradeSelectedApps = () => {
const upgradeSelectedApps = async () => {
const selectedApps = upgradableApps.value.filter((app) => app.selected);
selectedApps.forEach((app) => {
upgradeSingleApp(app);
});
for (const app of selectedApps) {
await upgradeSingleApp(app);
}
};
const openInstalledModal = () => {
@@ -945,8 +945,8 @@ const onDetailRemove = (app: App) => {
requestUninstall(app);
};
const onDetailInstall = (app: App) => {
handleInstall(app);
const onDetailInstall = async (app: App) => {
await handleInstall(app);
};
const closeUninstallModal = () => {

View File

@@ -21,10 +21,25 @@ import axios from "axios";
let downloadIdCounter = 0;
const logger = pino({ name: "processInstall.ts" });
export const handleInstall = (appObj?: App) => {
export const handleInstall = async (appObj?: App) => {
const targetApp = appObj || currentApp.value;
if (!targetApp?.pkgname) return;
// APM 应用:在创建下载任务前检查 APM 是否可用
if (targetApp.origin === "apm") {
const hasApm = await window.ipcRenderer.invoke("check-apm-available");
if (!hasApm) {
// 发送事件到主进程显示 APM 安装对话框
const { success, cancelled } = await window.ipcRenderer.invoke(
"show-apm-install-dialog",
);
if (!success || cancelled) {
// 用户取消或未安装成功,不继续安装应用
return;
}
}
}
if (
downloads.value.find(
(d) => d.pkgname === targetApp.pkgname && d.origin === targetApp.origin,
@@ -98,9 +113,24 @@ export const handleRetry = (download_: DownloadItem) => {
window.ipcRenderer.send("queue-install", JSON.stringify(download_));
};
export const handleUpgrade = (app: App) => {
export const handleUpgrade = async (app: App) => {
if (!app.pkgname) return;
// APM 应用:在创建下载任务前检查 APM 是否可用
if (app.origin === "apm") {
const hasApm = await window.ipcRenderer.invoke("check-apm-available");
if (!hasApm) {
// 发送事件到主进程显示 APM 安装对话框
const { success, cancelled } = await window.ipcRenderer.invoke(
"show-apm-install-dialog",
);
if (!success || cancelled) {
// 用户取消或未安装成功,不继续更新应用
return;
}
}
}
if (
downloads.value.find(
(d) => d.pkgname === app.pkgname && d.origin === app.origin,