diff --git a/src/modeuls/processInstall.ts b/src/modeuls/processInstall.ts index 145b8e3d..f2e3a16e 100644 --- a/src/modeuls/processInstall.ts +++ b/src/modeuls/processInstall.ts @@ -1,6 +1,7 @@ // window.ipcRenderer.on('main-process-message', (_event, ...args) => { // console.log('[Receive Main-process message]:', ...args) // }) +import pino from 'pino'; import { currentApp, currentAppIsInstalled } from "../global/storeConfig"; import { APM_STORE_BASE_URL } from "../global/storeConfig"; @@ -9,10 +10,16 @@ import { downloads } from "../global/downloadStatus"; import { InstallLog, DownloadItem, DownloadResult, App } from '../global/typedefinition'; let downloadIdCounter = 0; +const logger = pino({ name: 'processInstall.ts' }); export const handleInstall = () => { if (!currentApp.value?.pkgname) return; + if (downloads.value.find(d => d.pkgname === currentApp.value?.pkgname)) { + logger.info(`任务已存在,忽略重复添加: ${currentApp.value.pkgname}`); + return; + } + downloadIdCounter += 1; // 创建下载任务 const download: DownloadItem = { @@ -56,6 +63,11 @@ export const handleRetry = (download_: DownloadItem) => { export const handleUpgrade = (app: App) => { if (!app.pkgname) return; + if (downloads.value.find(d => d.pkgname === app.pkgname)) { + logger.info(`任务已存在,忽略重复添加: ${app.pkgname}`); + return; + } + downloadIdCounter += 1; const download: DownloadItem = { id: downloadIdCounter,