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
+32 -2
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,